/* Page tokens, derived from ui.css's --ink, --ok and --bad. */
body { --ink-soft: #4a4d57; --ok-soft: rgba(127, 216, 173, 0.14); --bad-soft: rgba(255, 154, 146, 0.14); }
.settings { max-width: 62rem; padding: 0; }

.settings h2 { color: var(--text); font-size: var(--t-l); font-weight: 700; margin-top: 1.5rem; }
.settings p.note { color: var(--soft); margin: 0.3rem 0 1rem; }


.box h3 { margin: 0 0 0.4rem; font-size: var(--t-l); font-weight: 700; }
.facts { display: flex; flex-wrap: wrap; gap: 0.4rem 1.6rem; color: var(--soft); margin: 0.6rem 0; font-variant-numeric: tabular-nums; }
.facts b { color: var(--text); font-weight: 600; }
.facts b.ok { color: var(--ok); }
.facts b.bad { color: var(--bad); }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
/* A short state ("attivo", "Inclusa", "in uso") reads as a pill. */
span.ok, b.ok, b.bad { display: inline-block; padding: 0.1em 0.65em; font-weight: 600; border-radius: var(--r-pill); background: var(--ok-soft); }
b.bad { background: var(--bad-soft); }
/* Counts as tiles: the number big, what it counts under it. */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(5rem, 1fr)); gap: var(--s3); margin: 0.8rem 0; }
.stat { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.8rem 1rem; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-radius: var(--r-s); }
.stat b { font-size: var(--t-xl); font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: var(--t-s); color: var(--soft); }
.box .buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.8rem; }


.form { display: grid; grid-template-columns: 12rem 1fr; gap: 0.7rem 1rem; align-items: center; margin: 0.8rem 0; }
.form label { color: var(--soft); }
.form textarea { min-height: 9rem; font-family: ui-monospace, monospace; font-size: 0.85rem; }
.form .full { grid-column: 1 / -1; }

/* Tables: hairlines, tabular numbers, the header as a quiet label. */
.counts { width: 100%; border-collapse: collapse; margin: 0.8rem 0; font-variant-numeric: tabular-nums; }
.counts th, .counts td { padding: 0.55rem 0.6rem; text-align: right; border-bottom: 1px solid var(--line); }
.counts th, .cats th { color: var(--soft); font-size: var(--t-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.counts tr:last-child td, .cats tr:last-child td { border-bottom: 0; }
.counts th:first-child, .counts td:first-child { text-align: left; }
.counts td.changed { color: var(--fav); }

.countries { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0.4rem 1rem; margin: 0.6rem 0; }
/* A tick box with its text: the whole row is the target, large enough
   for the TV pointer and a finger. */
.check { display: flex; gap: 0.7rem; align-items: center; padding: 0.55rem 0.8rem; color: var(--text);
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: var(--r-s); cursor: pointer; }
.form .check { color: var(--text); }
.check:hover { border-color: var(--soft); }
.check:focus-within { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.form .check input, .check input { flex: none; width: 1.4rem; height: 1.4rem; margin: 0; padding: 0; accent-color: var(--accent); cursor: pointer; }
.form .check input:focus { outline: none; }

.cats { width: 100%; border-collapse: collapse; }
.cats th { text-align: left; padding: 0.5rem 0.4rem; border-bottom: 1px solid var(--line); }
.cats td { padding: 0.45rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.cats td.n { text-align: right; color: var(--soft); font-variant-numeric: tabular-nums; }
.cats tr.off td.name { color: var(--soft); text-decoration: line-through; }
.cats .why { color: var(--soft); font-size: 0.85rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin: 1rem 0; }

.form > * { min-width: 0; }
.form input, .form select, .form textarea { width: 100%; }

@media (max-width: 700px) {
  /* Label above the field. */
  .form { grid-template-columns: 1fr; gap: 0.3rem; }
  .form label { margin-top: 0.6rem; }
  .form .check { margin-top: 0; }
  .box { padding: 1rem; }
  /* Categories: one compact card per row. */
  .cats tr:first-child { display: none; }
  .cats tr { display: grid; grid-template-columns: 1fr auto; gap: 0.3rem 0.6rem; padding: 0.7rem 0; border-bottom: 1px solid var(--line); }
  .cats td { padding: 0; border: 0; }
  .cats td.name { grid-column: 1 / -1; font-weight: 600; }
  .cats td.n { text-align: left; }
  .cats td.n:not(.size)::after { content: " titoli"; }
  .cats select { width: 100%; }
  .countries { grid-template-columns: 1fr; }
  .toolbar .pick { flex: 1 1 100%; }
}

/* ---- Layout: sections on the left, the open one on the right; on a
   phone the list first, then the section with its own Back. ---- */
.shell { display: grid; grid-template-columns: minmax(17rem, 22rem) 1fr; gap: 2.5rem; padding: 1.5rem var(--safe) 4rem; }
/* The menu is taller than a TV screen: it scrolls with the page until its
   end is in view, then stays (top set by settings.js), so a long section
   never leaves the left column empty. */
.side { position: sticky; top: var(--side-top, 1.5rem); align-self: start; }
.side h1 { margin: 0.9rem 0 1.2rem; font-size: var(--t-xl); font-weight: 800; }
.side-back { display: inline-flex; align-items: center; gap: 0.45em; padding: 0.4em 0.9em 0.4em 0.6em; margin-left: -0.6em; color: var(--soft); text-decoration: none; border-radius: var(--r-pill); }
.side-back:hover { color: var(--text); }
.side-back:focus { color: var(--ink); background: var(--focus); outline: none; box-shadow: var(--glow); }

/* The list: rows on an opaque card (no blur on lists). Only the focused
   row is white; the open section keeps a light fill and an accent bar,
   wherever the focus is. */
.group { margin-bottom: 1.3rem; }
.group-title { margin: 0 0 0.55rem 1rem; font-size: var(--t-xs); font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--soft); }
.group-list {
  display: flex; flex-direction: column; gap: 2px; padding: 0.3rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), var(--shadow-s);
}
.item {
  position: relative; display: flex; align-items: center; gap: 0.85rem; width: 100%;
  padding: 0.6rem 0.75rem; font: inherit; color: var(--text); text-align: left;
  background: none; border: 0; border-radius: var(--r-s); cursor: pointer;
  transition: background-color var(--dur), transform var(--dur) var(--ease);
}
.item-icon { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; flex: none; color: var(--text); background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-xs); }
.item-icon .icon { width: 1.15rem; height: 1.15rem; }
.item-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.item-title { font-weight: 600; }
.item-sub { font-size: var(--t-s); color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-go { color: var(--soft); display: flex; }
.item.active { background: rgba(255, 255, 255, 0.12); box-shadow: inset 0 1px 0 var(--glass-hi); }
.item.active::before { content: ""; position: absolute; top: 28%; bottom: 28%; left: 0.2rem; width: 3px; background: var(--accent); border-radius: var(--r-pill); }
.item:focus { z-index: 1; color: var(--ink); background: var(--focus); outline: none; transform: scale(1.02); box-shadow: var(--glow); }
.item:focus::before { display: none; }
.item:focus .item-sub, .item:focus .item-go { color: var(--ink-soft); }
.item:focus .item-icon { color: var(--text); background: var(--ink); border-color: transparent; }
@media (hover: hover) and (pointer: fine) {
  .item:not(.active):hover { background: rgba(255, 255, 255, 0.06); }
}

.pane { min-width: 0; }
.pane-head { display: none; }
/* The page title, as .page-title on the other pages. */
.pane .settings > h2:first-child { margin-top: 0.4rem; font-size: var(--t-xl); font-weight: 800; letter-spacing: -0.02em; }

@media (max-width: 800px) {
  .shell { display: block; padding: 0.6rem 16px 3rem; }
  .side { position: static; max-height: none; overflow: visible; }
  body:not(.at-list) .side { display: none; }
  body.at-list .pane { display: none; }
  .item { min-height: 3.6rem; }
  .item:focus { transform: none; }
  /* A floating glass bar: the section name and the way back to the list. */
  .pane-head {
    position: sticky; top: 0.5rem; z-index: 4; display: flex; align-items: center; gap: 0.6rem;
    margin: 0 0 var(--s4); padding: 0.4rem 1rem 0.4rem 0.4rem;
  }
  #pane-title { font-size: var(--t-l); font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pane-back { display: grid; place-items: center; flex: none; width: 2.75rem; height: 2.75rem; padding: 0; color: var(--text); background: rgba(255, 255, 255, 0.1); border: 1px solid var(--glass-line); border-radius: var(--r-pill); }
  .pane-back:focus { color: var(--ink); background: var(--focus); outline: none; box-shadow: var(--glow); }
  /* The bar already shows the section name. */
  .pane .settings > h2:first-child { display: none; }
}
/* Fingers: 44px targets. */
@media (pointer: coarse) {
  .pane-back { width: max(2.75rem, 44px); height: max(2.75rem, 44px); }
  .side-back { min-height: 44px; }
}
.form > button { justify-self: start; width: auto; min-width: 9rem; }
@media (max-width: 800px) { .form > button { justify-self: stretch; } }

/* Local collections: the folder field and the folder picker. */
.path { word-break: break-all; }
.path-field { display: flex; gap: 0.5rem; align-items: center; min-width: 0; }
.path-field input { flex: 1 1 auto; min-width: 0; }
.path-field button { flex: none; }
.picker-panel { grid-column: 1 / -1; }
.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0.4rem; margin-top: 0.8rem; max-height: 50vh; overflow-y: auto; padding: 0.2rem; }
.settings button.small.folder-row { display: block; text-align: left; border-radius: var(--r-s); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings button.small.folder-row::before { content: "📁 "; }
@media (max-width: 700px) {
  .path-field { flex-wrap: wrap; }
  .folders { grid-template-columns: 1fr; }
}

/* Release notes and the update command. */
.settings pre.notes { max-height: 16rem; overflow: auto; white-space: pre-wrap; font: inherit; font-size: 0.95rem; color: var(--soft); margin: 0.6rem 0; }
.settings pre.cmd { display: inline-block; margin: 0.2rem 0 0.6rem; padding: 0.5em 0.9em; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-xs); font-family: ui-monospace, monospace; user-select: all; max-width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-all; }
/* word-break: older WebViews (Android TV, Fire TV) ignore "anywhere". */
.settings .cmd-row { display: flex; align-items: flex-start; gap: 0.5rem; max-width: 100%; margin: 0.2rem 0 0.6rem; }
.settings .cmd-row pre.cmd { flex: 0 1 auto; min-width: 0; margin: 0; }
.settings .cmd-row button { flex: none; }

/* ---- Sections as cards: opaque (no blur on cards), hairline and the
   inner highlight of the glass. ui.css .card is the poster card: the
   settings card resets what it sets. ---- */
.settings .card {
  display: block; gap: 0; cursor: auto; transition: none;
  margin: 0 0 1.6rem;
  padding: 1.5rem 1.8rem 1.7rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), var(--shadow-s);
}
.settings .card > h2 { margin: 0 0 0.9rem; font-size: var(--t-l); font-weight: 700; color: var(--text); }
.card > p.note { line-height: 1.55; margin-bottom: 1.1rem; }
.card .form { gap: 0.9rem 1rem; }
.card > p.note:last-child, .card > :last-child { margin-bottom: 0; }
.card > h3 { margin: 1.6rem 0 0.5rem; padding-top: 1.3rem; font-size: var(--t-m); font-weight: 700; border-top: 1px solid var(--line); }
.card .box { background: rgba(255, 255, 255, 0.03); }
.card .form { margin-bottom: 0.2rem; }
.card .buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.8rem; }
.card > .check { margin-top: 0.6rem; }
.pane .settings > .card:first-child { margin-top: 0.4rem; }
/* The System page shows the server's warnings itself. */
body.view-system #server-problems { display: none; }
@media (max-width: 700px) {
  .settings .card { padding: 1.1rem 1.1rem 1.2rem; margin-bottom: 1.2rem; }
}
#problems-slot #server-problems { position: static; display: block; max-width: none; margin: 0 0 1rem; font-size: 0.9rem; }
#problems-slot #server-problems.compact { max-width: none; max-height: none; white-space: normal; } /* in its own place: always the text */
.sso-account { display: grid; grid-template-columns: 1fr minmax(8rem, 12rem) auto; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }
@media (max-width: 600px) { .sso-account { grid-template-columns: 1fr auto; } .sso-account input { grid-column: 1 / -1; } }

/* The assistant: the card that offers it, the three ways, the models. */
.promo {
  display: grid; grid-template-columns: auto 1fr; gap: 0.6rem 0.85rem; align-items: center;
  margin-bottom: 1.3rem; padding: 1rem; border-radius: var(--r);
  background: linear-gradient(135deg, var(--accent-soft), rgba(255, 255, 255, 0)), var(--surface);
  border: 1px solid var(--accent-soft);
}
.promo-icon { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; color: var(--accent-ink); background: var(--accent-grad); border-radius: var(--r-s); }
.promo-icon .icon { width: 1.3rem; height: 1.3rem; }
.promo-text { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.promo-text span { font-size: 0.86rem; color: var(--soft); }
.promo .buttons { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.ways { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0.6rem; }
.way {
  display: flex; flex-direction: column; gap: 0.3rem; padding: 0.85rem 0.95rem; text-align: left;
  font: inherit; color: var(--text); background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
}
.way span { font-size: 0.84rem; color: var(--soft); }
.way.chosen { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
/* One under the other: Up and Down on the remote, as a list. */
.ways.stack { grid-template-columns: 1fr; }
.way:focus { outline: 2px solid var(--focus); outline-offset: 2px; }
.box.model h3 { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; }
.box.model.dim { opacity: 0.6; }
.tag { padding: 0.1em 0.55em; font-size: 0.72rem; font-weight: 600; color: var(--soft); background: var(--raised); border-radius: 999px; }
.tag.good { color: var(--accent-ink); background: var(--accent); }
.tag.bad { color: var(--bad); }
.progress { height: 0.5rem; margin: 0.4rem 0 0.6rem; overflow: hidden; background: var(--raised); border-radius: 999px; }
.progress > div { height: 100%; background: var(--accent-grad); border-radius: inherit; transition: width 0.4s var(--ease); }
.progress.busy > div { animation: busy 1.2s ease-in-out infinite alternate; }
@keyframes busy { from { opacity: 0.35; } to { opacity: 1; } }
.cmd-row input { flex: 1; min-width: 0; }

/* ---- Aspetto: a row per choice, the text left and the control right
   (under it when the pane is narrow). ---- */
.look-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3) var(--s5); padding: var(--s4) 0; border-top: 1px solid var(--line); }
.look-box { padding-top: var(--s2); padding-bottom: var(--s2); }
.look-box > .look-row:first-child { border-top: 0; background-image: none; }
.look-text { display: flex; flex-direction: column; gap: 0.15rem; flex: 1 1 10rem; min-width: 0; }
.look-text b { font-weight: 600; }
.look-text span { font-size: var(--t-s); color: var(--soft); }
/* On/off row: a button with role="switch" as wide as the card (the
   negative margins keep its text in line with the other rows); focused
   it turns white like the list rows. */
.look-toggle {
  flex-wrap: nowrap; width: calc(100% + 2 * var(--s3)); margin: 0 calc(-1 * var(--s3)); padding: var(--s4) var(--s3);
  font: inherit; color: var(--text); text-align: left; border: 0; border-radius: var(--r-s); cursor: pointer;
  /* The hairline drawn as a background, as wide as the other rows'. */
  background: linear-gradient(var(--line), var(--line)) center top / calc(100% - 2 * var(--s3)) 1px no-repeat;
}
.look-toggle:focus { outline: none; color: var(--ink); background: var(--focus); box-shadow: var(--glow); }
.look-toggle:focus .look-text span { color: var(--ink-soft); }
.switch { position: relative; flex: none; width: 3.3rem; height: 1.9rem; background: rgba(255, 255, 255, 0.16); border: 1px solid var(--glass-line); border-radius: var(--r-pill); transition: background-color var(--dur); }
.switch::after { content: ""; position: absolute; top: 50%; left: 0.2rem; width: 1.4rem; height: 1.4rem; margin-top: -0.7rem; background: #fff; border-radius: 50%; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4); transition: transform var(--dur) var(--ease); }
.look-toggle:focus .switch { background: rgba(11, 12, 16, 0.22); border-color: transparent; }
.look-toggle[aria-checked="true"] .switch { background: var(--accent); border-color: transparent; }
.look-toggle[aria-checked="true"] .switch::after { transform: translateX(calc(1.5rem - 2px)); }
/* Grafite's track is near white: a dark knob keeps the switch readable. */
html[data-accent="grafite"] .look-toggle[aria-checked="true"] .switch::after { background: var(--ink); box-shadow: none; }
@media (hover: hover) and (pointer: fine) {
  .look-toggle:not(:focus):hover { background-color: rgba(255, 255, 255, 0.05); }
}
/* Segmented control: ui.css chips on a track; only the chosen (.active,
   a lighter pill) and the focused (white) option show a fill. */
.segmented { display: inline-flex; flex: none; flex-wrap: nowrap; gap: 2px; padding: 3px; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: var(--r-pill); }
.segmented .chip:not(.active):not(:focus) { background: none; border-color: transparent; }
.segmented .chip.active { font-weight: 600; }
/* Accent swatches: a round sample of each gradient, its name under it. */
.swatches { display: flex; flex-wrap: wrap; flex: 1 1 100%; gap: var(--s2); }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; width: 4.4rem; padding: 0.35rem 0; font: inherit; font-size: var(--t-xs); color: var(--soft); background: none; border: 0; cursor: pointer; }
.swatch-dot { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25); transition: transform var(--dur) var(--ease); }
.swatch-dot .icon { width: 1.3rem; height: 1.3rem; color: var(--ink); stroke-width: 3; opacity: 0; }
.swatch[aria-pressed="true"] { color: var(--text); font-weight: 600; }
/* Chosen: the check and the name; the white ring is the focus alone. */
.swatch[aria-pressed="true"] .swatch-dot .icon { opacity: 1; }
.swatch:focus { outline: none; color: var(--text); font-weight: 700; }
.swatch:focus .swatch-dot { transform: scale(1.12); box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--focus), var(--glow); }
/* The same gradients as html[data-accent] in ui.css (which only sets them on <html>). */
.swatch[data-accent="aurora"] .swatch-dot { background: linear-gradient(135deg, #00f5a0, #00b8f5); }
.swatch[data-accent="oceano"] .swatch-dot { background: linear-gradient(135deg, #4f8dff, #7bd0ff); }
.swatch[data-accent="tramonto"] .swatch-dot { background: linear-gradient(135deg, #ff6a3d, #ffb547); }
.swatch[data-accent="lavanda"] .swatch-dot { background: linear-gradient(135deg, #8b5cf6, #c4b5fd); }
.swatch[data-accent="menta"] .swatch-dot { background: linear-gradient(135deg, #22c55e, #86efac); }
.swatch[data-accent="rubino"] .swatch-dot { background: linear-gradient(135deg, #ff4d6d, #ff8fa3); }
.swatch[data-accent="grafite"] .swatch-dot { background: linear-gradient(135deg, #d9dbe3, #f5f5f7); }
@media (max-width: 700px) {
  .swatch { width: 3.9rem; }
}
