/* Apple-inspired look: system type, quiet greys, white cards, one blue accent. */
:root {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Segoe UI", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  color-scheme: light;
  --bg: #f5f5f7; --surface: #ffffff; --surface-2: #f5f5f7; --fill: #e8e8ed;
  --text: #1d1d1f; --muted: #6e6e73; --faint: #86868b; --line: #d2d2d7;
  --accent: #0071e3; --accent-hover: #0077ed; --accent-soft: #e8f2fd; --link: #0066cc;
  --green: #1d8a3a; --green-soft: #e3f5e8; --orange: #b25e00; --orange-soft: #fff4e0;
  --red: #d70015; --red-soft: #fdecee;
  --glass: rgba(251,251,253,.78); --shadow: 0 2px 12px rgba(0,0,0,.06);
  --shadow-hover: 0 8px 30px rgba(0,0,0,.10); --media: #000;
  --radius: 22px;
  --map-bg: #e8eee3; --map-road: #ffffff; --map-park: #cfe8c4; --map-water: #c6defa;
  color: var(--text); background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #000; --surface: #1c1c1e; --surface-2: #2c2c2e; --fill: #3a3a3c;
    --text: #f5f5f7; --muted: #a1a1a6; --faint: #8e8e93; --line: #38383a;
    --accent: #0a84ff; --accent-hover: #409cff; --accent-soft: #0a84ff26; --link: #2997ff;
    --green: #30d158; --green-soft: #30d15826; --orange: #ff9f0a; --orange-soft: #ff9f0a26;
    --red: #ff453a; --red-soft: #ff453a26;
    --glass: rgba(28,28,30,.72); --shadow: 0 0 0 1px rgba(255,255,255,.06);
    --shadow-hover: 0 0 0 1px rgba(255,255,255,.12);
    --map-bg: #26302a; --map-road: #3c4740; --map-park: #2f4a33; --map-water: #1f3550;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 30px; }
body { margin: 0; font-size: 15px; line-height: 1.55; background: var(--bg); color: var(--text); text-rendering: optimizeLegibility; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; letter-spacing: inherit; }

/* Buttons: filled blue pill, grey secondary, red text for destructive. */
button, .button-link { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 20px; border: 0; border-radius: 980px; background: var(--accent); color: #fff; font-size: 15px; font-weight: 500; cursor: pointer; touch-action: manipulation; transition: background .2s, transform .1s, opacity .2s; white-space: nowrap; }
button:hover, .button-link:hover { background: var(--accent-hover); text-decoration: none; }
button:active, .button-link:active { transform: scale(.97); }
button:disabled, .button-link[aria-disabled="true"] { opacity: .35; cursor: not-allowed; transform: none; }
.button-link[aria-disabled="true"] { pointer-events: none; }
:where(button,input,select,textarea,summary,a):focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }
.secondary { background: var(--fill); color: var(--text); }
.secondary:hover { background: color-mix(in srgb, var(--fill), var(--text) 8%); }
.danger { background: var(--red-soft); color: var(--red); }
.danger:hover { background: color-mix(in srgb, var(--red-soft), var(--red) 14%); }
.text-button { background: transparent; color: var(--link); padding-inline: 10px; }
.text-button:hover { background: transparent; text-decoration: underline; }

/* Shell: frosted sidebar like macOS Settings. */
.app-shell { display: grid; grid-template-columns: 252px minmax(0,1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 14px 20px; display: flex; flex-direction: column; background: var(--glass); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-right: 1px solid var(--line); }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 10px; font-size: 19px; font-weight: 600; letter-spacing: -.02em; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); letter-spacing: 0; margin-top: 1px; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; color: #fff; flex: none; background: linear-gradient(160deg, #3a9bff, #0060df); box-shadow: 0 2px 6px rgba(0,113,227,.35); }
.brand-mark svg { width: 23px; height: 23px; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-label { color: var(--faint); font-size: 12px; font-weight: 600; margin: 34px 12px 8px; }
.navigation { display: flex; flex-direction: column; gap: 2px; }
.navigation a { display: flex; align-items: center; gap: 10px; color: var(--text); padding: 8px 12px; border-radius: 9px; white-space: nowrap; font-size: 14px; }
.navigation a:hover { background: color-mix(in srgb, var(--text) 6%, transparent); text-decoration: none; }
.navigation a.is-active { background: var(--accent); color: #fff; font-weight: 500; }
.navigation a.is-active .icon { color: #fff; }
.icon { width: 19px; height: 19px; flex: none; color: var(--accent); stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-note { margin-top: auto; padding: 16px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); font-size: 13px; color: var(--muted); }
.sidebar-note strong { color: var(--text); font-weight: 600; }
.sidebar-note p { margin: 6px 0 0; font-size: 12px; line-height: 1.5; }
.note-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 7px; vertical-align: middle; }

main { min-width: 0; width: 100%; max-width: 1180px; margin: 0 auto; padding: 48px 48px 0; }
.page-header, .row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.page-header { margin-bottom: 36px; align-items: flex-end; }
.header-actions { display: flex; gap: 10px; align-items: center; }
.eyebrow { font-size: 14px; font-weight: 600; color: var(--muted); margin: 0 0 4px; }
h1 { font-size: 40px; font-weight: 700; letter-spacing: -.015em; line-height: 1.15; margin: 0; overflow-wrap: anywhere; }
h2 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; margin: 4px 0 0; }
h3 { font-size: 17px; font-weight: 600; line-height: 1.3; margin: 0; }
p { margin: 10px 0; }
.page-description { margin: 10px 0 0; color: var(--muted); font-size: 17px; }

/* Status pill & feedback. */
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px; background: var(--fill); color: var(--muted); border-radius: 980px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.pill:before, .device-state:before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.pill[data-state="active"] { background: var(--green-soft); color: var(--green); }
.pill[data-state="active"]:before, .device-state[data-state="online"]:before { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 25%, transparent); }
.pill[data-state="paused"] { background: var(--orange-soft); color: var(--orange); }
.pill[data-state="paused"]:before, .device-state[data-state="paused"]:before { background: var(--orange); }
.pill[data-state="error"] { background: var(--red-soft); color: var(--red); }
.pill[data-state="error"]:before { background: var(--red); }
.feedback { color: var(--red); background: var(--red-soft); border-radius: 14px; padding: 12px 16px; margin: 0 0 24px; font-size: 14px; overflow-wrap: anywhere; }
.feedback:empty, #mood-message:empty { display: none; }
.feedback[data-tone="success"] { color: var(--green); background: var(--green-soft); }

.section-kicker { font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--accent); text-transform: uppercase; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.section-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.heading-text { flex: 1; min-width: 0; }
.heading-text h2 { margin: 0; }
.section-heading p { font-size: 14px; margin: 3px 0 0; }
/* iOS Settings-style icon tiles. */
.tile { --t1: #3d9bff; --t2: #0a6cff; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none; color: #fff; background: linear-gradient(180deg, var(--t1), var(--t2)); box-shadow: inset 0 0 0 .5px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.12); }
.tile svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tile-lg { width: 52px; height: 52px; border-radius: 14px; }
.tile-lg svg { width: 28px; height: 28px; }
.tile-orange { --t1: #ffb340; --t2: #ff8a00; }
.tile-green { --t1: #4cd964; --t2: #23a94a; }
.tile-red { --t1: #ff6680; --t2: #fa2d48; }
.tile-gray { --t1: #aeaeb2; --t2: #7c7c80; }
.tile-indigo { --t1: #8a87ff; --t2: #5856d6; }
.glyph { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; display: block; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.actions:empty { display: none; }
#admin-refresh { margin-left: auto; }

/* Cards. */
section { margin-bottom: 28px; padding: 32px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.share-panel { background: linear-gradient(135deg, var(--surface) 0%, var(--surface) 55%, var(--accent-soft) 100%); }
.share-panel .row { margin-bottom: 24px; }
.link-row { display: flex; gap: 10px; align-items: stretch; margin-bottom: 20px; }
.link-field { flex: 1; min-width: 0; background: var(--surface-2); border-radius: 12px; padding: 9px 14px; }
.link-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 1px; }
.share-link { font-size: 14px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-link a { color: var(--link); }
.link-row button, .link-row .button-link { flex: none; align-self: center; }
.share-note { margin: 18px 0 0; font-size: 13px; }

.screen-board { padding: 0; background: none; box-shadow: none; }
.count-label { font-size: 13px; color: var(--muted); background: var(--fill); padding: 5px 12px; border-radius: 980px; white-space: nowrap; }
.viewer-tools { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.devices { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,340px),1fr)); gap: 20px; }
.device { min-width: 0; background: var(--surface); border-radius: var(--radius); padding: 22px; overflow: hidden; box-shadow: var(--shadow); transition: box-shadow .3s; }
.device:hover { box-shadow: var(--shadow-hover); }
.device-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.device-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.platform-icon { width: 42px; height: 42px; background: var(--accent-soft); color: var(--accent); border-radius: 11px; display: grid; place-items: center; flex: none; }
.device h2 { font-size: 17px; font-weight: 600; margin: 0; overflow-wrap: anywhere; }
.device-subtitle { font-size: 13px; color: var(--muted); margin: 2px 0 0; }
.device-state { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; color: var(--muted); }
.device-state[data-state="online"] { color: var(--green); }
.device-state[data-state="paused"] { color: var(--orange); }
.battery { font-size: 13px; color: var(--muted); margin: 10px 0; }
.device .actions { padding-top: 16px; border-top: 1px solid var(--line); margin-top: 16px; }
.device .actions button { font-size: 14px; min-height: 34px; padding: 6px 16px; }
.image-button { display: flex; width: 100%; min-height: 240px; align-items: center; justify-content: center; background: var(--surface-2); margin: 18px 0 12px; padding: 10px; border-radius: 14px; overflow: hidden; }
.image-button:hover { background: var(--fill); }
.image-button:active { transform: scale(.99); }
.device img { display: block; max-height: 440px; max-width: 100%; object-fit: contain; border-radius: 8px; }
.empty { display: flex; min-height: 230px; align-items: center; justify-content: center; flex-direction: column; text-align: center; color: var(--muted); background: var(--surface-2); border-radius: 14px; margin: 18px 0 12px; padding: 28px; font-size: 14px; gap: 12px; }
.empty-symbol { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--surface); color: var(--faint); box-shadow: var(--shadow); }
.empty-symbol .glyph { width: 26px; height: 26px; }
.mood-preview > .empty-symbol { margin-bottom: 14px; }
.phone-placeholder .empty-symbol { color: var(--accent); }
.device-footnote { font-size: 13px; color: var(--muted); margin: 12px 0 0; }
.devices-empty { grid-column: 1/-1; margin: 0; min-height: 220px; background: var(--surface); box-shadow: var(--shadow); border-radius: var(--radius); }
.live-player canvas { display: block; background: var(--media); max-width: 100%; max-height: 500px; min-height: 180px; margin: 18px auto 12px; object-fit: contain; border-radius: 14px; }
.live-player canvas:fullscreen { width: 100%; height: 100%; max-height: none; border-radius: 0; }
.live-fullscreen { font-size: 14px; }
#phone-relay { margin-top: 20px; }
#phone-relay iframe { display: block; width: 100%; height: min(72vh,720px); border: 0; border-radius: 16px; margin-top: 18px; background: var(--media); }
.phone-placeholder { min-height: 200px; }
.phone-placeholder .small { max-width: 370px; }

/* Mood, location and music read like widgets. */
.mood-card { overflow: hidden; }
.mood-layout { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.35fr); gap: 32px; }
.mood-preview { padding: 28px; border-radius: 18px; background: var(--surface-2); min-height: 230px; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; overflow-wrap: anywhere; }
#mood-preview { --mood-accent: var(--accent); --mood-fill: var(--accent-soft); transition: background .2s; }
#mood-preview[data-mood]:not([data-mood=""]) { background: linear-gradient(135deg, var(--surface-2), var(--mood-fill)); border-left: 4px solid var(--mood-accent); }
#mood-preview[data-mood="🙂"] { --mood-accent: var(--orange); --mood-fill: var(--orange-soft); }
#mood-preview[data-mood="😌"] { --mood-accent: var(--green); --mood-fill: var(--green-soft); }
#mood-preview[data-mood="🥱"] { --mood-accent: var(--muted); --mood-fill: var(--fill); }
#mood-preview[data-mood="🌧️"] { --mood-accent: var(--accent); --mood-fill: var(--accent-soft); }
.mood-emoji { font-size: 48px; line-height: 1.2; margin: 0 0 14px; }
.mood-label { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 6px; }
.mood-text { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.02em; line-height: 1.4; white-space: pre-wrap; color: var(--text); }
.mood-time { font-size: 13px; color: var(--muted); margin: 20px 0 0; }
.mood-options { margin: 0; padding: 0; min-width: 0; border: 0; display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 8px; }
.mood-options legend { width: 100%; font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 14px; }
.mood-options legend span { display: block; margin-top: 3px; font-size: 13px; font-weight: 400; color: var(--muted); }
.mood-options label { position: relative; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px; padding: 12px 6px; border-radius: 14px; margin: 0; font-size: 13px; cursor: pointer; color: var(--text); background: var(--surface-2); min-height: 86px; transition: background .2s, box-shadow .2s; }
.mood-options label:hover { background: var(--fill); }
.mood-options input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.mood-options label span { font-size: 28px; line-height: 1; }
.mood-options label:has(input:checked) { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.mood-options label:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }
.mood-options label:has(input:disabled) { opacity: .55; cursor: wait; }
.mood-options input:disabled { cursor: wait; }
#mood-note { margin-top: 20px; padding-top: 12px; }
#mood-note summary { display: list-item; min-height: 44px; padding: 10px 0; font-weight: 500; }
#mood-note label { margin-top: 8px; }
#mood-note textarea { min-height: 106px; }
#mood-message { margin: 14px 0 0; }
#mood-message[data-tone="success"] { color: var(--green); }
#mood-message[data-tone="error"] { color: var(--red); }
.mood-submit { margin-top: 8px; }
body[data-view="viewer"] .mood-layout { grid-template-columns: 1fr; }
body[data-view="viewer"] .mood-preview { min-height: 180px; }
/* Location widget: a drawn map tile (no third-party tiles are loaded) with a Find My-style pin. */
#position #location { font-size: 15px; font-variant-numeric: tabular-nums; margin: 0 0 14px; }
.map-tile { position: relative; isolation: isolate; height: 168px; border-radius: 16px; overflow: hidden; margin-bottom: 16px; transition: filter .4s, opacity .4s;
  background:
    radial-gradient(circle at 80% 26%, var(--map-park) 0 42px, transparent 43px),
    radial-gradient(ellipse 120px 70px at 6% 100%, var(--map-water) 0 99%, transparent 100%),
    repeating-linear-gradient(28deg, transparent 0 52px, var(--map-road) 52px 57px),
    repeating-linear-gradient(-62deg, transparent 0 78px, var(--map-road) 78px 85px),
    var(--map-bg); }
.map-pin { position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,.3); }
.map-pin::after { content: ""; position: absolute; inset: -17px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 22%, transparent); animation: pin-pulse 2.4s ease-out infinite; z-index: -1; }
#position:not([data-located="true"]) .map-tile { filter: grayscale(1); opacity: .55; }
#position:not([data-located="true"]) .map-pin { display: none; }
@keyframes pin-pulse { from { transform: scale(.5); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }

/* Music widget: neutral while idle, Apple Music-style gradient while a song is loaded. */
#music-preview { flex-direction: row; align-items: center; justify-content: flex-start; gap: 18px; min-height: 168px; transition: background .4s; }
.album-art { width: 88px; height: 88px; border-radius: 16px; display: grid; place-items: center; flex: none; background: var(--fill); color: var(--faint); }
.album-art .glyph { width: 40px; height: 40px; stroke-width: 1.5; }
.track { min-width: 0; }
.track .mood-label { display: flex; align-items: center; gap: 8px; }
.track .mood-time { margin-top: 12px; }
#music-preview:is([data-state="playing"],[data-state="paused"]) { background: linear-gradient(135deg, #fa2d48 0%, #fc5c7d 100%); color: #fff; }
#music-preview:is([data-state="playing"],[data-state="paused"]) .album-art { background: rgba(255,255,255,.22); color: #fff; box-shadow: 0 8px 24px rgba(120,0,20,.25); }
#music-preview:is([data-state="playing"],[data-state="paused"]) :is(.muted,.mood-label,.mood-time) { color: rgba(255,255,255,.85); }
#music-preview:is([data-state="playing"],[data-state="paused"]) .mood-text { color: #fff; }
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.eq i { width: 3px; height: 100%; border-radius: 2px; background: currentColor; transform-origin: bottom; animation: eq 1s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -.4s; }
.eq i:nth-child(3) { animation-delay: -.7s; }
@keyframes eq { 0%, 100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }

/* Location and music sit side by side as widgets when both are shown on a wide screen. */
@media (min-width: 1000px) {
  main { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); column-gap: 28px; align-content: start; }
  main > * { grid-column: 1 / -1; min-width: 0; }
  main:has(#position:not([hidden])):has(#music:not([hidden])) :is(#position, #music) { grid-column: auto; }
  #music:not([hidden]) { display: flex; flex-direction: column; }
  #music-preview { flex: 1; }
}

/* Forms. */
label { display: block; font-size: 14px; margin: 16px 0; color: var(--muted); }
input:not([type=radio]):not([type=range]), select, textarea { display: block; width: 100%; max-width: 460px; margin-top: 6px; border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; color: var(--text); background: var(--surface); font-size: 16px; transition: border-color .2s, box-shadow .2s; }
input:not([type=radio]):not([type=range]):focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { max-width: none; resize: vertical; min-height: 130px; }
input[type=file] { font-size: 13px; }
details { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 16px; }
summary { cursor: pointer; font-size: 14px; color: var(--link); }
.code { font-size: 34px; font-weight: 600; letter-spacing: .18em; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--text); background: var(--surface-2); border-radius: 14px; padding: 14px 20px; display: inline-block; overflow-wrap: anywhere; }
.code:empty { display: none; }
.binding-error { color: var(--red); }
.history-row { font-variant-numeric: tabular-nums; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; border-top: 1px solid var(--line); padding: 14px 0; color: var(--muted); font-size: 14px; }
.history-row:first-child { border-top: 0; }
.history-row button { font-size: 14px; min-height: 32px; padding: 5px 14px; }

/* Sign-in: a standalone centred card over a soft colour wash, Apple ID style. */
body[data-view="login"] { background: radial-gradient(55% 45% at 12% 8%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 70%), radial-gradient(45% 45% at 92% 92%, rgba(255,95,130,.16), transparent 70%), var(--bg); background-attachment: fixed; }
body[data-view="login"] .app-shell { grid-template-columns: minmax(0,1fr); }
body[data-view="login"] .sidebar, body[data-view="login"] .page-header { display: none; }
body[data-view="login"] main { display: flex; flex-direction: column; justify-content: center; min-height: 100vh; padding-top: 32px; }
body[data-view="login"] .feedback { width: 100%; max-width: 420px; margin: 0 auto 16px; }
body[data-view="login"] footer { justify-content: center; text-align: center; border-top: 0; }
.login-card { width: 100%; max-width: 420px; margin: 0 auto; padding: 40px 36px 36px; text-align: center; background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px); box-shadow: 0 12px 40px rgba(0,0,0,.08), 0 0 0 .5px rgba(0,0,0,.04); }
.login-mark { width: 72px; height: 72px; margin: 0 auto 20px; border-radius: 18px; display: grid; place-items: center; color: #fff; background: linear-gradient(160deg, #3a9bff, #0060df); box-shadow: 0 8px 22px rgba(0,113,227,.35); }
.login-mark svg { width: 40px; height: 40px; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.login-card h2 { font-size: 28px; margin: 6px 0 6px; }
.login-card form { margin-top: 28px; text-align: left; }
.login-card input:not([type=radio]):not([type=range]) { max-width: none; }
.login-card button { width: 100%; margin-top: 12px; min-height: 48px; font-size: 17px; }
body[data-view="login"] .navigation, body[data-view="login"] .nav-label { display: none; }
body[data-view="login"] .page-header { justify-content: center; text-align: center; }
body[data-view="login"] .page-header .header-actions { display: none; }
body:not([data-view="admin"]) .admin-only { display: none !important; }
body:not([data-view="viewer"]) .viewer-only { display: none !important; }

footer { border-top: 1px solid var(--line); padding: 20px 0 28px; margin: 40px 0 0; display: flex; justify-content: space-between; gap: 16px; color: var(--faint); font-size: 12px; flex-wrap: wrap; }
.location-row { padding: 12px 0; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
dialog { max-width: 95vw; max-height: 95vh; border: 0; border-radius: 20px; padding: 20px; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,0,0,.45); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
dialog img { display: block; max-width: 90vw; max-height: 80vh; object-fit: contain; margin: 16px auto 0; border-radius: 10px; }
dialog:fullscreen { max-width: none; max-height: none; width: 100vw; height: 100vh; border-radius: 0; background: #000; }
dialog:fullscreen img { max-height: 86vh; }

@media (max-width: 1150px) {
  .app-shell { grid-template-columns: 220px minmax(0,1fr); }
  main { padding: 40px 32px 0; }
  .link-row { flex-wrap: wrap; }
  .link-field { flex-basis: 100%; }
  .mood-layout { grid-template-columns: 1fr 1.3fr; gap: 24px; }
}
/* Tablet & phone: sidebar becomes a frosted top bar with a scrolling tab strip. */
@media (max-width: 850px), (orientation: landscape) and (max-height: 600px) and (max-width: 1200px) {
  .app-shell { grid-template-columns: minmax(0,1fr); }
  .sidebar { position: sticky; top: 0; z-index: 5; min-width: 0; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px 10px; display: block; }
  .brand { font-size: 17px; padding: 0; }
  .brand-mark { width: 32px; height: 32px; border-radius: 8px; }
  .brand-mark svg { width: 19px; height: 19px; }
  .nav-label, .sidebar-note { display: none; }
  .navigation { flex-direction: row; gap: 6px; margin-top: 12px; overflow-x: auto; padding: 2px 0; scrollbar-width: none; }
  .navigation::-webkit-scrollbar { display: none; }
  .navigation a { padding: 7px 14px; font-size: 14px; gap: 6px; min-height: 36px; border-radius: 980px; background: var(--fill); }
  .navigation a .icon { width: 16px; height: 16px; }
  main { padding: 28px 20px 0; }
  html { scroll-padding-top: 120px; }
  .login-card { margin-top: 24px; }
}
@media (max-width: 600px) {
  main { padding: 24px 16px 0; }
  .page-header { align-items: flex-start; margin-bottom: 24px; gap: 12px; }
  h1 { font-size: 32px; }
  .page-description { font-size: 15px; }
  .header-actions { flex-direction: column; align-items: flex-end; gap: 8px; }
  .header-actions button { font-size: 14px; padding: 6px 14px; min-height: 34px; }
  h2 { font-size: 22px; }
  section { padding: 22px 20px; margin-bottom: 20px; border-radius: 20px; }
  .section-heading { margin-bottom: 18px; gap: 12px; }
  .tile-lg { width: 44px; height: 44px; }
  .share-panel .actions button { flex: 1 1 calc(50% - 10px); }
  .share-panel .actions .text-button { flex-basis: 100%; }
  .link-row button, .link-row .button-link { flex: 1; }
  .share-link { font-size: 13px; }
  .device { padding: 18px; }
  .image-button, .empty { min-height: 200px; }
  #phone-relay iframe { height: min(68vh,620px); }
  .mood-layout { grid-template-columns: 1fr; gap: 24px; }
  .mood-preview { min-height: 180px; padding: 24px; }
  .mood-emoji { font-size: 40px; }
  .mood-text { font-size: 20px; }
  .mood-options { gap: 6px; }
  .mood-options label { min-height: 82px; padding-inline: 4px; }
  .viewer-tools { align-items: flex-start; flex-direction: column; }
  footer { flex-direction: column; gap: 6px; margin-top: 28px; }
  .login-card { padding: 32px 22px; }
  .login-card h2 { font-size: 26px; }
  .code { font-size: 26px; }
  dialog { padding: 14px; }
  dialog .row { flex-wrap: wrap; }
  dialog img { max-width: 86vw; }
}
/* A phone can be wider than the tablet breakpoint after rotation. */
@media (orientation: landscape) and (max-height: 600px) and (max-width: 1200px) {
  body[data-view="viewer"] .sidebar { display: flex; flex-direction: row; align-items: center; gap: 16px; padding: 6px max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left)); }
  body[data-view="viewer"] .brand { flex: none; font-size: 15px; gap: 8px; }
  body[data-view="viewer"] .brand small { display: none; }
  body[data-view="viewer"] .navigation { flex: 1; min-width: 0; margin-top: 0; }
  body[data-view="viewer"] .navigation a { padding: 6px 10px; }
  body[data-view="viewer"] main { display: block; padding: 12px max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); }
  body[data-view="viewer"] .page-header { align-items: center; margin-bottom: 8px; }
  body[data-view="viewer"] .page-header h1 { font-size: 22px; }
  body[data-view="viewer"] .page-header :is(.eyebrow, .page-description) { display: none; }
  body[data-view="viewer"] #screens:has(#phone-relay:not([hidden])) { display: flex; flex-direction: column; }
  body[data-view="viewer"] #screens:has(#phone-relay:not([hidden])) > :is(.section-heading, .viewer-tools) { display: none; }
  body[data-view="viewer"] #screens:has(#phone-relay:not([hidden])) > #devices { order: 1; margin-top: 16px; }
  body[data-view="viewer"] #phone-relay { margin-top: 0; padding: 10px; border-radius: 14px; }
  body[data-view="viewer"] #phone-relay :is(.device-head, .device-footnote) { display: none; }
  body[data-view="viewer"] #phone-relay iframe { margin-top: 0; height: calc(100vh - 148px); height: calc(100dvh - 148px); min-height: 100px; border-radius: 8px; }
}
/* Sections ease in when a view opens. */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
main > section:not([hidden]) { animation: rise .45s cubic-bezier(.2,.7,.2,1) both; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  button, .button-link, .device, .map-tile, #music-preview { transition: none; }
  main > section:not([hidden]), .map-pin::after, .eq i { animation: none; }
}
