/* Portfolio demos (loaded on /portfolio only) */
body.demo-open { overflow: hidden; }
.demo { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; background: var(--mist); color: var(--text); font-size: .95rem; line-height: 1.5; }
.demo--dark { background: var(--navy-950); color: var(--on-navy); }
.demo h2, .demo h3, .demo h4 { font-family: var(--font-display); color: var(--navy); letter-spacing: -0.01em; }
.demo--dark h2, .demo--dark h3, .demo--dark h4 { color: #fff; }
.demo__bar { display: flex; align-items: center; gap: .85rem; padding: .65rem 1rem; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.demo--dark .demo__bar { background: var(--navy); border-color: rgba(255, 255, 255, .12); }
.demo__brand { display: flex; align-items: center; gap: .65rem; margin-right: auto; min-width: 0; }
.demo__brand b { display: block; color: var(--navy); font: 700 1rem/1.2 var(--font-display); }
.demo--dark .demo__brand b { color: #fff; }
.demo__brand small { display: block; font-size: .78rem; color: var(--text); }
.demo--dark .demo__brand small { color: #9fb0d6; }
.demo__mark { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 9px; background: var(--navy); color: var(--gold); font: 700 .85rem/1 var(--font-display); }
.demo--dark .demo__mark { background: var(--gold); color: var(--navy); }
.demo__pill { padding: .25rem .7rem; border-radius: 999px; background: var(--green-100); color: var(--green); font-size: .8rem; font-weight: 600; white-space: nowrap; }
.demo--dark .demo__pill { background: rgba(61, 220, 151, .14); color: #7de9b9; }
.demo__close { display: inline-flex; align-items: center; gap: .4rem; min-height: 40px; padding: 0 .85rem; border: 1.5px solid var(--line); border-radius: 8px; background: #fff; color: var(--navy); font: 600 .9rem/1 var(--font-body); cursor: pointer; }
.demo__close:hover { background: var(--mist); }
.demo--dark .demo__close { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .35); }
.demo--dark .demo__close:hover { background: rgba(255, 255, 255, .1); }
.demo__body { flex: 1; min-height: 0; display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.demo__body--col { display: block; overflow-y: auto; padding: 1.25rem; }
.demo__side { display: flex; flex-direction: column; gap: .2rem; padding: 1rem .75rem; background: #fff; border-right: 1px solid var(--line); overflow-y: auto; }
.demo__side button { display: flex; align-items: center; gap: .65rem; text-align: left; padding: .7rem .85rem; border: 0; border-radius: 8px; background: transparent; color: var(--text); font: 600 .92rem/1.2 var(--font-body); cursor: pointer; }
.demo__side button svg { flex: none; }
.demo__side button:hover { background: var(--mist); }
.demo__side button[aria-current="page"] { background: var(--navy); color: #fff; }
.demo__main { overflow-y: auto; padding: 1.4rem clamp(1rem, 3vw, 2rem) 2rem; outline: none; }
.demo__head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.demo__head h2 { font-size: 1.5rem; }
.demo__head p { margin-top: .2rem; font-size: .92rem; }
.demo__head--bar { max-width: 1180px; margin-inline: auto; margin-bottom: 1rem; }
.demo--dark .demo__head p { color: #9fb0d6; }
.demo__toast { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; padding: .7rem 1rem; border: 1px solid #b6dfc7; border-radius: 8px; background: var(--green-100); color: #124d30; font-weight: 600; font-size: .9rem; }
.demo__toast button { border: 0; background: transparent; color: inherit; cursor: pointer; display: grid; }
.demo__foot { padding: .55rem 1rem; text-align: center; font-size: .8rem; background: #fff; border-top: 1px solid var(--line); }
.demo--dark .demo__foot { background: var(--navy); border-color: rgba(255, 255, 255, .12); color: #9fb0d6; }

/* Shared components */
.dm-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .9rem; }
.dm-metric { padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.dm-metric span { display: block; font-size: .85rem; }
.dm-metric b { display: block; margin-top: .25rem; font: 700 1.9rem/1.1 var(--font-display); color: var(--navy); }
.dm-metric small { display: block; margin-top: .2rem; font-size: .78rem; color: var(--green); }
.dm-two { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 1rem; margin-top: 1rem; }
.dm-card { padding: 1.15rem 1.25rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.dm-card--flush { padding: 0; overflow: hidden; }
.dm-card h3 { font-size: 1.05rem; margin-bottom: .75rem; }
.dm-list { list-style: none; }
.dm-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .85rem 1.1rem; border-bottom: 1px solid var(--line); }
.dm-card:not(.dm-card--flush) .dm-list li { padding-inline: 0; }
.dm-list li:last-child { border-bottom: 0; }
.dm-list b { display: block; color: var(--navy); }
.dm-list span { font-size: .85rem; }
.dm-list select, .dm-form input { font: inherit; font-size: .88rem; padding: .45rem .6rem; border: 1.5px solid #b4bfd8; border-radius: 8px; background: #fff; color: var(--navy); }
.dm-list select:focus, .dm-form input:focus { outline: 3px solid var(--gold); outline-offset: 1px; }
.dm-empty { color: var(--text); }
.dm-pill { display: inline-block; padding: .2rem .65rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.dm-pill--n { background: var(--gold-100); color: var(--navy); }
.dm-pill--g { background: var(--green-100); color: var(--green); }
.dm-tasks { list-style: none; display: grid; gap: .5rem; }
.dm-tasks label { display: flex; align-items: flex-start; gap: .7rem; padding: .7rem .8rem; border-radius: 8px; background: var(--mist); cursor: pointer; }
.dm-tasks input { margin-top: .25rem; width: 1.05rem; height: 1.05rem; accent-color: var(--navy); }
.dm-tasks .is-done { text-decoration: line-through; opacity: .6; }
.dm-note { margin-top: .75rem; font-size: .82rem; }
.dm-form { display: grid; gap: .8rem; max-width: 30rem; margin-bottom: 1rem; }
.dm-form label { display: grid; gap: .3rem; font-weight: 600; color: var(--navy); font-size: .88rem; }
.dm-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.dm-bars { list-style: none; display: grid; gap: .7rem; }
.dm-bars li { display: grid; grid-template-columns: 90px minmax(0, 1fr) 28px; align-items: center; gap: .75rem; }
.dm-bars i { display: block; height: 14px; min-width: 4px; border-radius: 7px; background: var(--gold); }
.dm-bars b { color: var(--navy); }
.dm-kanban { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .9rem; align-items: start; }
.dm-col { padding: .8rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.dm-col h3 { display: flex; justify-content: space-between; font-size: .95rem; margin-bottom: .6rem; }
.dm-col h3 small { padding: 0 .5rem; border-radius: 999px; background: var(--mist); font-size: .8rem; }
.dm-kcard { margin-bottom: .55rem; padding: .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--mist); }
.dm-kcard b { display: block; color: var(--navy); }
.dm-kcard span { font-size: .82rem; }
.dm-kcard button { display: block; margin-top: .5rem; padding: .35rem .6rem; border: 1.5px solid var(--navy); border-radius: 6px; background: #fff; color: var(--navy); font: 600 .8rem/1 var(--font-body); cursor: pointer; }
.dm-kcard button:hover { background: var(--navy); color: #fff; }

/* Flowdesk */
.fd { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1rem; max-width: 1180px; margin-inline: auto; }
.fd__canvas { display: flex; align-items: center; gap: 0; padding: 2rem 1rem; border: 1px solid rgba(255, 255, 255, .14); border-radius: 12px; background: var(--navy); overflow-x: auto; }
.fd__node { flex: none; width: 108px; min-height: 108px; padding: .8rem; text-align: left; border: 2px solid rgba(255, 255, 255, .22); border-radius: 12px; background: var(--navy-800); color: #fff; font: inherit; cursor: pointer; transition: border-color .2s, background-color .2s; }
.fd__node small { display: block; font-size: .72rem; color: #9fb0d6; }
.fd__node b { display: block; margin: .25rem 0; font: 700 .92rem/1.25 var(--font-display); }
.fd__node span { font-size: .78rem; color: #9fb0d6; }
.fd__node.is-sel { border-color: var(--gold); }
.fd__node.is-done { background: #0f4a3b; border-color: #3ddc97; }
.fd__node.is-active { background: #136b53; border-color: #7de9b9; }
.fd__link { flex: none; width: 20px; height: 2px; background: repeating-linear-gradient(90deg, #6f82ad 0 5px, transparent 5px 9px); }
.fd__link.is-done { background: #3ddc97; }
.fd__side { display: grid; gap: 1rem; align-content: start; }
.demo--dark .dm-card { background: var(--navy); border-color: rgba(255, 255, 255, .14); color: var(--on-navy); }
.fd__out { margin-top: 1rem; padding: .75rem; border-radius: 8px; background: var(--navy-950); }
.fd__out small { display: block; color: #9fb0d6; font-size: .75rem; }
.fd__out b { color: #7de9b9; }
.fd__log { max-height: 190px; overflow-y: auto; display: grid; gap: .35rem; font: .8rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.demo--dark .dm-note { color: #9fb0d6; }
.demo--dark .btn--outline-light:disabled, .demo--dark .btn--gold:disabled { opacity: .5; cursor: progress; }

/* Data Studio */
.ds__legend { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; max-width: 1180px; margin: 0 auto 1rem; }
.ds__legend li { padding: .3rem .75rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: .82rem; }
.ds { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1rem; max-width: 1180px; margin-inline: auto; align-items: start; }
.ds__canvas { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; padding: 1.25rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.ds__table { display: block; width: 100%; padding: 0; text-align: left; border: 2px solid var(--line); border-radius: 10px; background: #fff; font: inherit; cursor: pointer; overflow: hidden; }
.ds__table:hover { border-color: var(--navy); }
.ds__table.is-rel { border-style: dashed; border-color: var(--navy); }
.ds__table.is-sel { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-100); }
.ds__name { display: block; padding: .55rem .8rem; background: var(--navy); color: #fff; font: 700 .95rem/1.2 var(--font-display); }
.ds__f { display: flex; justify-content: space-between; gap: .75rem; padding: .35rem .8rem; font-size: .85rem; color: var(--navy); }
.ds__f small { color: var(--text); }
.ds__f b { color: #a77a20; font-size: .78rem; }
.ds__inspect h4 { margin: 1rem 0 .3rem; font-size: .95rem; }
.ds__inspect pre { overflow-x: auto; padding: .8rem; border-radius: 8px; background: var(--navy); color: #e6edfb; font: .8rem/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; }

@media (max-width: 900px) {
  /* App-style bottom tab bar: the body wrapper dissolves so the nav can sit below the content */
  .demo__body:not(.demo__body--col) { display: contents; }
  .demo__main { order: 1; flex: 1; min-height: 0; }
  .demo__foot { order: 2; }
  .demo__side { order: 3; flex: none; flex-direction: row; gap: 0; overflow: hidden; padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); box-shadow: 0 -4px 14px rgba(11, 31, 75, .06); }
  .demo__side button { flex: 1 1 0; min-width: 0; flex-direction: column; justify-content: center; gap: .2rem; padding: .45rem 0; font-size: .64rem; font-weight: 600; letter-spacing: -.01em; text-align: center; }
  .demo__side button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .demo__side button[aria-current="page"] { background: transparent; color: var(--navy); box-shadow: inset 0 2px 0 var(--gold); border-radius: 0 0 8px 8px; }
  .demo__side button[aria-current="page"] svg { stroke: var(--navy); stroke-width: 2.2; }
  .dm-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dm-two, .fd, .ds { grid-template-columns: minmax(0, 1fr); }
  .dm-kanban { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .demo__bar { gap: .5rem; }
  .demo__close span { display: none; }
  .demo__pill { display: none; }
  .demo__body--col { padding: .9rem; }
  .ds__canvas { grid-template-columns: minmax(0, 1fr); }
  .dm-kanban { grid-template-columns: minmax(0, 1fr); }
  .dm-list li { flex-wrap: wrap; }
  .fd__canvas { flex-direction: column; align-items: stretch; padding: 1rem; }
  .fd__node { width: 100%; min-height: 0; }
  .fd__link { width: 2px; height: 20px; align-self: center; background: repeating-linear-gradient(180deg, #6f82ad 0 5px, transparent 5px 9px); }
  .fd__link.is-done { background: #3ddc97; }
}
@media (prefers-reduced-motion: reduce) { .fd__node { transition: none; } }
