/* Boat Smart Logbook — design system.
   Two looks chosen in Impostazioni › Aspetto: "chiaro" (default) and "notte".
   Every colour of the app comes from these variables. */

@font-face {
  font-family: Archivo;
  src: url("/fonts/archivo-latin-wdth.woff2") format("woff2");
  font-weight: 100 900; font-stretch: 62% 125%; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/fonts/atkinson-next-latin-wght.woff2") format("woff2");
  font-weight: 200 800; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/fonts/atkinson-next-latin-wght-italic.woff2") format("woff2");
  font-weight: 200 800; font-style: italic; font-display: swap;
}

:root, :root[data-theme="chiaro"] {
  color-scheme: light;
  --font-body: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: Archivo, "Arial Narrow", system-ui, sans-serif;

  --bg: #f2f5f3;
  --card: #ffffff;
  --line: rgba(13, 29, 38, .14);
  --line-soft: rgba(13, 29, 38, .08);
  --ink: #0d1d26;
  --ink-2: #3c4f5a;
  --ink-3: #66787f;

  --sea-900: #0c2029;
  --sea-800: #15384a;
  --sea-700: #1d4b61;
  --sea-500: #3f7a90;

  --red: #e63946;
  --red-deep: #b8232f;
  --red-on-dark: #ff7d86;
  --mint: #3dd6a3;
  --amber: #f2a93b;

  --chip-red: #fde8ea;
  --chip-amber: #fdf1dc;
  --chip-sea: #e3edf1;
  --chip-mint: #dcf7ee;
  --chip-violet: #ece9f7;

  --radius: 10px;
  --radius-btn: 6px;
  --radius-icon: 7px;
  --shadow-card: 0 2px 6px rgba(12, 32, 41, .06);

  /* legacy aliases used by rules further down */
  --muted: var(--ink-3);
  --field: #ffffff;
  --surface2: #eef3f1;
  --sea: var(--sea-900);
  --header-ink: #ffffff;
  --header-muted: rgba(255, 255, 255, .76);
  --accent: var(--red);
  --accent-ink: #ffffff;
  --bubble: var(--sea-800);
  --bubble-ink: #ffffff;
  --brass: var(--red);
  --danger: var(--red);
  --warn: var(--amber);
  --warn-ink: #3c2600;
  --warn-bg: #fdf1dc;
  --warn-line: #efd6a6;
  --ok: #14795a;
  --note-bg: #eef7f3;
  --toast-bg: var(--sea-900);
  --toast-ink: #ffffff;
  --toast-action: var(--red-on-dark);
  --on-dark: rgba(255, 255, 255, .76);
  --on-dark-strong: rgba(255, 255, 255, .93);
  --line-dark: rgba(255, 255, 255, .13);
}

:root[data-theme="notte"] {
  color-scheme: dark;
  --bg: #071219;
  --card: #0c2029;
  --line: rgba(255, 255, 255, .13);
  --line-soft: rgba(255, 255, 255, .08);
  --ink: rgba(255, 255, 255, .93);
  --ink-2: rgba(255, 255, 255, .76);
  --ink-3: rgba(255, 255, 255, .56);

  --sea-900: #0c2029;
  --sea-800: #15384a;
  --sea-700: #1d4b61;
  --sea-500: #3f7a90;

  --red: #ff5a66;
  --red-deep: #e63946;
  --red-on-dark: #ff7d86;
  --mint: #3dd6a3;
  --amber: #f2a93b;

  --chip-red: rgba(230, 57, 70, .16);
  --chip-amber: rgba(242, 169, 59, .16);
  --chip-sea: rgba(63, 122, 144, .2);
  --chip-mint: rgba(61, 214, 163, .14);
  --chip-violet: rgba(160, 145, 220, .16);

  --shadow-card: 0 2px 6px rgba(0, 0, 0, .3);

  --muted: var(--ink-3);
  --field: #0a1a23;
  --surface2: rgba(255, 255, 255, .06);
  --sea: var(--sea-900);
  --header-ink: #ffffff;
  --header-muted: rgba(255, 255, 255, .76);
  --accent: var(--red);
  --accent-ink: #ffffff;
  --bubble: var(--sea-800);
  --bubble-ink: #ffffff;
  --brass: var(--red);
  --danger: var(--red);
  --warn: var(--amber);
  --warn-ink: #1c1405;
  --warn-bg: rgba(242, 169, 59, .13);
  --warn-line: rgba(242, 169, 59, .35);
  --ok: var(--mint);
  --note-bg: rgba(61, 214, 163, .08);
  --toast-bg: #e9eef0;
  --toast-ink: #071219;
  --toast-action: var(--sea-900);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--font-body);
  overflow: hidden;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; margin: 0; letter-spacing: -.01em; line-height: 1.12; }
p { margin: 0; }
a { color: var(--red); text-decoration-thickness: 1px; text-underline-offset: .2em; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; }
::selection { background: var(--red); color: #fff; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }

.screen { height: 100%; height: 100dvh; display: flex; flex-direction: column; min-height: 0; }
#login { align-items: center; justify-content: center; padding: 1rem; overflow-y: auto; }
.muted { color: var(--ink-3); font-size: .9rem; }
.error { color: var(--red); min-height: 1.2em; margin: .25rem 0 0; }
.notice { color: var(--ink-3); min-height: 1.2em; margin: .25rem 0 0; }

/* ---------------------------------------------------------------- shell */
#app { width: 100%; max-width: 560px; margin-inline: auto; }
body:not([data-screen="home"]) .app-head { display: none; }
body[data-screen="boat"] #app > nav,
body[data-screen="items"] #app > nav,
body[data-screen="work"] #app > nav { display: none; }

.app-head {
  background: var(--sea-900);
  color: #fff;
  padding: calc(1.1rem + env(safe-area-inset-top)) 1.1rem 1.2rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .8rem;
}
.app-head .head-main { min-width: 0; }
.app-head .eyebrow { color: var(--red-on-dark); margin-bottom: .35rem; }
.app-head h1 { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; }
.app-head #boat-sub { display: block; margin-top: .2rem; color: var(--on-dark); font-size: .88rem; }
.head-pills { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .8rem; }
.header-actions { display: flex; align-items: center; gap: .4rem; }
#logout { color: var(--on-dark-strong); padding: .4rem; }

.pill {
  display: inline-flex; align-items: center; gap: .4rem;
  min-height: 26px; padding: .2rem .65rem;
  border: 1px solid var(--line-dark); border-radius: 999px;
  color: var(--on-dark-strong); font-size: .78rem; white-space: nowrap;
}
.pill.mint { border-color: rgba(61, 214, 163, .45); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); flex: none; }
.pill.mint .dot { box-shadow: 0 0 0 3px rgba(61, 214, 163, .18); }

.readonly-bar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem .9rem;
  background: var(--warn-bg); border-bottom: 1px solid var(--warn-line); font-size: .9rem; color: var(--ink); }

nav {
  order: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  min-height: 78px;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card);
  border-top: 1px solid var(--line);
}
nav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem;
  min-height: 44px; padding: .35rem .1rem .55rem;
  border: 0; background: none; color: var(--ink-3);
  font-size: .68rem; letter-spacing: .01em; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
nav button .icon { width: 22px; height: 22px; }
nav button.active { color: var(--red); font-weight: 700; }
nav button.active .icon { stroke-width: 2.1; }

main { flex: 1; display: flex; flex-direction: column; min-height: 0; order: 5; }
section {
  flex: 1; width: 100%; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: .9rem .9rem 1.4rem;
}
section > * + * { margin-top: .75rem; }
#tab-chat { display: flex; flex-direction: column; padding-bottom: 0; overflow: hidden; }

.eyebrow, .section-label {
  font-family: var(--font-body);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3);
}
.page-head { display: flex; align-items: center; gap: .6rem; padding: .2rem 0 .1rem; }
.page-head > h2 { flex: 1; font-size: 1.55rem; letter-spacing: -.02em; }
.page-head > .eyebrow { flex: 0 0 100%; margin-bottom: -.35rem; }
.page-head { flex-wrap: wrap; }
.page-head .head-actions { margin-left: auto; position: relative; }
.view-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem; }
.view-head h2 { font-size: 1.4rem; }
.back { display: inline-flex; align-items: center; gap: .15rem; padding: .35rem 0; color: var(--red); font-weight: 700; }
.back .icon { width: 18px; height: 18px; }
.settings-head { flex-direction: column; align-items: flex-start; gap: .1rem; }
.settings-head .back { margin-bottom: .2rem; }
.settings-head h2 { font-size: 1.7rem; }

/* ---------------------------------------------------------------- components */
.card {
  width: 100%;
  display: flex; flex-direction: column; gap: .6rem;
  padding: .9rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  text-align: left;
  margin: 0;
}
.card.dark { background: var(--sea-900); border-color: var(--sea-900); color: #fff; }
.card.dark .muted, .card.dark .metric-label { color: var(--on-dark); }
.card.dark h3, .card.dark .card-title { color: #fff; }
.card.agent-card { box-shadow: var(--shadow-card); }
.agent-card .two-up .btn { font-size: .82rem; padding: .5rem .4rem; gap: .35rem; }
.agent-card .two-up .btn .icon { width: 18px; height: 18px; }
.card-head { display: flex; align-items: center; gap: .5rem; }
.card-head h3, .card-head .card-title { flex: 1; font-size: 1.05rem; }
.card-head .link { flex: none; }
.card-title { font-size: 1.05rem; }
.link { border: 0; background: none; color: var(--red); font-weight: 700; padding: .25rem .1rem; cursor: pointer; }
.link.danger { color: var(--red); }
.section-label { margin-top: 1.1rem; }

.rows { list-style: none; margin: 0; padding: 0; }
ul.rows > li { display: flex; align-items: center; gap: .6rem; padding: .6rem 0; border-top: 1px solid var(--line-soft); }
ul.rows > li:first-child { border-top: 0; }
ul.rows > li.empty { color: var(--ink-3); font-size: .9rem; }
.row-main { display: flex; flex-direction: column; gap: .05rem; min-width: 0; flex: 1; }
.row-main strong { font-weight: 700; font-size: .95rem; }
.row-main em, .row-main span { font-style: normal; color: var(--ink-3); font-size: .82rem; line-height: 1.3; }
.row-value { color: var(--ink-3); font-size: .82rem; text-align: right; white-space: nowrap; }
.row-when { color: var(--ink-3); font-size: .82rem; text-align: right; white-space: nowrap; }
.row-when.soon { color: var(--amber); font-weight: 700; }
.row-when.overdue { color: var(--red); font-weight: 700; }

.dot-status { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--sea-500); }
.dot-status.overdue { background: var(--red); }
.dot-status.soon { background: var(--amber); }
.dot-status.ok { background: var(--mint); }

.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: .35rem; min-width: 0;
  min-height: 44px; padding: .8rem;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink); text-align: left; cursor: pointer; margin: 0;
  -webkit-tap-highlight-color: transparent;
}
.tile strong { font-family: var(--font-display); font-size: 1rem; font-weight: 700; max-width: 100%; }
.tile-line { color: var(--ink-3); font-size: .8rem; line-height: 1.3; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile.action { align-items: center; justify-content: center; gap: .3rem; text-align: center; font-size: .78rem; font-weight: 600; }
.tile.action .icon-chip { margin-bottom: .1rem; }
.tile.action > span:last-child { color: var(--ink-2); }

.home-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.home-grid .tile { min-height: 116px; }

.icon-chip {
  display: grid; place-items: center; width: 30px; height: 30px; flex: none;
  border-radius: var(--radius-icon);
  background: var(--chip-sea); color: var(--sea-700);
}
.icon-chip .icon { width: 17px; height: 17px; }
.chip-red { background: var(--chip-red); color: var(--red); }
.chip-amber { background: var(--chip-amber); color: #a86a06; }
.chip-sea { background: var(--chip-sea); color: var(--sea-700); }
.chip-mint { background: var(--chip-mint); color: #14865f; }
.chip-violet { background: var(--chip-violet); color: #6c5aa8; }
:root[data-theme="notte"] .chip-amber { color: var(--amber); }
:root[data-theme="notte"] .chip-mint { color: var(--mint); }
:root[data-theme="notte"] .chip-sea { color: #9fc7d6; }
:root[data-theme="notte"] .chip-violet { color: #b9aee8; }

.badge {
  display: inline-flex; align-items: center; align-self: flex-start; gap: .25rem;
  padding: .12rem .5rem; border-radius: 999px;
  font-size: .7rem; font-weight: 700; white-space: nowrap;
}
.badge.amber { background: var(--chip-amber); color: #8a5600; }
.badge.mint { background: var(--chip-mint); color: #0f6f4f; }
.badge.red { background: var(--chip-red); color: var(--red-deep); }
.badge.sea { background: var(--chip-sea); color: var(--sea-700); }
:root[data-theme="notte"] .badge.amber { color: var(--amber); }
:root[data-theme="notte"] .badge.mint { color: var(--mint); }
:root[data-theme="notte"] .badge.red { color: var(--red-on-dark); }
:root[data-theme="notte"] .badge.sea { color: #9fc7d6; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: .55rem .9rem;
  border-radius: var(--radius-btn); border: 1.5px solid transparent;
  font-family: var(--font-display); font-weight: 700; font-size: .92rem;
  cursor: pointer; text-align: center; text-decoration: none; white-space: normal; line-height: 1.15;
}
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.border { background: var(--card); border-color: var(--line); color: var(--ink); }
.btn.on-dark { background: #fff; border-color: #fff; color: var(--sea-900); }
.btn.border-on-dark { background: transparent; border-color: var(--red-on-dark); color: var(--red-on-dark); }
.btn.full { width: 100%; }
.btn.small { min-height: 34px; padding: .25rem .6rem; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: default; }

.two-up { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.three-up { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }

.pill-field {
  display: flex; align-items: center; gap: .4rem;
  padding: .3rem .3rem .3rem .85rem;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--field);
}
.pill-field input { flex: 1; min-width: 0; border: 0; background: none; padding: .45rem 0; color: var(--ink); }
.pill-field input:focus { outline: none; }
.pill-field > .icon { color: var(--ink-3); }
:root[data-theme="notte"] .pill-field button.round { background: var(--red); }
.pill-field button.round, .round {
  display: grid; place-items: center; width: 38px; height: 38px; flex: none;
  border: 0; border-radius: 50%; background: var(--sea-900); color: #fff; cursor: pointer;
}
.pill-field.search-pill { padding-left: .75rem; }
.pill-field.search-pill input { padding: .5rem 0; }

.icon-button { display: grid; place-items: center; width: 38px; height: 38px; padding: 0;
  border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; }
.icon-button.round { background: rgba(255, 255, 255, .1); color: #fff; }
body:not([data-screen="home"]) .icon-button.round { background: var(--surface2); color: var(--ink); }
.icon-button.active { color: var(--red); }

.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; }
.metric {
  display: flex; flex-direction: column; align-items: flex-start; gap: .05rem;
  padding: .6rem .7rem; border-radius: 8px; background: var(--sea-800);
}
.metric-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--on-dark); }
.metric strong {
  font-family: var(--font-display); font-weight: 700; font-size: 28px; line-height: 1.05;
  font-variant-numeric: tabular-nums; color: #fff;
}
.metric em { font-style: normal; font-size: .72rem; color: var(--on-dark); }

.menu {
  position: absolute; right: 0; top: calc(100% + .35rem); z-index: 20;
  min-width: 15rem; padding: .35rem;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 18px 36px rgba(7, 18, 25, .22);
}
.menu-item { display: flex; align-items: center; gap: .55rem; width: 100%; min-height: 44px; padding: .5rem .65rem;
  border: 0; border-radius: 6px; background: none; color: var(--ink); text-align: left; cursor: pointer; }
.menu-item:hover { background: var(--surface2); }
.menu-item.danger { color: var(--red); }
.menu .instruments { padding: .4rem .65rem; }
.menu .instruments summary { cursor: pointer; color: var(--ink-2); }

.row { display: flex; gap: .5rem; align-items: flex-end; }
.row.end { justify-content: flex-end; }
.row.wrap { flex-wrap: wrap; align-items: center; }
.row > input, .row > select { flex: 1; }
.spacer { flex: 1; }
.toggles { gap: .9rem; }
.quick-note { align-items: stretch; margin: .6rem 0; }
.quick-note input { min-width: 0; }

/* ---------------------------------------------------------------- forms */
label { display: flex; flex-direction: column; gap: .2rem; font-size: .8rem; color: var(--ink-3); flex: 1; min-width: 0; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--red); }
input, textarea, select {
  font: inherit; color: var(--ink);
  padding: .55rem .65rem; min-height: 44px;
  border: 1px solid var(--line); border-radius: var(--radius-btn);
  background: var(--field); width: 100%;
}
textarea { min-height: 3rem; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--red); outline-offset: 0; border-color: var(--red); }
button, .button {
  font: inherit; min-height: 44px; padding: .5rem .9rem;
  border-radius: var(--radius-btn); border: 1px solid var(--line);
  background: var(--card); color: var(--ink); cursor: pointer; white-space: normal; text-align: center;
}
.primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 700; }
.button.primary { background: var(--red); border-color: var(--red); color: #fff; }
button:disabled { opacity: .55; cursor: default; }
label.check { flex-direction: row; align-items: center; gap: .5rem; min-height: 44px; }
label.check input { width: auto; min-height: 0; }
.check { display: flex; align-items: center; gap: .5rem; }
.danger-fill { background: var(--red); border-color: var(--red); color: #fff; }
.go-green { background: #14795a; border-color: #14795a; color: #fff; }
.go-green:disabled { background: var(--surface2); border-color: var(--line); color: var(--ink-3); opacity: 1; }
#tab-items .row, #tab-work .row { flex-wrap: wrap; }

/* ---------------------------------------------------------------- chat */
#tab-chat { gap: 0; }
#messages { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: .5rem; padding: .3rem 0 .75rem; }
.msg { max-width: 85%; padding: .55rem .75rem; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; flex: 0 0 auto; font-size: .95rem; }
.msg.user { align-self: flex-end; background: var(--sea-800); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.pending { color: var(--ink-3); font-style: italic; }
.msg.failed { align-self: center; color: var(--red); background: none; font-size: .9rem; }
.msg .files { display: block; margin-top: .25rem; font-size: .85rem; opacity: .85; }
#chat-send { background: var(--bg); display: flex; flex-direction: column; gap: .35rem; }
#chat-form { display: flex; gap: .5rem; padding: .5rem 0 .35rem; align-items: flex-end; }
#chat-text { resize: none; flex: 1 1 0; min-width: 0; width: auto; min-height: 44px; border-radius: 999px; padding: .65rem .9rem; }
#chat-text::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chat-submit { flex: 0 0 auto; width: 42px; height: 42px; min-height: 0; padding: 0; border: 0; border-radius: 50%;
  display: grid; place-items: center; background: var(--red); color: #fff; }
#chat-form.recording #chat-submit { display: none; }
.chat-tools { display: flex; align-items: center; gap: .4rem; padding: 0 0 .45rem; }
.tool-button { flex: 0 0 auto; width: 42px; height: 42px; min-height: 0; padding: 0; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%; background: var(--card); color: var(--red); }
.tool-button:disabled { opacity: .55; cursor: default; }
#chat-hint { text-align: right; padding-right: .2rem; }
#tab-chat.dropping { outline: 2px dashed var(--red); outline-offset: -6px; background: var(--surface2); }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { display: inline-flex; align-items: center; gap: .25rem; background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: .15rem .3rem .15rem .6rem; font-size: .85rem; }
.chip .link { padding: 0 .3rem; color: var(--ink-3); }
.chips.quick { margin: .5rem 0; }
.chips.quick button { border-radius: 999px; padding: .35rem .8rem; min-height: 36px; font-size: .8rem; }

/* ---------------------------------------------------------------- inventory */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; margin-top: .6rem; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 0; overflow: hidden;
  text-align: left; display: flex; flex-direction: column; white-space: normal; min-height: 0; }
.item img, .item .nophoto { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--surface2); }
.item .body { padding: .5rem .6rem; display: flex; flex-direction: column; gap: .1rem; }
.item .name { font-weight: 700; }
.item .where { color: var(--red); font-size: .82rem; }
.item .aka { color: var(--ink-3); font-size: .78rem; }
.found .item { width: 150px; }
.found-plans { display: flex; gap: .6rem; flex-wrap: wrap; }
.found-plans figure { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .4rem; text-align: center; }
.found-plans .plan-figure img { max-height: 300px; }
.found-plans figcaption { font-size: .8rem; color: var(--ink-3); line-height: 1.3; margin-top: .3rem; }

/* ---------------------------------------------------------------- locations and plans */
.tree, .plain { list-style: none; margin: .6rem 0 0; padding: 0; }
.plain li { display: flex; justify-content: space-between; gap: .5rem; padding: .4rem 0; border-bottom: 1px solid var(--line-soft); }
.tree ul { list-style: none; padding-left: 1.1rem; border-left: 2px solid var(--line); margin-left: .4rem; }
.tree li { padding: .25rem 0; }
.tree .count { color: var(--ink-3); font-size: .85rem; }
.tree .go { color: var(--red); cursor: pointer; text-decoration: underline dotted; }
.chip.tab { cursor: pointer; padding: .3rem .8rem; min-height: 36px; font-size: .9rem; }
.chip.tab.active { background: var(--red); border-color: var(--red); color: #fff; }
.plan-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 320px); gap: .8rem; margin-top: .6rem; align-items: start; }
@media (max-width: 720px) { .plan-layout { grid-template-columns: 1fr; } }
.plan-view { text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem; min-height: 120px; }
.plan-figure { position: relative; display: inline-block; line-height: 0; touch-action: manipulation; }
.plan-figure img { display: block; max-width: 100%; max-height: 78vh; width: auto; height: auto; user-select: none; -webkit-user-drag: none; }
.plan-view.mapping .plan-figure { cursor: crosshair; outline: 2px dashed var(--red); outline-offset: 3px; }
.pin { position: absolute; transform: translate(-50%, -50%); min-width: 26px; height: 26px; padding: 0 .35rem; border-radius: 13px;
  background: var(--sea-700); color: #fff; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35);
  font-size: .75rem; line-height: 22px; font-weight: 700; white-space: nowrap; cursor: pointer; min-height: 0; }
.pin.dim { background: #7d8f9c; }
.pin.hit { background: var(--red); min-width: 30px; height: 30px; line-height: 26px; z-index: 2; }
.pin.selected, .pin.new { background: var(--amber); color: #241700; z-index: 3; }
.pin.dot { min-width: 16px; width: 16px; height: 16px; padding: 0; border-radius: 8px; font-size: 0; line-height: 0; }
.plan-mini { position: relative; display: block; text-align: center; min-height: 96px;
  background: var(--surface2); border-radius: 8px; overflow: hidden; }
.plan-mini .plan-figure { display: inline-block; }
.plan-mini .plan-figure img { width: auto; height: auto; max-height: 130px; }
.plan-mini .pin { min-width: 9px; width: 9px; height: 9px; padding: 0; font-size: 0; line-height: 0; border-width: 1.5px; }
.plan-card { cursor: pointer; }
.row-link { flex-direction: row; align-items: center; gap: .65rem; cursor: pointer; }
.row-link .row-main { flex: 1; }
.row-link .chevron { width: 16px; height: 16px; color: var(--ink-3); flex: none; }
.plan-card .link { pointer-events: none; }
.side h3 { margin: 0 0 .4rem; }
.side .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.side ol, .side ul { padding-left: 1.2rem; margin: .4rem 0; }
.side li.current { font-weight: 700; color: var(--red); }
.side li.done { color: var(--ink-3); }
.side .actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.proposal { display: flex; gap: .8rem; align-items: center; margin-top: .6rem; }
.proposal img { width: 90px; height: 120px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
#items-plans { margin-top: .6rem; }
#location-list { margin-top: .8rem; }
#location-list summary { cursor: pointer; font-weight: 700; }
.row.wrap > label.button, .row.wrap > button { flex: 0 0 auto; }
.map-hint { position: sticky; top: 0; z-index: 5; margin: 0 0 .5rem; padding: .45rem .7rem; background: var(--warn-bg);
  border: 1px solid var(--warn-line); border-radius: 8px; line-height: 1.3; }
.effects { margin: 0 0 .4rem; padding-left: 1.2rem; }
.effects li { margin: .2rem 0; }
.labels-bar { margin: .5rem 0; }
.labels-bar .muted { flex: 1 1 260px; }
.label-toggle { display: inline-flex; flex: 0 0 auto; margin-right: .4rem; vertical-align: middle; }
.label-toggle input { width: 1.1rem; height: 1.1rem; min-height: 0; margin: 0; }
#place-dialog { width: min(96vw, 720px); }
.place { display: flex; flex-direction: column; gap: .5rem; }
.place h2 { margin: 0; }
.plan-view.readonly .pin { pointer-events: none; }
.plan-view.readonly .plan-figure img { max-height: 68vh; pointer-events: none; }
#item-show-place { flex: 0 0 auto; }
#item-show-place:disabled { opacity: .45; }
#place-dialog img { width: auto; max-width: 100%; max-height: 68vh; object-fit: fill; border-radius: 0; background: none; }

/* ---------------------------------------------------------------- tables and usage */
.bar { height: 8px; border-radius: 999px; background: var(--surface2); overflow: hidden; margin: .4rem 0; }
.bar > div { height: 100%; background: var(--red); }
.bar.mint > div { background: var(--mint); }
.bar.warn > div { background: var(--amber); }
.bar.over > div { background: var(--red); }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
td, th { text-align: left; padding: .3rem .4rem .3rem 0; border-bottom: 1px solid var(--line-soft); }
td.num, th.num { text-align: right; }
.token-guide td { padding: .25rem .4rem .25rem 0; vertical-align: top; }
.token-guide td:last-child { white-space: nowrap; font-weight: 700; }

/* ---------------------------------------------------------------- dialogs: bottom sheets */
dialog {
  position: fixed; inset: auto 0 0 0; margin: 0 auto;
  width: 100%; max-width: 560px; max-height: 92vh;
  padding: 0 0 env(safe-area-inset-bottom);
  border: 1px solid var(--line); border-bottom: 0;
  border-radius: 16px 16px 0 0;
  background: var(--card); color: var(--ink);
  overflow-y: auto;
}
dialog[open] { animation: sheet-in .22s ease-out; }
@keyframes sheet-in { from { transform: translateY(18px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { dialog[open] { animation: none; } }
dialog::backdrop { background: rgba(7, 18, 25, .5); }
dialog > form, dialog > .place, dialog > .note-popup, dialog > .sheet {
  display: flex; flex-direction: column; gap: .6rem; padding: 1rem 1rem 1.2rem;
}
dialog > form::before, dialog > .place::before, dialog > .note-popup::before, dialog > .sheet::before {
  content: ""; display: block; width: 38px; height: 4px; margin: -.35rem auto .3rem;
  border-radius: 999px; background: var(--line); flex: none;
}
dialog h2 { font-size: 1.2rem; }
dialog img { width: 100%; max-height: 220px; object-fit: contain; border-radius: 8px; background: var(--surface2); }
dialog .row.end { flex-wrap: wrap; }
#new-dialog .sheet { gap: .5rem; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.sheet-head .icon-button.round { background: var(--surface2); color: var(--ink); }
#new-dialog .tile.action { flex-direction: row; justify-content: flex-start; gap: .7rem; width: 100%; }
#gallery-dialog { width: min(96vw, 960px); }
#note-dialog { width: min(96vw, 520px); }
.note-popup h2 { margin: 0; }
.note-body { white-space: pre-wrap; line-height: 1.45; }
.note-sources { display: flex; flex-wrap: wrap; gap: .4rem .8rem; font-size: .82rem; }
.note-sources a { color: var(--red); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; max-height: 70vh; overflow-y: auto; }
.gallery a { display: flex; flex-direction: column; gap: .2rem; color: var(--ink-3); font-size: .8rem; text-decoration: none; }
#gallery-dialog .gallery img { width: 100%; max-height: none; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }
.gallery .tile { display: flex; flex-direction: column; gap: .2rem; font-size: .75rem; color: var(--ink-3); min-width: 0; }
.gallery .tile .line { display: flex; justify-content: space-between; gap: .3rem; align-items: center; }
.gallery .tile .line span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery .tile .link { font-size: .75rem; padding: 0; }
.gallery .tile video, .gallery .tile audio { width: 100%; }

/* paused: only the logbook, read only (print and exports stay) */
body.readonly nav button:not([data-tab="log"]), body.readonly #settings-open,
body.readonly #log-start, body.readonly #log-controls, body.readonly #log-close,
body.readonly #log-delete, body.readonly #log-levels, body.readonly #log-fix, body.readonly #log-end,
body.readonly .actions-tiles, body.readonly #log-note-form, body.readonly #log-table .del { display: none !important; }
body.readonly #log-table tr { cursor: default; }

/* ---------------------------------------------------------------- toast */
#toast {
  position: fixed; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex; align-items: center; gap: .8rem;
  background: var(--toast-bg); color: var(--toast-ink);
  padding: .55rem .9rem; border-radius: 8px;
  width: max-content; max-width: min(92vw, 36rem);
  z-index: 60;
}
#toast-action { color: var(--toast-action); font-weight: 700; padding: 0; }
body[data-screen="home"] #toast, body[data-screen="chat"] #toast, body[data-screen="log"] #toast,
body[data-screen="barca"] #toast, body[data-screen="galley"] #toast { bottom: calc(88px + env(safe-area-inset-bottom)); }

/* ---------------------------------------------------------------- logbook */
#tab-log { max-width: 560px; }
.log-hero .card-head h3 { color: #fff; font-size: 1.02rem; }
.log-hero .card-head .pill { color: #fff; }
.log-hero .metrics { margin-top: .15rem; }
.log-hero .muted { font-size: .82rem; line-height: 1.35; }
.log-status { margin: .2rem 0 .4rem; font-size: .88rem; }
.log-status.ok { color: var(--ok); }
.log-status.warn { color: var(--amber); }
.instruments { margin-top: .3rem; }
.instruments summary { cursor: pointer; color: var(--red); }
.exports { margin-top: .4rem; gap: 1rem; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: .6rem 0; }
.logtable { font-size: .8rem; white-space: nowrap; }
.logtable th { position: sticky; top: 0; background: var(--surface2); padding: .35rem .5rem; }
.logtable td { padding: .3rem .5rem; vertical-align: top; }
.logtable td.text { white-space: nowrap; width: 16rem; max-width: 16rem; }
.logtable td.text .brief { display: inline-block; max-width: 9.8rem; overflow: hidden; vertical-align: bottom; }
.logtable .more-note { color: var(--red); background: none; border: none; padding: .15rem .45rem; font-weight: 700;
  font-size: 1rem; line-height: 1; cursor: pointer; min-width: 1.9rem; min-height: 0; }
.logtable tr.event td { background: var(--warn-bg); }
.logtable .media a { margin-right: .3rem; }
.logtable .del { color: var(--ink-3); padding: 0 .2rem; }
.logtable tr.note td { background: var(--note-bg); }
.logtable tr.note td.text { font-style: italic; }
.logtable tr { cursor: pointer; }
.logtable .sources a { font-style: normal; font-size: .75rem; margin-right: .4rem; }
.voyages li { cursor: pointer; flex-direction: column; align-items: flex-start; gap: .1rem; }
.voyages li .meta { color: var(--ink-3); font-size: .82rem; }
.log-map { height: 380px; border-radius: var(--radius); border: 1px solid var(--line); margin: .8rem 0; }
.log-narrative { background: var(--surface2); border-left: 3px solid var(--red); border-radius: 6px; padding: .6rem .8rem; margin: .5rem 0 .7rem; }
.log-narrative h3 { margin: 0 0 .4rem; font-size: .95rem; }
.log-narrative p { margin: 0 0 .5rem; font-size: .9rem; line-height: 1.45; }
.log-narrative p:last-child { margin-bottom: 0; }
.log-narrative strong { color: var(--red); }
#log-watch:empty, #log-sun:empty { display: none; }
.today-card { margin-top: .6rem; }
ul.rows > li.day-entry { display: grid; grid-template-columns: 3.1rem minmax(0, 1fr); gap: .5rem; align-items: start; padding: .55rem 0; }
.day-entry time { font-family: var(--font-display); font-weight: 700; font-size: .9rem; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.day-entry .row-main strong { font-size: .9rem; }
.day-entry .agent-tag { display: inline-flex; align-items: center; gap: .2rem; margin-top: .15rem; color: var(--red);
  font-size: .72rem; font-weight: 700; }
.action-aside { color: var(--ink-3); font-size: .75rem; }

/* ---------------------------------------------------------------- works and equipment */
.stats-year { margin-bottom: .8rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .5rem; margin: .5rem 0; }
.tile-num { background: var(--surface2); border-radius: 8px; padding: .5rem .6rem; }
.tile-num strong { display: block; font-family: var(--font-display); font-size: 1.5rem; }
.tile-num span { color: var(--ink-3); font-size: .8rem; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; margin: 1.5rem 0 .2rem; }
.bars .bar-col { flex: 1; height: 100%; display: flex; align-items: flex-end; position: relative; cursor: pointer; }
.bars .bar-col:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; border-radius: 3px; }
.bars .bar-fill { width: 100%; background: var(--red); border-radius: 3px 3px 0 0; min-height: 1px; }
.bars .bar-col.on .bar-fill { background: var(--sea-500); }
.bars .bar-value { position: absolute; left: 50%; transform: translateX(-50%); display: none; padding: .05rem .3rem;
  border-radius: 4px; background: var(--surface2); color: var(--ink); font-size: .68rem; white-space: nowrap;
  border: 1px solid var(--line); z-index: 2; }
.bars .bar-col.on .bar-value { display: block; }
.bars-labels { display: flex; gap: 4px; font-size: .7rem; color: var(--ink-3); }
.bars-labels span { flex: 1; text-align: center; }
.due li { align-items: center; }
.due .badge { font-size: .72rem; padding: .1rem .5rem; border-radius: 999px; color: #fff; flex: 0 0 auto; }
.due .overdue { background: var(--red); } .due .soon { background: var(--amber); color: #3c2600; }
.due .ok { background: #14795a; } .due .unknown { background: #7d8f9c; }
.due .what { flex: 1; display: flex; flex-direction: column; }
.due .what span { color: var(--ink-3); font-size: .82rem; }
#equipment-card summary { cursor: pointer; }
#equipment .what { display: flex; flex-direction: column; flex: 1; }
.equipment-row .what { display: flex; flex-direction: column; gap: .2rem; }
.equipment-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .3rem; align-items: center; }
.equipment-actions button:not(.link) { padding: .4rem .7rem; min-height: 36px; }
.works li { flex-direction: column; align-items: stretch; gap: .15rem; padding: .6rem 0; }
.works .head { display: flex; justify-content: space-between; gap: .5rem; font-weight: 700; }
.works .meta { color: var(--ink-3); font-size: .82rem; }
.works .line { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.work-photos { display: flex; gap: .3rem; flex-wrap: wrap; cursor: pointer; margin-top: .3rem; align-items: center; }
.work-photos img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.work-photos .more { font-size: .85rem; color: var(--red); font-weight: 700; padding: 0 .3rem; }

/* ---------------------------------------------------------------- galley */
.galley-actions { align-items: stretch; }
.galley li { align-items: center; gap: .55rem; }
.galley .what { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.galley .what span { color: var(--ink-3); font-size: .8rem; }
.galley .keeping { font-style: italic; }
.galley .badge { font-size: .7rem; padding: .1rem .5rem; border-radius: 999px; color: #fff; flex: 0 0 auto; }
.galley .scaduto { background: var(--red); } .galley .subito { background: var(--amber); color: #3c2600; }
.galley .presto { background: #b59a00; } .galley .ok { background: #14795a; } .galley .senza-data { background: #7d8f9c; }
.galley-buttons { display: flex; flex-direction: column; align-items: flex-end; gap: .15rem; }
.galley-buttons button { min-height: 30px; padding: .2rem .5rem; font-size: .76rem; }
button.row-main { border: 0; background: none; padding: 0; min-height: 0; text-align: left; cursor: pointer; }
button.row-main:hover em, button.row-main:hover strong { color: var(--red); }
.shopping li { align-items: center; gap: .55rem; }
.shopping .check { flex: 1; min-width: 0; color: var(--ink); font-size: .92rem; }
.shopping input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--sea-900); }
.shopping .buying { color: var(--ink-3); }
.shopping .buying .check { color: var(--ink-3); text-decoration: line-through; }
.shopping button { min-height: 32px; padding: .2rem .55rem; font-size: .76rem; }
#galley-manual summary { cursor: pointer; }

/* ---------------------------------------------------------------- voice */
#voice-button .stop-icon { display: none; }
#voice-button.recording { background: var(--red); border-color: var(--red); color: #fff; }
#voice-button.recording .mic-icon { display: none; }
#voice-button.recording .stop-icon { display: block; }
#voice-button.busy { opacity: .6; pointer-events: none; }
#chat-form.recording #chat-text { display: none; }
.voice-status { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: .5rem; font-variant-numeric: tabular-nums; }
.voice-status::before { content: ""; width: .7rem; height: .7rem; border-radius: 50%; background: var(--red); animation: voice-blink 1s infinite; }
.voice-status.working::before { background: var(--red); }
@keyframes voice-blink { 50% { opacity: .2; } }
.voice-cancel { flex: 0 0 auto; padding: .55rem .7rem; }
#telegram-code { margin: .6rem 0; }
#telegram-code .code { font: 600 1.3rem/1.2 ui-monospace, monospace; letter-spacing: .05em; user-select: all; }
#telegram-code a.button { display: inline-block; text-decoration: none; }
#telegram-code p { margin: .4rem 0; }
#telegram-links li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }

.live { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; gap: .8rem;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
  background: var(--sea-900); color: #fff; }
.live[hidden] { display: none; }
.live-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; background: none; padding: 0; }
.live-clock { font-variant-numeric: tabular-nums; opacity: .85; }
.live-center { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; min-height: 12rem; }
.live-orb { --level: 0; width: 11rem; height: 11rem; border-radius: 50%; display: grid; place-items: center; text-align: center;
  font-size: 1.2rem; font-weight: 700; background: var(--sea-700);
  box-shadow: 0 0 0 calc(var(--level) * 1.6rem) rgba(120, 190, 235, .25); transition: background .3s, box-shadow .08s; }
.live-orb[data-status="listening"] { background: var(--sea-500); }
.live-orb[data-status="thinking"], .live-orb[data-status="checking"] { background: #8a6d1f; animation: live-pulse 1.4s infinite; }
.live-orb[data-status="speaking"] { background: #2c8a5a; }
.live-orb[data-status="closed"] { background: #555; }
@keyframes live-pulse { 50% { opacity: .65; } }
.live-hint { opacity: .8; text-align: center; max-width: 22rem; }
.live-lines { list-style: none; margin: 0; padding: 0; max-height: 30vh; overflow-y: auto; display: flex; flex-direction: column; gap: .4rem; }
.live-lines li { padding: .45rem .7rem; border-radius: .6rem; background: rgba(255, 255, 255, .08); line-height: 1.35; display: block; border: 0; }
.live-lines li.user { align-self: flex-end; background: rgba(120, 190, 235, .22); }
.live-lines li.partial { opacity: .75; }
.live-lines li:empty::before { content: '…'; }
.live-error { color: #ffb4a8; }
.live-controls { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.live-controls .button { min-height: 3.2rem; font-size: 1rem; background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .25); }
.live-controls .button[aria-pressed="true"] { background: var(--red); border-color: var(--red); }
.live-controls .danger-fill { background: var(--red); border-color: var(--red); }
.live-tool { padding: .45rem .8rem; border-radius: .6rem; background: rgba(255, 210, 120, .14); color: #ffe2a8; text-align: center; max-width: 24rem; }
.live-tool.done { background: rgba(120, 220, 160, .14); color: #bff0cf; }
.live-tool.failed { background: rgba(255, 140, 120, .16); color: #ffc4b8; }

/* ---------------------------------------------------------------- subscription and settings */
.paused-screen { align-items: center; justify-content: center; padding: 1rem; background: var(--sea-900); }
.paused-screen .card { max-width: 26rem; text-align: center; }
.paused-screen .primary { width: 100%; padding: .9rem; font-size: 1rem; margin: .5rem 0; }
.paused-screen .button { width: 100%; }
.billing-status { font-weight: 700; }
.billing-status.warn { color: var(--red); }
.token-bar { display: flex; height: .55rem; border-radius: 999px; overflow: hidden; background: var(--surface2); margin: .4rem 0; }
.token-bar .month { background: var(--red); }
.token-bar .topup { background: #14795a; }
.billing-actions { display: flex; flex-direction: column; gap: .5rem; margin-top: .75rem; }
label.waiver { flex-direction: row; gap: .5rem; align-items: flex-start; font-size: .82rem; }
label.waiver input { width: auto; min-height: 0; margin-top: .15rem; flex: none; }
.billing-actions button { white-space: normal; text-align: center; }

.settings-menu { list-style: none; padding: 0; overflow: hidden; gap: 0; }
.settings-groups { display: flex; flex-direction: column; gap: .2rem; }
.settings-groups > .section-label { margin: .9rem .1rem .35rem; }
.settings-groups > .section-label:first-child { margin-top: .3rem; }
.settings-menu li { border-top: 1px solid var(--line-soft); }
.settings-menu li:first-child { border-top: 0; }
.settings-menu button {
  width: 100%; display: flex; align-items: center; gap: .6rem;
  min-height: 52px; padding: .55rem .1rem;
  background: none; border: 0; border-radius: 0; text-align: left; color: var(--ink);
}
.settings-menu .chevron { width: 16px; height: 16px; color: var(--ink-3); flex: none; }
.settings-menu .row-main strong { font-size: .92rem; }
#settings-menu[hidden] { display: none; }
.sub-card { gap: .5rem; }
.sub-card .card-head h3 { font-size: .95rem; }
.sub-tokens { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.sub-card .muted { color: var(--on-dark); font-size: .8rem; }
.sub-card .bar { background: rgba(255, 255, 255, .16); }

.settings-head { display: flex; }
#tab-boat [data-pane] > h2 { display: none; }
.copy-url { display: flex; gap: .4rem; align-items: center; }
.copy-url code { flex: 1; overflow-wrap: anywhere; background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: .35rem .5rem; font-size: .82rem; }
#apps-list li { align-items: center; }
#apps-list li span small { display: block; color: var(--ink-3); }

/* ---------------------------------------------------------------- splash and login */
.hero { display: flex; flex-direction: column; align-items: center; gap: .45rem; text-align: center; color: var(--ink); }
.hero .art { width: 120px; height: 120px; color: var(--sea-900); }
.hero .kicker { margin: 0; font-size: .7rem; letter-spacing: .16em; text-transform: uppercase; color: var(--red); font-weight: 700; }
.hero h1 { margin: 0; font-size: 1.9rem; line-height: 1.02; font-weight: 700; letter-spacing: -.02em; }
.hero .tagline { margin: .2rem 0 0; max-width: 20rem; color: var(--ink-3); font-size: .95rem; line-height: 1.45; }
#splash { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1.5rem; background: var(--sea-900); transition: opacity .35s ease; }
#splash.gone { opacity: 0; pointer-events: none; }
#splash .hero, #splash .hero h1 { color: #fff; }
#splash .hero .art { color: #fff; }
#splash .hero .kicker { color: var(--red-on-dark); }
#splash .tagline { color: var(--on-dark); }
.splash-bar { width: 140px; height: 3px; border-radius: 2px; background: var(--line-dark); overflow: hidden; }
.splash-bar::after { content: ""; display: block; width: 40%; height: 100%; background: var(--red-on-dark); animation: splash-run 1.1s ease-in-out infinite; }
@keyframes splash-run { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }
@media (prefers-reduced-motion: reduce) { .splash-bar::after { animation: none; } #splash { transition: none; } }
.dial-sweep { transform-origin: 60px 60px; animation: dial 6s ease-in-out infinite alternate; }
@keyframes dial { from { transform: rotate(-12deg); } to { transform: rotate(12deg); } }
@media (prefers-reduced-motion: reduce) { .dial-sweep { animation: none; } }
#login { justify-content: flex-start; gap: 1.2rem; padding: max(2rem, env(safe-area-inset-top)) 1rem 1.2rem; }
#login .hero .art { width: 110px; height: 110px; }
#login .lang-pick { width: min(100%, 360px); flex: none; }
#login-form { gap: .8rem; width: 100%; max-width: 360px; }
#login-form .primary { min-height: 50px; font-size: 1rem; }
#login-form .oauth { display: flex; align-items: center; justify-content: center; gap: .55rem; min-height: 48px; font-size: 1rem; font-weight: 600; }
#login-form .oauth svg { width: 20px; height: 20px; flex: none; }
#login-form .login-or { display: flex; align-items: center; gap: .6rem; margin: 0; font-size: .76rem; color: var(--ink-3); }
#login-form .login-or::before, #login-form .login-or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.legal { margin: auto 0 0; font-size: .75rem; color: var(--ink-3); text-align: center; }
.legal a { color: inherit; }
.narrow { width: min(100%, 360px); }

/* ---------------------------------------------------------------- Impostazioni › Aspetto */
.themes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.theme-option { display: flex; flex-direction: column; gap: .35rem; padding: .5rem; border: 2px solid var(--line); border-radius: var(--radius);
  cursor: pointer; color: var(--ink); font-size: .85rem; }
.theme-option:has(input:checked) { border-color: var(--red); }
.theme-option input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.theme-option:focus-within { outline: 2px solid var(--red); outline-offset: 2px; }
.theme-option strong { font-size: .9rem; font-family: var(--font-display); }
.swatch { height: 70px; border-radius: 7px; display: flex; flex-direction: column; justify-content: space-between; padding: .45rem; }
.swatch.chiaro { background: #f2f5f3; border: 1px solid rgba(13, 29, 38, .14); }
.swatch.notte { background: #071219; border: 1px solid rgba(255, 255, 255, .16); }
.swatch .bar1 { height: 14px; border-radius: 3px; }
.swatch.chiaro .bar1 { background: #fff; border-left: 4px solid #e63946; }
.swatch.notte .bar1 { background: #0c2029; border-left: 4px solid #ff5a66; }
.swatch .dots { display: flex; gap: 4px; }
.swatch .dots span { width: 14px; height: 14px; border-radius: 7px; }

/* ---------------------------------------------------------------- boat sheet gathered online */
#dossier h3 { font-family: var(--font-display); font-size: 1rem; margin: 1rem 0 .3rem; color: var(--red); }
.dossier-summary { margin: .2rem 0; font-size: 1rem; }
.dossier-fields { display: grid; grid-template-columns: minmax(7rem, 38%) 1fr; gap: .35rem .8rem; margin: 0; }
.dossier-fields dt { color: var(--ink-3); font-size: .86rem; }
.dossier-fields dd { margin: 0; font-weight: 600; }
.dossier-fields dd small { display: block; font-weight: 400; color: var(--ink-3); }
.refs { font-size: .75rem; white-space: nowrap; }
.refs a { margin-right: .15rem; text-decoration: none; }
.dossier-list, .dossier-sources { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: .3rem; }
.dossier-sources { font-size: .85rem; color: var(--ink-3); }

/* ---------------------------------------------------------------- install hint on iPhone */
#ios-install {
  position: fixed; z-index: 70; left: 10px; right: 10px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 88px);
  display: grid; grid-template-columns: 44px 1fr 28px; gap: 12px; align-items: start;
  padding: 14px 12px 14px 14px; border-radius: 14px;
  background: var(--card); color: var(--ink); border: 1px solid var(--red);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
  transform: translateY(16px); opacity: 0; transition: transform .3s ease, opacity .3s ease;
  max-width: 520px; margin: 0 auto;
}
body:not(:has(#app:not([hidden]))) #ios-install { bottom: calc(env(safe-area-inset-bottom, 0px) + 14px); }
#ios-install.in { transform: none; opacity: 1; }
#ios-install.gone { transform: translateY(16px); opacity: 0; }
#ios-install img { width: 44px; height: 44px; border-radius: 10px; }
#ios-install strong { display: block; font-family: var(--font-display); font-size: 1rem; margin-bottom: .2rem; }
#ios-install p { margin: 0 0 .35rem; font-size: .9rem; line-height: 1.35; color: var(--ink-3); }
#ios-install p.how { color: var(--ink); font-weight: 700; }
#ios-install p.more { font-size: .78rem; margin: 0; }
#ios-install .share { display: inline-flex; vertical-align: -3px; color: var(--red); }
#ios-install .close { background: none; border: 0; color: var(--ink-3); font-size: 1.6rem; line-height: 1; padding: 0; width: 28px; height: 28px; min-height: 0; cursor: pointer; }
@media (prefers-reduced-motion: reduce) { #ios-install { transition: none; } }

/* ---------------------------------------------------------------- public pages */
body.doc { overflow-y: auto; height: auto; }
main.doc { max-width: 760px; margin: 0 auto; padding: 1rem 1.2rem 3rem; line-height: 1.5; }
main.doc section { border-top: 1px solid var(--line); margin-top: 1.5rem; padding-top: .5rem; }
main.doc h1 { font-size: 1.5rem; } main.doc h2 { font-size: 1.1rem; margin-top: 1.2rem; }
main.doc code { background: var(--card); border: 1px solid var(--line); border-radius: 4px; padding: .1rem .3rem; }
main.connect { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
main.connect .narrow { width: min(100%, 420px); }
main.connect .ask { font-size: 1.05rem; margin-bottom: .3rem; }
main.connect .scopes { margin: 0 0 .6rem; padding-left: 1.2rem; }
main.connect .scopes li { margin: .3rem 0; }
main.connect .row { justify-content: flex-end; margin: .8rem 0 .4rem; }
.langs { font-size: .9rem; }

/* ---------------------------------------------------------------- narrow phones */
@media (max-width: 380px) {
  section { padding: .75rem .7rem 1.2rem; }
  .home-grid .tile { min-height: 108px; }
  .two-up .btn { padding-left: .4rem; padding-right: .4rem; font-size: .84rem; }
  .metric strong { font-size: 24px; }
  nav button { font-size: .62rem; }
}
@media (max-width: 520px) {
  #location-form { flex-wrap: wrap; }
  #location-form > * { flex: 1 1 100%; }
  #chat-form { gap: .4rem; }
  #tab-items .row > #search { flex: 1 1 100%; }
  #tab-items .row > label.button, #tab-items .row > button { flex: 1 1 0; padding-left: .4rem; padding-right: .4rem; }
  #tab-galley .row { flex-wrap: wrap; }
  #tab-galley .row > label { flex: 1 1 45%; min-width: 0; }
  #tab-galley .row > label:first-child { flex: 1 1 100%; }
}
@media (min-width: 900px) {
  body { background: color-mix(in srgb, var(--bg) 82%, var(--sea-900)); }
  #app { background: var(--bg); box-shadow: 0 0 0 1px var(--line); }
}

/* ---------------------------------------------------------------- weather */
.weather-pill {
  background: rgba(255, 255, 255, .08);
  border-color: var(--red-on-dark);
  color: var(--on-dark-strong);
  font-family: var(--font-body);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.weather-pill:active { background: rgba(255, 255, 255, .16); }

.weather-sheet .sheet-titles { min-width: 0; }
.weather-sheet h2 { margin: 0; }
#weather-sub { font-size: .8rem; margin: .1rem 0 0; }

.weather-label {
  margin: 0; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: var(--on-dark);
}
.wind-top { display: flex; align-items: center; gap: .8rem; }
.wind-dial {
  display: grid; place-items: center; width: 56px; height: 56px; flex: none;
  border-radius: 50%; background: #fff; color: var(--sea-900);
}
.wind-arrow { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; transition: transform .3s ease; }
.wind-dial .wind-arrow { color: #14865f; }
.wind-read { display: flex; flex-direction: column; min-width: 0; }
.wind-read strong {
  font-family: var(--font-display); font-weight: 700; font-size: 28px; line-height: 1.05;
  font-variant-numeric: tabular-nums; color: #fff;
}
.wind-read span { font-size: .8rem; color: var(--on-dark); }
.wind-gusts { margin: 0; color: var(--red-on-dark); font-weight: 700; font-size: .82rem; }
.wind-card { gap: .55rem; }
.weather-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; }
.weather-grid .metric { background: rgba(255, 255, 255, .07); }
.weather-grid .metric strong { font-size: 22px; }
.weather-grid .metric em { white-space: nowrap; }

.weather-cols { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: .2rem; }
.weather-col { display: flex; flex-direction: column; align-items: center; gap: .2rem;
  padding: .35rem .1rem; border-radius: 6px; min-width: 0; }
.weather-col span { font-size: .7rem; color: var(--ink-3); }
.weather-col strong { font-family: var(--font-display); font-size: .82rem; font-weight: 700;
  font-variant-numeric: tabular-nums; }
.weather-col .wind-arrow { width: 15px; height: 15px; color: var(--sea-500); }
.weather-col.soon strong { color: #8a5600; }
.weather-col.strong-wind strong { color: var(--red-deep); }
.weather-col.soon .wind-arrow { color: var(--amber); }
.weather-col.strong-wind .wind-arrow { color: var(--red); }
:root[data-theme="notte"] .weather-col.soon strong { color: var(--amber); }
:root[data-theme="notte"] .weather-col.strong-wind strong { color: var(--red-on-dark); }

.weather-warning {
  margin: 0; padding: .5rem .7rem; border-radius: 8px; font-size: .82rem; line-height: 1.35;
  background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink);
}
.weather-error {
  margin: 0; padding: .6rem .7rem; border-radius: 8px; font-size: .88rem; line-height: 1.35;
  background: var(--chip-red); color: var(--red-deep);
}
:root[data-theme="notte"] .weather-error { color: var(--red-on-dark); }
.weather-note { margin: 0; font-size: .72rem; line-height: 1.35; color: var(--ink-3); }
.weather-source { margin: 0; font-size: .7rem; color: var(--ink-3); }

.daily-day { display: flex; align-items: center; gap: .5rem; flex: 0 0 auto; min-width: 4.4rem; }
.daily-day .wind-arrow { width: 16px; height: 16px; color: var(--sea-500); }
.daily-day strong { font-size: .84rem; }
.daily-day span { display: block; font-size: .72rem; color: var(--ink-3); }

@media (max-width: 380px) {
  .weather-cols { gap: .1rem; }
  .weather-col strong { font-size: .76rem; }
  .wind-read strong { font-size: 25px; }
}
:root[data-theme="notte"] .wind-card { border-color: var(--line); }
.weather-sheet { padding: .85rem .85rem 1rem; gap: .5rem; }
.wind-card { padding: .8rem; gap: .45rem; }
.weather-grid .metric { padding: .45rem .6rem; }
.weather-grid .metric strong { font-size: 20px; }
.weather-col { padding: .25rem .1rem; gap: .15rem; }
.weather-unit { font-size: .72rem; color: var(--ink-3); flex: none; margin-right: .2rem; }
/* the chip is small like the mockup; the finger gets 44px anyway */
.weather-pill { position: relative; }
.weather-pill::after { content: ""; position: absolute; inset: -8px -5px; border-radius: 999px; }
/* the photo sheet: two full-width choices, like the "+" sheet */
#media-dialog .tile.action { flex-direction: row; justify-content: flex-start; gap: .7rem; width: 100%; }
#media-dialog .tile.action .icon-chip { margin-bottom: 0; }
