/* Base e struttura della pagina: barra laterale, barra in alto, area principale. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--fs-m)/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 600; }
p { margin: 0; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-s); }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.small { font-size: var(--fs-s); }
.xsmall { font-size: var(--fs-xs); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.i-s { width: 15px; height: 15px; }

/* ---------- Struttura ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  grid-template-rows: var(--bar-h) minmax(0, 1fr);
  grid-template-areas: "rail bar" "rail main";
  min-height: 100vh;
  min-height: 100dvh;
}
.rail {
  grid-area: rail;
  position: sticky; top: 0;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; gap: 2px;
  padding: 14px 12px;
  background: var(--rail-bg);
  color: var(--rail-ink);
}
.rail-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 18px;
  color: var(--rail-ink-strong); font-weight: 700; font-size: var(--fs-l); letter-spacing: -.01em;
}
.rail-brand:hover { text-decoration: none; }
.rail-logo {
  width: 26px; height: 26px; flex: none;
  background: var(--tag);
  clip-path: polygon(0 0, 72% 0, 100% 50%, 72% 100%, 0 100%);
  position: relative;
}
.rail-logo::after {
  content: ''; position: absolute; left: 60%; top: 50%; width: 5px; height: 5px; margin: -2.5px 0 0 -2.5px;
  border-radius: 50%; background: var(--rail-bg);
}
.rail-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--r-m);
  color: var(--rail-ink); font-weight: 500;
}
.rail-item:hover { background: var(--rail-hover); color: var(--rail-ink-strong); text-decoration: none; }
.rail-item.on { background: var(--rail-active); color: var(--rail-ink-strong); box-shadow: inset 3px 0 0 #8fb0ff; }
.rail-item.on .i { color: #8fb0ff; }
.rail-count {
  margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 10px;
  background: var(--tag); color: var(--tag-ink); font: 600 var(--fs-xs)/1.4 var(--font-num); text-align: center;
}
.rail-count.plain { background: rgba(255, 255, 255, .12); color: var(--rail-ink-strong); }
.rail-dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--rail-ink); }
.rail-dot.ok { background: #3cc583; }
.rail-dot.warn { background: var(--warn); }
.rail-dot.bad { background: var(--bad); }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--rail-line); padding-top: 10px; }
.rail-tool {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border: 0; border-radius: var(--r-m);
  background: none; color: var(--rail-ink); font-size: var(--fs-s); text-align: left;
}
.rail-tool:hover { background: var(--rail-hover); color: var(--rail-ink-strong); }
.rail-tool.off { color: #6b778d; }

.bar {
  grid-area: bar;
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 0 var(--gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--line-strong);
  box-shadow: 0 1px 3px rgba(18, 26, 43, .06);
}
.bar-search {
  display: flex; align-items: center; gap: 10px;
  flex: 1; max-width: 460px; height: 38px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--r-m);
  background: var(--surface-2); color: var(--ink-3); text-align: left;
}
.bar-search:hover { border-color: var(--line-strong); color: var(--ink-2); }
.bar-search span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
kbd {
  font: 500 11px/1 var(--font); padding: 4px 6px; border-radius: 4px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-3);
}
.bar-engine {
  display: inline-flex; align-items: center; gap: 8px; margin-left: auto;
  height: 38px; padding: 0 12px; border-radius: var(--r-m);
  color: var(--ink-2); font-size: var(--fs-s); white-space: nowrap;
}
.bar-engine:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.bar-engine b { color: var(--ink); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }

.main {
  grid-area: main;
  min-width: 0;
  padding: 26px var(--gutter) 80px;
  outline: none;
}
.page { max-width: 1320px; margin: 0 auto; }
.page-narrow { max-width: 980px; margin: 0 auto; }

/* ---------- Schermi grandi (2K e oltre): testo un po' più grande e pagine più larghe ---------- */
@media (min-width: 1900px) {
  :root { --fs-xs: 12.5px; --fs-s: 14px; --fs-m: 15px; --fs-l: 17px; --fs-xl: 22px; --fs-2xl: 29px; --fs-3xl: 38px; --rail-w: 236px; --bar-h: 64px; --gutter: 40px; }
  .page { max-width: 1680px; }
  .page-narrow { max-width: 1180px; }
  .i { width: 19px; height: 19px; }
}
@media (min-width: 2400px) {
  .page { max-width: 1960px; }
}

/* ---------- Telefono: barra in basso ---------- */
@media (max-width: 860px) {
  :root { --gutter: 16px; --bar-h: 56px; }
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-areas: "bar" "main"; }
  .rail {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 30;
    height: auto; flex-direction: row; justify-content: space-around; gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--rail-line);
  }
  .rail-brand, .rail-foot { display: none; }
  .rail-item { flex-direction: column; gap: 3px; padding: 6px 4px; flex: 1; font-size: 11px; position: relative; justify-content: center; }
  .rail-item.on { background: none; }
  .rail-item.on span { color: var(--rail-ink-strong); }
  .rail-item.on { box-shadow: inset 0 3px 0 #8fb0ff; border-radius: 0; }
  .rail-count { position: absolute; top: 1px; left: 50%; margin-left: 6px; min-width: 16px; padding: 0 4px; font-size: 10px; }
  .rail-dot { position: absolute; top: 6px; left: 50%; margin-left: 9px; width: 7px; height: 7px; }
  .bar { gap: 6px; }
  .bar-search { height: 36px; min-width: 0; }
  .bar-ask { display: none !important; }
  .bar-search kbd, .bar-engine .bar-engine-text { display: none; }
  .bar-engine { padding: 0 8px; margin-left: 0; }
  .bar .btn span { display: none; }
  .bar .btn { padding: 0 10px; }
  .main { padding: 18px var(--gutter) 96px; }
}
