:root {
  --ink: #12222e;
  --muted: #5b6b78;
  --line: #d6dde3;
  --bg: #f4f6f8;
  --card: #ffffff;
  --sea: #0f3b57;
  --accent: #0b6fa4;
  --danger: #b3261e;
  --radius: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden; /* la pagina non scorre: scorrono l'elenco e i moduli */
}

h1 { font-size: 1.4rem; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); font-size: .9rem; }
.error { color: var(--danger); min-height: 1.2em; margin: .25rem 0 0; }

/* L'intestazione e le schede restano ferme: questo contenitore è alto quanto
   lo schermo e ogni scheda scorre per conto suo. */
.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; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.narrow { width: min(100%, 360px); }

label { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--muted); flex: 1; }
input, textarea, select {
  font: inherit;
  color: var(--ink);
  padding: .55rem .65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  width: 100%;
}
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

button, .button {
  font: inherit;
  padding: .55rem .9rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
}
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.link { border: none; background: none; color: var(--accent); padding: .3rem; }
.danger { color: var(--danger); }
button:disabled { opacity: .55; cursor: default; }

header {
  background: var(--sea);
  color: #fff;
  padding: .7rem 1rem;
  padding-top: calc(.7rem + env(safe-area-inset-top));
  display: flex;
  justify-content: space-between;
  align-items: center;
}
header .muted { color: #b8cedb; margin-left: .5rem; }
header .link { color: #fff; }

nav { display: flex; background: var(--card); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
nav button {
  flex: 1 0 auto;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: none;
  padding: .7rem .2rem;
  color: var(--muted);
}
nav button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
section {
  flex: 1;
  padding: 1rem;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.row { display: flex; gap: .5rem; align-items: flex-end; }
.row.end { justify-content: flex-end; }
.row > input, .row > select { flex: 1; }

/* Chat: scorre solo la lista dei messaggi, la casella resta in basso. */
#tab-chat { display: flex; flex-direction: column; padding-bottom: 0; overflow: hidden; }
#messages { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: .5rem; padding-bottom: .75rem; }
.msg { max-width: 85%; padding: .55rem .75rem; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; flex: 0 0 auto; }
.msg.user { align-self: flex-end; background: var(--accent); 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(--muted); font-style: italic; }
.msg.failed { align-self: center; color: var(--danger); background: none; font-size: .9rem; }
.found { align-self: flex-start; display: flex; gap: .5rem; flex-wrap: wrap; max-width: 100%; flex: 0 0 auto; }
#chat-form {
  display: flex;
  gap: .5rem;
  padding: .6rem 0 calc(.6rem + env(safe-area-inset-bottom));
  align-items: flex-end;
}
#chat-send {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
#chat-text { resize: none; max-height: 200px; flex: 1 1 0; min-width: 0; width: auto; }
#chat-text::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chat-attach { flex: 0 0 auto; display: flex; align-items: center; padding: .55rem; color: var(--accent); }
#chat-hint { text-align: right; padding-right: .2rem; }
#tab-chat.dropping { outline: 2px dashed var(--accent); outline-offset: -6px; background: #eaf3f8; }
.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(--muted); }
.msg .files { display: block; margin-top: .25rem; font-size: .85rem; opacity: .85; }

/* 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;
}
.item img, .item .nophoto { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #e6ebef; }
.item .body { padding: .5rem .6rem; display: flex; flex-direction: column; gap: .1rem; }
.item .name { font-weight: 600; }
.item .where { color: var(--accent); font-size: .85rem; }
.item .aka { color: var(--muted); font-size: .8rem; }
.found .item { width: 150px; }

/* Locations */
.tree, .plain { list-style: none; margin: .75rem 0 0; padding: 0; }
.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(--muted); font-size: .85rem; }
.plain li { display: flex; justify-content: space-between; gap: .5rem; padding: .3rem 0; border-bottom: 1px solid var(--line); }

/* Usage */
.bar { height: 10px; border-radius: 5px; background: #e6ebef; overflow: hidden; margin: .4rem 0; }
.bar > div { height: 100%; background: var(--accent); }
.bar.warn > div { background: #c77700; }
.bar.over > div { background: var(--danger); }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
td, th { text-align: left; padding: .25rem .4rem .25rem 0; border-bottom: 1px solid var(--line); }
td.num, th.num { text-align: right; }

dialog { border: none; border-radius: var(--radius); padding: 1rem; width: min(96vw, 480px); max-height: 92vh; }
dialog::backdrop { background: rgba(10, 25, 35, .5); }
dialog form { display: flex; flex-direction: column; gap: .55rem; }
dialog img { width: 100%; max-height: 220px; object-fit: contain; border-radius: 8px; background: #e6ebef; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: .55rem .9rem;
  border-radius: 8px;
  max-width: 90vw;
  z-index: 10;
}

@media (max-width: 520px) {
  #location-form { flex-wrap: wrap; }
  #location-form > * { flex: 1 1 100%; }
  #chat-form { gap: .4rem; }
  #chat-form .primary { padding: .55rem .7rem; }
  section { padding: .75rem; }
}

/* Lavori */
.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: 600; }
.works .meta { color: var(--muted); font-size: .85rem; }
.works .line { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
label.check { flex-direction: row; align-items: center; gap: .5rem; }
label.check input { width: auto; }
#tab-items .row, #tab-work .row { flex-wrap: wrap; }

/* Plans */
.row.wrap { flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.chip.tab { cursor: pointer; padding: .3rem .8rem; font-size: .9rem; }
.chip.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.plan-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 320px); gap: .8rem; margin-top: .6rem; align-items: start; }
#tab-locations { max-width: 1100px; }
@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(--accent); outline-offset: 3px; }
.pin {
  position: absolute; transform: translate(-50%, -50%);
  min-width: 26px; height: 26px; padding: 0 .35rem; border-radius: 13px;
  background: var(--accent); color: #fff; border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.35); font-size: .75rem; line-height: 22px; font-weight: 600;
  white-space: nowrap; cursor: pointer;
}
.pin.dim { background: #7d8f9c; }
.pin.hit { background: var(--danger); min-width: 30px; height: 30px; line-height: 26px; z-index: 2; animation: pulse 1.4s ease-in-out infinite; }
.pin.selected { background: #c77700; z-index: 3; }
.pin.new { background: #c77700; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(179, 38, 30, .2); } }
.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(--accent); }
.side li.done { color: var(--muted); }
.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; }
.found-plans { display: flex; gap: .6rem; flex-wrap: wrap; flex: 0 0 auto; align-self: flex-start; }
.found-plans .plan-figure img { max-height: 300px; }
.found-plans figure { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .4rem; text-align: center; }
.found-plans figcaption { font-size: .8rem; color: var(--muted); line-height: 1.3; margin-top: .3rem; }
#items-plans { margin-top: .6rem; }
#location-list { margin-top: .8rem; }
#location-list summary { cursor: pointer; font-weight: 600; }
.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: #fff6e6; border: 1px solid #f0c27a; border-radius: 8px; line-height: 1.3; }
.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.effects { margin: 0 0 .4rem; padding-left: 1.2rem; }
.effects li { margin: .2rem 0; }
#toast { display: flex; align-items: center; gap: .8rem; }
#toast-action { color: #9fd3ff; font-weight: 700; padding: 0; }
.pin.dot { min-width: 16px; width: 16px; height: 16px; padding: 0; border-radius: 8px; font-size: 0; line-height: 0; }
.pin.dot:hover, .pin.dot:focus-visible { transform: translate(-50%, -50%) scale(1.3); }
.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; margin: 0; }
.tree .go { color: var(--accent); cursor: pointer; text-decoration: underline dotted; }
#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; }
.go-green { background: #1f8a4c; border-color: #1f8a4c; color: #fff; }
.go-green:hover:not(:disabled) { background: #187040; border-color: #187040; }
.go-green:disabled { background: #e6ebef; border-color: var(--line); color: var(--muted); opacity: 1; }
.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(--accent); font-weight: 600; padding: 0 .3rem; }
#gallery-dialog { width: min(96vw, 960px); }
.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(--muted); 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(--muted); 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; }

/* Logbook */
#tab-log { max-width: 1200px; }
.grow { flex: 1; margin: 0; }
.log-status { margin: .3rem 0 .6rem; font-size: .9rem; }
.log-status.ok { color: #1f6b3d; }
.log-status.warn { color: #9a5b00; }
.chips.quick { margin: .6rem 0; }
.chips.quick button { border-radius: 999px; padding: .3rem .8rem; font-size: .85rem; }
.instruments { margin-top: .6rem; }
.instruments summary { cursor: pointer; color: var(--accent); }
.exports { margin-top: .4rem; gap: 1rem; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: .8rem 0; }
.logtable { font-size: .82rem; white-space: nowrap; }
.logtable th { position: sticky; top: 0; background: #eef2f5; padding: .35rem .5rem; }
.logtable td { padding: .3rem .5rem; vertical-align: top; }
.logtable td.text { white-space: normal; min-width: 220px; }
.logtable tr.event td { background: #fbf7ee; }
.logtable .media a { margin-right: .3rem; }
.logtable .del { color: var(--muted); padding: 0 .2rem; }
.voyages li { cursor: pointer; flex-direction: column; align-items: flex-start; }
.voyages li .meta { color: var(--muted); font-size: .85rem; }
.section-title { font-size: 1.05rem; margin: 1rem 0 .3rem; }
.gallery .tile video, .gallery .tile audio { width: 100%; }
.space-row { margin-top: .6rem; }
.log-map { height: 380px; border-radius: var(--radius); border: 1px solid var(--line); margin: .8rem 0; }
.logtable tr.note td { background: #eef6f1; }
.logtable tr.note td.text { font-style: italic; }
.logtable tr { cursor: pointer; }
.logtable .sources a { font-style: normal; font-size: .75rem; margin-right: .4rem; }
.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: #f4f7f9; border-radius: 8px; padding: .5rem .6rem; }
.tile-num strong { display: block; font-size: 1.25rem; }
.tile-num span { color: var(--muted); font-size: .8rem; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; margin: .4rem 0 .2rem; }
.bars div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 1px; position: relative; }
.bars-labels { display: flex; gap: 4px; font-size: .7rem; color: var(--muted); }
.bars-labels span { flex: 1; text-align: center; }
#log-watch:empty, #log-sun:empty { display: none; }
.due li { align-items: center; }
.due .badge { font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; color: #fff; flex: 0 0 auto; }
.due .overdue { background: var(--danger); } .due .soon { background: #c77700; } .due .ok { background: #1f8a4c; } .due .unknown { background: #7d8f9c; }
.due .what { flex: 1; display: flex; flex-direction: column; }
.due .what span { color: var(--muted); font-size: .85rem; }
#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: .45rem .8rem; }

.galley-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.galley li { align-items: flex-start; gap: .5rem; }
.galley .what { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.galley .what span { color: var(--muted); font-size: .85rem; }
.galley .keeping { font-style: italic; }
.galley .badge { font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; color: #fff; flex: 0 0 auto; margin-top: .15rem; }
.galley .scaduto { background: var(--danger); } .galley .subito { background: #c77700; } .galley .presto { background: #b59a00; }
.galley .ok { background: #1f8a4c; } .galley .senza-data { background: #7d8f9c; }
.galley-buttons { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; }
#shopping li { align-items: center; }
#shopping .what { flex: 1; }

/* ---------------------------------------------------------------- voice */
#voice-button { flex: 0 0 auto; display: flex; align-items: center; padding: .55rem; color: var(--accent); }
#voice-button .stop-icon { display: none; }
#voice-button.recording { background: #c0392b; border-color: #c0392b; 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: #c0392b; animation: voice-blink 1s infinite; }
.voice-status.working::before { background: var(--accent); }
@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[hidden] { display: none; }
#telegram-links li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }

/* ---------------------------------------------------------------- live voice (hands-free) */
#live-button { flex: 0 0 auto; display: flex; align-items: center; padding: .55rem; color: var(--accent); }
.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: #0e2a3d; color: #f2f6f9; }
.live[hidden] { display: none; }
.live-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; }
.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.25rem; font-weight: 600; background: #1b4a69;
  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: #1f6f9e; }
.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 { margin: 0; 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; }
.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 { margin: 0; color: #ffb4a8; }
.live-controls { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.live-controls .button { min-height: 3.2rem; font-size: 1.05rem; background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .25); }
.live-controls .button[aria-pressed="true"] { background: #c0392b; border-color: #c0392b; }
.live-controls .danger-fill { background: #c0392b; border-color: #c0392b; }
.live-tool { margin: 0; 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 */
.paused-screen { align-items: center; justify-content: center; padding: 1rem; background: var(--sea); }
.paused-screen .card { max-width: 26rem; text-align: center; }
.paused-screen .primary { width: 100%; padding: .9rem; font-size: 1.05rem; margin: .5rem 0; }
.billing-status { font-weight: 600; }
.billing-status.warn { color: var(--danger); }
.token-bar { display: flex; height: .7rem; border-radius: 999px; overflow: hidden; background: var(--line); margin: .4rem 0; }
.token-bar .month { background: var(--accent); }
.token-bar .topup { background: #2e8b57; }
.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: .85rem; }
label.waiver input { width: auto; margin-top: .15rem; flex: none; }
.billing-actions button { white-space: normal; text-align: center; }

/* paused: only the logbook, read only (export and print stay) */
.paused-screen .button { width: 100%; }
.readonly-bar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem .9rem;
  background: #fff4d6; border-bottom: 1px solid #e8d49a; font-size: .9rem; }
body.readonly nav button:not([data-tab="log"]),
body.readonly #log-start, body.readonly #log-controls, body.readonly #log-close,
body.readonly #log-delete, body.readonly #log-table .del { display: none !important; }
body.readonly #log-table tr { cursor: default; }

/* ---------------------------------------------------------------- settings */
.header-actions { display: flex; align-items: center; gap: .6rem; }
.icon-button { background: none; border: none; color: #fff; padding: .25rem; display: grid; place-items: center; }
.icon-button.active { color: #9fd3f5; }
.settings-head { display: flex; flex-direction: column; gap: .2rem; margin: .2rem 0 .6rem; }
.settings-head .link { align-self: flex-start; padding: 0; }
.settings-head h2 { margin: 0; }
.settings-menu { list-style: none; padding: 0; overflow: hidden; }
.settings-menu li + li { border-top: 1px solid var(--line); }
.settings-menu button { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: .1rem;
  background: none; border: none; border-radius: 0; padding: .75rem 1rem; text-align: left; color: var(--ink); }
.settings-menu button::after { content: '›'; position: absolute; right: 1.2rem; color: var(--muted); font-size: 1.3rem; }
.settings-menu li { position: relative; }
.settings-menu span { color: var(--muted); font-size: .85rem; }
.token-guide td { padding: .25rem .4rem .25rem 0; vertical-align: top; }
.token-guide td:last-child { white-space: nowrap; font-weight: 600; }
body.readonly #settings-open { display: none; }
/* the pane title already names the card: no second heading */
#billing-card > h2, #boat-form > h2, #agent-form > h2,
#tab-boat [data-pane="telegram"] > h2, #tab-boat [data-pane="manuals"] > h2, #tab-boat [data-pane="memory"] > h2 { display: none; }
nav button { padding-left: .55rem; padding-right: .55rem; }

/* connector: consent screen (connect.html) and «App collegate» */
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; }
#tab-boat [data-pane="apps"] > h2 { display: none; }
#apps-list li { align-items: center; }
#apps-list li span small { display: block; color: var(--muted); }
.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: .85rem; }
/* public pages: connector guide, privacy, terms */
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; }
.langs { font-size: .9rem; }
