/* WingLog — wet-finger, gloved-hand UI. Big targets, high contrast, dark. */
:root {
  --navy: #0c243c;
  --navy-2: #14304e;
  --navy-3: #1d3e63;
  --gold: #d4a028;
  --gold-dim: #a87d1c;
  --orca: #3fa9d6;
  --teal: #2bb39a;
  --alert: #e0613a;
  --ink: #eef3f8;
  --ink-dim: #9fb2c6;
  --line: #24405f;
  --ok: #34c77b;
  --warn: #f0b429;
  --tap: 64px;            /* minimum tap target */
  --radius: 16px;
  font-size: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--navy);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-user-select: none; user-select: none;
  overscroll-behavior: none;
}

#app { display: flex; flex-direction: column; min-height: 100dvh; }

/* ---- Header (vessel + captain context) ---- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 16px 12px;
  background: var(--navy-2); border-bottom: 1px solid var(--line);
}
.topbar .brand { font-weight: 800; letter-spacing: .5px; color: var(--ink); }
.topbar .brand b { color: var(--gold); }
.topbar .context { margin-left: auto; text-align: right; line-height: 1.2; }
.topbar .context .vessel { font-weight: 700; }
.topbar .context .captain { font-size: .8rem; color: var(--ink-dim); }
.topbar .context button {
  background: none; border: none; color: var(--orca); font-size: .8rem;
  padding: 4px 0 0; cursor: pointer;
}
.topbar .context button.end-log {
  margin-top: 4px; color: var(--alert); border: 1px solid var(--alert);
  border-radius: 999px; padding: 6px 14px; font-weight: 700;
}

/* ---- Start screen (front page) ---- */
.start-screen {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 18px; padding: 24px;
  text-align: center;
}
.start-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.start-logo { width: 168px; height: 168px; border-radius: 32px; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.start-tag { color: var(--ink-dim); font-size: 1rem; letter-spacing: .3px; }
.start-date { color: var(--ink); font-size: 1.1rem; font-weight: 600; margin-top: 4px; }
.start-btn {
  width: 100%; max-width: 420px; min-height: 84px; border-radius: 20px;
  background: var(--gold); color: var(--navy); border: none; cursor: pointer;
  font-size: 1.6rem; font-weight: 800; margin-top: 8px;
}
.start-btn:active { transform: scale(.98); }
.start-hint { color: var(--ink-dim); font-size: .85rem; }

/* ---- Main ---- */
main { flex: 1; padding: 16px; }

/* Home 2x2 tile grid */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; height: 100%; }
.tile {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 8px; min-height: 38dvh; border-radius: var(--radius);
  background: var(--navy-2); border: 2px solid var(--line);
  color: var(--ink); font-size: 1.5rem; font-weight: 800; cursor: pointer;
  transition: transform .05s ease;
}
.tile:active { transform: scale(.97); }
.tile .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent, var(--gold)); }
.tile .sub { font-size: .8rem; font-weight: 500; color: var(--ink-dim); }
.tile[data-accent] { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }

/* ---- Footer (sync + counter) ---- */
.footer {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  background: var(--navy-2); border-top: 1px solid var(--line); font-size: .9rem;
}
.footer .status { display: flex; align-items: center; gap: 8px; }
.footer .status .dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.green { background: var(--ok); }
.dot.amber { background: var(--warn); }
.footer .count {
  margin-left: auto; color: var(--ink); background: var(--navy-3);
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px;
  font-size: .9rem; font-weight: 600; cursor: pointer;
}
.footer .count:active { transform: scale(.97); }

/* ---- Daily log list ---- */
.log-list { display: flex; flex-direction: column; gap: 10px; }
.log-row {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px;
  background: var(--navy-2); border: 1px solid var(--line); border-radius: var(--radius);
}
.log-time { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); min-width: 48px; }
.log-main { flex: 1; min-width: 0; }
.log-cat { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.log-cat .tag {
  font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .5px;
  color: var(--navy); background: var(--accent, var(--gold)); padding: 2px 8px; border-radius: 999px;
}
.log-summary { font-weight: 600; }
.log-pos { font-size: .82rem; color: var(--ink-dim); margin-top: 4px; }
.log-pos.stale { color: var(--warn); }
.log-pos.nofix { color: var(--ink-dim); font-style: italic; }
.log-pos .acc { opacity: .7; }
.log-row > .dot { margin-top: 6px; flex: none; }

/* toast: allow longer position strings */
.toast { max-width: 92vw; }

/* ---- Flow screen ---- */
.flow-head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 8px;
}
.flow-head .back {
  width: var(--tap); height: var(--tap); border-radius: var(--radius);
  background: var(--navy-2); border: 1px solid var(--line); color: var(--ink);
  font-size: 1.6rem; cursor: pointer;
}
.flow-head h1 { font-size: 1.5rem; margin: 0; }
.flow-head .accent { width: 16px; height: 16px; border-radius: 50%; background: var(--accent, var(--gold)); }

.row { margin: 14px 0; }
.row > .row-label { font-size: .85rem; color: var(--ink-dim); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .5px; }
.row > .row-label .req { color: var(--alert); }

/* chip + grid options */
.opts { display: flex; flex-wrap: wrap; gap: 10px; }
.opts.grid { display: grid; grid-template-columns: repeat(3, 1fr); }
.opt {
  min-height: var(--tap); padding: 12px 16px; border-radius: var(--radius);
  background: var(--navy-2); border: 2px solid var(--line); color: var(--ink);
  font-size: 1.05rem; font-weight: 600; cursor: pointer; text-align: center;
  display: flex; align-items: center; justify-content: center;
}
.opts.grid .opt { font-size: 1.15rem; }
.opt:active { transform: scale(.97); }
.opt.sel { background: var(--accent, var(--gold)); border-color: var(--accent, var(--gold)); color: var(--navy); }

textarea, input[type="text"], input[type="search"] {
  width: 100%; min-height: var(--tap); padding: 14px; border-radius: var(--radius);
  background: var(--navy-2); border: 2px solid var(--line); color: var(--ink);
  font-size: 1.1rem; font-family: inherit; -webkit-user-select: text; user-select: text;
}
textarea { min-height: 96px; resize: vertical; }

.note-tools { display: flex; gap: 10px; margin-top: 10px; }
.note-tools button, .photo-btn {
  min-height: var(--tap); padding: 12px 16px; border-radius: var(--radius);
  background: var(--navy-2); border: 2px solid var(--line); color: var(--ink);
  font-size: 1rem; font-weight: 600; cursor: pointer; display: inline-flex;
  align-items: center; gap: 8px;
}
.note-tools button.recording { border-color: var(--alert); color: var(--alert); }
.photo-btn img { height: 40px; border-radius: 8px; }

/* submit */
.submit-bar { position: sticky; bottom: 0; padding: 16px 0 max(16px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--navy) 30%); }
.submit {
  width: 100%; min-height: 72px; border-radius: var(--radius);
  background: var(--gold); color: var(--navy); border: none;
  font-size: 1.3rem; font-weight: 800; cursor: pointer;
}
.submit:disabled { background: var(--navy-3); color: var(--ink-dim); }
.submit:active:not(:disabled) { transform: scale(.99); }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px);
  background: var(--ok); color: #04261a; padding: 16px 28px; border-radius: 999px;
  font-size: 1.25rem; font-weight: 800; opacity: 0; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* picker modal (vessel/captain) */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4,12,22,.7); display: flex;
  align-items: flex-end; z-index: 40;
}
.modal {
  width: 100%; background: var(--navy-2); border-top-left-radius: 24px;
  border-top-right-radius: 24px; padding: 20px 16px max(20px, env(safe-area-inset-bottom));
}
.modal h2 { margin: 4px 0 12px; font-size: 1.2rem; }
.modal .opts { flex-direction: column; }
.modal .opt { justify-content: flex-start; }
