:root {
  color-scheme: dark;
  --bg: #12071f;
  --bg-raised: #1d0d31;
  --panel: #27113f;
  --panel-2: #17111f;
  --line: #573176;
  --line-soft: #3a2748;
  --text: #fbf8ff;
  --muted: #c9bdd8;
  --green: #46ee86;
  --blue: #5a9cff;
  --violet: #a977f4;
  --magenta: #d66bc7;
  --warm: #f0c568;
  --danger: #ca7bc0;
  --safe-bottom: max(14px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: 0; }
body.screensaver-open { overflow: hidden; }
button, input, textarea { font: inherit; letter-spacing: 0; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.app-shell { min-height: 100dvh; max-width: 760px; margin: 0 auto; background: linear-gradient(155deg, #180829 0%, #0f0b17 52%, #241038 100%); }
.app-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; min-height: 64px; padding: max(10px, env(safe-area-inset-top)) 16px 10px; background: rgba(18, 7, 31, .94); border-bottom: 1px solid var(--line-soft); backdrop-filter: blur(14px); }
.brand-lockup { display: flex; align-items: center; gap: 10px; }
.brand-lockup strong { display: block; font-size: 19px; }
.brand-lockup small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.brand-mark, .pair-mark { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid #8060aa; border-radius: 8px; background: linear-gradient(145deg, #253c78, #51266f); color: white; font-weight: 800; box-shadow: inset 0 0 16px rgba(109, 140, 255, .24); }
.mobile-brain-home { position: relative; display: block; width: 38px; height: 38px; padding: 0; border: 0; background: transparent; overflow: hidden; }
.mobile-brain-home img { display: block; width: 100%; height: 100%; object-fit: contain; }
.mobile-brain-home.working::after,.mobile-brain-graphic.working::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(110deg,transparent 30%,#e3d6ff 46%,#81e8ff 51%,transparent 65%); background-size: 260% 100%; mask: url('/brain-graphic.png') center/contain no-repeat; -webkit-mask: url('/brain-graphic.png') center/contain no-repeat; animation: mobile-brain-current 1.15s linear infinite; }
@keyframes mobile-brain-current { from { background-position: 125% 0; } to { background-position: -125% 0; } }

.app-main { min-height: calc(100dvh - 130px); padding: 12px 14px 184px; }
.app-view { display: none; }
.app-view.active { display: block; }
.view-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 2px 14px; }
.brain-mobile-heading { display: grid; grid-template-columns: minmax(0, 1fr) 44px minmax(86px, auto); }
.view-heading h1 { margin: 0; font-size: 26px; font-weight: 680; }
.eyebrow { margin: 0 0 4px; color: var(--green); font-size: 10px; font-weight: 800; }
.state-pill { max-width: 52%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 6px 8px; border: 1px solid var(--line); border-radius: 999px; background: #1f1230; color: var(--muted); font-size: 10px; font-weight: 750; }
.brain-mobile-heading .state-pill { max-width: 100%; justify-self: end; }
.mobile-brain-graphic { position: relative; width: 42px; height: 42px; margin: 0; opacity: .72; filter: saturate(.82) drop-shadow(0 0 7px rgba(169,119,244,.3)); }
.mobile-brain-graphic img { display: block; width: 100%; height: 100%; object-fit: contain; }
.mobile-brain-graphic.working { opacity: 1; filter: saturate(1) drop-shadow(0 0 12px rgba(90,156,255,.55)); }
.mobile-brain-graphic.working img { animation: mobile-brain-pulse 1.6s ease-in-out infinite; }
.mobile-brain-graphic[data-request-state="timeout"], .mobile-brain-graphic[data-request-state="fail-closed"] { opacity: .55; filter: grayscale(.25) drop-shadow(0 0 6px rgba(214,107,199,.35)); }
@keyframes mobile-brain-pulse { 0%,100% { transform: scale(.94); } 50% { transform: scale(1.06); } }

.icon-button, .command-button, .transport-button { display: inline-grid; place-items: center; flex: 0 0 auto; border: 1px solid #77529c; background: #2b1644; color: var(--text); cursor: pointer; }
.icon-button { width: 42px; height: 42px; border-radius: 50%; }
.icon-button.quiet { background: #1a1026; border-color: var(--line-soft); }
.icon-button:hover, .command-button:hover, .transport-button:hover { border-color: var(--blue); box-shadow: 0 0 16px rgba(90, 156, 255, .2); }
.icon-button:active, .command-button:active, .transport-button:active { transform: translateY(1px); background: #382056; }

.brain-messages { display: flex; flex-direction: column; gap: 12px; min-height: 46dvh; padding-bottom: 12px; }
.message { max-width: 92%; padding: 11px 12px; border: 1px solid var(--line-soft); border-radius: 8px; background: var(--panel-2); line-height: 1.45; overflow-wrap: anywhere; scroll-margin-bottom: 110px; }
.message.user { align-self: flex-end; background: #30204a; border-color: #66418a; }
.message.brain { align-self: flex-start; }
.message p { margin: 0 0 9px; }
.message p:last-child { margin-bottom: 0; }
.message.user .message-answer { white-space: pre-wrap; }
.message-answer { overflow-wrap: anywhere; }
.message-answer h1, .message-answer h2, .message-answer h3, .message-answer h4, .message-answer h5, .message-answer h6 { margin: 10px 0 6px; font-size: 15px; letter-spacing: 0; }
.message-answer ul, .message-answer ol { margin: 7px 0; padding-left: 20px; }
.message-answer pre { max-width: 100%; overflow: auto; margin: 8px 0; padding: 9px; border: 1px solid var(--line-soft); border-radius: 7px; background: #0b0810; white-space: pre; }
.message-answer code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .9em; }
.message-answer :not(pre) > code { padding: 1px 4px; border-radius: 4px; background: #0b0810; }
.message-answer a { color: var(--green); }
.unsafe-link { color: var(--muted); font-size: .88em; }
.message small { display: block; margin-top: 7px; color: var(--muted); font-size: 10px; }
.message details { margin-top: 8px; color: var(--muted); font-size: 11px; }
.message details div { margin-top: 5px; padding-top: 5px; border-top: 1px solid var(--line-soft); }
.brain-composer { position: sticky; bottom: 126px; z-index: 8; display: grid; grid-template-columns: minmax(0, 1fr) 48px; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: rgba(29, 13, 49, .97); box-shadow: 0 12px 30px rgba(0, 0, 0, .35); }
.brain-composer textarea { min-height: 48px; max-height: 142px; resize: vertical; border: 0; background: transparent; color: var(--text); padding: 10px; outline: 0; }
.command-button { width: 48px; height: 48px; align-self: end; border-radius: 8px; background: linear-gradient(145deg, #2d5592, #663083); font-size: 24px; }
.command-button:disabled { opacity: .6; cursor: wait; }

.search-field { display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: center; min-height: 48px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #1b1128; color: var(--muted); }
.search-field input { min-width: 0; height: 46px; border: 0; outline: 0; background: transparent; color: var(--text); }
.segmented { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; margin: 10px 0; padding: 3px; border: 1px solid var(--line-soft); border-radius: 8px; background: #120d19; }
.segmented button { min-width: 0; min-height: 38px; padding: 4px 2px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 9px; font-weight: 750; }
.segmented button.active { background: linear-gradient(145deg, #263c6d, #532a69); color: white; box-shadow: inset 0 0 0 1px #7658a0; }
.section-meta { color: var(--muted); font-size: 11px; }
.media-library { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.media-item { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--line-soft); border-radius: 8px; background: #1b1127; }
.media-open { display: block; width: 100%; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; }
.media-art { position: relative; width: 100%; aspect-ratio: 1; overflow: hidden; background: linear-gradient(145deg, #243351, #361d49 55%, #17271f); }
.media-art img { width: 100%; height: 100%; object-fit: cover; }
.media-art span { position: absolute; inset: 0; display: grid; place-items: center; padding: 14px; color: #d9cee4; text-align: center; }
.media-copy { min-height: 68px; padding: 9px; }
.media-copy strong, .media-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-copy strong { font-size: 13px; }
.media-copy small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.favorite-button { border: 0; background: transparent; color: #d6c9e2; font-size: 26px; cursor: pointer; }
.media-item > .favorite-button { position: absolute; top: 5px; right: 5px; z-index: 2; width: 40px; height: 40px; border-radius: 50%; background: rgba(14, 8, 21, .78); }
.favorite-button[aria-pressed="true"] { color: var(--warm); }
.wide { width: 100%; margin-top: 12px; }
.secondary-button { min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: #211331; color: var(--text); }

.detail-back { margin-bottom: 10px; }
.album-hero { display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 14px; align-items: end; padding: 0 0 14px; border-bottom: 1px solid var(--line-soft); }
.album-hero .media-art { border-radius: 8px; }
.album-hero h2 { margin: 0; font-size: 21px; overflow-wrap: anywhere; }
.album-hero p { margin: 5px 0 0; color: var(--muted); }
.album-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.play-album { min-height: 42px; padding: 0 14px; border: 1px solid #668ec9; border-radius: 8px; background: linear-gradient(145deg, #26518a, #68317c); color: white; font-weight: 760; }
.track-list { margin-top: 10px; }
.track-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) 42px; align-items: center; gap: 4px; min-height: 56px; border-bottom: 1px solid var(--line-soft); cursor: pointer; touch-action: manipulation; }
.track-row.active { background: rgba(70, 238, 134, .07); }
.track-number { grid-column: 1; color: var(--muted); text-align: center; font-size: 11px; }
.track-play { width: 40px; height: 40px; border: 0; border-radius: 50%; background: #2b1840; color: white; }
.track-title { grid-column: 2; min-width: 0; }
.track-title strong, .track-title small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-title small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.track-favorite { grid-column: 3; justify-self: center; }

.learning-band { padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: #1b102b; }
.learning-primary { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.learning-primary strong { font-size: 24px; }
.learning-primary span { color: var(--muted); font-size: 12px; }
.progress-label { display: flex; justify-content: space-between; gap: 12px; margin-top: 13px; color: var(--muted); font-size: 10px; }
.progress-track { height: 8px; margin-top: 5px; overflow: hidden; border-radius: 4px; background: #352142; }
.progress-track.slim { height: 4px; }
.progress-track span { display: block; width: 0; height: 100%; transition: width .4s ease; }
.coverage-bar { background: linear-gradient(90deg, var(--green) 0%, #51db99 48%, var(--violet) 76%, #7447b7 100%); }
.phase-bar { background: linear-gradient(90deg, #687cff, var(--violet), #c365d0); }
.block-wall { display: flex; gap: 5px; margin-top: 14px; overflow-x: auto; padding-bottom: 3px; }
.block-brick { position: relative; flex: 0 0 54px; height: 24px; overflow: hidden; border: 1px solid #5d3e73; border-radius: 4px; background: #2b183b; }
.block-brick span { position: absolute; inset: auto 0 0; height: 0; background: var(--green); }
.block-brick:nth-child(even) span { background: var(--violet); }
.block-brick b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 9px; }
.counter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.counter-grid div { min-width: 0; padding: 10px; border-left: 2px solid var(--violet); background: #17111f; }
.counter-grid dt { color: var(--muted); font-size: 9px; }
.counter-grid dd { margin: 4px 0 0; font-size: 17px; font-weight: 700; }
.learning-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.learning-button { position: relative; min-width: 0; min-height: 48px; overflow: hidden; border: 1px solid #7659a4; border-radius: 8px; color: #fbf8ff; font-size: 11px; font-weight: 800; }
.learning-button.start { background: linear-gradient(145deg, #213c76, #512873); }
.learning-button.pause { background: linear-gradient(145deg, #31175b, #582369); }
.learning-button.resume { background: linear-gradient(145deg, #293d77, #582771); }
.learning-button.stop { border-color: #a75ca8; background: linear-gradient(145deg, #21112f, #431944); }
.learning-button:disabled { opacity: .64; color: #eee8f6; }
.learning-button:not(:disabled):hover { border-color: var(--blue); box-shadow: 0 0 16px rgba(112, 104, 232, .24); }
.learning-button.stop i { position: absolute; inset: auto 0 0; width: 0; height: 3px; background: linear-gradient(90deg, var(--blue), var(--magenta)); }
.learning-button.stop.holding i { animation: hold-fill 1.7s linear forwards; }
@keyframes hold-fill { to { width: 100%; } }
@media (prefers-reduced-motion: reduce) { .mobile-brain-graphic.working img,.mobile-brain-graphic.working::before,.mobile-brain-home.working::after { animation: none; } }
.action-state { display: block; min-height: 20px; margin-top: 8px; color: var(--muted); font-size: 11px; }

.work-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.work-toolbar .secondary-button { min-width: 82px; }
.work-note-form, .work-results, .work-section { margin-top: 12px; padding: 13px; border: 1px solid var(--line-soft); border-radius: 8px; background: #181020; }
.work-note-form label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 10px; font-weight: 750; }
.work-note-form textarea, .work-note-form select { width: 100%; min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #100a17; color: var(--text); }
.work-note-form textarea { resize: vertical; }
.work-note-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 8px; }
.command-text-button { min-height: 44px; padding: 8px 12px; border: 1px solid #6f76bb; border-radius: 8px; background: linear-gradient(145deg, #274b83, #5b2e76); color: white; font-size: 10px; font-weight: 800; }
.work-section h2 { margin: 0; font-size: 18px; }
.work-section p { color: var(--muted); font-size: 11px; }
.work-section summary { cursor: pointer; color: var(--text); font-size: 12px; font-weight: 760; }
.work-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.work-section-head span { color: var(--green); font-size: 9px; font-weight: 800; }
.work-row { min-width: 0; margin-top: 9px; padding: 7px 9px; border-left: 2px solid var(--violet); background: #120c19; overflow-wrap: anywhere; }
.work-row strong, .work-row small { display: block; }
.work-row strong { font-size: 12px; }
.work-row small { margin-top: 3px; color: var(--muted); font-size: 10px; }

.admin-section { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.admin-section-head, .admin-row-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.admin-section-head h2 { margin: 0; font-size: 17px; }
.admin-section-head span { color: var(--green); font-size: 9px; font-weight: 800; }
.admin-action-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; margin-top: 11px; }
.admin-action-row select, .admin-field select { width: 100%; min-width: 0; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #100a17; color: var(--text); }
.pairing-output { display: block; min-height: 28px; margin-top: 10px; color: var(--green); font-size: 18px; font-weight: 780; overflow-wrap: anywhere; }
.admin-list { margin-top: 7px; }
.admin-row { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.admin-row.compact { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.admin-row strong, .admin-row small, .audit-line strong, .audit-line small { display: block; overflow-wrap: anywhere; }
.admin-row small, .audit-line small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.admin-field { display: grid; grid-template-columns: 104px minmax(0, 1fr); align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 10px; }
.admin-shares { display: grid; gap: 7px; margin-top: 10px; }
.admin-share { display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: center; gap: 7px; color: var(--text); font-size: 10px; overflow-wrap: anywhere; }
.admin-share input { width: 17px; height: 17px; margin: 0; accent-color: var(--violet); }
.audit-line { padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.admin-row button:disabled, .admin-action-row button:disabled, .admin-field select:disabled { opacity: .45; cursor: not-allowed; }
.admin-add-user{display:grid;gap:9px;margin:10px 0;padding:11px;border:1px solid var(--line);border-radius:9px;background:#120c19;min-width:0}
.admin-add-user[hidden]{display:none}.admin-add-user>label{display:grid;gap:4px;min-width:0;color:var(--muted);font-size:11px}
.admin-add-user input:not([type=checkbox]),.admin-add-user select{box-sizing:border-box;width:100%;min-width:0;max-width:100%;min-height:42px;padding:7px;border:1px solid var(--line);border-radius:8px;background:#100a17;color:var(--text)}
.admin-add-user>label.admin-enabled,.admin-add-user .admin-shares label{display:flex;align-items:center;justify-content:flex-start;gap:8px;color:var(--text)}
.admin-add-actions{display:flex;flex-wrap:wrap;gap:8px}
@media(max-width:520px){.admin-add-actions button{width:100%}}

.now-layout { display: grid; justify-items: center; padding: 4px 8px 18px; }
.now-artwork { width: min(84vw, 430px); aspect-ratio: 1; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #1b1127; box-shadow: 0 24px 45px rgba(0, 0, 0, .38); }
.now-artwork img { width: 100%; height: 100%; object-fit: cover; }
.now-copy { width: 100%; margin-top: 17px; text-align: center; }
.now-copy h2 { margin: 0; font-size: 22px; overflow-wrap: anywhere; }
.now-copy p { margin: 5px 0 0; color: var(--muted); }
.local-video-player { width: 100%; max-height: 62vh; margin: 16px 0; border: 1px solid var(--line); border-radius: 8px; background: #08060b; }
.identity-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; margin: 16px 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.identity-grid span { min-width: 0; padding: 12px; color: var(--muted); overflow-wrap: anywhere; }
.identity-grid b { display: block; margin-bottom: 4px; color: var(--text); font-size: 10px; }
@media (max-width: 520px) { .identity-grid { grid-template-columns: 1fr; } }
.seek-row { display: grid; grid-template-columns: 42px minmax(0, 1fr) 42px; align-items: center; gap: 8px; width: 100%; margin-top: 15px; color: var(--muted); font-size: 10px; }
input[type="range"] { width: 100%; accent-color: var(--violet); }
.transport-row { display: flex; align-items: center; justify-content: center; gap: 20px; margin-top: 18px; }
.transport-button { width: 52px; height: 52px; border-radius: 50%; font-size: 19px; }
.transport-button.primary { width: 66px; height: 66px; background: linear-gradient(145deg, #2b5593, #6b337e); font-size: 24px; }
.volume-row { display: grid; grid-template-columns: 58px minmax(0, 1fr); align-items: center; gap: 8px; width: 100%; margin-top: 20px; color: var(--muted); font-size: 11px; }

.mini-player { position: fixed; left: 8px; right: 8px; bottom: calc(70px + var(--safe-bottom)); z-index: 25; display: grid; grid-template-columns: minmax(0, 1fr) 42px 42px; align-items: center; gap: 4px; max-width: 744px; min-height: 58px; margin: 0 auto; padding: 6px; border: 1px solid #69468a; border-radius: 8px; background: rgba(29, 13, 49, .97); box-shadow: 0 10px 30px rgba(0, 0, 0, .45); backdrop-filter: blur(14px); }
.mini-copy { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; gap: 8px; min-width: 0; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; }
.mini-copy > span:last-child { min-width: 0; }
.mini-copy strong, .mini-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-copy small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.mini-art { width: 44px; height: 44px; overflow: hidden; border-radius: 6px; background: #231632; }
.mini-art img { width: 100%; height: 100%; object-fit: cover; }

.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 760px; min-height: calc(62px + var(--safe-bottom)); margin: 0 auto; padding: 5px 6px var(--safe-bottom); border-top: 1px solid var(--line-soft); background: rgba(15, 8, 24, .97); backdrop-filter: blur(14px); }
.bottom-nav button { display: grid; place-items: center; align-content: center; gap: 3px; min-width: 0; border: 0; border-radius: 6px; background: transparent; color: #aa9ab8; font-size: 9px; font-weight: 760; }
.bottom-nav button span { font-size: 18px; }
.bottom-nav button.active { color: white; background: #291540; }

.screensaver { position: fixed; inset: 0; z-index: 100; overflow: hidden; background: #09050e; }
.saver-artwork { position: absolute; inset: -4%; background-position: center; background-size: cover; filter: saturate(.92); animation: saver-drift 24s ease-in-out infinite alternate; }
.saver-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(8, 3, 13, .06) 25%, rgba(13, 5, 22, .9) 88%); }
@keyframes saver-drift { from { transform: translate3d(-1.5%, -1%, 0) scale(1.04); } to { transform: translate3d(1.5%, 1%, 0) scale(1.08); } }
.saver-controls { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; padding: max(16px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom)); transition: opacity .7s ease; }
.saver-controls.receded { opacity: .12; }
.saver-close { position: absolute; top: max(14px, env(safe-area-inset-top)); right: 14px; background: rgba(14, 8, 22, .62); }
.saver-copy { text-align: center; text-shadow: 0 2px 14px #000; }
.saver-copy h2 { margin: 0; font-size: 27px; }
.saver-copy p { margin: 6px 0 0; color: #eee6f5; }

.toast { position: fixed; left: 50%; bottom: calc(146px + var(--safe-bottom)); z-index: 120; max-width: calc(100vw - 32px); transform: translateX(-50%) translateY(10px); padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: #21132f; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.pairing-body, .setup-body { min-height: 100dvh; background: linear-gradient(155deg, #170829, #0f0b17 55%, #241038); }
.pairing-shell, .setup-shell { width: min(100% - 28px, 620px); margin: 0 auto; padding: max(36px, env(safe-area-inset-top)) 0 40px; }
.pairing-shell h1, .setup-shell h1 { margin: 12px 0 8px; font-size: 30px; }
.pair-copy, .setup-url, .setup-band p { color: var(--muted); }
.pair-form { display: grid; gap: 9px; margin-top: 24px; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-raised); }
.pair-form label { color: var(--muted); font-size: 11px; }
.pair-form input { min-height: 48px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: #120b1b; color: white; }
.pair-form button, .setup-band button { min-height: 46px; border: 1px solid #6e78bd; border-radius: 8px; background: linear-gradient(145deg, #244985, #613079); color: white; font-weight: 760; }
.setup-band select { width: 100%; min-height: 46px; margin: 5px 0 10px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #120b1b; color: white; }
.setup-label { color: var(--muted); font-size: 11px; }
.pair-form output { min-height: 22px; color: var(--warm); }
.setup-band { margin-top: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-raised); }
.setup-band h2 { margin: 0; font-size: 18px; }
.setup-band p { margin: 5px 0 14px; }
#pairingCode { display: block; min-height: 26px; margin-top: 12px; color: var(--green); font-size: 20px; font-weight: 760; }
.session-row, .account-row, .prospect-row, .audit-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line-soft); }
.session-row b, .session-row small, .account-row b, .account-row small, .prospect-row b, .prospect-row small, .audit-row b, .audit-row small { display: block; overflow-wrap: anywhere; }
.session-row small, .account-row small, .prospect-row small, .audit-row small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.session-row button, .account-row button, .prospect-row button { min-height: 38px; padding: 0 10px; }
.setup-band button:disabled { opacity: .45; cursor: not-allowed; }

@media (min-width: 620px) {
  .app-main { padding-left: 22px; padding-right: 22px; }
  .media-library { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .counter-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 374px) {
  .app-main { padding-left: 10px; padding-right: 10px; }
  .segmented button { font-size: 8px; }
  .learning-controls { gap: 5px; }
  .learning-button { font-size: 10px; }
  .album-hero { grid-template-columns: 96px minmax(0, 1fr); }
  .work-toolbar, .work-note-actions, .admin-action-row, .admin-field { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Keep the existing mobile presentation; navigation is a compact drawer. */
.mobile-section-tree{position:fixed;top:14px;right:64px;z-index:60}.mobile-section-tree>summary{cursor:pointer;list-style:none;border:1px solid #67517a;border-radius:9px;padding:7px 11px;background:#21142f;font-size:12px}.mobile-section-tree .bottom-nav{position:absolute;top:45px;right:-50px;bottom:auto;left:auto;width:260px;max-height:75vh;overflow:auto;display:flex;flex-direction:column;align-items:stretch;background:#170a2a;padding:12px;border:1px solid #67517a;border-radius:12px}.mobile-section-tree .bottom-nav a,.mobile-section-tree .bottom-nav button{text-align:left;display:block;padding:11px;color:#eee;text-decoration:none}.mobile-section-tree:not([open]) .bottom-nav{display:none}.app-main{padding-bottom:100px}
.mobile-section-tree .bottom-nav [hidden]{display:none!important}.mobile-section-tree .bottom-nav summary{padding:11px;cursor:pointer;color:#ceb9ff}.mobile-section-tree .bottom-nav details a,.mobile-section-tree .bottom-nav details button{padding-left:25px}
#mobileWorkNodes{display:flex;flex-direction:column;gap:5px;padding-left:12px;grid-column:1/-1}
#mobileWorkNodes details{padding:5px 0 5px 8px;border-left:1px solid #513469}
#mobileWorkNodes summary{padding:8px;cursor:pointer}
#mobileWorkNodes button{display:block;text-align:left;width:100%;margin:4px 0}
#workSummary>button{display:block;text-align:left;width:100%;margin:7px 0}
#workSummary details{margin:10px 0;overflow-wrap:anywhere}
#workSummary .work-credit{border-left:4px solid #ed6b7d;background:#492231;padding:12px;color:#ffdce2}
#workSummary .work-due{border-left:4px solid #e4ba52;background:#3c321b;padding:12px;color:#ffedbb}
/* Preserve native hidden semantics for authenticated capability projection. */
[hidden] { display: none !important; }

/* Shell S4: role-specific bottom tab bar (rendered server-side from nav_model); the Sections drawer doubles as the More sheet. */
.jb-tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; max-width: 760px; min-height: calc(62px + var(--safe-bottom)); margin: 0 auto; padding: 5px 6px var(--safe-bottom); border-top: 1px solid var(--line-soft); background: rgba(15, 8, 24, .97); backdrop-filter: blur(14px); }
.jb-tabs a, .jb-tabs button { flex: 1 1 0; display: grid; place-items: center; align-content: center; gap: 3px; min-width: 0; min-height: 52px; border: 0; border-radius: 6px; background: transparent; color: #aa9ab8; font: inherit; font-size: 10px; font-weight: 760; text-decoration: none; }
.jb-tabs span { font-size: 18px; }
.jb-tabs .active { color: white; background: #291540; }
.jb-tabs [hidden] { display: none !important; }
.mobile-section-tree.from-more .bottom-nav { position: fixed; top: auto; right: 8px; left: 8px; bottom: calc(72px + var(--safe-bottom)); width: auto; max-height: 65vh; }

/* Shell S5: normal-user Home and Starred (built from existing account-scoped catalog, favorites and resume state). */
.s5-block { margin: 0 0 20px; }
.s5-block h2 { margin: 0 0 8px; font-size: 15px; font-weight: 700; color: #d9c8f0; }
.s5-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 10px; margin: 0 0 8px; padding: 6px; border: 1px solid var(--line-soft); border-radius: 10px; background: rgba(35, 22, 50, .6); }
.s5-row .s5-open { display: grid; grid-template-columns: 52px minmax(0, 1fr); align-items: center; gap: 10px; min-width: 0; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; grid-column: 1 / 3; }
.s5-row .s5-open span:last-child { min-width: 0; }
.s5-row strong, .s5-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s5-row small { color: var(--muted); font-size: 11px; }
.s5-art { width: 52px; height: 52px; overflow: hidden; border-radius: 6px; background: #231632; }
.s5-art img { width: 100%; height: 100%; object-fit: cover; }
.s5-empty { color: var(--muted); font-size: 13px; }
.s5-more { margin: 4px 0 0; border: 1px solid var(--line-soft); border-radius: 8px; background: transparent; color: #d9c8f0; padding: 8px 12px; font: inherit; font-size: 12px; }
.s5-ask label { display: block; margin: 0 0 6px; font-size: 13px; color: #d9c8f0; }
.s5-ask-row { display: flex; gap: 8px; }
.s5-ask-row input { flex: 1 1 auto; min-width: 0; padding: 11px 12px; border: 1px solid var(--line-soft); border-radius: 10px; background: rgba(15, 8, 24, .8); color: inherit; font: inherit; }
