/* Shared chrome for every page: menu bar, account menu, login page and dark theme. */

/* ---------- Menu bar ---------- */
:root {
  --page-gutter: clamp(16px, 3vw, 32px);
  --safe-start: max(var(--page-gutter), calc(env(safe-area-inset-left) + 12px));
  --safe-end: max(var(--page-gutter), calc(env(safe-area-inset-right) + 12px));
  --app-width: min(1180px, calc(100% - var(--safe-start) - var(--safe-end)));
  --app-start: max(var(--safe-start), calc((100% - 1180px) / 2));
  --chrome-bg: var(--cream);
  --chrome-line: var(--ink);
}
:root[data-theme="dark"] { --chrome-bg: #111; --chrome-line: var(--wall-ink); }
.app-bar { position: sticky; top: 0; z-index: 20; padding: max(8px, env(safe-area-inset-top)) 0 9px; background: var(--chrome-bg); border-bottom: 2px solid var(--chrome-line); }
.app-shell { width: var(--app-width); margin-inline: var(--app-start) auto; }
.app-top { display: flex; align-items: center; gap: 14px; min-height: 48px; }
.app-top .brand { flex: 0 1 auto; min-width: 0; }
.app-primary-nav { display: none; }
.menu-desktop-label { display: none; }
.app-nav { display: flex; gap: 6px; margin-inline: auto; padding: 4px; border: var(--line); border-radius: 99px; background: var(--white); box-shadow: 3px 3px 0 var(--ink); }
.app-nav a { display: grid; place-items: center; min-height: 38px; padding: 0 14px; border-radius: 99px; font-weight: 700; font-size: .92rem; white-space: nowrap; }
.app-nav a:hover { background: var(--yellow); }
.app-nav a[aria-current="page"] { background: var(--ink); color: var(--cream); }
.app-tools { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; margin-left: auto; }
.icon-button { width: 44px; padding: 0; border-radius: 50%; font-size: 1.15rem; }
.app-account { position: relative; }
.app-account summary { list-style: none; cursor: pointer; }
.app-account summary::-webkit-details-marker { display: none; }
.app-account summary::marker { content: ""; }
.app-menu { position: absolute; right: 0; top: calc(100% + 10px); z-index: 30; display: grid; gap: 8px;
  width: min(280px, calc(100vw - var(--safe-start) - var(--safe-end))); padding: 12px;
  border: var(--line); border-radius: 14px; background: var(--white); box-shadow: var(--shadow); }
.app-menu > :is(strong, p), .app-menu a { overflow-wrap: anywhere; }
.app-menu a { font-weight: 700; padding: 6px 2px; }
.app-menu a:hover { text-decoration: underline; text-underline-offset: 4px; }
.app-menu .muted { font-size: .85rem; }

@media (max-width: 720px) {
  .app-top { gap: 8px; }
  .app-top .brand strong { font-size: clamp(.85rem, 3.6vw, 1.08rem); }
  .app-top .brand-mark { flex-basis: 29px; height: 29px; }
  .app-account summary { padding-inline: 10px; }
  .app-nav { order: 3; flex: 1 0 100%; justify-content: space-evenly; margin: 0; }
  .app-nav a { flex: 1; padding: 0 8px; }
}

/* Settings: section menu */
.section-menu { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
.section-menu a { padding: 7px 12px; border: var(--line); border-radius: 99px; background: var(--white); color: #111111; font-weight: 700; font-size: .88rem; }
.section-menu a:hover { background: var(--yellow); }
.settings section[id] { scroll-margin-top: 90px; }

/* ---------- Login page ---------- */
.login-page { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; color: var(--ink); }
.login-top { display: flex; justify-content: space-between; align-items: center; padding-block-start: max(16px, env(safe-area-inset-top)); padding-inline: var(--safe-start) var(--safe-end); }
.login-main { display: grid; place-items: center; padding: 24px var(--safe-end) max(32px, env(safe-area-inset-bottom)) var(--safe-start); }
.login-card { width: min(420px, 100%); display: grid; gap: 10px; padding: clamp(20px, 4vw, 32px); }
.login-card h1 { font-family: var(--heading); font-size: clamp(2rem, 7vw, 2.8rem); line-height: 1; }
.login-card h1 span { color: var(--blue); }
.login-card label { font-size: .9rem; font-weight: 700; }
.login-card button[type=submit] { justify-self: start; margin-top: 6px; }
.login-card form { display: grid; gap: 9px; }
.login-message { min-height: 1.4em; font-weight: 700; }
.login-message:empty { display: none; }

/* Account list: actions side by side */
.account-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.account-list li > span { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; min-width: 0; }
.account-list .dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.account-list .dialog-actions button { width: auto; min-width: 0; display: inline-flex; }

/* ======================================================================
   Palettes (preset colour sets that fit the style; chosen per account)
   green/blue carry white text, orange/pink/yellow carry black text.
   ====================================================================== */
:root[data-palette="tropicale"] { --green: #0F766E; --blue: #6D28D9; --orange: #FF7A59; --pink: #FFB4A2; --yellow: #C6F432; }
:root[data-palette="memphis"]   { --green: #00838F; --blue: #D6006F; --orange: #FF9F1C; --pink: #8EE3F5; --yellow: #FFF275; }
:root[data-palette="pastello"]  { --green: #2F6B4F; --blue: #4F4FC9; --orange: #FFB38A; --pink: #F7C6E0; --yellow: #FFF1A8; }
:root[data-palette="agrumi"]    { --green: #2E6B30; --blue: #B23A0B; --orange: #FFA62B; --pink: #FFD3B0; --yellow: #FFE600; }
:root[data-palette="mare"]      { --green: #00695C; --blue: #0B3D91; --orange: #FF6F61; --pink: #A0E7E5; --yellow: #FFE66D; }
:root[data-palette="bosco"]     { --green: #2D6A4F; --blue: #7B2D26; --orange: #E9A23B; --pink: #D8E2B3; --yellow: #F4D35E; }

/* ======================================================================
   Painted wall: big shapes fixed at the screen edges (theme.js draws them)
   ====================================================================== */
html { background: var(--cream); }
body { background: transparent; }
:root[data-theme="dark"] { background: #111111; }
.wall { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; animation: wall-in .9s cubic-bezier(.2, .9, .3, 1.2) both; }
.wall svg { position: absolute; display: block; height: auto; }
/* Shapes live on the right edge (behind opaque cards); the left edge carries the
   page titles, so shapes appear there only when the screen has free margins. */
.w-blob     { width: 440px; right: -150px; top: 70px; animation: wall-float 11s ease-in-out infinite; }
.w-burst    { width: 130px; right: 70px; top: 38%; animation: spin 40s linear infinite; }
.w-stripes  { width: 150px; right: -48px; top: 50%; transform: rotate(6deg); }
.w-swoosh   { width: 520px; right: -130px; bottom: -60px; animation: wall-float 13s ease-in-out -4s infinite; }
.w-zig      { width: 300px; left: -150px; top: 30%; animation: wall-float 12s ease-in-out -7s infinite; }
.w-checker  { width: 240px; left: -70px; bottom: -60px; transform: rotate(-12deg); }
@keyframes wall-in { from { opacity: 0; transform: scale(1.04); } to { opacity: 1; transform: none; } }
@keyframes wall-float { 0%, 100% { translate: 0 0; } 50% { translate: -8px 12px; } }
@media (max-width: 1599px) { .wall .w-zig, .wall .w-checker { display: none; } }
@media (max-width: 1100px) {
  .w-blob { width: 300px; right: -150px; top: 64px; }
  .wall .w-burst { display: none; }
  .w-stripes { width: 110px; right: -62px; top: 52%; }
  .w-swoosh { width: 380px; right: -170px; bottom: -80px; }
}
@media (max-width: 600px) {
  .w-blob { width: 210px; right: -150px; top: 58%; }
  .wall .w-stripes { display: none; }
  .w-swoosh { width: 260px; right: -150px; bottom: -80px; }
}
.login-page .wall :is(.w-zig, .w-burst, .w-checker) { display: none; }

/* ======================================================================
   Stickers (inline SVG drawn by theme.js into [data-sticker])
   ====================================================================== */
.sticker { position: absolute; z-index: 0; pointer-events: none; width: var(--size, 72px); animation: sticker-float 6s ease-in-out infinite; }
.sticker .sticker-svg { display: block; width: 100%; height: auto; }
.sticker-vinyl { animation: spin 9s linear infinite; }
.login-main .sticker-star { --size: 92px; top: 12%; left: max(4%, calc(50% - 330px)); }
.login-main .sticker-vinyl { --size: 120px; bottom: 9%; right: max(3%, calc(50% - 360px)); }
.login-main .sticker-plant { --size: 84px; bottom: 7%; left: max(3%, calc(50% - 360px)); animation-delay: -2s; }
.login-main .sticker-squiggle { --size: 110px; top: 16%; right: max(4%, calc(50% - 320px)); animation-delay: -4s; }
.login-main { position: relative; overflow: hidden; }
.login-card { position: relative; z-index: 1; background: var(--white); border-radius: 30px 20px 34px 22px;
  box-shadow: 12px 12px 0 -3px var(--pink), 12px 12px 0 0 var(--ink); }
.login-badge { justify-self: start; display: inline-block; padding: 6px 11px; border: var(--line); border-radius: 7px;
  background: var(--yellow); box-shadow: 3px 3px 0 var(--ink); font-size: .74rem; font-weight: 700; letter-spacing: .08em;
  transform: rotate(-3deg); color: #111111; }
@media (max-width: 560px) {
  .login-main .sticker-squiggle, .login-main .sticker-plant { display: none; }
  .login-main .sticker-star { --size: 64px; top: 4%; }
  .login-main .sticker-vinyl { --size: 84px; bottom: 3%; }
}
.login-card .muted, .login-card p { color: #111111; }

/* Sticker next to the page titles and in the Ascolta hero */
.screen-heading h1 { position: relative; }
.screen-heading h1:has(.title-sticker) { padding-right: 1.05em; }
.title-sticker { position: absolute; top: -.2em; right: 0; width: .85em; animation: sticker-float 5s ease-in-out infinite; }
.title-sticker .sticker-svg { display: block; width: 100%; height: auto; }
.listen-hero { position: relative; overflow: hidden; }
.hero-sticker { position: absolute; right: -26px; bottom: -30px; width: 110px; pointer-events: none; animation: spin 12s linear infinite; }
.hero-sticker .sticker-svg { display: block; width: 100%; height: auto; }
.listen-hero > :not(.hero-sticker) { position: relative; z-index: 1; }

/* Palette picker (account menu) */
.palette-picker { display: grid; gap: 6px; margin: 4px 0; padding: 0; border: 0; }
.palette-picker legend { font-size: .8rem; font-weight: 700; margin-bottom: 4px; }
.palette-option { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 38px;
  padding: 6px 9px; border: var(--line); border-radius: 10px; background: var(--white); color: #111111; font-size: .85rem; font-weight: 700;
  box-shadow: 2px 2px 0 var(--ink); cursor: pointer; }
.palette-option:hover { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }
.palette-option[aria-checked="true"] { background: var(--yellow); }
.palette-swatches { display: flex; }
.palette-swatches i { width: 16px; height: 16px; margin-left: -4px; border: 2px solid #111111; border-radius: 50%; }
.app-menu { max-height: calc(100vh - 90px); max-height: calc(100dvh - 90px - env(safe-area-inset-top)); overflow: auto; }

/* ======================================================================
   Animations
   ====================================================================== */
@keyframes pop-in { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes drop-in { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
@keyframes sticker-float { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-9px) rotate(5deg); } }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-7deg); } 75% { transform: rotate(7deg); } }
@keyframes badge-tilt { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(2deg); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }

.app-bar { animation: drop-in .45s cubic-bezier(.2, .9, .3, 1.2) both; }
.login-card, main .panel, .section-menu a, .notice, .intro-copy > *, .hero-visual, .album-button, .song-list > * {
  animation: pop-in .5s cubic-bezier(.2, .9, .3, 1.15) both;
}
.workspace > :nth-child(2), .explore-grid > :nth-child(2), .section-menu a:nth-child(2) { animation-delay: .06s; }
.workspace > :nth-child(3), .explore-grid > :nth-child(3), .section-menu a:nth-child(3) { animation-delay: .12s; }
.workspace > :nth-child(4), .explore-grid > :nth-child(4), .section-menu a:nth-child(4) { animation-delay: .18s; }
.section-menu a:nth-child(5) { animation-delay: .24s; }
.intro-copy > :nth-child(2) { animation-delay: .05s; }
.intro-copy > :nth-child(3) { animation-delay: .1s; }
.intro-copy > :nth-child(4) { animation-delay: .15s; }
.hero-visual { animation-delay: .15s; }
#settings-main > section:nth-of-type(2) { animation-delay: .06s; }
#settings-main > section:nth-of-type(3) { animation-delay: .1s; }
#settings-main > section:nth-of-type(4) { animation-delay: .14s; }
#settings-main > section:nth-of-type(5) { animation-delay: .18s; }
.login-badge, .model { animation: badge-tilt 4s ease-in-out infinite; }
.brand:hover .brand-mark { animation: spin 1.2s linear infinite; }
.section-menu a:hover, .app-nav a:hover { animation: wobble .35s ease-in-out; }
#theme-toggle svg { transition: transform .45s cubic-bezier(.2, .9, .3, 1.3); }
#theme-toggle:active svg, #theme-toggle:hover svg { transform: rotate(160deg); }
.login-message.shake { animation: shake .4s ease-in-out; }
.app-menu { animation: pop-in .22s ease-out both; transform-origin: top right; }
.album-button:hover .art { animation: wobble .4s ease-in-out; }

@media (prefers-reduced-motion: reduce) {
  .sticker, .title-sticker, .hero-sticker, .wall, .wall svg, .login-badge, .model { animation: none !important; }
  .app-bar, .login-card, main .panel, .section-menu a, .notice, .intro-copy > *, .hero-visual, .album-button,
  .song-list > *, .app-menu { animation: none !important; }
}

/* ======================================================================
   Dark theme "parete di notte": black wall, palette colours kept at full
   strength. Black text on pink/yellow/cream, white on blue/green/black.
   ====================================================================== */
:root[data-theme="dark"] {
  color-scheme: dark;
  --wall: #111111;
  --wall-ink: #FAF8F5;
  --pop: var(--yellow);    /* hard shadow of blocks hanging on the wall */
  background: var(--wall);
  color: var(--wall-ink);
}
:root[data-theme="dark"] body { color: var(--wall-ink); }
:root[data-theme="dark"] :is(input:not([type=range]), select, textarea) { color-scheme: light; }

/* Every block keeps its own colours and black text... */
:where(:root[data-theme="dark"]) :where(.panel, .login-card, .app-menu, .audio-dock, .notice, dialog, .mini-copy, .album-detail, .app-nav,
  .explore-grid > section, .section-menu a, #https-required, .pending-card) { color: #111111; }
/* ...except the blue, green and black ones (white text). */
:root[data-theme="dark"] :is(.hdmi, .radio-grid .panel, .marquee) { color: #fff; }
:root[data-theme="dark"] .radio-grid .panel:nth-child(3) { color: #111111; }
:root[data-theme="dark"] .radio-grid .panel:disabled { color: #111111; }

/* Hard coloured shadows so the blocks stand out from the black wall */
:root[data-theme="dark"] main .panel { box-shadow: 6px 6px 0 var(--pop); }
:root[data-theme="dark"] .explore-grid > section { box-shadow: 4px 4px 0 var(--pink); }
:root[data-theme="dark"] main .panel:nth-child(3n+2) { box-shadow: 6px 6px 0 var(--pink); }
:root[data-theme="dark"] main .panel:nth-child(3n) { box-shadow: 6px 6px 0 color-mix(in srgb, var(--blue) 65%, #fff); }
:root[data-theme="dark"] .panel .panel { box-shadow: var(--shadow); }
:root[data-theme="dark"] .notice { box-shadow: 5px 5px 0 var(--pink); }
:root[data-theme="dark"] .login-card { box-shadow: 12px 12px 0 -3px var(--yellow), 12px 12px 0 0 var(--wall-ink); }

/* Things sitting straight on the wall: cream outline, coloured shadow */
:root[data-theme="dark"] :is(.hero-actions .button, .section-menu a, .app-tools .secondary, .listen-nav button,
  .model, .mode, .login-badge, .deck-heading .mode, #install) { border-color: var(--wall-ink); box-shadow: 4px 4px 0 var(--pop); }
:root[data-theme="dark"] .listen-nav button { color: #111111; }
:root[data-theme="dark"] :is(.model, .mode, .login-badge) { color: #111111; }
:root[data-theme="dark"] .listen-nav [aria-current] { color: #fff; }
:root[data-theme="dark"] :is(.hero-actions .button, .section-menu a, .app-tools .secondary, .listen-nav button):not(:disabled):is(:hover, :active) { box-shadow: 2px 2px 0 var(--pop); }

/* Menu bar */
:root[data-theme="dark"] .app-bar { background: rgba(17, 17, 17, .92); border-bottom-color: var(--wall-ink); backdrop-filter: blur(6px); }
:root[data-theme="dark"] .app-nav { border-color: var(--wall-ink); box-shadow: 4px 4px 0 var(--pink); }
:root[data-theme="dark"] .app-nav a[aria-current="page"] { background: #111111; color: var(--wall-ink); }
:root[data-theme="dark"] .app-nav a:hover { background: var(--yellow); }
:root[data-theme="dark"] .brand-mark { border-color: var(--wall-ink); }

/* Titles and accents on the wall */
:root[data-theme="dark"] :is(h1, .deck-heading h2) > span { color: var(--yellow); }
:root[data-theme="dark"] .panel h1 > span { color: var(--blue); }
:root[data-theme="dark"] .muted { color: #CFC8BD; }
:root[data-theme="dark"] :is(.panel, .explore-grid > section, .album-button, .audio-dock, .login-card, .app-menu, .song-main, .album-detail) .muted { color: var(--muted); }
:root[data-theme="dark"] :is(.intro-copy, .deck-heading, .screen-heading) .muted { color: #CFC8BD; }
:root[data-theme="dark"] .marquee { border-color: var(--wall-ink); }
:root[data-theme="dark"] .footer { border-top-color: var(--wall-ink); }
:root[data-theme="dark"] .footer :is(.button, .secondary) { border-color: var(--wall-ink); }
:root[data-theme="dark"] .audio-dock { border-top-color: var(--wall-ink); }
:root[data-theme="dark"] .hero-board { box-shadow: 8px 8px 0 var(--pink); }
:root[data-theme="dark"] .account-list li { border-bottom-color: rgba(17, 17, 17, .18); }
:root[data-theme="dark"] .login-page { color: var(--wall-ink); }

/* System status (Settings) */
.system-panel { max-width: 980px; background: var(--white); color: #111; }
.system-updated { font-size: .8rem; font-weight: 700; color: var(--muted); }
.system-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-top: 12px; }
#settings-main { width: min(1020px, var(--app-width)); margin-inline: max(var(--safe-start), calc((100% - 1020px) / 2)) auto; }
#settings-main > .screen-heading { margin-bottom: 18px; }
#settings-main > .screen-heading h1 { font-size: clamp(1.9rem, 5.8vw, 3.6rem); }
.settings-index { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.settings-group { align-self: start; display: grid; gap: 9px; padding: 14px; border: var(--line); border-radius: 16px; background: var(--cream); box-shadow: var(--shadow); }
.settings-group h2 { font-size: 1.12rem; }
.settings-group a { position: relative; display: grid; gap: 2px; padding: 10px 34px 10px 10px; min-height: 52px; border: var(--line); border-radius: 10px; background: var(--white); color: #111; }
.settings-group a::after { content: ""; position: absolute; inset-inline-end: 14px; align-self: center; width: 8px; height: 8px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(-45deg); }
.settings-group a span { font-size: .81rem; line-height: 1.28; }
.settings-group a:is(:hover, :focus-visible) { background: var(--yellow); }
.settings-back { margin-bottom: 12px; min-height: 44px; }
#settings-detail > section:not([data-active]) { display: none; }
#settings-detail > section { margin-top: 0; max-width: none; }
.access-layout { display: flex; flex-wrap: wrap; align-items: start; gap: 16px; margin-top: 14px; }
.access-layout img { max-width: 100%; height: auto; border: var(--line); border-radius: 12px; background: white; }
.access-layout .wifi-form { flex: 1 1 16rem; min-width: 0; }
.access-layout button { justify-self: start; }
#stereo-groups, .stereo-keys { display: grid; gap: 10px; }
main.stereo-remote { width: min(580px, calc(100% - 28px)); margin: clamp(16px, 4vw, 36px) auto;
  padding: clamp(10px, 3vw, 22px); border: 3px solid #111; border-radius: 26px;
  background: #242424; color: #faf8f5; box-shadow: 5px 5px 0 var(--yellow); }
.stereo-remote-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.stereo-remote-head h1 { flex: 1 1 auto; margin: 0; max-width: 100%; font-size: clamp(1.45rem, 5vw, 2.25rem);
  letter-spacing: -.04em; overflow-wrap: anywhere; }
.stereo-remote-head h1 span { color: var(--yellow); }
.stereo-remote-head p { flex-basis: 100%; font-size: .84rem; }
.stereo-remote-head p:empty { display: none; }
.stereo-profile-select { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.stereo-profile-select button { flex: 1 1 118px; min-width: 0; box-shadow: none; }
.stereo-profile-select button[aria-pressed="true"] { background: #ffd60a; }
.stereo-group { padding: 8px; border: 2px solid #585858; border-radius: 16px; background: #141414; }
.stereo-group summary { padding: 7px; cursor: pointer; font-weight: 700; }
.stereo-group h2 { padding: 7px; font: 700 1rem "Space Grotesk", sans-serif; letter-spacing: 0; }
.stereo-group-hint { padding: 0 7px 7px; color: #e3ddd5; font-size: .83rem; }
.stereo-keys { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; padding: 5px; }
.remote-key { display: grid; place-content: center; gap: 3px; min-width: 0; min-height: 54px;
  padding: 6px 4px; border: 2px solid #111; border-radius: 12px; background: var(--cream);
  color: #111; box-shadow: 0 3px 0 #575757; line-height: 1.13; font-size: .82rem;
  font-weight: 700; overflow-wrap: anywhere; }
.remote-key-icon { font-size: 1.26rem; line-height: 1; }
.stereo-group[data-kind="power"] .stereo-keys { grid-template-columns: minmax(0, 1fr); }
.stereo-group[data-kind="power"] .remote-key { grid-auto-flow: column; gap: 10px; align-items: center; min-height: 55px; }
.stereo-group[data-kind="volume"] .remote-key:not(:disabled) { min-height: 66px; background: #1b7f5c; color: #fff; }
.stereo-group[data-kind="sources"] .remote-key:not(:disabled) { background: #ffd60a; }
.remote-key:is([data-command="on"], [data-command="off"], [data-command="power"], [data-command="tuner_power"]):not(:disabled) {
  background: #ff8a56; }
.remote-key:disabled { opacity: .6; }
.remote-key:focus-visible { outline-color: #faf8f5; outline-offset: 2px; }
.remote-key:not(:disabled):active { transform: translateY(2px); box-shadow: 0 1px 0 #575757; }
#rfid-list-title { margin-top: 18px; font-size: 1.1rem; }
@media (max-width: 850px) {
  .settings-index { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 580px) {
  #settings-main > .screen-heading h1 { font-size: clamp(1.5rem, 7vw, 2.3rem); }
  .settings-index { grid-template-columns: minmax(0, 1fr); }
  .settings-group { padding: 12px; }
}
#hdmi-panel .system-tile { margin-block-start: 0; }
#hdmi-panel :is(select, button) { max-width: 100%; }
#hdmi-refresh { margin-block-start: 16px; }
.system-tile { display: grid; gap: 6px; align-content: start; padding: 12px; border: var(--line); border-radius: 14px 10px 16px 12px; background: var(--cream); box-shadow: 3px 3px 0 var(--ink); min-width: 0; }
.system-tile.ok { background: var(--tint-green); }
.system-tile.warn { background: var(--tint-yellow); }
.system-tile.bad { background: var(--orange); }
.system-label { font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.system-tile strong { font-family: var(--heading); font-size: 1.35rem; line-height: 1.05; overflow-wrap: anywhere; white-space: pre-wrap; }
.system-detail { font-size: .8rem; overflow-wrap: anywhere; }
.system-bar { height: 10px; border: 2px solid #111; border-radius: 99px; background: var(--white); overflow: hidden; }
.system-bar i { display: block; height: 100%; background: var(--blue); transition: width .6s ease; }
.system-tile.warn .system-bar i { background: var(--orange); }
.system-tile.bad .system-bar i { background: #111; }
.system-alerts .notice { margin: 10px 0 0; }
.offline-info { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 2px dashed rgba(17, 17, 17, .25); font-size: .82rem; font-weight: 700; color: #111; }
.offline-info .secondary { min-height: 44px; padding: 4px 10px; }

/* Line icons drawn with the text colour (same weight as the menu icons, never system emoji). */
.ico { display: inline-block; width: 1.15em; height: 1.15em; flex: 0 0 auto; vertical-align: -.2em; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220%200%2024%2024%22%20fill=%22none%22%20stroke=%22%23000%22%20stroke-width=%222.6%22%20stroke-linecap=%22round%22%20stroke-linejoin=%22round%22%3E%3Cpath%20d=%22M3.5%206.5h17%22/%3E%3Cpath%20d=%22M9%206.5V4.2c0-.7.5-1.2%201.2-1.2h3.6c.7%200%201.2.5%201.2%201.2v2.3%22/%3E%3Cpath%20d=%22M5.6%206.5l1.1%2013.1c.1%201%20.9%201.9%202%201.9h6.6c1.1%200%201.9-.9%202-1.9l1.1-13.1%22/%3E%3Cpath%20d=%22M10%2010.5v7M14%2010.5v7%22/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220%200%2024%2024%22%20fill=%22none%22%20stroke=%22%23000%22%20stroke-width=%222.6%22%20stroke-linecap=%22round%22%20stroke-linejoin=%22round%22%3E%3Cpath%20d=%22M3.5%206.5h17%22/%3E%3Cpath%20d=%22M9%206.5V4.2c0-.7.5-1.2%201.2-1.2h3.6c.7%200%201.2.5%201.2%201.2v2.3%22/%3E%3Cpath%20d=%22M5.6%206.5l1.1%2013.1c.1%201%20.9%201.9%202%201.9h6.6c1.1%200%201.9-.9%202-1.9l1.1-13.1%22/%3E%3Cpath%20d=%22M10%2010.5v7M14%2010.5v7%22/%3E%3C/svg%3E") center / contain no-repeat; }
button .ico + *, button .ico { pointer-events: none; }
.app-menu-nav { display: grid; gap: 6px; padding-bottom: 8px; border-bottom: 3px solid var(--ink); }
.app-menu-nav[hidden] { display: none; }
.app-menu-nav a { display: grid; place-items: center; min-height: 44px; padding: 8px 12px; border: var(--line); border-radius: 99px; background: var(--white); color: #111; text-align: center; box-shadow: 3px 3px 0 var(--ink); }
.app-menu-nav a:hover { background: var(--yellow); text-decoration: none; }
.app-menu-nav a[aria-current="page"] { background: var(--ink); color: var(--cream); box-shadow: none; }
:root[data-theme="dark"] .app-menu-nav { border-color: var(--wall-ink); }
:root[data-theme="dark"] .app-menu-nav a { box-shadow: 3px 3px 0 var(--pop); }
:root[data-theme="dark"] .app-menu-nav a[aria-current="page"] { background: #111; color: var(--wall-ink); }
.app-account summary::after { content: " ▾"; }
@media (min-width: 821px) {
  .app-primary-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-inline: auto; }
  .app-primary-nav a { display: grid; place-items: center; min-height: 44px; padding: 6px 13px; border-radius: 9px; font-weight: 700; }
  .app-primary-nav a[aria-current] { background: var(--blue); color: var(--on-accent); }
  .app-primary-nav a:not([aria-current]):hover { background: var(--yellow); color: #111; }
  .app-menu-nav:not([hidden]), .menu-mobile-label { display: none; }
  .menu-desktop-label { display: inline; }
}
@media (max-width: 959px) {
  #settings-main[data-detail] .settings-index { display: none; }
}
@media (min-width: 960px) {
  #settings-main[data-detail] { display: grid; grid-template-columns: minmax(210px, 245px) minmax(0, 1fr); align-items: start; gap: 0 22px; }
  #settings-main[data-detail] > .screen-heading { grid-column: 1 / -1; }
  #settings-main[data-detail] .settings-index { grid-template-columns: minmax(0, 1fr); position: sticky; top: 86px;
    max-height: calc(100dvh - 100px); overflow: auto; }
  #settings-main[data-detail] .settings-group { box-shadow: none; padding: 9px; gap: 6px; }
  #settings-main[data-detail] .settings-group a { min-height: 44px; }
  #settings-main[data-detail] .settings-group a span { display: none; }
  #settings-main[data-detail] .settings-group a[aria-current] { background: var(--yellow); }
}
/* Settings and media forms must shrink inside their panels on small screens. */
.listen :is(.screen-heading, .lib-section-head, .tuner-head, .offline-info) { flex-wrap: wrap; }
.listen .screen-heading > :is(h1, h2) { min-width: 0; overflow-wrap: anywhere; }
.listen :is(.screen-heading, .lib-section-head, .tuner-head) > :is(h1, h2) { flex: 1 1 auto; }
.listen :is(.button, button, summary, .wifi-form, .wifi-form strong, .notice, .station-info, .app-menu) { min-width: 0; overflow-wrap: anywhere; }
.listen .wifi-list :is(strong, span), .listen .card-list :is(strong, span) { min-width: 0; }
.listen .wifi-list button { flex-wrap: wrap; }
.listen .wifi-list button > strong { flex: 1 1 135px; }
.listen .system-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
@media (max-width: 650px) {
  .listen :is(textarea, input:not([type=range]), select), .login-page input { font-size: 16px; }
  .listen .playlist-dialog { padding: 14px; }
  .listen .inline-form > :is(input,select) { flex-basis: 100%; }
  .listen .update-versions { grid-template-columns: minmax(0, 1fr); }
}
/* Decorative stickers may poke out of the page: never let them widen it on phones (clip keeps sticky bars working). */
html, body { overflow-x: clip; }


/* Impostazioni → Alexa: stereo a voce e modello della libreria */
.voice-extra { display: grid; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 3px dashed var(--ink); }
.voice-extra h3 { margin: 0; }
.stereo-voice-state { font-weight: 700; }
.stereo-voice-map { display: grid; gap: 8px; margin-top: 10px; }
.stereo-voice-map label { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: center; font-weight: 600; }
.voice-extra code { overflow-wrap: anywhere; }
@media (max-width: 560px) { .stereo-voice-map label { grid-template-columns: minmax(0, 1fr); } }
:root[data-theme="dark"] .voice-extra { border-top-color: var(--wall-ink); }
