/* ==========================================================================
   Spindle — design system
   Calm, precise work tool. Palette Spindle: ciano #00D9F5, indaco #4040D0, viola #32176E, ardesia #232838.
   Gradiente solo su logo, indicatore nav attiva e velatura del login.
   ========================================================================== */

/* ---------- Fonts (self-hosted, GDPR: no third-party CDN) ---------- */
@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/instrument-sans-latin-wght-normal.woff2") format("woff2-variations"),
       url("/fonts/instrument-sans-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/instrument-sans-latin-ext-wght-normal.woff2") format("woff2-variations"),
       url("/fonts/instrument-sans-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
    U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/jetbrains-mono-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;

  --canvas: #F5F6FA;
  --surface: #FFFFFF;
  --surface-2: #F9FAFC;
  --sunken: #EEF0F5;
  --ink: #15161D;
  --ink-2: #484C5C;
  --ink-3: #666B7C;          /* brief: #8A85A0 — darkened to pass 4.5:1 on surface/sunken */
  --ink-4: #8A8FA0;          /* decorative only (icons, illustrations, placeholders) */
  --line: #E3E5EC;
  --line-strong: #CDD1DB;
  --accent: #4040D0;
  --accent-hover: #3333B5;
  --accent-2: #00D9F5;
  --accent-soft: #ECECFB;
  --accent-ink: #3434B8;
  --accent-solid: #4040D0;   /* filled buttons (white text) */
  --accent-solid-hover: #3333B5;
  --on-accent: #FFFFFF;
  --ok: #0E8F63;
  --ok-soft: #E6F6EF;
  --danger: #D33A4C;
  --danger-ink: #B4253A;
  --danger-soft: #FDECEE;
  --warn: #A3530B;
  --warn-soft: #FEF3E2;
  --star: #D99A00;
  --focus: 0 0 0 3px rgba(64, 64, 208, .28);

  --brand-gradient: linear-gradient(180deg, #00D9F5 0%, #4040D0 70%, #32176E 100%);
  --backdrop: rgba(21, 22, 29, .42);

  --shadow-xs: 0 1px 2px rgba(23, 19, 43, .06);
  --shadow-sm: 0 1px 2px rgba(23, 19, 43, .06), 0 2px 8px -2px rgba(76, 29, 149, .10);
  --shadow-md: 0 1px 2px rgba(23, 19, 43, .06), 0 12px 32px -14px rgba(76, 29, 149, .30);
  --shadow-lg: 0 2px 6px rgba(23, 19, 43, .08), 0 24px 64px -20px rgba(76, 29, 149, .42);

  /* avatar tints */
  --av0-bg: #EDE7FE; --av0-ink: #5B21B6;
  --av1-bg: #E3E6FD; --av1-ink: #3730A3;
  --av2-bg: #DEEBFE; --av2-ink: #1D4ED8;
  --av3-bg: #DDF5FA; --av3-ink: #0B6476;
  --av4-bg: #ECE6F7; --av4-ink: #4A2A8C;
  --av5-bg: #E7E9EF; --av5-ink: #394052;

  --font-ui: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --r-control: 8px;
  --r-panel: 10px;
  --r-modal: 16px;

  --ease: cubic-bezier(.2, .7, .2, 1);
  --t-fast: 150ms;
  --t-med: 200ms;

  --sidebar-w: 248px;
  --list-w: 380px;
  --chat-w: 340px;
}

[data-theme="dark"] {
  color-scheme: dark;

  --canvas: #101218;
  --surface: #161920;
  --surface-2: #1A1E27;
  --sunken: #0D0F14;
  --ink: #ECEEF4;
  --ink-2: #B1B6C6;
  --ink-3: #8D93A6;          /* brief: #7E7898 — lifted to pass 4.5:1 */
  --ink-4: #687084;
  --line: #242833;
  --line-strong: #323846;
  --accent: #7C7CF2;
  --accent-hover: #9A9AF7;
  --accent-2: #00D9F5;
  --accent-soft: #1D2042;
  --accent-ink: #ADADFB;
  --accent-solid: #4A4AE0;
  --accent-solid-hover: #5C5CEA;
  --on-accent: #FFFFFF;
  --ok: #34D399;
  --ok-soft: #0F2A22;
  --danger: #F87171;
  --danger-ink: #FCA5A5;
  --danger-soft: #2E1519;
  --warn: #FBBF24;
  --warn-soft: #2E220C;
  --star: #F5B83D;
  --focus: 0 0 0 3px rgba(124, 124, 242, .45);

  --backdrop: rgba(4, 5, 9, .62);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35), 0 2px 8px -2px rgba(0, 0, 0, .35);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, .4), 0 14px 36px -14px rgba(0, 0, 0, .6);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .45), 0 28px 72px -20px rgba(0, 0, 0, .75);

  --av0-bg: #2A1F4A; --av0-ink: #C4B5FD;
  --av1-bg: #1F2350; --av1-ink: #A5B4FC;
  --av2-bg: #172A4A; --av2-ink: #93C5FD;
  --av3-bg: #0E2B33; --av3-ink: #67E3F5;
  --av4-bg: #271F42; --av4-ink: #C9B8F4;
  --av5-bg: #22262F; --av5-ink: #B8BFCE;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
}
#app { min-height: 100%; }

h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-ink); }
img, svg { max-width: 100%; }
code { font-family: var(--font-mono); font-size: .92em; }
::selection { background: var(--accent-soft); color: var(--ink); }
[data-theme="dark"] ::selection { background: #2A2D6B; }

/* thin themed scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background-color: var(--ink-4); }

:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus); }

/* ---------- Icons ---------- */
.i {
  width: 18px;
  height: 18px;
  flex: none;
  display: inline-block;
  vertical-align: -0.22em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}
.i--fill { fill: currentColor; }

/* ---------- Logo ---------- */
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.logo__mark { display: block; flex: none; width: 28px; height: 28px; }
.logo__word { display: block; flex: none; width: auto; height: 26px; overflow: visible; }
.logo--sm .logo__mark { width: 26px; height: 26px; }
.logo--sm .logo__word { height: 24px; }
.logo--md .logo__mark { width: 32px; height: 32px; }
.logo--md .logo__word { height: 30px; }
.logo--lg { gap: 12px; }
.logo--lg .logo__mark { width: 40px; height: 40px; }
.logo--lg .logo__word { height: 42px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--r-control);
  background: transparent;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 550;
  letter-spacing: -0.005em;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.btn .i { width: 17px; height: 17px; }
.btn:active:not(:disabled) { transform: translateY(.5px); }

.btn--primary {
  background: var(--accent-solid);
  color: var(--on-accent);
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, .12);
}
.btn--primary:hover:not(:disabled) { background: var(--accent-solid-hover); }
.btn--primary:focus-visible { box-shadow: var(--focus); }

.btn--secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
}
.btn--secondary:hover:not(:disabled) { background: var(--sunken); border-color: var(--ink-4); }

.btn--ghost { color: var(--ink-2); }
.btn--ghost:hover:not(:disabled) { background: var(--sunken); color: var(--ink); }
.btn--ghost .i { color: var(--ink-3); }
.btn--ghost:hover .i { color: var(--ink); }

.btn--danger { background: var(--danger-soft); color: var(--danger-ink); }
.btn--danger:hover:not(:disabled) { background: var(--danger); color: #fff; }

.btn--sm { height: 30px; padding: 0 11px; font-size: 13px; gap: 6px; }
.btn--sm .i { width: 15px; height: 15px; }
.btn--block { display: flex; width: 100%; height: 42px; font-size: 14px; }

.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: var(--r-control);
  background: transparent;
  color: var(--ink-2);
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.icon-btn:hover:not(:disabled) { background: var(--sunken); color: var(--ink); }
.icon-btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn--primary { background: var(--accent-solid); color: var(--on-accent); }
.icon-btn--primary:hover:not(:disabled) { background: var(--accent-solid-hover); color: var(--on-accent); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 7px; min-width: 0; }
.field__label { font-size: 12.5px; font-weight: 550; color: var(--ink-2); letter-spacing: .005em; }

.input,
.select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.input::placeholder { color: var(--ink-4); }
.input:hover, .select:hover { border-color: var(--ink-4); }
.input:focus, .input:focus-visible,
.select:focus, .select:focus-visible { border-color: var(--accent); box-shadow: var(--focus); }
.input[aria-invalid="true"] { border-color: var(--danger); }

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238A8FA0' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-position: calc(100% - 10px) 50%;
  background-size: 18px 18px;
  background-repeat: no-repeat;
}

.form-error {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 9px 12px;
  border-radius: var(--r-control);
  background: var(--danger-soft);
  color: var(--danger-ink);
  font-size: 13px;
  line-height: 1.4;
}
.form-error .i { width: 16px; height: 16px; margin-top: 1px; }

.hint { font-size: 13px; line-height: 1.5; color: var(--ink-2); }
.hint a { color: var(--accent-ink); font-weight: 550; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.hint a:hover { text-decoration-thickness: 2px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--sunken);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .9;
}
.badge--on { background: var(--ok-soft); color: var(--ok); }
.badge--off { background: var(--sunken); color: var(--ink-3); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- Avatars ---------- */
.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--av0-bg);
  color: var(--av0-ink);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .01em;
  line-height: 1;
  text-transform: uppercase;
  user-select: none;
}
.avatar--sm { width: 28px; height: 28px; font-size: 11px; }
.avatar--lg { width: 44px; height: 44px; font-size: 15px; }
.avatar--sq { width: 28px; height: 28px; border-radius: 8px; font-size: 12px; }
.avatar--h0 { background: var(--av0-bg); color: var(--av0-ink); }
.avatar--h1 { background: var(--av1-bg); color: var(--av1-ink); }
.avatar--h2 { background: var(--av2-bg); color: var(--av2-ink); }
.avatar--h3 { background: var(--av3-bg); color: var(--av3-ink); }
.avatar--h4 { background: var(--av4-bg); color: var(--av4-ink); }
.avatar--h5 { background: var(--av5-bg); color: var(--av5-ink); }

/* ==========================================================================
   Auth shell — the bold moment
   ========================================================================== */
.auth {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  gap: 32px;
  padding:
    max(32px, env(safe-area-inset-top)) max(32px, 7vw, env(safe-area-inset-right))
    max(32px, env(safe-area-inset-bottom)) max(32px, 7vw, env(safe-area-inset-left));
  /* fallback when the photo is absent: deep violet → indigo night */
  background-color: #170B36;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: #fff;
  overflow: hidden;
}

/* scrim: brand tint over photo; on its own it becomes the designed fallback */
.auth__scrim {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60% 70% at 88% 12%, rgba(0, 217, 245, .18) 0%, rgba(0, 217, 245, 0) 70%),
    radial-gradient(50% 60% at 70% 95%, rgba(64, 64, 208, .34) 0%, rgba(64, 64, 208, 0) 70%),
    linear-gradient(100deg, rgba(20, 8, 52, .94) 0%, rgba(26, 11, 66, .84) 30%, rgba(30, 14, 78, .48) 58%, rgba(30, 20, 90, .10) 100%);
}
/* vignette */
.auth__scrim::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 60% 45%, rgba(0, 0, 0, 0) 55%, rgba(6, 3, 20, .55) 100%);
}
/* grain */
.auth__scrim::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .09;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 160px 160px;
}

.auth__brand { grid-row: 1; display: flex; align-items: center; }
.auth__brand .logo { color: #fff; }

.auth__panel {
  grid-row: 2;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
}

.auth__tagline {
  grid-row: 3;
  max-width: 16ch;
  font-size: clamp(28px, 2.9vw, 42px);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.03em;
  color: rgba(255, 255, 255, .94);
  text-wrap: balance;
  text-shadow: 0 1px 24px rgba(10, 4, 30, .35);
}

.photo-credit {
  position: absolute;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 1;
  max-width: 60vw;
  font-size: 11px;
  line-height: 1.3;
  color: rgba(255, 255, 255, .80);
  text-align: right;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .55), 0 0 12px rgba(0, 0, 0, .35);
}
.photo-credit:empty { display: none; }
.photo-credit a { color: #fff; text-decoration: underline; text-underline-offset: 2px; text-decoration-color: rgba(255, 255, 255, .55); }

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 36px 32px 28px;
  border-radius: var(--r-modal);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, .6);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .5) inset,
    0 2px 4px rgba(10, 4, 30, .12),
    0 32px 80px -24px rgba(10, 4, 30, .65);
  animation: card-in 420ms var(--ease) both;
}
[data-theme="dark"] .auth-card {
  border-color: var(--line-strong);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .05) inset, 0 32px 80px -24px rgba(0, 0, 0, .85);
}
.auth-card--wide { max-width: 480px; }

.auth-card__title {
  font-size: 26px;
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--ink);
  text-wrap: balance;
}
.auth-card__lead {
  margin-top: 8px;
  margin-bottom: 26px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-2);
  text-wrap: pretty;
}
.auth-card .form .btn--primary { margin-top: 4px; }
.auth-card > * + .form-error,
.auth-card > * + .hint { margin-top: 14px; }
.auth-card__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.auth-card__footer .btn--ghost { margin-left: -10px; }
.auth-card > .btn + .btn,
.auth-card > .btn + .choice-list { margin-top: 10px; }

@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* enrollment pieces */
.choice-list { display: grid; gap: 10px; }
.choice {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 14px 14px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-panel);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.choice:hover { border-color: var(--accent); background: var(--accent-soft); }
.choice > .i:last-child { color: var(--ink-4); transition: transform var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.choice:hover > .i:last-child { color: var(--accent-ink); transform: translateX(2px); }
.choice__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.choice:hover .choice__icon { background: var(--surface); }
.choice__icon .i { width: 20px; height: 20px; }
.choice__body { display: grid; gap: 2px; min-width: 0; }
.choice__title { font-size: 14px; font-weight: 600; color: var(--ink); }
.choice__desc { font-size: 12.5px; line-height: 1.45; color: var(--ink-2); }

.qr {
  display: grid;
  place-items: center;
  width: fit-content;
  margin: 4px auto 4px;
  padding: 14px;
  border-radius: 14px;
  background: #FFFFFF;           /* always white: scanners need contrast */
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.qr img { display: block; width: 184px; height: 184px; image-rendering: pixelated; }

.secret {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--sunken);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: .06em;
  color: var(--ink);
  word-break: break-all;
}

.codes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: code;
}
.codes li { counter-increment: code; position: relative; }
.codes li code {
  display: block;
  padding: 10px 12px 10px 34px;
  border-radius: var(--r-control);
  background: var(--sunken);
  border: 1px dashed var(--line-strong);
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: .08em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.codes li::before {
  content: counter(code);
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* ---------- Empty states ---------- */
.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 0;
  padding: 48px 24px;
  text-align: center;
  color: var(--ink-4);
}
.empty__art,
.empty > svg:first-child {
  width: 180px;
  height: auto;
  margin-bottom: 18px;
  color: var(--ink-4);
}
.empty__title { font-size: 15px; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }
.empty__text { max-width: 34ch; font-size: 13.5px; line-height: 1.5; color: var(--ink-3); text-wrap: pretty; }
.empty--reader { background: var(--surface); }
.empty--reader .empty__art,
.empty--reader > svg:first-child { width: 200px; }

/* ---------- Toasts ---------- */
.toast-stack {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  max-width: min(380px, calc(100vw - 32px));
  padding: 11px 14px;
  border-radius: var(--r-panel);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.4;
  box-shadow: var(--shadow-md);
  animation: toast-in 220ms var(--ease) both;
}
.toast .i { color: var(--ink-3); }
.toast--ok .i { color: var(--ok); }
.toast--error { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.toast--error .i { color: var(--danger); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px) scale(.98); }
  to { opacity: 1; transform: none; }
}

/* ---------- Modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--backdrop);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: fade-in 160ms var(--ease) both;
}
.modal__card {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 520px;
  max-height: calc(100dvh - 48px);
  overflow: hidden;
  border-radius: var(--r-modal);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  animation: modal-in 220ms var(--ease) both;
}
.modal__card--wide { max-width: 640px; }
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 14px 6px 24px;
}
.modal__title { font-size: 17px; font-weight: 650; letter-spacing: -0.018em; color: var(--ink); }
.modal__body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 10px 24px 22px;
  overflow-y: auto;
  min-height: 0;
}
.modal__body > * { flex-shrink: 0; }
.modal__foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(6px) scale(.985); }
  to { opacity: 1; transform: none; }
}
@keyframes sheet-up {
  from { transform: translateY(100%); }
  to { transform: none; }
}

/* settings (security modal) */
.setting-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  overflow: hidden;
  background: var(--surface);
}
.setting {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  grid-template-areas: "icon body action" "icon badge action";
  align-items: center;
  column-gap: 14px;
  row-gap: 8px;
  padding: 14px 14px 14px 16px;
}
.setting > .setting__icon { grid-area: icon; align-self: start; }
.setting > .setting__body { grid-area: body; }
.setting > .badge { grid-area: badge; justify-self: start; }
.setting > .btn { grid-area: action; }
.setting + .setting { border-top: 1px solid var(--line); }
.setting__icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.setting__icon .i { width: 18px; height: 18px; }
.setting__body { display: grid; gap: 2px; min-width: 0; }
.setting__title { font-size: 14px; font-weight: 600; color: var(--ink); }
.setting__desc { font-size: 12.5px; line-height: 1.45; color: var(--ink-3); }

.subpanel {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  background: var(--surface-2);
}
.subpanel:empty { display: none; }
.subpanel .form .btn--primary { justify-self: start; }

.admin-block {
  display: grid;
  gap: 10px;
  padding-top: 18px;
  border-top: 1px dashed var(--line-strong);
}
.admin-block__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--ink-2);
  letter-spacing: .005em;
}
.admin-block__title .i { width: 16px; height: 16px; color: var(--ink-3); }

/* ==========================================================================
   Responsive: modali e accesso
   ========================================================================== */
@media (max-width: 699px) {
  /* bottom sheet modals */
  .modal { place-items: end stretch; padding: 0; }
  .modal__card,
  .modal__card--wide {
    max-width: 100%;
    max-height: 92dvh;
    border-radius: 18px 18px 0 0;
    border-bottom: 0;
    animation: sheet-up 260ms var(--ease) both;
  }
  .modal__card::before {
    content: "";
    align-self: center;
    flex: none;
    width: 36px;
    height: 4px;
    margin-top: 8px;
    border-radius: 999px;
    background: var(--line-strong);
  }
  .modal__head { padding-top: 10px; padding-left: 20px; }
  .modal__body { padding-left: 20px; padding-right: 20px; }
  .modal__foot { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .modal__foot .btn { flex: 1; }

  /* auth on phones */
  .auth {
    gap: 22px;
    padding:
      max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
      max(44px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    grid-template-rows: auto 1fr;
  }
  .auth__scrim {
    background:
      radial-gradient(80% 50% at 90% 0%, rgba(0, 217, 245, .18) 0%, rgba(0, 217, 245, 0) 70%),
      linear-gradient(180deg, rgba(20, 8, 52, .80) 0%, rgba(26, 11, 66, .70) 50%, rgba(20, 8, 52, .88) 100%);
  }
  .auth__panel { align-items: flex-start; }
  .auth-card, .auth-card--wide { max-width: 100%; padding: 28px 22px 22px; }
  .auth-card__title { font-size: 23px; }
  .auth__tagline { display: none; }
  .photo-credit { left: 16px; right: 16px; max-width: none; text-align: center; }
  .codes { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .setting { grid-template-areas: "icon body body" "icon badge action"; }
}
@media (max-height: 640px) and (min-width: 700px) {
  .auth__tagline { display: none; }
}

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Spindle v3 — client multi-casella collaborativo
   ========================================================================== */

:root {
  --rail-w: 64px;
  --side-w: 252px;
  --list-w: 372px;
  --chat-w: 340px;
  --topbar-h: 56px;

  --rail-bg: #1B1F2B;
  --rail-ink: rgba(255, 255, 255, .62);
  --cyan: #00D9F5;
  --indigo: #4040D0;
  --violet: #32176E;
  --compose-gradient: linear-gradient(100deg, #0099CC 0%, #3A5FD8 52%, #4040D0 100%);
  --hairline-gradient: linear-gradient(90deg, #00D9F5 0%, #4040D0 100%);

  /* presa in carico: cyan = mia, indaco = di un collega */
  --own-me: #00C2DC;
  --own-me-soft: #E0F8FC;
  --own-me-ink: #006A7E;
  --own-me-wash: rgba(0, 217, 245, .055);
  --own-other: #4040D0;
  --own-other-soft: #ECECFB;
  --own-other-ink: #3434B8;
  --global: #8A3FD0;
  --global-soft: #F3EAFD;
  --global-ink: #6A2BAA;

  /* palette caselle: tinta piena, testo su tinta chiara (≥4.5:1), fondo chiaro */
  --mbx: #00A6C4; --mbx-ink: #00708A; --mbx-soft: #E0F6FA;
}
[data-theme="dark"] {
  --rail-bg: #0B0D13;
  --own-me: #22D3EE;
  --own-me-soft: #0E2B33;
  --own-me-ink: #67E3F5;
  --own-me-wash: rgba(34, 211, 238, .07);
  --own-other: #8C8CF5;
  --own-other-soft: #1D2042;
  --own-other-ink: #B4B4FB;
  --global: #B58CF0;
  --global-soft: #2A1E45;
  --global-ink: #D2B9F8;
}

.mbx-c0 { --mbx: #00A6C4; --mbx-ink: #00708A; --mbx-soft: #E0F6FA; }
.mbx-c1 { --mbx: #4040D0; --mbx-ink: #3434B8; --mbx-soft: #ECECFB; }
.mbx-c2 { --mbx: #1E88E5; --mbx-ink: #1565C0; --mbx-soft: #E3F0FC; }
.mbx-c3 { --mbx: #7B3FD0; --mbx-ink: #6A2FC0; --mbx-soft: #F2EAFC; }
.mbx-c4 { --mbx: #0B8FAE; --mbx-ink: #076A83; --mbx-soft: #DFF3F8; }
.mbx-c5 { --mbx: #5B2BB0; --mbx-ink: #4E2399; --mbx-soft: #EFE8FA; }
.mbx-c6 { --mbx: #3F63E0; --mbx-ink: #2F4FC4; --mbx-soft: #E7ECFC; }
.mbx-c7 { --mbx: #5B4BE0; --mbx-ink: #4A3BC8; --mbx-soft: #EEEBFC; }
.mbx-custom {
  --mbx: var(--mbx-custom);
  --mbx-ink: color-mix(in srgb, var(--mbx-custom) 78%, #000);
  --mbx-soft: color-mix(in srgb, var(--mbx-custom) 12%, #fff);
}
[data-theme="dark"] .mbx-c0 { --mbx: #22D3EE; --mbx-ink: #67E3F5; --mbx-soft: #0E2B33; }
[data-theme="dark"] .mbx-c1 { --mbx: #7C7CF2; --mbx-ink: #ADADFB; --mbx-soft: #1D2042; }
[data-theme="dark"] .mbx-c2 { --mbx: #4FA3F0; --mbx-ink: #93C5FD; --mbx-soft: #142A44; }
[data-theme="dark"] .mbx-c3 { --mbx: #A37BEB; --mbx-ink: #C9B0F6; --mbx-soft: #2A1E45; }
[data-theme="dark"] .mbx-c4 { --mbx: #2BB5D3; --mbx-ink: #7DD8EC; --mbx-soft: #0E2A32; }
[data-theme="dark"] .mbx-c5 { --mbx: #9466E0; --mbx-ink: #C2A8F2; --mbx-soft: #261C40; }
[data-theme="dark"] .mbx-c6 { --mbx: #6F8BF2; --mbx-ink: #A6B8FA; --mbx-soft: #1A2347; }
[data-theme="dark"] .mbx-c7 { --mbx: #8C7EF5; --mbx-ink: #B9B0FA; --mbx-soft: #221E47; }
[data-theme="dark"] .mbx-custom {
  --mbx: color-mix(in srgb, var(--mbx-custom) 80%, #fff);
  --mbx-ink: color-mix(in srgb, var(--mbx-custom) 55%, #fff);
  --mbx-soft: color-mix(in srgb, var(--mbx-custom) 22%, #161920);
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}
kbd {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
}

.icon-btn--sm { width: 30px; height: 30px; }
.icon-btn--sm .i { width: 16px; height: 16px; }
.icon-btn--soft { background: var(--accent-soft); color: var(--accent-ink); }
.icon-btn--soft:hover:not(:disabled) { background: var(--accent); color: #fff; }
.btn--danger-solid { background: var(--danger); color: #fff; }
.btn--danger-solid:hover:not(:disabled) { background: var(--danger-ink); }
[data-theme="dark"] .btn--danger-solid { background: #C2334A; }
.avatar--xs { width: 22px; height: 22px; font-size: 9px; letter-spacing: 0; }
.textarea { height: auto; padding: 10px 12px; line-height: 1.5; resize: vertical; }

/* ---------- Guscio ---------- */
.app {
  display: grid;
  grid-template-columns: var(--rail-w) var(--side-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--canvas);
}
.work {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.panes {
  flex: 1;
  display: grid;
  grid-template-columns: var(--list-w) minmax(0, 1fr);
  min-height: 0;
}
.scrim { display: none; }

/* ---------- Barra applicazioni (sempre scura) ---------- */
.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 0;
  padding: 14px 0 14px;
  background: var(--rail-bg);
  color: var(--rail-ink);
  position: relative;
  z-index: 30;
}
.rail__logo { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 14px; }
.rail__logo .logo__mark { width: 34px; height: 34px; }
.rail__group { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.rail__group--end { margin-top: auto; }
.rail__btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--rail-ink);
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.rail__btn .i { width: 20px; height: 20px; }
.rail__btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.rail__btn:focus-visible { box-shadow: 0 0 0 2px var(--cyan); }
.rail__btn.is-active { background: rgba(255, 255, 255, .1); color: #fff; }
.rail__btn.is-active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--cyan);
}
.rail__btn.is-panel::before { display: none; }
.rail__badge {
  position: absolute;
  top: 4px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--cyan);
  color: #0b2530;
  font: 700 11px/18px var(--font, inherit);
  text-align: center;
  box-shadow: 0 0 0 2px var(--rail-bg);
  pointer-events: none;
}
.rail__label { display: none; }

/* ---------- Barra laterale posta ---------- */
.side {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface-2);
  border-right: 1px solid var(--line);
}
.side__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 12px 0 18px;
  flex: none;
}
.side__close { display: none; }
.compose-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 2px 14px 10px;
  height: 40px;
  padding: 0 12px 0 14px;
  border: 0;
  border-radius: 10px;
  background: var(--compose-gradient);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  box-shadow: 0 1px 2px rgba(23, 19, 43, .12), 0 6px 16px -8px rgba(64, 64, 208, .6);
  transition: filter var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.compose-btn .i { width: 17px; height: 17px; }
.compose-btn:hover { filter: brightness(1.07) saturate(1.05); }
.compose-btn:active { transform: translateY(.5px); }
.compose-btn:focus-visible { box-shadow: 0 0 0 3px rgba(0, 217, 245, .45); }
.compose-btn kbd {
  margin-left: auto;
  border-color: rgba(255, 255, 255, .35);
  background: rgba(255, 255, 255, .14);
  color: rgba(255, 255, 255, .9);
}
.side__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 10px 12px;
}
.sb-sec + .sb-sec { margin-top: 10px; }
.sb-sec__head { display: flex; align-items: center; gap: 6px; padding: 0 6px 0 2px; }
.sb-sec__toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 6px 0 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-3);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.sb-sec__toggle .i { width: 14px; height: 14px; transition: transform var(--t-fast) var(--ease); }
.sb-sec.is-collapsed .sb-sec__toggle .i { transform: rotate(-90deg); }
.sb-sec__toggle:hover { color: var(--ink); }
.sb-sec__meta { margin-left: auto; font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.sb-sec__body { display: flex; flex-direction: column; gap: 1px; padding-top: 2px; }
.sb-empty { padding: 8px 10px; font-size: 13px; color: var(--ink-3); }

.sb-item-wrap { position: relative; display: flex; align-items: center; }
.sb-item,
.mbx__main,
.mbx__folder {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  text-align: left;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.sb-item { height: 36px; padding: 0 10px; font-size: 13.5px; font-weight: 520; }
.sb-item .i { width: 17px; height: 17px; color: var(--ink-3); }
.sb-item__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-item:hover, .mbx__main:hover, .mbx__folder:hover { background: var(--sunken); color: var(--ink); }
.sb-item.is-active,
.mbx.is-active > .sb-item-wrap > .mbx__main,
.mbx__folder.is-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 620;
}
.sb-item.is-active .i { color: var(--accent-ink); }
.sb-item.is-active::before,
.mbx.is-active > .sb-item-wrap > .mbx__main::before,
.mbx__folder.is-active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--cyan);
}
.sb-count {
  flex: none;
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--sunken);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 650;
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.sb-item.is-active .sb-count { background: var(--surface); color: var(--accent-ink); }
.sb-count--mine { background: var(--own-me-soft); color: var(--own-me-ink); }

.sb-more {
  position: absolute;
  right: 4px;
  top: 50%;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  margin-top: -13px;
  border: 0;
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-2);
  box-shadow: var(--shadow-xs);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-fast) var(--ease);
}
.sb-more .i { width: 16px; height: 16px; }
.sb-item-wrap:hover > .sb-more,
.sb-item-wrap:focus-within > .sb-more,
.sb-more[aria-expanded="true"] { opacity: 1; pointer-events: auto; }
.sb-more:hover { color: var(--ink); background: var(--sunken); }
@media (hover: none) {
  .sb-more { opacity: .9; pointer-events: auto; background: transparent; box-shadow: none; }
}

.mbx { position: relative; }
.mbx__main { min-height: 44px; padding: 5px 10px 5px 12px; }
.mbx__dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--mbx);
  box-shadow: 0 0 0 3px var(--mbx-soft);
}
.mbx__text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.mbx__name { font-size: 13.5px; font-weight: 560; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mbx__addr { font-size: 11.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mbx.is-active .mbx__name { color: var(--accent-ink); }
.mbx__count {
  flex: none;
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--mbx-soft);
  color: var(--mbx-ink);
  font-size: 11.5px;
  font-weight: 650;
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.mbx__toggle {
  position: absolute;
  left: -12px;
  top: 50%;
  display: grid;
  place-items: center;
  width: 18px;
  height: 22px;
  margin-top: -11px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-3);
}
.mbx__toggle .i { width: 13px; height: 13px; transition: transform var(--t-fast) var(--ease); }
.mbx__toggle.is-open .i { transform: rotate(90deg); }
.mbx__toggle:hover { color: var(--ink); background: var(--sunken); }
.side__scroll .sb-sec__body:has(.mbx__toggle) { padding-left: 10px; }
.mbx__folders { display: flex; flex-direction: column; gap: 1px; padding: 1px 0 4px 18px; }
.mbx__folder { height: 32px; padding: 0 10px; font-size: 13px; }
.mbx__folder .i { width: 15px; height: 15px; color: var(--ink-3); }
.mbx__folder-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mbx__folder.is-active .i { color: var(--accent-ink); }
.mbx-custom .mbx__count, .mbx-c0 .mbx__count { font-weight: 700; }
.is-dragging-mail [data-drop] { outline: 1px dashed var(--line-strong); outline-offset: -2px; }
[data-drop].is-drop { background: var(--accent-soft); outline: 2px solid var(--accent); outline-offset: -2px; }

.side__foot {
  flex: none;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--line);
}
.me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.me__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.me__name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me__role { font-size: 11.5px; color: var(--ink-3); }

/* ---------- Barra superiore e ricerca globale ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  height: var(--topbar-h);
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.topbar__menu { display: none; }
.gsearch {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 640px;
  height: 38px;
  padding: 0 8px 0 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--sunken);
  color: var(--ink-3);
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.gsearch:hover { border-color: var(--line-strong); }
.gsearch:focus-within { background: var(--surface); border-color: var(--accent); box-shadow: var(--focus); }
.gsearch__input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
}
.gsearch__input::placeholder { color: var(--ink-3); }
.gsearch__input:focus, .gsearch__input:focus-visible { box-shadow: none; outline: none; }
.gsearch__input::-webkit-search-cancel-button { display: none; }
.gsearch__clear {
  display: none;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-3);
}
.gsearch__clear .i { width: 16px; height: 16px; }
.gsearch__clear:hover { background: var(--line); color: var(--ink); }
.gsearch.has-value .gsearch__clear { display: grid; }
.gsearch.has-value .gsearch__kbd,
.gsearch:focus-within .gsearch__kbd { display: none; }

/* ---------- Elenco ---------- */
.lp {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.lp-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: none;
  padding: 14px 14px 6px 18px;
}
.lp-head__titles { flex: 1; min-width: 0; }
.lp-head__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 680;
  letter-spacing: -0.02em;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lp-head__dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--mbx); box-shadow: 0 0 0 3px var(--mbx-soft); }
.lp-head__sub { color: var(--ink-3); font-weight: 520; overflow: hidden; text-overflow: ellipsis; }
.lp-head__meta { margin-top: 2px; font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.seg {
  display: inline-flex;
  align-items: center;
  flex: none;
  padding: 2px;
  border-radius: 8px;
  background: var(--sunken);
}
.seg__opt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-3);
  font-size: 12.5px;
  font-weight: 560;
  white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.seg--icons .seg__opt { width: 30px; padding: 0; }
.seg__opt .i { width: 16px; height: 16px; }
.seg__opt:hover { color: var(--ink); }
.seg__opt.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-xs); }

.lp-filters { display: flex; flex-direction: column; gap: 8px; flex: none; padding: 4px 14px 8px 18px; }
.lp-filters .seg--text { align-self: flex-start; }
.fchips {
  display: flex;
  flex-wrap: nowrap;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
  margin-right: -14px;
  padding-right: 22px;
  -webkit-mask: linear-gradient(90deg, #000 calc(100% - 26px), transparent);
  mask: linear-gradient(90deg, #000 calc(100% - 26px), transparent);
}
.fchips::-webkit-scrollbar { display: none; }
.fchip { flex: none; }
.fchip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 25px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 540;
  white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.fchip .i { width: 14px; height: 14px; }
.fchip:hover { border-color: var(--ink-4); color: var(--ink); }
.fchip.is-on { border-color: transparent; background: var(--accent-soft); color: var(--accent-ink); }

.lp-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  min-height: 42px;
  padding: 4px 10px 4px 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.lp-tools.has-selection { background: var(--accent-soft); }
.lp-tools__hint { flex: 1; min-width: 0; font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-tools__count { font-size: 13px; font-weight: 620; color: var(--accent-ink); white-space: nowrap; }
.lp-tools__actions { display: flex; align-items: center; gap: 1px; margin-left: auto; }
.lp-tools__actions .icon-btn { color: var(--accent-ink); }
.lp-tools__actions .icon-btn:hover { background: var(--surface); }
.lp-tools__end { margin-left: auto; }
.lp-tools-slot:empty { display: none; }
.lp-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.check { position: relative; display: inline-grid; place-items: center; flex: none; width: 22px; height: 22px; cursor: pointer; }
.check input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.check__box {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  color: transparent;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.check__box .i { width: 13px; height: 13px; stroke-width: 2.6; }
.check:hover .check__box { border-color: var(--ink-4); }
.check input:checked + .check__box,
.check__box.is-mixed { background: var(--accent-solid); border-color: var(--accent-solid); color: #fff; }
.check input:focus-visible + .check__box { box-shadow: var(--focus); }

.msg-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 12px; }

/* ---------- Riga: barretta a sinistra = solo colore della casella ---------- */
.row {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 28px;
  gap: 10px;
  padding: 11px 8px 11px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  outline: none;
  transition: background-color var(--t-fast) var(--ease);
}
.row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--mbx);
}
.row.own-me { background: linear-gradient(90deg, var(--own-me-wash), var(--own-me-wash)), var(--surface); }
.row:hover { background: var(--surface-2); }
.row.own-me:hover { background: linear-gradient(90deg, var(--own-me-wash), var(--own-me-wash)), var(--surface-2); }
.row:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.row.is-selected { background: var(--accent-soft); }
.row.is-picked { background: color-mix(in srgb, var(--accent-soft) 70%, var(--surface)); }
.row__pick { position: relative; width: 36px; height: 36px; }
.row__pick .avatar { width: 36px; height: 36px; transition: opacity var(--t-fast) var(--ease); }
.row__check { position: absolute; inset: 0; width: 36px; height: 36px; opacity: 0; transition: opacity var(--t-fast) var(--ease); }
.row__check .check__box { width: 20px; height: 20px; }
.row:hover .row__check,
.row:focus-visible .row__check,
.row:has(:focus-visible) .row__check,
.row.is-picked .row__check,
.msg-list.has-selection .row__check { opacity: 1; }
.row:hover .row__avatar,
.row:focus-visible .row__avatar,
.row:has(:focus-visible) .row__avatar,
.row.is-picked .row__avatar,
.msg-list.has-selection .row__avatar { opacity: 0; }
@media (hover: none) {
  .row__check { opacity: 0; }
  .msg-list.has-selection .row__check, .row.is-picked .row__check { opacity: 1; }
  .row:hover .row__avatar, .row:focus-within .row__avatar { opacity: 1; }
  .msg-list.has-selection .row__avatar, .row.is-picked .row__avatar { opacity: 0; }
}
.row__main { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row__top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.row__from {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 540;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row.is-unread .row__from { font-weight: 700; color: var(--ink); }
.row.is-unread .row__from::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 1px;
}
.row__icons { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-3); }
.row__icon { display: inline-grid; place-items: center; }
.row__icon .i { width: 14px; height: 14px; }
.row__icon--shared { color: var(--accent-ink); }
.row__icon--snooze { color: var(--warn); }
.row__date { flex: none; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row.is-unread .row__date { color: var(--accent-ink); font-weight: 600; }
.row__subject { font-size: 13.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.is-unread .row__subject { color: var(--ink); font-weight: 600; }
.row__snippet {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.row__note { display: flex; gap: 6px; align-items: flex-start; margin-top: 4px; padding: 5px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-ink); font-size: 12px; line-height: 1.4; }
.row__note .i { width: 13px; height: 13px; margin-top: 2px; flex: none; }
.row__foot { display: flex; align-items: center; gap: 6px; min-width: 0; margin-top: 5px; }
.row__foot:not(:has(.mbx-chip)):not(:has(.row__live > *)) { display: none; }
.row__live { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; min-width: 0; }
.row__live:empty { display: none; }
.row__side { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.row__more {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-3);
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
}
.row__more .i { width: 17px; height: 17px; }
.row:hover .row__more, .row:focus-visible .row__more, .row:has(:focus-visible) .row__more, .row__more[aria-expanded="true"] { opacity: 1; }
.row__more:hover { background: var(--sunken); color: var(--ink); }
@media (hover: none) { .row__more { opacity: .8; } }

.star {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-4);
  transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.star .i { width: 17px; height: 17px; }
.star:hover { color: var(--star); background: var(--sunken); }
.star.is-on { color: var(--star); }

.mbx-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  max-width: 60%;
  height: 20px;
  padding: 0 8px 0 6px;
  border-radius: 999px;
  background: var(--mbx-soft);
  color: var(--mbx-ink);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mbx-chip__dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--mbx); }
.mbx-chip--lg { height: 26px; max-width: none; padding: 0 10px 0 8px; font-size: 12.5px; }
.mbx-chip__addr { font-weight: 500; opacity: .85; margin-left: 2px; }
.ctx-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--sunken);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 540;
}
.ctx-chip .i { width: 14px; height: 14px; }
.ctx-chip--snooze { background: var(--warn-soft); color: var(--warn); }

/* Densità compatta */
.density-compact .row { grid-template-columns: 26px minmax(0, 1fr) 28px; padding-top: 7px; padding-bottom: 7px; gap: 8px; }
.density-compact .row__pick, .density-compact .row__check { width: 26px; height: 26px; }
.density-compact .row__pick .avatar { width: 26px; height: 26px; font-size: 10px; }
.density-compact .row__snippet,
.density-compact .row__note { display: none; }
.density-compact .row__main { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; align-items: center; }
.density-compact .row__top { grid-column: 1 / -1; }
.density-compact .row__foot { margin-top: 0; grid-row: 2; grid-column: 2; }
.density-compact .row__foot .mbx-chip { max-width: 110px; }
.density-compact .row__side { flex-direction: row; align-items: center; }
.density-compact .row__more { display: none; }

/* ---------- Presa in carico (statica) ---------- */
.face {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--av0-bg);
  color: var(--av0-ink);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
  text-transform: uppercase;
}
.face img { width: 100%; height: 100%; object-fit: cover; }
.face.avatar--h0 { background: var(--av0-bg); color: var(--av0-ink); }
.face.avatar--h1 { background: var(--av1-bg); color: var(--av1-ink); }
.face.avatar--h2 { background: var(--av2-bg); color: var(--av2-ink); }
.face.avatar--h3 { background: var(--av3-bg); color: var(--av3-ink); }
.face.avatar--h4 { background: var(--av4-bg); color: var(--av4-ink); }
.face.avatar--h5 { background: var(--av5-bg); color: var(--av5-ink); }

.owner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  height: 24px;
  padding: 0 9px 0 2px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  white-space: nowrap;
}
.owner__face { width: 20px; height: 20px; font-size: 8.5px; box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 3px var(--own); }
.owner__label { overflow: hidden; text-overflow: ellipsis; }
.owner--me { --own: var(--own-me); background: var(--own-me-soft); color: var(--own-me-ink); }
.owner--other { --own: var(--own-other); background: var(--own-other-soft); color: var(--own-other-ink); }
.owner--big { height: 30px; padding: 0 11px 0 4px; font-size: 12.5px; gap: 8px; }
.owner--big .owner__face { width: 22px; height: 22px; font-size: 9px; }

/* ---------- Chi sta lavorando (live) ---------- */
.live-stack { display: inline-flex; align-items: center; flex: none; }
.live {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
}
.live + .live { margin-left: -7px; }
.live__face { position: relative; z-index: 1; width: 20px; height: 20px; font-size: 8.5px; box-shadow: 0 0 0 2px var(--surface); }
.live--active::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #00D9F5 0deg, #4040D0 200deg, rgba(64, 64, 208, 0) 300deg, rgba(0, 217, 245, 0) 360deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.6px), #000 calc(100% - 2.4px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2.6px), #000 calc(100% - 2.4px));
  animation: live-spin 1.3s linear infinite;
}
.live--active::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 50%;
  box-shadow: 0 0 10px 1px rgba(0, 217, 245, .55);
  opacity: .35;
  animation: live-glow 2.4s ease-in-out infinite;
}
.live--active .live__face { animation: live-breathe 2.4s ease-in-out infinite; }
.live--done .live__face { filter: grayscale(1); opacity: .7; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line-strong); }
.live__done {
  position: absolute;
  right: -1px;
  bottom: -1px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink-3);
  color: var(--surface);
  box-shadow: 0 0 0 1.5px var(--surface);
}
.live__done .i { width: 8px; height: 8px; stroke-width: 3.2; }
.live-more {
  display: inline-grid;
  place-items: center;
  height: 20px;
  min-width: 20px;
  margin-left: 2px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--sunken);
  color: var(--ink-2);
  font-size: 10.5px;
  font-weight: 700;
}
.live-stack--md .live { width: 32px; height: 32px; }
.live-stack--md .live__face { width: 25px; height: 25px; font-size: 10px; }
.live-text { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-text--active { color: var(--own-me-ink); }
.live-text--done { color: var(--ink-3); font-weight: 520; }
.live-text__more { color: var(--ink-3); font-weight: 600; }
@keyframes live-spin { to { transform: rotate(360deg); } }
@keyframes live-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }
@keyframes live-glow { 0%, 100% { opacity: .2; } 50% { opacity: .65; } }
@keyframes live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) {
  .live--active::before {
    animation: none !important;
    background: var(--cyan);
  }
  .live--active::after { animation: none !important; opacity: .3; }
  .live--active .live__face {
    animation: live-pulse 3s ease-in-out infinite !important;
    animation-duration: 3s !important;
    animation-iteration-count: infinite !important;
  }
}

/* ---------- Lettore ---------- */
.reader {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
}
.reader__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  min-height: 56px;
  padding: 8px 12px 8px 24px;
  border-bottom: 1px solid var(--line);
}
.reader__back { display: none; margin-left: -10px; }
.reader__owner { flex: none; display: flex; align-items: center; }
.reader__live { display: flex; align-items: center; gap: 8px; min-width: 0; }
.reader__live:empty { display: none; }
.reader__actions { display: flex; align-items: center; gap: 2px; margin-left: auto; flex: none; }
.star-btn.is-on { color: var(--star); }
.split { display: inline-flex; align-items: stretch; }
.split__main { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split__more { width: 30px; padding: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }
.split__more .i { width: 15px; height: 15px; }
.split--ghost .split__more { border-left: 1px solid var(--line); }
.owner-btn {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 0 4px 0 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-3);
}
.owner-btn > .i { width: 15px; height: 15px; }
.owner-btn:hover .owner { filter: brightness(.97); }
.owner-btn:focus-visible { box-shadow: var(--focus); }

.reader__scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 48px; }
.mail { padding: 22px 40px 8px; }
.mail > *, .disc, .alog { max-width: 720px; }
.mail__context { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.mail__subject {
  margin-bottom: 18px;
  font-size: 22px;
  font-weight: 680;
  line-height: 1.28;
  letter-spacing: -0.022em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.mail__note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 18px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 13px;
}
.mail__note p { margin-top: 2px; color: var(--ink); }
.mail__head {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.mail__who { min-width: 0; }
.mail__from { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 6px; }
.mail__from-name { font-size: 14px; font-weight: 620; }
.mail__from-addr { font-size: 13px; color: var(--ink-3); overflow-wrap: anywhere; }
.mail__to { margin-top: 2px; font-size: 13px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail__date { align-self: start; padding-top: 3px; font-size: 12.5px; color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mail__body { font-size: 15px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.mail__reply { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }

.atts { margin-top: 24px; }
.atts__title { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 12.5px; font-weight: 620; color: var(--ink-3); }
.atts__title .i { width: 15px; height: 15px; }
.atts__list { display: flex; flex-wrap: wrap; gap: 8px; }
.att {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 300px;
  padding: 7px 10px 7px 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  text-decoration: none;
  transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
a.att:hover { border-color: var(--accent); background: var(--surface); }
.att__icon {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.att__ext {
  position: absolute;
  bottom: -3px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0 3px;
  border-radius: 3px;
  background: var(--accent-solid);
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  line-height: 11px;
  letter-spacing: .02em;
}
.att__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.att__name { font-size: 13px; font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att__size { font-size: 11.5px; color: var(--ink-3); }
.att__dl { color: var(--ink-3); }
.att__dl .i { width: 16px; height: 16px; }
a.att:hover .att__dl { color: var(--accent-ink); }
.att__rm { display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--ink-3); }
.att__rm:hover { background: var(--sunken); color: var(--ink); }
.att__rm .i { width: 14px; height: 14px; }

/* Composer in linea */
.composer {
  margin-top: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.composer:focus-within { border-color: var(--accent); }
.composer__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.composer__mode { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 650; }
.composer__mode .i { width: 16px; height: 16px; color: var(--accent-ink); }
.composer__from { flex: 1; min-width: 0; font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer__from strong { color: var(--ink-2); font-weight: 600; }
.composer__field { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 4px 14px; border-bottom: 1px solid var(--line); }
.composer__label { flex: none; width: 52px; font-size: 12.5px; color: var(--ink-3); }
.composer__chips { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.composer__subject { min-width: 0; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer__input { flex: 1; min-width: 0; height: 30px; border: 0; background: transparent; font-size: 13.5px; }
.composer__input:focus { box-shadow: none; }
.composer__body {
  display: block;
  width: 100%;
  min-height: 180px;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
}
.composer__body:focus, .composer__body:focus-visible { box-shadow: none; }
.composer .form-error { margin: 0 14px 10px; }
.composer__foot { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--surface-2); }
.composer__hint { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; font-size: 12px; color: var(--own-me-ink); }
.composer__hint .i { width: 15px; height: 15px; }
.addr-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  height: 24px;
  padding: 0 4px 0 9px;
  border-radius: 999px;
  background: var(--sunken);
  color: var(--ink);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.composer__chips .addr-chip { padding-right: 9px; }
.addr-chip.is-invalid { background: var(--danger-soft); color: var(--danger-ink); }
.addr-chip button { display: grid; place-items: center; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--ink-3); }
.addr-chip button:hover { background: var(--line-strong); color: var(--ink); }
.addr-chip button .i { width: 12px; height: 12px; }

/* Discussione interna */
.disc {
  margin: 28px 40px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  overflow: hidden;
}
.disc__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.disc--empty .disc__head { border-bottom: 0; }
.disc__title { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 650; }
.disc__title .i { width: 16px; height: 16px; color: var(--accent-ink); }
.disc__hint { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; font-size: 12px; color: var(--ink-3); }
.disc__hint .i { width: 13px; height: 13px; }
.disc__start { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 4px 14px 14px; font-size: 13px; color: var(--ink-2); }
.disc__start p { flex: 1; min-width: 220px; }
.disc__messages { display: flex; flex-direction: column; gap: 10px; max-height: 340px; overflow-y: auto; padding: 14px; }
.disc__composer, .chat__composer { position: relative; display: flex; align-items: center; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: var(--surface); }
.mention-field { position: relative; flex: 1; min-width: 0; }
.mention-field .input { height: 38px; }
.disc__composer .icon-btn, .chat__composer .icon-btn { width: 38px; height: 38px; }
.mention {
  display: inline-block;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--own-other-soft);
  color: var(--own-other-ink);
  font-weight: 650;
  line-height: 1.5;
}
.mention--me { background: var(--accent-solid); color: #fff; }
.bubble--own .mention { background: var(--surface); }
.bubble--own .mention--me { background: var(--accent-solid); }
.mention-pop {
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  z-index: 20;
  min-width: 220px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.mention-pop__opt { display: flex; align-items: center; gap: 8px; width: 100%; height: 34px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; font-size: 13px; text-align: left; }
.mention-pop__opt.is-active, .mention-pop__opt:hover { background: var(--accent-soft); color: var(--accent-ink); }

/* Bolle (riuso) */
.bubble {
  align-self: flex-start;
  max-width: 86%;
  padding: 8px 12px 9px;
  border-radius: 14px 14px 14px 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xs);
}
.bubble--own { align-self: flex-end; border-radius: 14px 14px 4px 14px; background: var(--accent-soft); border-color: transparent; box-shadow: none; }
.bubble__meta { margin-bottom: 2px; font-size: 11.5px; font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.bubble--own .bubble__meta { color: var(--accent-ink); text-align: right; }
.bubble__text { font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Registro attività */
.alog { margin: 20px 40px 0; }
.alog__title { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; font-size: 12.5px; font-weight: 650; color: var(--ink-3); letter-spacing: .02em; }
.alog__title .i { width: 15px; height: 15px; }
.alog__list { position: relative; margin: 0; padding: 0; list-style: none; }
.alog__list::before { content: ""; position: absolute; left: 10.5px; top: 8px; bottom: 8px; width: 1px; background: var(--line-strong); }
.alog__item { position: relative; display: flex; align-items: center; gap: 10px; min-height: 30px; font-size: 13px; color: var(--ink-2); }
.alog__item .avatar { position: relative; z-index: 1; box-shadow: 0 0 0 3px var(--surface); }
.alog__text { flex: 1; min-width: 0; }
.alog__text strong { color: var(--ink); font-weight: 620; }
.alog__item--all .alog__text::after {
  content: "per tutti";
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--global-soft);
  color: var(--global-ink);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 17px;
  vertical-align: 1px;
}
.alog__time { flex: none; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- Pannello "Tutte le chat" ---------- */
.chat {
  position: relative;
  display: none;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
  border-left: 1px solid var(--line);
}
.chat::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--hairline-gradient); z-index: 1; }
.chat__head { display: flex; align-items: center; gap: 6px; flex: none; height: var(--topbar-h); padding: 0 8px 0 18px; border-bottom: 1px solid var(--line); }
.chat__head #chat-back { margin-left: -10px; }
.chat__head-text { flex: 1; min-width: 0; }
.chat__title { flex: 1; min-width: 0; font-size: 15px; font-weight: 680; letter-spacing: -0.012em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat__sub { font-size: 12px; color: var(--ink-3); }
.chat__threads { flex: 1; min-height: 0; overflow-y: auto; padding: 6px; }
.chat__threads .empty { padding: 32px 16px; }
.thread {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}
.thread:hover { background: var(--sunken); }
.thread__type { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 9px; }
.thread__type .i { width: 17px; height: 17px; }
.thread__type--chat { background: #DDF7FC; color: #00708A; }
.thread__type--mail { background: var(--accent-soft); color: var(--accent-ink); }
[data-theme="dark"] .thread__type--chat { background: #0E2B33; color: #67E3F5; }
.thread__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.thread__top { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.thread__id { flex: none; font-size: 12px; font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.thread__title { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread__date { flex: none; font-size: 11.5px; color: var(--ink-3); }
.thread__sub { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people { display: inline-flex; align-items: center; margin-top: 4px; }
.people .avatar + .avatar { margin-left: -4px; }
.people .avatar { box-shadow: 0 0 0 2px var(--surface); }
.disc__head .people { margin-top: 0; }
.people__more { margin-left: 4px; font-size: 11px; font-weight: 650; color: var(--ink-3); }
.chat__linked {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  margin: 10px 12px 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 560;
  text-align: left;
}
.chat__linked span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat__linked .i { width: 16px; height: 16px; }
.chat__linked:hover { border-color: var(--accent); }
.chat__messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 10px; padding: 14px 14px 18px; }

/* ---------- Popover e menu ---------- */
.pop {
  position: fixed;
  z-index: 90;
  min-width: 220px;
  max-width: min(340px, calc(100vw - 16px));
  max-height: min(70vh, 520px);
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: modal-in 140ms var(--ease) both;
}
.pop__header { padding: 7px 10px 5px; font-size: 11.5px; font-weight: 650; color: var(--ink-3); letter-spacing: .02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop__sep { height: 1px; margin: 5px 6px; background: var(--line); }
.pop__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font-size: 13.5px;
  text-align: left;
}
.pop__item .i { width: 16px; height: 16px; color: var(--ink-3); }
.pop__label { flex: 1; min-width: 0; }
.pop__hint { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.pop__tag { display: inline-flex; align-items: center; gap: 3px; height: 18px; padding: 0 6px; border-radius: 999px; background: var(--global-soft); color: var(--global-ink); font-size: 10.5px; font-weight: 700; white-space: nowrap; }
.pop__tag .i { width: 11px; height: 11px; color: currentColor; }
.pop__item:hover:not(:disabled), .pop__item:focus-visible { background: var(--sunken); box-shadow: none; }
.pop__item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pop__item.is-danger { color: var(--danger-ink); }
.pop__item.is-danger .i { color: var(--danger); }
.pop__item:disabled { color: var(--ink-3); cursor: default; }

.pop--picker { width: 300px; padding: 0; }
.picker__title { padding: 12px 14px 6px; font-size: 12.5px; font-weight: 650; color: var(--ink-3); }
.picker__search { display: flex; align-items: center; gap: 8px; margin: 0 10px 6px; padding: 0 10px; height: 36px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink-3); }
.picker__search:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.picker__search input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; font-size: 13.5px; }
.picker__search input:focus { box-shadow: none; }
.picker__list { display: flex; flex-direction: column; gap: 1px; max-height: 300px; overflow-y: auto; padding: 0 5px 6px; }
.picker__opt { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 4px 9px; border: 0; border-radius: 8px; background: transparent; text-align: left; color: var(--ink); }
.picker__opt:hover, .picker__opt:focus-visible { background: var(--sunken); box-shadow: none; }
.picker__opt.is-current { background: var(--own-other-soft); }
.picker__opt > .i { width: 16px; height: 16px; color: var(--accent-ink); margin-left: auto; }
.picker__opt--none > .i:first-child { width: 28px; margin-left: 0; color: var(--ink-3); }
.picker__face { width: 28px; height: 28px; font-size: 10.5px; }
.picker__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.picker__name { font-size: 13.5px; font-weight: 560; }
.picker__name em { font-style: normal; color: var(--ink-3); font-weight: 500; }
.picker__mail { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker__empty { padding: 10px; font-size: 13px; color: var(--ink-3); }

/* ---------- Modali v3 ---------- */
.modal__card--confirm { max-width: 440px; }
.confirm__text { font-size: 14px; line-height: 1.55; color: var(--ink-2); }
.confirm__text strong { color: var(--ink); }
.confirm__live { display: inline-block; margin-top: 8px; padding: 3px 8px; border-radius: 6px; background: var(--own-me-soft); color: var(--own-me-ink); font-size: 12.5px; font-weight: 600; }

.people-pick { display: flex; flex-direction: column; gap: 4px; }
.people-pick__opt { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.people-pick__opt:hover { border-color: var(--line-strong); }
.people-pick__opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.people-pick__opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.people-pick__opt:has(input:focus-visible) { box-shadow: var(--focus); }
.people-pick__face { width: 30px; height: 30px; font-size: 11px; }
.people-pick__text { flex: 1; display: flex; flex-direction: column; line-height: 1.3; font-size: 13.5px; font-weight: 560; }
.people-pick__text small { font-size: 12px; font-weight: 400; color: var(--ink-3); }
.people-pick__opt input:checked ~ .check__box { background: var(--accent-solid); border-color: var(--accent-solid); color: #fff; }

.swatches { border: 0; margin: 0; padding: 0; }
.swatches__row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.swatch { position: relative; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.swatch__dot { display: block; width: 28px; height: 28px; border-radius: 50%; background: var(--mbx); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line); }
.swatch input:checked + .swatch__dot { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.swatch input:focus-visible + .swatch__dot { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.swatch__auto { font-size: 12.5px; color: var(--ink-2); padding-right: 4px; }

.shortcuts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; margin: 0; }
.shortcuts__row { display: flex; align-items: center; gap: 10px; min-height: 30px; }
.shortcuts dt { flex: none; min-width: 66px; display: flex; gap: 4px; }
.shortcuts dd { margin: 0; font-size: 13px; color: var(--ink-2); }

/* Scrivi */
.compose { max-width: 720px; height: min(680px, calc(100dvh - 48px)); position: relative; }
.compose .modal__body { flex: 1; padding: 0; gap: 0; }
.cmp { display: flex; flex-direction: column; flex: 1; min-height: 100%; }
.cmp__row { position: relative; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 20px; border-bottom: 1px solid var(--line); }
.cmp__label { flex: none; width: 56px; font-size: 13px; color: var(--ink-3); }
.cmp__select { flex: 1; min-width: 0; height: 34px; border: 0; background: transparent; color: var(--ink); font-size: 13.5px; font-weight: 560; cursor: pointer; }
.cmp__select:focus-visible { box-shadow: var(--focus); border-radius: 6px; }
.cmp__input { flex: 1; min-width: 0; height: 34px; border: 0; background: transparent; font-size: 14px; }
.cmp__input:focus { box-shadow: none; }
.cmp__toggle { flex: none; height: 26px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-3); font-size: 12.5px; font-weight: 600; }
.cmp__toggle:hover { background: var(--sunken); color: var(--ink); }
.cmp__chips { position: relative; flex: 1; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-height: 34px; }
.chips__list { display: contents; }
.chips__input { flex: 1; min-width: 120px; height: 30px; border: 0; background: transparent; font-size: 14px; }
.chips__input:focus { box-shadow: none; }
.suggest { position: absolute; left: -8px; top: calc(100% + 4px); z-index: 10; width: min(360px, 100%); padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-md); }
.suggest__opt { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 3px 8px; border: 0; border-radius: 7px; background: transparent; text-align: left; }
.suggest__opt.is-active, .suggest__opt:hover { background: var(--accent-soft); }
.suggest__face { width: 26px; height: 26px; font-size: 10px; }
.suggest__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; font-size: 13.5px; }
.suggest__text em { font-style: normal; color: var(--own-me-ink); font-size: 12px; }
.suggest__text small { color: var(--ink-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.cmp__body { flex: 1; min-height: 220px; width: 100%; padding: 16px 20px; border: 0; background: transparent; color: var(--ink); font-size: 14.5px; line-height: 1.6; resize: none; }
.cmp__body:focus, .cmp__body:focus-visible { box-shadow: none; }
.cmp__atts { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 20px 12px; }
.cmp__atts:empty { display: none; }
.att--chip { padding-right: 4px; }
.cmp__drop {
  position: absolute;
  inset: 10px;
  z-index: 5;
  display: none;
  place-items: center;
  align-content: center;
  gap: 8px;
  border: 2px dashed var(--accent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent-soft) 88%, transparent);
  color: var(--accent-ink);
  font-weight: 650;
  pointer-events: none;
}
.cmp__drop .i { width: 28px; height: 28px; }
.compose.is-dropping .cmp__drop { display: grid; }
.cmp .form-error { margin: 0 20px 12px; }
.compose .modal__foot { justify-content: flex-start; }
.cmp__attach { cursor: pointer; }
.cmp__status { flex: 1; min-width: 0; font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Toast con azione (Annulla invio) */
.toast--action { position: relative; overflow: hidden; padding-right: 8px; }
.toast__msg { flex: 1; min-width: 0; }
.toast__btn { flex: none; height: 30px; padding: 0 12px; border: 0; border-radius: 7px; background: var(--accent-soft); color: var(--accent-ink); font-size: 13px; font-weight: 650; }
.toast__btn:hover { background: var(--accent-solid); color: #fff; }
.toast__bar { position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: var(--hairline-gradient); transform-origin: left; animation: toast-bar linear both; }
@keyframes toast-bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.toast.is-leaving { opacity: 0; transform: translateY(4px); transition: opacity 200ms var(--ease), transform 200ms var(--ease); }

/* ---------- Responsive ---------- */

/* Chat: colonna solo su schermi molto larghi, altrimenti pannello sovrapposto. */
@media (min-width: 1440px) {
  .app--chat-open { grid-template-columns: var(--rail-w) var(--side-w) minmax(0, 1fr) var(--chat-w); }
  .app--chat-open .chat { display: flex; }
}
@media (max-width: 1439px) {
  .chat {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    width: min(380px, 100%);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform var(--t-med) var(--ease), visibility 0s linear var(--t-med);
  }
  .app--chat-open .chat {
    transform: none;
    visibility: visible;
    box-shadow: var(--shadow-lg);
    transition: transform var(--t-med) var(--ease), visibility 0s;
  }
}
@media (max-width: 1279px) {
  :root { --side-w: 236px; --list-w: 340px; }
  .mail { padding-left: 28px; padding-right: 28px; }
  .disc, .alog { margin-left: 28px; margin-right: 28px; }
  .reader__bar { padding-left: 16px; }
  .split--ghost .split__main span { display: none; }
  .split--ghost .split__main { width: 36px; padding: 0; }
}

/* < 1100: la barra laterale diventa un cassetto */
@media (max-width: 1099px) {
  :root { --rail-w: 56px; --list-w: 330px; }
  .app, .app--chat-open { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  .rail__btn { width: 40px; height: 40px; }
  .rail__btn.is-active::before { left: -8px; }
  .side {
    position: fixed;
    top: 0;
    bottom: 0;
    left: var(--rail-w);
    z-index: 60;
    width: min(292px, calc(100vw - var(--rail-w) - 24px));
    padding-top: env(safe-area-inset-top);
    transform: translateX(calc(-100% - var(--rail-w)));
    visibility: hidden;
    transition: transform var(--t-med) var(--ease), visibility 0s linear var(--t-med);
  }
  .app--nav-open .side {
    transform: none;
    visibility: visible;
    box-shadow: var(--shadow-lg);
    transition: transform var(--t-med) var(--ease), visibility 0s;
  }
  .side__close { display: inline-grid; }
  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: var(--backdrop);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-med) var(--ease);
  }
  .app--nav-open .scrim { opacity: 1; pointer-events: auto; }
  .topbar__menu { display: inline-grid; margin-left: -6px; }
  .mail { padding: 20px 24px 8px; }
  .disc, .alog { margin-left: 24px; margin-right: 24px; }
  .reader__live .live-text { display: none; }
}

/* < 700: una colonna, barra applicazioni in basso, lettore sovrapposto */
@media (max-width: 699px) {
  :root { --tabbar-h: calc(58px + env(safe-area-inset-bottom)); }
  .app, .app--chat-open { grid-template-columns: minmax(0, 1fr); padding-bottom: var(--tabbar-h); }
  .rail {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    flex-direction: row;
    justify-content: space-around;
    height: var(--tabbar-h);
    padding: 4px 4px env(safe-area-inset-bottom);
    gap: 0;
  }
  .rail__logo, .rail__btn--desk { display: none; }
  /* Sul telefono la barra in basso tiene 4 app + «Altro»: le altre si aprono dal menu Altro. */
  .rail__btn--ovf { display: none; }
  .rail__group, .rail__group--end { display: contents; }
  .rail__btn {
    flex: 1;
    width: auto;
    max-width: 84px;
    height: 50px;
    grid-template-rows: 24px auto;
    gap: 1px;
    border-radius: 10px;
  }
  .rail__btn .i { width: 20px; height: 20px; align-self: end; }
  .rail__label { display: block; font-size: 10.5px; font-weight: 600; line-height: 1.2; }
  .rail__btn.is-active::before { left: 30%; right: 30%; top: -4px; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  .rail__badge { top: 2px; right: calc(50% - 22px); }
  .side { left: 0; width: min(304px, 86vw); bottom: var(--tabbar-h); }
  .side__head { padding-top: env(safe-area-inset-top); height: calc(var(--topbar-h) + env(safe-area-inset-top)); }
  .topbar { padding: env(safe-area-inset-top) 12px 0; height: calc(var(--topbar-h) + env(safe-area-inset-top)); }
  .topbar__menu { margin-left: -4px; }
  .gsearch__kbd { display: none; }
  .panes { grid-template-columns: minmax(0, 1fr); }
  .lp { border-right: 0; }
  .lp-head { padding-left: 16px; padding-right: 12px; }
  .lp-filters { padding-left: 16px; padding-right: 12px; }
  .fchips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-right: -12px; padding-right: 12px; }
  .fchips::-webkit-scrollbar { display: none; }
  .fchip { flex: none; }
  .lp-tools { padding-left: 16px; }
  .lp-tools__hint { display: none; }
  .row { padding-left: 16px; }
  .reader {
    position: fixed;
    inset: 0 0 var(--tabbar-h) 0;
    z-index: 40;
    transform: translateX(100%);
    visibility: hidden;
    transition: transform var(--t-med) var(--ease), visibility 0s linear var(--t-med);
  }
  .app--detail-open .reader { transform: none; visibility: visible; transition: transform var(--t-med) var(--ease), visibility 0s; }
  .reader__bar { gap: 6px; padding: max(8px, env(safe-area-inset-top)) 6px 8px 12px; flex-wrap: wrap; }
  .reader__back { display: inline-grid; margin-left: -6px; }
  .reader__actions { gap: 0; }
  .reader__actions > .icon-btn#share-btn { display: none; }
  .reader__live { order: 5; flex-basis: 100%; padding-left: 34px; }
  .reader__live .live-text { display: inline; }
  .split__main span { display: none; }
  .split__main { width: 36px; padding: 0; }
  .owner--big .owner__label { max-width: 96px; }
  .mail { padding: 18px 16px 8px; }
  .mail__subject { font-size: 19px; }
  .mail__head { grid-template-columns: 40px minmax(0, 1fr); }
  .mail__head .avatar--lg { width: 40px; height: 40px; font-size: 14px; }
  .mail__date { grid-column: 2; padding-top: 0; }
  .mail__reply .btn { flex: 1 1 auto; padding: 0 10px; }
  .composer__hint { display: none; }
  .disc, .alog { margin-left: 16px; margin-right: 16px; }
  .disc__hint { margin-left: 0; flex-basis: 100%; }
  .chat { width: 100%; bottom: var(--tabbar-h); border-left: 0; }
  .toast-stack { bottom: calc(var(--tabbar-h) + 12px); }
  .compose { height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .modal:has(.compose) { padding: 0; place-items: stretch; }
  .modal:has(.compose) .modal__card::before { display: none; }
  .compose .modal__foot .cmp__attach span { display: none; }
  .shortcuts { grid-template-columns: 1fr; }
  .att { max-width: 100%; }
}
@media (max-width: 380px) {
  .lp-head__title { font-size: 17px; }
  .rail__label { font-size: 10px; }
  .mail__reply .btn span { font-size: 13px; }
}


.confirm__badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  margin-bottom: 10px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--global-soft);
  color: var(--global-ink);
  font-size: 12px;
  font-weight: 700;
}
.confirm__badge .i { width: 14px; height: 14px; }
.confirm__badge--danger { background: var(--danger-soft); color: var(--danger-ink); }


/* =====================================================================
   v3b — selezione con azioni, etichette di squadra, nuova presa in carico
   ===================================================================== */
.lp { container-type: inline-size; container-name: lp; }

/* Barra della selezione: due righe (conteggio | azioni) */
.lp-tools.has-selection { flex-direction: column; align-items: stretch; gap: 2px; padding: 6px 8px 6px 18px; }
.lp-tools__line { display: flex; align-items: center; gap: 10px; min-height: 32px; }
.lp-tools__clear { margin-left: auto; color: var(--accent-ink); }
.lp-tools.has-selection .lp-tools__actions { display: flex; justify-content: space-between; gap: 2px; margin: 0 0 0 -8px; }
.selbtn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1 1 0;
  min-width: 34px;
  height: 36px;
  padding: 0 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--accent-ink);
  cursor: pointer;
}
.selbtn .i { width: 18px; height: 18px; }
.selbtn:hover { background: var(--surface); }
.selbtn:focus-visible { box-shadow: var(--focus); }
.selbtn.is-on .i { color: var(--warn); }
.selbtn.is-danger { color: var(--danger-ink); }
.selbtn__label { display: none; font-size: 10.5px; font-weight: 600; line-height: 1.1; white-space: nowrap; }
@container lp (min-width: 520px) {
  .selbtn { height: 46px; }
  .selbtn__label { display: block; }
}

/* Pannello della selezione al posto del lettore */
.reader--selection { background: var(--canvas, var(--surface-2)); }
.selpanel { max-width: 720px; margin: 0 auto; padding: 32px 36px 40px; overflow-y: auto; height: 100%; }
.selpanel__head { display: flex; align-items: center; gap: 14px; }
.selpanel__stack { display: inline-flex; flex: none; }
.selpanel__stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.selpanel__stack .avatar + .avatar { margin-left: -6px; }
.selpanel__titles { flex: 1; min-width: 0; }
.selpanel__title { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
.selpanel__meta { margin: 2px 0 0; font-size: 13px; color: var(--ink-3); }
.selpanel__list { list-style: none; margin: 18px 0 6px; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.selpanel__mail { display: flex; gap: 10px; align-items: baseline; padding: 9px 14px; border-top: 1px solid var(--line); font-size: 13px; min-width: 0; }
.selpanel__mail:first-child { border-top: 0; }
.selpanel__from { flex: none; max-width: 40%; font-weight: 620; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selpanel__subj { flex: 1; min-width: 0; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selpanel__more { padding: 8px 14px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-3); }
.selpanel__group { margin-top: 22px; }
.selpanel__label { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; font-size: 12.5px; font-weight: 650; color: var(--ink-3); }
.selpanel__label .i { width: 14px; height: 14px; }
.selpanel__group--all .selpanel__label { color: var(--global-ink); }
.selpanel__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 8px; }
.selact {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 560;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.selact .i { width: 18px; height: 18px; flex: none; color: var(--accent-ink); }
.selact:hover { border-color: var(--accent); background: var(--accent-soft); }
.selact:focus-visible { box-shadow: var(--focus); }
.selact.is-global .i { color: var(--global-ink); }
.selact.is-global:hover { border-color: var(--global-ink); background: var(--global-soft); }
.selact.is-danger { color: var(--danger-ink); }
.selact.is-danger .i { color: var(--danger); }
.selact.is-danger:hover { border-color: var(--danger); background: var(--danger-soft); }
.selact.is-off { opacity: .45; }
.selpanel__hint { margin: 22px 0 0; font-size: 12.5px; color: var(--ink-3); }

/* Etichette di squadra */
.lbl {
  --lbl: #5B6478;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  max-width: 120px;
  height: 20px;
  padding: 0 7px 0 6px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--lbl) 13%, var(--surface));
  color: color-mix(in srgb, var(--lbl) 72%, var(--ink));
  font-size: 11.5px;
  font-weight: 620;
  white-space: nowrap;
}
.lbl__dot { flex: none; width: 7px; height: 7px; border-radius: 2px; background: var(--lbl); }
.lbl__name { overflow: hidden; text-overflow: ellipsis; }
.lbl--more { background: var(--sunken); color: var(--ink-2); padding: 0 6px; }
.lbl--lg { height: 26px; max-width: none; padding: 0 10px 0 8px; font-size: 12.5px; border-radius: 7px; }
.lbl--lg .lbl__dot { width: 8px; height: 8px; }
[data-theme="dark"] .lbl { background: color-mix(in srgb, var(--lbl) 22%, var(--surface)); color: color-mix(in srgb, var(--lbl) 55%, #fff); }
.row__labels { display: inline-flex; align-items: center; gap: 4px; min-width: 0; overflow: hidden; }
.row__foot:has(.row__labels) { display: flex !important; }
.mail__labels { display: contents; }
.lp-head__dot--lbl { border-radius: 3px; background: var(--lbl); box-shadow: 0 0 0 3px color-mix(in srgb, var(--lbl) 18%, transparent); }

.lbl-nav { display: flex; flex-direction: column; gap: 1px; }
.lbl-item .lbl-item__dot { flex: none; width: 10px; height: 10px; margin: 0 4px 0 3px; border-radius: 3px; background: var(--lbl); }
.lbl-item.is-active { background: color-mix(in srgb, var(--lbl) 12%, var(--surface)); color: var(--ink); }
.lbl-item.is-active .sb-item__label { color: var(--ink); }
.lbl-item__count { background: color-mix(in srgb, var(--lbl) 14%, var(--surface)); color: color-mix(in srgb, var(--lbl) 72%, var(--ink)); }
.sb-add {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
}
.sb-add .i { width: 15px; height: 15px; }
.sb-add:hover { background: var(--sunken); color: var(--ink); }
.sb-add:focus-visible { box-shadow: var(--focus); }

.lblpick__list { display: flex; flex-direction: column; gap: 1px; max-height: 280px; overflow-y: auto; padding: 0 5px 4px; }
.lblpick__item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 4px 9px; border: 0; border-radius: 8px; background: transparent; text-align: left; color: var(--ink); cursor: pointer; }
.lblpick__item:hover, .lblpick__item:focus-visible { background: var(--sunken); box-shadow: none; }
.lblpick__item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.lblpick__item .check__box { color: transparent; }
.lblpick__item .check__box.is-on, .lblpick__item .check__box.is-mixed { background: var(--accent-solid); border-color: var(--accent-solid); color: #fff; }
.lblpick__item .lbl { max-width: 200px; }
.lblpick__new { color: var(--accent-ink); font-size: 13.5px; font-weight: 600; }
.lblpick__new .i { width: 16px; height: 16px; margin: 0 1px; }
.lblpick__note { display: flex; align-items: center; gap: 6px; margin: 0; padding: 8px 14px 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-3); }
.lblpick__note .i { width: 14px; height: 14px; flex: none; }
.modal__foot .lbl-del { margin-right: auto; }

/* ---------- Presa in carico, variante B (attiva): colonna "responsabile" a destra ---------- */
.owner-v-b .row { grid-template-columns: 36px minmax(0, 1fr) 40px; }
.owner-v-b .row__side { gap: 4px; padding-top: 1px; }
.oslot {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.oslot__face { width: 26px; height: 26px; font-size: 10px; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--own); }
.oslot__tag { margin-top: 3px; max-width: 40px; font-size: 10.5px; font-weight: 700; line-height: 1.15; color: var(--own-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oslot--me { --own: var(--own-me); --own-ink: var(--own-me-ink); }
.oslot--other { --own: var(--own-other); --own-ink: var(--own-other-ink); }
.oslot--me .oslot__face::after { content: none; }
.oslot--free {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px dashed var(--line-strong);
  color: var(--ink-3);
  justify-content: center;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
}
.oslot--free .i { width: 15px; height: 15px; }
.row:hover .oslot--free, .row:focus-visible .oslot--free, .row:has(:focus-visible) .oslot--free { opacity: 1; }
.oslot--free:hover { border-color: var(--own-me); color: var(--own-me-ink); background: var(--own-me-soft); }
.oslot:focus-visible { outline: none; }
.oslot:focus-visible .oslot__face, .oslot--free:focus-visible { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.oslot--free:focus-visible { opacity: 1; }
@media (hover: none) { .oslot--free { display: none; } }
.owner-v-b .row.own-other { background: var(--surface); }
.owner-v-b .row.own-other:hover { background: var(--surface-2); }
.owner-v-b .row.is-selected { background: var(--accent-soft); }
.owner-v-b .row.is-picked { background: color-mix(in srgb, var(--accent-soft) 70%, var(--surface)); }
.density-compact.owner-v-b .row { grid-template-columns: 26px minmax(0, 1fr) auto; }
.density-compact .oslot { flex-direction: row; width: auto; gap: 5px; }
.density-compact .oslot__face { width: 20px; height: 20px; font-size: 8.5px; box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 3px var(--own); }
.density-compact .oslot__tag { display: none; }
.density-compact .oslot--free { width: 24px; height: 24px; }

/* ---------- Presa in carico, variante A (alternativa): firma sull'avatar del mittente ---------- */
.obadge {
  position: absolute;
  right: -5px;
  bottom: -5px;
  z-index: 2;
  display: grid;
  place-items: center;
  border-radius: 50%;
  pointer-events: none;
}
.obadge__face { width: 19px; height: 19px; font-size: 7.5px; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--own); }
.obadge--me { --own: var(--own-me); }
.obadge--other { --own: var(--own-other); }
.row:hover .obadge, .row.is-picked .obadge, .msg-list.has-selection .obadge { opacity: 0; }
.density-compact .obadge { right: -6px; bottom: -6px; }
.density-compact .obadge__face { width: 15px; height: 15px; font-size: 6.5px; }

/* Lettore */
.reader__actions #reader-read, .reader__actions #reader-labels-btn { flex: none; }

/* Barra contestuale della selezione su telefono */
.mselbar { display: none; }
@media (max-width: 699px) {
  .app--selecting .rail { visibility: hidden; }
  .mselbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 46;
    display: flex;
    align-items: stretch;
    gap: 0;
    height: var(--tabbar-h);
    padding: 4px 4px env(safe-area-inset-bottom);
    background: var(--rail-bg);
    color: var(--rail-ink);
    box-shadow: 0 -6px 18px -10px rgba(0, 0, 0, .4);
  }
  .mselbar__close, .mselbar__btn {
    flex: 1 1 0;
    min-width: 0;
    display: grid;
    grid-template-rows: 24px auto;
    place-items: center;
    gap: 1px;
    height: 50px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: inherit;
    font-size: 10.5px;
    font-weight: 600;
  }
  .mselbar__btn .i, .mselbar__close .i { width: 20px; height: 20px; align-self: end; }
  .mselbar__btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .mselbar__close { flex: .8 1 0; color: var(--cyan); }
  .mselbar__close span { font-size: 12px; font-weight: 750; }
  .mselbar__btn.is-danger { color: #FF9AA8; }
  .mselbar__btn:active, .mselbar__close:active { background: rgba(255, 255, 255, .08); }
  .lp-tools.has-selection .lp-tools__actions { display: none; }
  .lp-tools.has-selection { padding: 4px 8px 4px 16px; }
  .lp-tools__clear span { display: none; }
  .selpanel { padding: 20px 16px 32px; }
}
@media (max-width: 380px) {
  .mselbar__btn span { font-size: 9.5px; }
}

/* ---------- Invia / Invia più tardi ---------- */
.split--primary .split__more { width: 34px; margin-left: 0; border-left: 1px solid rgba(255, 255, 255, .28); }
@media (max-width: 699px) {
  .split--primary .split__main { width: auto; padding: 0 14px; }
  .split--primary .split__main span { display: inline; }
}
.pop__check { position: relative; display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 6px 10px; border-radius: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.pop__check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pop__check input:checked + .check__box { background: var(--accent-solid); border-color: var(--accent-solid); color: #fff; }
.pop__check input:focus-visible + .check__box { box-shadow: var(--focus); }
.pop__check:hover { background: var(--sunken); }

/* ---------- Programmate ---------- */
.sb-count--warn { background: var(--warn-soft); color: var(--warn); }
.obox-list { padding-top: 2px; }
.obox {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.obox::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--mbx); }
.obox__when { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 650; color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.obox__when > .i { width: 15px; height: 15px; }
.obox__status { display: inline-flex; align-items: center; gap: 4px; height: 20px; margin-left: auto; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.obox__status .i { width: 12px; height: 12px; }
.obox__status--failed { background: var(--danger-soft); color: var(--danger-ink); }
.obox__status--cancelled { background: var(--sunken); color: var(--ink-3); }
.obox--failed .obox__when { color: var(--danger-ink); }
.obox--cancelled { opacity: .6; }
.obox__subject { font-size: 13.5px; font-weight: 620; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.obox__kind { display: inline-block; margin-right: 6px; padding: 1px 6px; border-radius: 5px; background: var(--sunken); color: var(--ink-2); font-size: 11px; font-weight: 650; vertical-align: 1px; }
.obox__to { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.obox__error { margin: 4px 0 0; padding: 6px 9px; border-radius: 7px; background: var(--danger-soft); color: var(--danger-ink); font-size: 12.5px; line-height: 1.4; }
.obox__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.obox__link { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; color: var(--accent-ink); font-size: 12px; font-weight: 600; cursor: pointer; }
.obox__link .i { width: 14px; height: 14px; }
.obox__link:hover { background: var(--accent-soft); }
.obox__actions { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: auto; }
.obox__cancel { color: var(--danger-ink); }

/* ---------- Sola lettura ---------- */
.ro-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 999px; background: var(--sunken); color: var(--ink-2); font-size: 12.5px; font-weight: 650; }
.ro-chip .i { width: 15px; height: 15px; }
.ro-banner { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 16px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--ink-2); font-size: 13px; line-height: 1.5; }
.ro-banner > .i { flex: none; width: 17px; height: 17px; margin-top: 2px; color: var(--ink-3); }
.ro-banner p { margin: 0; }
.ro-banner strong { color: var(--ink); font-weight: 650; }
.mbx-chip--ro { --mbx: var(--ink-3); --mbx-soft: var(--sunken); --mbx-ink: var(--ink-2); }

/* ---------- Unificata: sottocartelle della posta in arrivo ---------- */
.mbx__folder { padding-left: calc(10px + var(--depth, 0) * 16px); }
.mbx-chip__name { flex: none; }
.mbx-chip__sub { min-width: 0; font-weight: 520; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__foot .mbx-chip { flex-shrink: 0; max-width: 72%; }
.row__foot .row__labels { flex: 0 1 auto; }
.fld-chip { display: inline-flex; align-items: center; gap: 4px; flex: none; height: 20px; padding: 0 7px; border-radius: 6px; background: var(--sunken); color: var(--ink-2); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.fld-chip .i { width: 12px; height: 12px; }

/* ---------- Ricerca mirata ---------- */
.gsearch { position: relative; }
.shelp {
  position: absolute;
  left: -1px;
  right: -1px;
  top: calc(100% + 6px);
  z-index: 70;
  display: none;
  padding: 12px 12px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.gsearch.show-help .shelp { display: block; }
.shelp__title { margin: 0 4px 8px; font-size: 12.5px; color: var(--ink-3); }
.shelp__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 2px 6px; }
.shelp__op { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: baseline; padding: 6px 8px; border: 0; border-radius: 8px; background: transparent; text-align: left; color: var(--ink); cursor: pointer; }
.shelp__op:hover, .shelp__op:focus-visible { background: var(--sunken); box-shadow: none; }
.shelp__op code { grid-row: 1 / 3; align-self: center; padding: 2px 6px; border-radius: 5px; background: var(--accent-soft); color: var(--accent-ink); font: 600 12px/1.4 var(--font-mono, ui-monospace, monospace); white-space: nowrap; }
.shelp__label { font-size: 13px; font-weight: 560; }
.shelp__ex { font-size: 11.5px; color: var(--ink-3); }
.lp-filters--search { gap: 8px; }
.sscope .seg__opt { gap: 6px; padding: 0 10px; max-width: 220px; }
.sscope .seg__opt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sscope .seg__opt .i { width: 14px; height: 14px; flex: none; }
#speriod .i:last-child { width: 13px; height: 13px; margin-left: 2px; }
.lgroup { position: sticky; top: 0; z-index: 2; padding: 6px 20px 5px; border-bottom: 1px solid var(--line); background: var(--surface-2); color: var(--ink-3); font-size: 12px; font-weight: 650; }
.row mark { padding: 0 1px; border-radius: 3px; background: color-mix(in srgb, var(--cyan) 30%, transparent); color: inherit; }
[data-theme="dark"] .row mark { background: color-mix(in srgb, var(--cyan) 28%, transparent); color: var(--ink); }
.match-in { display: flex; align-items: center; gap: 4px; margin-top: 3px; font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.match-in .i { width: 12px; height: 12px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 699px) {
  .shelp { position: fixed; left: 12px; right: 12px; top: calc(var(--topbar-h) + env(safe-area-inset-top) + 4px); max-height: 60vh; overflow-y: auto; }
  .shelp__grid { grid-template-columns: 1fr; }
  .lp-filters--search .fchips { flex-wrap: nowrap; }
}

/* ---------- Barra applicazioni con i nomi (da 700 px in su) ----------
   Le sezioni principali mostrano il nome sotto l'icona, come Google Workspace e Teams: con le sole icone la Rubrica
   e il Calendario passavano inosservati. I comandi in basso (tasti, sicurezza, tema, esci) restano solo icone. */
@media (min-width: 700px) {
  :root { --rail-w: 72px; }
  .rail__group:not(.rail__group--end) { gap: 4px; }
  .rail__group:not(.rail__group--end) .rail__btn { width: calc(var(--rail-w) - 10px); height: 52px; grid-template-rows: 24px auto; align-content: center; gap: 3px; }
  .rail__group:not(.rail__group--end) .rail__btn .i { align-self: end; justify-self: center; }
  .rail__group:not(.rail__group--end) .rail__label { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; font-weight: 600; line-height: 1.1; }
  .rail__group:not(.rail__group--end) .rail__btn.is-active::before { left: -5px; }
  .rail__group:not(.rail__group--end) .rail__badge { top: 2px; right: 6px; }
}
@media (min-width: 700px) and (max-width: 1099px) {
  :root { --rail-w: 66px; }
}

/* Finestra della Scrivania (?embed=1): solo la sezione, senza barra delle applicazioni né chat laterale. */
:root.is-embed { --rail-w: 0px !important; }
.is-embed .app:not(.app--popout) > aside.chat { display: none !important; }
/* La barra resta nella griglia (colonna larga 0) così le altre colonne non si spostano; semplicemente non si vede. */
.is-embed .rail { visibility: hidden !important; width: 0 !important; min-width: 0 !important; padding: 0 !important; overflow: hidden !important; border: 0 !important; }

/* Risposta e inoltro: allegati aggiunti (dal computer o dalla Scrivania). */
.composer__atts:empty { display: none; }
.composer__atts { padding: 4px 12px 8px; }
.composer__note { display: flex; align-items: center; gap: 6px; margin: 0; padding: 4px 12px; font-size: 12px; color: var(--ink-3); }
.composer__note .i { width: 14px; height: 14px; }
.composer.is-over { box-shadow: inset 0 0 0 2px var(--accent); }
.composer__foot { flex-wrap: wrap; }

/* Strumenti sugli allegati (firma, fattura) sotto l'elenco degli allegati. */
.atts__tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.att-tool { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; padding: 6px 10px; border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); border-radius: 9px; background: var(--accent-soft); color: var(--accent-ink, var(--ink)); font-size: 12.5px; cursor: pointer; text-align: left; }
.att-tool span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-tool .i { width: 15px; height: 15px; flex: none; }
.att-tool--soft { background: transparent; border-color: var(--line); color: var(--ink-2); }
.att-tool:hover { filter: brightness(.97); }
.is-embed #cx-dock { display: none !important; }

/* ---------- Telefono e tablet: niente zoom automatico sui campi ----------
   Safari su iPhone/iPad ingrandisce la pagina quando si tocca un campo con testo più piccolo di 16 px, e dopo
   l'accesso la pagina resta ingrandita. Sui dispositivi touch i campi usano quindi almeno 16 px: niente zoom, e lo
   zoom manuale con due dita resta possibile (non si blocca con maximum-scale, per l'accessibilità). */
@media (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]),
  select,
  textarea,
  [contenteditable="true"] { font-size: 16px !important; }
}

/* ---------- Profilo e impostazioni ---------- */
.me { width: 100%; padding: 6px; margin: -6px; border: 0; border-radius: 10px; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.me:hover { background: var(--sunken); }
.me:focus-visible { box-shadow: var(--focus); outline: none; }
.me__go { margin-left: auto; color: var(--ink-4); display: inline-flex; }
.me__go .i { width: 16px; height: 16px; }
.avatar--photo { padding: 0; overflow: hidden; background: var(--sunken); }
.avatar--photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar--xl { width: 72px; height: 72px; font-size: 24px; }
.pf-modal .modal__body { display: flex; flex-direction: column; gap: 18px; }
.pf-head { display: flex; gap: 16px; align-items: flex-start; }
.pf-who { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pf-name { font-size: 17px; }
.pf-meta { color: var(--ink-3); font-size: 13px; overflow-wrap: anywhere; }
.pf-photo-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.pf-photo-btns label.btn { cursor: pointer; }
.pf-photo-btns .is-disabled { opacity: .5; pointer-events: none; }
.pf-sec { display: flex; flex-direction: column; gap: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.pf-sec__title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; }
.pf-sec__title .i { width: 17px; height: 17px; color: var(--ink-3); }
.pf-pw { gap: 10px; }
.pf-pw__foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.pf-links { gap: 4px; }
.pf-link { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px; border: 0; border-radius: 10px; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.pf-link:hover { background: var(--sunken); }
.pf-link:focus-visible { box-shadow: var(--focus); outline: none; }
.pf-link > .i:first-child { width: 20px; height: 20px; color: var(--accent); flex: none; }
.pf-link > .i:last-child { width: 16px; height: 16px; margin-left: auto; color: var(--ink-4); flex: none; }
.pf-link span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pf-link small { color: var(--ink-3); font-size: 12.5px; }
@media (max-width: 480px) { .pf-head { flex-direction: column; align-items: center; text-align: center; } .pf-who { align-items: center; } .pf-photo-btns { justify-content: center; } }
