/* Handwriting font for the Divemaster signature on the printable dive log. */
@font-face{
  font-family:'Juliette';
  font-style:normal;
  font-weight:400;
  font-display:swap;
  src:url('/static/fonts/juliette.woff') format('woff');
}
:root{
  --bg0:#04101a; --bg1:#06141f; --ink:#e9f6ff; --mut:#8fb0c4;
  --teal:#5eead4; --sky:#38bdf8; --card:rgba(13,30,44,.62);
  --line:rgba(123,176,200,.18); --err:#fb7185; --ok:#34d399;
  --radius:20px; --shadow:0 24px 60px -20px rgba(0,0,0,.65);
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0; color:var(--ink); font:16px/1.55 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  background:radial-gradient(1200px 800px at 80% -10%,#0b2436 0,transparent 60%),
             radial-gradient(900px 700px at -10% 110%,#072b30 0,transparent 55%),
             linear-gradient(160deg,var(--bg1),var(--bg0));
  background-attachment:fixed;
  background-repeat:no-repeat;
  overflow-x:hidden;
}

/* Themed scrollbars — slim, rounded, teal→sky thumb on a faint track, to match
   the rest of the deep-ocean UI instead of the default OS bar. */
*{scrollbar-width:thin; scrollbar-color:rgba(94,234,212,.55) transparent}
::-webkit-scrollbar{width:10px;height:10px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{
  background:linear-gradient(180deg,var(--teal),var(--sky));
  border-radius:999px;
  border:2px solid transparent;
  background-clip:padding-box;
}
::-webkit-scrollbar-thumb:hover{
  background:linear-gradient(180deg,#7df3e0,#5cc9fb);
  background-clip:padding-box;
}
::-webkit-scrollbar-corner{background:transparent}

/* ambient glow + rising bubbles */
.glow{position:fixed;inset:0;pointer-events:none;z-index:0;
  background:radial-gradient(600px 300px at 50% 0%,rgba(56,189,248,.10),transparent 70%)}
.bubbles{position:fixed;inset:0;z-index:0;pointer-events:none;overflow:hidden}
.bubbles::before,.bubbles::after{
  content:"";position:absolute;left:0;right:0;bottom:-60px;height:160%;
  background-image:
    radial-gradient(3px 3px at 12% 90%,rgba(94,234,212,.5),transparent),
    radial-gradient(2px 2px at 28% 70%,rgba(56,189,248,.5),transparent),
    radial-gradient(4px 4px at 46% 85%,rgba(255,255,255,.25),transparent),
    radial-gradient(2px 2px at 64% 60%,rgba(94,234,212,.45),transparent),
    radial-gradient(3px 3px at 82% 80%,rgba(56,189,248,.4),transparent),
    radial-gradient(2px 2px at 92% 50%,rgba(255,255,255,.2),transparent);
  background-repeat:repeat-y;background-size:100% 700px;
  animation:rise 22s linear infinite;opacity:.7}
.bubbles::after{animation-duration:34s;opacity:.4;background-size:100% 900px}
@keyframes rise{from{transform:translateY(0)}to{transform:translateY(-700px)}}

.stage{position:relative;z-index:1;min-height:100%;
  display:grid;grid-template-columns:1.1fr .9fr;gap:48px;align-items:center;
  max-width:1100px;margin:0 auto;padding:64px 28px 48px;min-width:0}

/* hero */
.logo{display:flex;align-items:center;gap:12px;margin-bottom:22px}
.brand{font-size:24px;font-weight:600;letter-spacing:.3px}
.brand b{font-weight:800;background:linear-gradient(90deg,var(--teal),var(--sky));
  -webkit-background-clip:text;background-clip:text;color:transparent}
.hero h1{font-size:clamp(34px,5vw,56px);line-height:1.05;margin:.1em 0 .35em;
  font-weight:800;letter-spacing:-.02em}
.lede{color:var(--mut);max-width:46ch;font-size:17px}
.lede.sm{font-size:15px;margin:.4em 0 1.4em}
.feats{list-style:none;padding:0;margin:28px 0 0;display:flex;flex-direction:column;gap:12px}
.feats li{display:flex;align-items:center;gap:12px;color:#cfe6f2;font-size:15px}
.feats span{display:grid;place-items:center;width:34px;height:34px;border-radius:11px;
  background:rgba(94,234,212,.10);border:1px solid var(--line)}

/* glass card */
.card{position:relative;background:var(--card);backdrop-filter:blur(18px) saturate(120%);
  -webkit-backdrop-filter:blur(18px) saturate(120%);
  border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);
  padding:30px 28px;min-height:340px;display:flex;flex-direction:column;justify-content:center;min-width:0}

.tabs{display:flex;gap:6px;background:rgba(0,0,0,.25);border:1px solid var(--line);
  border-radius:13px;padding:5px;margin-bottom:22px}
.tab{flex:1;border:0;background:transparent;color:var(--mut);font:inherit;font-weight:600;
  padding:10px;border-radius:9px;cursor:pointer;transition:.18s}
.tab.on{background:linear-gradient(90deg,rgba(94,234,212,.22),rgba(56,189,248,.22));
  color:var(--ink);box-shadow:inset 0 0 0 1px var(--line)}

.field{display:block;margin-bottom:16px}
.field span{display:block;font-size:13px;color:var(--mut);margin-bottom:7px;font-weight:600}
.field input{width:100%;padding:13px 14px;border-radius:12px;color:var(--ink);
  background:rgba(0,0,0,.28);border:1px solid var(--line);font:inherit;transition:.18s}
.field input::placeholder{color:#5b7c8e}
.field input:focus{outline:0;border-color:var(--sky);
  box-shadow:0 0 0 3px rgba(56,189,248,.18)}
.hint{margin:-6px 0 14px;font-size:12.5px;color:var(--mut)}

.primary{position:relative;width:100%;border:0;cursor:pointer;font:inherit;font-weight:700;
  color:#04212a;padding:14px;border-radius:13px;
  background:linear-gradient(90deg,var(--teal),var(--sky));
  box-shadow:0 12px 30px -10px rgba(56,189,248,.6);transition:.18s}
.primary:hover{filter:brightness(1.06);transform:translateY(-1px)}
.primary:active{transform:translateY(0)}
.primary:disabled{opacity:.7;cursor:default;transform:none}
/* aria-disabled keeps title tooltips working (native :disabled suppresses them) */
.primary[aria-disabled="true"]{opacity:.45;cursor:not-allowed;box-shadow:none}
.primary[aria-disabled="true"]:hover{filter:none;transform:none}

.ghost{width:100%;border:1px solid var(--line);background:rgba(255,255,255,.04);
  color:var(--ink);font:inherit;font-weight:600;padding:13px;border-radius:13px;cursor:pointer;transition:.18s}
.ghost:hover{background:rgba(255,255,255,.08)}
/* aria-disabled keeps title tooltips working (native :disabled suppresses them) */
.ghost[aria-disabled="true"]{opacity:.45;cursor:not-allowed}
.ghost[aria-disabled="true"]:hover{background:rgba(255,255,255,.04)}

.spinner{position:absolute;top:50%;left:50%;width:18px;height:18px;margin:-9px 0 0 -9px;
  border:2px solid rgba(4,33,42,.4);border-top-color:#04212a;border-radius:50%;
  animation:spin .7s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

.msg{min-height:20px;margin:14px 0 0;font-size:14px;text-align:center}
.msg.err{color:var(--err)} .msg.ok{color:var(--ok)}

/* logged-in */
.badge{display:inline-flex;align-items:center;gap:6px;align-self:flex-start;
  font-size:13px;font-weight:700;color:var(--ok);
  background:rgba(52,211,153,.12);border:1px solid rgba(52,211,153,.3);
  padding:6px 12px;border-radius:999px;margin-bottom:18px}
button.badge{font-family:inherit;font-size:13px;font-weight:700;cursor:pointer;outline:none}
.welcome{font-size:26px;font-weight:800;line-height:1.1;margin:.15em 0 0;letter-spacing:-.01em}
.welcome span{background:linear-gradient(90deg,var(--teal),var(--sky));
  -webkit-background-clip:text;background-clip:text;color:transparent}

/* dashboard: hide marketing hero, single centered column */
body.authed .hero{display:none}
/* Home page matches the dive-log page width (was 640px). */
body.authed .stage{grid-template-columns:1fr;max-width:780px}
/* Brand bar: mask logo + "Smart Dive" — top-left on desktop, centered on mobile. */
.brand-bar{display:flex;align-items:center;gap:10px;margin:0 0 36px}
.brand-bar .mask-logo{width:40px;height:40px;flex-shrink:0;filter:drop-shadow(0 0 6px rgba(56,189,248,.35))}
.brand-bar .brand{font-size:22px}
.home-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px}
.home-head .badge{margin-bottom:8px}
.ghost.sm{width:auto;padding:9px 14px;font-size:14px}

.panel{margin-top:18px;padding:16px;border:1px solid var(--line);border-radius:14px;background:rgba(0,0,0,.18)}
.panel-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:10px}
.panel-head h3{margin:0;font-size:15px;font-weight:700;letter-spacing:.2px}
.muted{color:var(--mut);font-size:14px;margin:0}
.muted.sm{font-size:12.5px;margin-top:8px}
.mini{border:1px solid var(--line);background:rgba(255,255,255,.05);color:var(--ink);
  font:inherit;font-size:13px;font-weight:600;padding:7px 12px;border-radius:9px;cursor:pointer;transition:.15s}
.mini:hover{background:rgba(94,234,212,.14);border-color:var(--teal)}

.token-box{display:flex;align-items:center;gap:8px;margin-top:10px;
  background:rgba(0,0,0,.35);border:1px solid var(--line);border-radius:10px;padding:8px 10px}
.token-box code{flex:1;font-size:12.5px;color:var(--teal);word-break:break-all}

.dives{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:8px;max-height:375px;overflow:auto}
.dives .empty{padding:6px 2px}
.dive{position:relative;overflow:hidden;display:flex;align-items:center;gap:10px;
  padding:16px 14px;border-radius:11px;
  background:rgba(255,255,255,.035);border:1px solid var(--line);
  transition:border-color .15s ease}
.dive .d-bg{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;z-index:0}
.dive .d-bg-overlay{position:absolute;inset:0;z-index:0;background:rgba(6,20,31,.72);
  transition:background .15s ease}
.dive:hover{border-color:#fff}
.dive:hover .d-bg-overlay{background:rgba(6,20,31,.48)}
@media (min-width: 821px) {
  .dives {
    max-height: 468px;
  }
  .dive .d-bg-overlay {
    background: linear-gradient(to right, rgba(4, 14, 22, 0.88) 0%, rgba(6, 20, 31, 0.72) 60%, rgba(6, 20, 31, 0.72) 100%);
  }
  .dive:hover .d-bg-overlay {
    background: linear-gradient(to right, rgba(4, 14, 22, 0.62) 0%, rgba(6, 20, 31, 0.48) 60%, rgba(6, 20, 31, 0.48) 100%);
  }
}
.dive .d-main{position:relative;z-index:1;flex:1;min-width:0}
.dive-rating-bar{position:relative;z-index:1;width:4px;height:38px;border-radius:2px;background:rgba(255,255,255,.08);display:flex;flex-direction:column;justify-content:flex-end;overflow:hidden;flex-shrink:0}
.dive-rating-fill{width:100%;border-radius:2px;background:linear-gradient(0deg,var(--teal),var(--sky))}
.dive .d-when{font-size:14px;font-weight:600;transition:color .15s ease,text-shadow .15s ease}
.dive .d-sub{font-size:12.5px;color:var(--mut);margin-top:2px}
.dive .d-del{border:0;background:transparent;color:var(--mut);font-size:18px;cursor:pointer;
  line-height:1;padding:4px 6px;border-radius:8px}
.dive .d-del:hover{color:var(--err);background:rgba(251,113,133,.12)}
.dot{width:9px;height:9px;border-radius:50%;flex:0 0 auto}
.dot.on{background:var(--ok);box-shadow:0 0 6px var(--ok)}
.dot.off{background:#64748b}
.dot.crash{background:var(--err);box-shadow:0 0 6px var(--err)}

footer{position:relative;z-index:1;text-align:center;color:#5b7c8e;font-size:11px;padding:10px 0 20px;opacity:0.7}
footer a{color:inherit;text-decoration:none;border-bottom:1px dotted rgba(91,124,142,0.6)}
footer a:hover{color:var(--teal)}
.legal-card{max-width:760px}
.legal-body{color:var(--ink);font-size:14px;line-height:1.7;margin-top:18px}
.legal-body h2{font-size:16px;color:var(--teal);margin:22px 0 6px}
.legal-body p{margin:0 0 12px;color:#c7dbe6}
.legal-body a{color:var(--sky);text-decoration:none}
.legal-body a:hover{text-decoration:underline}

/* Dive-passport stamp — floats top-right of the hero banner (see .dive-banner
   below) at all breakpoints, so it reads consistently over any photo:
   forced white via filter (brightness(0) turns every opaque pixel black,
   invert(1) flips that to white, alpha untouched) at 95% opacity — "white,
   just a touch transparent" — rather than editing the stamp SVGs themselves. */
.stamp-slot{position:absolute;top:16px;right:20px;z-index:2;display:flex;align-items:flex-start}
.stamp-img-btn{background:none;border:0;padding:0;cursor:pointer;line-height:0;transition:transform .15s}
.stamp-img-btn:hover{transform:rotate(-4deg) scale(1.04)}
.stamp-img-btn img{width:96px;height:96px;display:block;opacity:.95;
  filter:brightness(0) invert(1) drop-shadow(0 4px 10px rgba(0,0,0,0.35))}
.stamp-modal{position:fixed;inset:0;z-index:1000;display:flex;align-items:center;justify-content:center;background:rgba(3,12,20,0.72);backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px);padding:20px}
.stamp-modal[hidden]{display:none}
.stamp-modal-card{width:min(560px,100%);max-height:88vh;overflow:auto;background:rgba(8,24,36,0.98);border:1px solid var(--line);border-radius:18px;padding:22px;box-shadow:0 24px 64px rgba(0,0,0,0.6)}
.stamp-modal-head{display:flex;align-items:center;justify-content:space-between;gap:10px}
.stamp-modal-head h3{margin:0;font-size:18px}
.stamp-modal-x{background:none;border:0;color:var(--mut);font-size:26px;line-height:1;cursor:pointer;padding:0 4px}
.stamp-modal-x:hover{color:var(--ink)}
.stamp-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:14px}
.stamp-choice{background:rgba(0,0,0,0.25);border:2px solid var(--line);border-radius:14px;padding:8px;cursor:pointer;transition:border-color .15s,transform .15s,background .15s}
.stamp-choice:hover{border-color:var(--teal);transform:translateY(-2px);background:rgba(94,234,212,0.08)}
.stamp-choice.selected{border-color:var(--teal);background:rgba(94,234,212,0.12)}
.stamp-choice img{width:100%;height:auto;display:block}
.stamp-modal-foot{display:flex;justify-content:flex-end;margin-top:16px}
@media(max-width:520px){
  .stamp-grid{grid-template-columns:repeat(2,1fr)}
  .stage, body.authed .stage, body.dive-page .stage{padding:30px 12px 60px}
  .card{padding:22px 14px}
  .panel-head{flex-direction:column;align-items:flex-start;gap:8px}
  .panel-head > div{width:100%;justify-content:flex-start;flex-wrap:wrap}
  #dive-map-toolbar{justify-content:space-between}
  .map-btn-row{justify-content:space-between;width:100%}
  .home-head{flex-direction:column;align-items:flex-start;gap:16px}
  .stat-grid{grid-template-columns:repeat(auto-fit, minmax(110px, 1fr))}
  .edit-grid{grid-template-columns:1fr}
  
  .back-badge {
    top: 24px;
    left: 14px;
  }
  /* #stamp-slot (parent) is already absolute at every breakpoint now — only
     resize the icon here, don't re-position (its own top/right would offset
     against the parent's box, not the card, and double up). */
  .stamp-slot {
    top: 12px;
    right: 14px;
  }
  .dive-card .stamp-img-btn img {
    width: 60px;
    height: 60px;
  }
}

/* ── Dive detail page ─────────────────────────────────────────────────────── */
body.dive-page .stage{grid-template-columns:1fr;max-width:780px;justify-items:stretch}
.dive-card{justify-content:flex-start;min-height:auto}
.back-badge{text-decoration:none;cursor:pointer}
.back-badge:hover{background:rgba(52,211,153,.22);border-color:rgba(52,211,153,.5)}

/* Dive-log hero banner: the diver's featured photo (or a Wikipedia-sourced
   fallback for the dive's location) shown behind the brand bar + header, with
   a left-side dark gradient so the back button/title/date stay legible.
   Sits inside the card's own padding box (no bleed) so it needs no
   per-breakpoint offset math; brand-bar/home-head are lifted above it. */
.dive-banner{position:absolute;top:0;left:0;right:0;height:230px;
  border-radius:16px;background-size:cover;background-position:center;
  z-index:0;overflow:hidden}
.dive-banner::after{content:'';position:absolute;inset:0;
  background:linear-gradient(90deg,rgba(4,16,26,.95) 0%,rgba(4,16,26,.68) 40%,rgba(4,16,26,.22) 75%,rgba(4,16,26,0) 100%)}
.dive-card .brand-bar,.dive-card .home-head{position:relative;z-index:1}
@media(max-width:520px){
  .dive-banner{height:190px}
}

.stat-grid{display:grid;grid-template-columns:repeat(auto-fit, minmax(120px, 1fr));grid-auto-rows:1fr;gap:10px;margin:18px 0 0}
/* Gas/Air/Initial-air editable cells always share one full-width row of 4. */
.stat-gas-row{grid-column:1 / -1;display:grid;grid-template-columns:repeat(4,1fr);gap:10px}
/* Read-only stats: one full-width row, split into equal columns (--cols set inline). */
.stat-readonly-row{grid-column:1 / -1;display:grid;grid-template-columns:repeat(var(--cols,4),1fr);gap:10px}
@media (max-width:820px){
  .stat-readonly-row{grid-template-columns:repeat(2,1fr)}
}
.stat-cell{background:rgba(0,0,0,.25);border:1px solid var(--line);border-radius:10px;padding:10px 14px;
  display:flex;flex-direction:column;justify-content:center}
.stat-label{font-size:11px;color:var(--mut);font-weight:700;text-transform:uppercase;letter-spacing:.5px;margin-bottom:4px}
.stat-value{font-size:16px;font-weight:700}
.stat-cell.deco{border-color:rgba(239,68,68,.55);background:rgba(239,68,68,.10)}
.stat-cell.deco .stat-label{color:#f87171}
.stat-cell.deco .stat-value{color:#f87171}

/* Editable stat cells with lock/unlock */
.stat-editable .stat-label{display:flex;align-items:center;justify-content:space-between;gap:4px}
.stat-lock{background:none;border:none;padding:1px 2px;cursor:pointer;font-size:11px;
  line-height:1;color:var(--mut);transition:color .15s,transform .15s;flex-shrink:0}
.stat-lock:hover{color:var(--teal);transform:scale(1.2)}
.stat-lock:disabled{opacity:.45;cursor:default;transform:none}
.stat-editor{display:flex;align-items:center;gap:6px;flex-wrap:nowrap}
.stat-editor select,.stat-editor input[type="number"]{
  background:rgba(56,189,248,.08);border:1px solid var(--sky);color:var(--ink);
  font:inherit;font-size:16px;font-weight:700;border-radius:8px;padding:6px 9px;
  min-width:0;flex:1;outline:none;box-shadow:0 0 0 3px rgba(56,189,248,.18)}
.stat-editor select{-webkit-appearance:none;appearance:none;padding-right:26px;cursor:pointer;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23e9f6ff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat:no-repeat;background-position:right 8px center}
.stat-editor select:focus,.stat-editor input:focus{border-color:var(--sky);box-shadow:0 0 0 3px rgba(56,189,248,.28)}
.stat-save{display:inline-flex;align-items:center;justify-content:center;
  border:0;color:#04212a;cursor:pointer;flex-shrink:0;
  padding:7px 10px;border-radius:9px;
  background:linear-gradient(90deg,var(--teal),var(--sky));
  box-shadow:0 6px 16px -6px rgba(56,189,248,.6);transition:.18s}
.stat-save:hover{filter:brightness(1.06);transform:translateY(-1px)}
.stat-save:active{transform:translateY(0)}
.stat-save:disabled{opacity:.6;cursor:default;transform:none}
.stat-save svg{display:block}

/* On-brand number stepper: hide native spinners, add themed chevron buttons */
.num-wrap{position:relative;display:flex;flex:1;min-width:0}
.num-wrap > input[type="number"]{-moz-appearance:textfield;width:100%;padding-right:48px}
.num-wrap > input[type="number"]::-webkit-outer-spin-button,
.num-wrap > input[type="number"]::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}
/* Centre the content-sized group with translateY(-50%): exact, and avoids the
   percentage-height (calc(100%)) that Safari mis-resolves on an auto-height
   flex parent. top:% resolves reliably, unlike height:%. */
.num-steps{position:absolute;right:5px;top:50%;transform:translateY(-50%);
  width:36px;display:flex;flex-direction:column;gap:4px}
.num-step{width:100%;flex:0 0 auto;height:18px;display:flex;align-items:center;justify-content:center;padding:0;cursor:pointer;
  color:var(--mut);background:rgba(94,234,212,.10);border:1px solid var(--line);border-radius:6px;
  transition:.15s}
.num-step:hover{color:var(--teal);border-color:var(--teal);background:rgba(94,234,212,.22)}
.num-step:active{transform:scale(.92)}
.num-step svg{display:block;width:14px;height:14px}

/* Lead / Suit: number stepper on desktop, native <select> on mobile (≤820px).
   Both controls stay in sync (see dive.js) so saving works in either mode. */
.field-sel{display:none;width:100%;padding:13px 38px 13px 14px;border-radius:12px;color:var(--ink);
  background:rgba(0,0,0,.28);border:1px solid var(--line);font:inherit;font-size:16px;cursor:pointer;
  -webkit-appearance:none;appearance:none;transition:.18s;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23e9f6ff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat:no-repeat;background-position:right 12px center}
.field-sel:focus{outline:0;border-color:var(--sky);box-shadow:0 0 0 3px rgba(56,189,248,.18)}
/* Always-visible variant (not a mobile-only mirror) — e.g. Visibility. */
.field-sel.always{display:block}
@media (max-width:820px){
  .field-stepper{display:none !important}
  .field-sel{display:block}
  /* CSV export is a desktop convenience — hide it on phones. */
  #dl-btn{display:none}
}

/* Read-only field value (e.g. computed Light/lux) — looks like a muted input. */
.field-readout{width:100%;padding:13px 14px;border-radius:12px;color:var(--ink);
  background:rgba(0,0,0,.18);border:1px dashed var(--line);font:inherit;font-size:15px;
  min-height:48px;display:flex;align-items:center;gap:8px}
.field-readout .ro-sub{color:var(--mut);font-size:12.5px;font-weight:600}
/* Small inline "refresh" button next to a field label. */
.field-refresh{display:inline-flex;align-items:center;justify-content:center;vertical-align:middle;
  margin-left:4px;padding:2px;border:0;background:none;color:var(--mut);cursor:pointer;
  border-radius:6px;transition:color .15s,transform .4s}
.field-refresh:hover{color:var(--teal)}
.field-refresh.spinning{animation:spin .8s linear infinite}

/* Panel text input — matches the .field text boxes used elsewhere */
.panel-input{width:100%;flex:1;min-width:0;padding:11px 14px;border-radius:12px;color:var(--ink);
  background:rgba(0,0,0,.28);border:1px solid var(--line);font:inherit;font-size:14px;transition:.18s}
.panel-input::placeholder{color:#5b7c8e}
.panel-input:focus{outline:0;border-color:var(--sky);box-shadow:0 0 0 3px rgba(56,189,248,.18)}

/* Custom buddy combo box — a fully-styled autocomplete replacing native <datalist> */
.combo{position:relative}
.combo > input{width:100%;padding-right:38px}
.combo-toggle{position:absolute;right:6px;top:50%;transform:translateY(-50%);
  display:flex;align-items:center;justify-content:center;width:26px;height:26px;padding:0;
  background:none;border:0;color:var(--mut);cursor:pointer;transition:color .15s}
.combo-toggle:hover{color:var(--teal)}
.combo-toggle svg{display:block;width:16px;height:16px}
.combo-menu{position:absolute;z-index:60;left:0;right:0;top:calc(100% + 6px);margin:0;padding:6px;
  list-style:none;max-height:230px;overflow-y:auto;text-align:left;
  background:rgba(6,20,31,.98);border:1px solid var(--line);border-radius:12px;
  box-shadow:0 16px 36px rgba(0,0,0,.55)}
.combo-menu li{display:flex;flex-direction:column;gap:1px;padding:9px 12px;border-radius:8px;
  cursor:pointer;color:var(--ink);font:inherit;font-size:15px;font-weight:600;line-height:1.3;text-align:left}
.combo-menu li small{font-size:12px;font-weight:500;color:var(--mut)}
.combo-menu li:hover,.combo-menu li.active{background:rgba(56,189,248,.16)}
.combo-menu li.empty{cursor:default;color:var(--mut);font-size:13px;font-weight:500}
.combo-menu li.empty:hover{background:none}
.combo-menu li:active{background:rgba(56,189,248,.26)}

/* Mobile: bigger touch targets + a full-height tap zone for the chevron. */
@media (max-width:820px){
  .combo > input{padding-right:48px}
  .combo-toggle{top:0;bottom:0;right:0;width:46px;height:auto;transform:none;
    border-radius:0 12px 12px 0;-webkit-tap-highlight-color:transparent}
  .combo-toggle svg{width:20px;height:20px}
  .combo-menu{max-height:55vh;padding:8px;top:calc(100% + 8px)}
  .combo-menu li{padding:14px 14px;font-size:16px;border-radius:10px}
  .combo-menu li small{font-size:13px}
  .combo-menu li.empty{font-size:14px;padding:14px}
}

/* Edit panel and map styles */
.edit-panel {
  margin-top: 20px;
  background: var(--panel-bg, rgba(0,0,0,.18));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: inset 0 0 12px rgba(255,255,255,.02);
}
.edit-panel h3 {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .2px;
}
.edit-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
.slider {
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.38);
  border: 1px solid var(--line);
  outline: none;
  margin-top: 15px;
  transition: opacity .2s;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--teal);
  cursor: pointer;
  box-shadow: 0 0 8px var(--teal);
  transition: transform .1s;
}
.slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}
.map-field {
  margin-bottom: 20px;
}
.map-field > span {
  display: block;
  font-size: 13px;
  color: var(--mut);
  margin-bottom: 7px;
  font-weight: 600;
}
.map-container {
  height: 260px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg0);
  z-index: 5;
}
.sm-btn {
  width: auto;
  display: inline-block;
  padding: 11px 24px;
  font-size: 14px;
  border-radius: 10px;
  box-shadow: 0 4px 15px -4px rgba(56,189,248,.4);
}

.graph-wrap{margin-top:16px;background:rgba(4,16,26,.45);border:1px solid var(--line);
  border-radius:12px;padding:14px 10px 8px;min-width:0}
#graph-canvas{min-width:0;width:100%;overflow:hidden}

.graph-slider-wrap{padding:2px 6px 4px}
.graph-slider-labels{display:flex;margin-bottom:4px;padding:0 2px}
.graph-slider-labels span{font-size:12px;color:var(--mut);font-weight:600;cursor:pointer;
  transition:color .18s;flex:1;text-align:center}
.graph-slider-labels span:first-child{text-align:left}
.graph-slider-labels span:last-child{text-align:right}
.graph-slider-labels span.gsl-active{color:var(--teal)}

.graph-tip{position:fixed;pointer-events:none;z-index:200;display:none;
  background:rgba(6,20,31,.95);border:1px solid rgba(123,176,200,.25);
  border-radius:9px;padding:9px 13px;font-size:13px;line-height:1.6;
  color:var(--ink);box-shadow:0 8px 24px rgba(0,0,0,.55);min-width:145px}
.graph-tip b{color:var(--teal)}
.tip-msg{color:#f59e0b}

/* clickable dive row */
.d-link{text-decoration:none;color:inherit;cursor:pointer;flex:1;min-width:0}
.dive:hover .d-when{color:#fff;text-shadow:0 1px 3px rgba(0,0,0,.6)}

@media (max-width:820px){
  .stage, body.authed .stage, body.dive-page .stage{grid-template-columns:1fr;gap:30px;padding:44px 20px 70px}
  .hero{text-align:center} .logo{justify-content:center}
  .lede,.hero h1{margin-left:auto;margin-right:auto}
  .feats{align-items:center}
  /* Brand bar: centered and a touch smaller on mobile (like the splash). */
  .brand-bar{justify-content:center;margin-bottom:28px}
  .brand-bar .mask-logo{width:34px;height:34px}
  .brand-bar .brand{font-size:19px}
  
  .dive-card {
    position: relative;
  }
  .back-badge {
    position: absolute;
    top: 32px;
    left: 20px;
    margin: 0 !important;
    z-index: 10;
  }
  /* Same note as the ≤520px block: reposition the parent #stamp-slot, not
     this nested button (see .stamp-slot base rule for why). */
  .stamp-slot {
    top: 12px;
    right: 20px;
    z-index: 10;
  }
  .dive-card .stamp-img-btn img {
    width: 72px;
    height: 72px;
  }
}

/* Divider & Google Login Button */
.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--mut);
  font-size: 13px;
  margin: 16px 0;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--line);
}
.divider:not(:empty)::before {
  margin-right: 12px;
}
.divider:not(:empty)::after {
  margin-left: 12px;
}
.google-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  padding: 13px;
  border-radius: 13px;
  cursor: pointer;
  transition: .18s;
  box-shadow: 0 4px 15px -4px rgba(0, 0, 0, 0.2);
}
.google-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}
.google-btn:active {
  transform: translateY(0);
}
.google-btn svg {
  flex-shrink: 0;
}

/* Edit Username Button and Form */
.edit-btn {
  background: transparent;
  border: 0;
  padding: 4px;
  cursor: pointer;
  color: var(--mut);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.18s, transform 0.18s;
  vertical-align: middle;
}
.edit-btn:hover {
  color: var(--teal);
  transform: scale(1.1);
}
.edit-btn:active {
  transform: scale(0.95);
}
.edit-username-form:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Modal dialog styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(4, 10, 16, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: opacity 0.2s ease;
}

.modal-content {
  background: var(--bg0);
  border: 1px solid var(--line);
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: modalSlide 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlide {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  color: var(--teal);
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: 0;
  color: var(--mut);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}

.modal-close:hover {
  color: var(--ink);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink);
}

.modal-desc {
  margin: 0;
  color: var(--ink);
  opacity: 0.95;
}

.fish-table-wrap {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
}

.fish-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13.5px;
}

.fish-table th {
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 12px;
  font-weight: 600;
  color: var(--mut);
  border-bottom: 1px solid var(--line);
}

.fish-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}

.fish-table tr:last-child td {
  border-bottom: 0;
}

.fish-table tr:hover td {
  background: rgba(94, 234, 212, 0.06);
}

.fish-table tr:active td {
  background: rgba(94, 234, 212, 0.12);
}

/* Global hidden utility override */
[hidden] {
  display: none !important;
}

/* --- fish catalog gallery styles --- */
.fish-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
  margin-top: 14px;
}

.fish-card {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s, box-shadow 0.2s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.fish-card:hover {
  transform: translateY(-4px);
  border-color: var(--teal);
  box-shadow: 0 10px 25px -5px rgba(94, 234, 212, 0.2), 0 8px 10px -6px rgba(94, 234, 212, 0.2);
}

.fish-card img {
  width: 100%;
  height: 130px;
  object-fit: cover;
  border-bottom: 1px solid var(--line);
  transition: filter 0.2s;
}

.fish-card:hover img {
  filter: brightness(1.08);
}

.fish-info {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.fish-title {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--ink);
}

.fish-latin {
  font-size: 12.5px;
  font-style: italic;
  color: var(--mut);
  margin-top: -2px;
}

.fish-desc {
  font-size: 12.5px;
  color: var(--mut);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 6px;
  flex: 1;
}

.fish-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  margin-top: 12px;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
  color: var(--ink);
}

.fish-badge {
  padding: 2px 7px;
  border-radius: 5px;
  font-weight: 700;
  font-size: 10.5px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.danger-low {
  background: rgba(52, 211, 153, 0.12);
  color: var(--ok);
  border: 1px solid rgba(52, 211, 153, 0.2);
}

.danger-med {
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.2);
}

.danger-high {
  background: rgba(251, 113, 133, 0.12);
  color: var(--err);
  border: 1px solid rgba(251, 113, 133, 0.2);
}

/* Photos panel and gallery */
.photos-panel {
  margin-top: 20px;
  background: var(--panel-bg, rgba(0,0,0,.18));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: inset 0 0 12px rgba(255,255,255,.02);
}
.photos-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.photos-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .2px;
}
.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  background: linear-gradient(90deg, var(--teal), var(--sky));
  color: #04212a;
  border: 0;
  font-weight: 700;
  border-radius: 15px;
  padding: 5px 12px;
  font-size: 11px;
}
.upload-btn:hover {
  filter: brightness(1.08);
}
.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}
.photo-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
}
.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}
.photo-item:hover img {
  transform: scale(1.05);
}
.photo-delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(251, 113, 133, 0.85);
  color: #fff;
  border: 0;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease, background 0.15s;
  z-index: 5;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.photo-item:hover .photo-delete-btn {
  opacity: 1;
}
.photo-delete-btn:hover {
  background: #fb7185;
}

/* Featured-photo star: opposite corner from delete. Gold + always visible
   once featured; otherwise hover-reveal like delete. */
.photo-star-btn {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(4, 16, 26, 0.55);
  color: #fff;
  border: 0;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease, background 0.15s, color 0.15s;
  z-index: 5;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.photo-item:hover .photo-star-btn {
  opacity: 1;
}
.photo-star-btn.featured {
  opacity: 1;
  color: #fbbf24;
  background: rgba(4, 16, 26, 0.72);
}
.photo-star-btn:hover {
  background: rgba(4, 16, 26, 0.85);
  color: #fbbf24;
}

.photo-fish-hint {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(4, 16, 26, 0.85);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  color: #e0f2fe;
  font-size: 10px;
  padding: 4px 6px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-top: 1px solid rgba(0, 240, 255, 0.15);
  pointer-events: none;
  z-index: 4;
}

/* --- Photo Upload Progress Modal --- */
#upload-progress-modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 16, 26, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.progress-card {
  width: 90%;
  max-width: 400px;
  background: rgba(10, 25, 41, 0.95);
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.65), 0 0 30px rgba(0, 240, 255, 0.15);
  display: flex;
  flex-direction: column;
  gap: 20px;
  transform: scale(0.9);
  transition: transform 0.25s ease;
}
.progress-header {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  text-align: center;
  letter-spacing: 0.5px;
}
.progress-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00d2ff, #00f0ff);
  box-shadow: 0 0 8px #00f0ff;
  border-radius: 3px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.progress-step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: #94a3b8;
  transition: color 0.25s;
}
.progress-step.active {
  color: #e2e8f0;
}
.progress-step.completed {
  color: #00f0ff;
}
.progress-step-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.progress-step-icon.pending::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #475569;
}
.progress-step-icon.active::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #00f0ff;
  border-top-color: transparent;
  animation: spin 0.8s linear infinite;
}
.progress-step-icon.completed::before {
  content: "✓";
  font-weight: bold;
  color: #00f0ff;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Timeline View Styles --- */
#dive-timeline {
  position: relative;
  width: 100%;
  height: 420px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 40px;
  scrollbar-width: thin;
  user-select: none;
  cursor: grab;
  margin: 10px 0;
}

#dive-timeline.grabbing {
  cursor: grabbing;
}

.timeline-track {
  position: relative;
  height: 100%;
  min-width: 100%;
}

.timeline-axis {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--teal), var(--sky));
  box-shadow: 0 0 10px rgba(94, 234, 212, 0.4);
  transform: translateY(-50%);
  z-index: 1;
}

.timeline-year-marker {
  position: absolute;
  top: 15px;
  bottom: 15px;
  width: 1px;
  border-left: 1px dashed rgba(123, 176, 200, 0.22);
  z-index: 1;
}

.timeline-year-label {
  position: absolute;
  top: 18px;
  transform: translateX(-50%);
  background: var(--bg0);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px 8px;
  color: var(--teal);
  font-size: 12.5px;
  font-weight: 700;
  z-index: 2;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.timeline-month-tick {
  position: absolute;
  top: calc(50% - 6px);
  height: 12px;
  width: 1px;
  background: rgba(123, 176, 200, 0.35);
  z-index: 1;
}

.timeline-month-label {
  position: absolute;
  top: calc(50% - 22px);
  transform: translateX(-50%);
  color: var(--mut);
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  opacity: 0.65;
  z-index: 2;
}

/* Today marker */
.timeline-today-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 2px dashed rgba(251, 191, 36, 0.65);
  transform: translateX(-1px);
  z-index: 5;
  pointer-events: none;
}

.timeline-today-label {
  position: absolute;
  top: calc(50% - 38px);
  transform: translateX(-50%);
  color: rgb(251, 191, 36);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.85;
  z-index: 5;
  pointer-events: none;
  text-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}

.timeline-item {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  z-index: 3;
}

.timeline-fork {
  position: absolute;
  left: 0;
  width: 2px;
  background: rgba(123, 176, 200, 0.3);
  transform: translateX(-50%);
  z-index: 2;
}

.timeline-item.normal .timeline-fork {
  height: 36px;
}

.timeline-item.high .timeline-fork {
  height: 72px;
}

.timeline-item.up .timeline-fork {
  bottom: 50%;
}

.timeline-item.down .timeline-fork {
  top: 50%;
}

.timeline-circle {
  position: absolute;
  left: 0;
  border-radius: 50%;
  border: 2px solid var(--bg1);
  z-index: 3;
  transition: transform 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.22s ease, filter 0.22s ease;
  cursor: pointer;
}

.timeline-item.up.normal .timeline-circle {
  bottom: calc(50% + 36px);
  transform: translate(-50%, 50%);
}

.timeline-item.up.high .timeline-circle {
  bottom: calc(50% + 72px);
  transform: translate(-50%, 50%);
}

.timeline-item.down.normal .timeline-circle {
  top: calc(50% + 36px);
  transform: translate(-50%, -50%);
}

.timeline-item.down.high .timeline-circle {
  top: calc(50% + 72px);
  transform: translate(-50%, -50%);
}

.timeline-item.up:hover .timeline-circle {
  transform: translate(-50%, 50%) scale(1.35);
  filter: brightness(1.2);
}

.timeline-item.down:hover .timeline-circle {
  transform: translate(-50%, -50%) scale(1.35);
  filter: brightness(1.2);
}

.timeline-card {
  position: absolute;
  left: 0;
  width: 120px;
  background: rgba(13, 30, 44, 0.86);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 8px;
  text-align: center;
  white-space: normal;
  z-index: 4;
  transition: width 0.25s cubic-bezier(0.25, 0.8, 0.25, 1), 
              transform 0.25s cubic-bezier(0.25, 0.8, 0.25, 1), 
              border-color 0.22s ease, 
              background-color 0.22s ease, 
              box-shadow 0.25s ease, 
              padding 0.25s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.timeline-item.up.normal .timeline-card {
  bottom: calc(50% + 52px);
  transform: translateX(-50%);
}

.timeline-item.up.high .timeline-card {
  bottom: calc(50% + 88px);
  transform: translateX(-50%);
}

.timeline-item.down.normal .timeline-card {
  top: calc(50% + 52px);
  transform: translateX(-50%);
}

.timeline-item.down.high .timeline-card {
  top: calc(50% + 88px);
  transform: translateX(-50%);
}

/* Hover expansion */
.timeline-item:hover {
  z-index: 10;
}

.timeline-item:hover .timeline-card {
  width: 185px;
  padding: 10px 12px;
  z-index: 10;
}

.timeline-item.up:hover .timeline-card {
  transform: translateX(-50%) translateY(-4px);
  border-color: rgba(94, 234, 212, 0.4);
  background: rgba(13, 30, 44, 0.95);
  box-shadow: 0 8px 24px rgba(94, 234, 212, 0.2);
}

.timeline-item.down:hover .timeline-card {
  transform: translateX(-50%) translateY(4px);
  border-color: rgba(94, 234, 212, 0.4);
  background: rgba(13, 30, 44, 0.95);
  box-shadow: 0 -8px 24px rgba(94, 234, 212, 0.2);
}

.timeline-card-link {
  color: inherit;
  text-decoration: none;
  display: block;
}

.timeline-card-date {
  font-size: 9.5px;
  color: var(--teal);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
  transition: font-size 0.25s ease;
}

.timeline-item:hover .timeline-card-date {
  font-size: 10.5px;
}

.timeline-card-title {
  font-size: 12px;
  font-weight: 700;
  margin: 0;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: font-size 0.25s ease, margin 0.25s ease;
}

.timeline-item:hover .timeline-card-title {
  font-size: 13.5px;
  margin-bottom: 4px;
}

.timeline-card-diver {
  font-size: 9.5px;
  color: var(--mut);
  opacity: 0.75;
  font-weight: 400;
  display: block;
  margin-top: 1px;
}

.timeline-card-meta {
  font-size: 11px;
  color: var(--mut);
  line-height: 1.35;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.2s ease, margin 0.25s ease;
}

.timeline-item:hover .timeline-card-meta {
  max-height: 50px;
  opacity: 1;
  margin-top: 4px;
}

.timeline-card-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  border-top: 1px solid transparent;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  padding-top: 0;
  margin-top: 0;
  transition: max-height 0.25s ease, opacity 0.2s ease, margin 0.25s ease, padding 0.25s ease, border-color 0.25s ease;
}

.timeline-item:hover .timeline-card-actions {
  max-height: 40px;
  opacity: 1;
  margin-top: 8px;
  border-top-color: rgba(123, 176, 200, 0.15);
  padding-top: 8px;
}

.timeline-card-actions button {
  font-size: 10px;
  padding: 2px 6px;
}

/* Timeline zoom bar */
.timeline-zoom-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(13, 30, 44, 0.7);
  color: var(--sky);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.timeline-zoom-btn:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--sky);
  transform: scale(1.1);
}

.timeline-zoom-btn:active {
  transform: scale(0.95);
}


/* Slide toggle (device-config Alarms, Android-style) */
.sw{position:relative;display:inline-block;width:42px;height:24px;flex:none}
.sw input{opacity:0;width:0;height:0;position:absolute}
.sw i{position:absolute;inset:0;background:rgba(255,255,255,.10);border:1px solid var(--line);border-radius:24px;transition:background .15s,border-color .15s}
.sw i:before{content:"";position:absolute;width:18px;height:18px;left:2px;top:2px;background:var(--mut);border-radius:50%;transition:transform .15s,background .15s}
.sw input:checked+i{background:rgba(94,234,212,.25);border-color:var(--teal)}
.sw input:checked+i:before{transform:translateX(18px);background:var(--teal)}
.alarm-row{display:flex;align-items:center;gap:12px;padding:10px 0;border-bottom:1px solid var(--line)}
.alarm-row:last-of-type{border-bottom:0}
.alarm-row .alarm-info{flex:1;min-width:0}
.alarm-row .alarm-info b{font-weight:600}
.alarm-row .alarm-info .sh{margin:2px 0 0;font-size:13px}
.alarm-row input[type=number]{width:76px;flex:none;text-align:center}
.alarm-row input[type=number]:disabled{opacity:.4}
.alarm-unit{color:var(--mut);font-size:13px;width:26px;flex:none}

/* ── Device detail modal ──────────────────────────────────────────────────── */
.dd-chips{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:6px}
.dd-chip{display:inline-flex;align-items:center;gap:5px;padding:4px 10px;border-radius:999px;
  background:rgba(0,0,0,.28);border:1px solid var(--line);font-size:12px;color:var(--mut)}
.dd-section{margin-top:20px}
.dd-section:first-of-type{margin-top:14px}
.dd-section-head{display:flex;align-items:baseline;justify-content:space-between;gap:10px;
  margin-bottom:8px;border-bottom:1px solid var(--line);padding-bottom:5px}
.dd-section-head h4{margin:0;font-size:14px;font-weight:700;color:var(--ink);letter-spacing:.02em}
.dd-note{font-size:12px;color:var(--mut);white-space:nowrap}

/* crash list */
.dd-crashes{display:flex;flex-direction:column;gap:6px}
.dd-crash{background:rgba(0,0,0,.22);border:1px solid var(--line);border-radius:10px;overflow:hidden}
.dd-crash>summary{list-style:none;cursor:pointer;display:flex;align-items:center;
  justify-content:space-between;gap:10px;padding:9px 12px;font-size:13px}
.dd-crash>summary::-webkit-details-marker{display:none}
.dd-crash>summary:hover{background:rgba(255,255,255,.03)}
.dd-crash-name{font-weight:600;color:var(--ink)}
.dd-crash-meta{color:var(--mut);font-size:12px;text-align:right}
.dd-crash-body{padding:2px 12px 12px;border-top:1px solid var(--line)}
.dd-crash-ckpt{font-size:12px;color:var(--mut);margin:9px 0}
.dd-log{margin:8px 0 0;padding:10px;background:#02090f;border:1px solid var(--line);border-radius:8px;
  font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;color:#b9d4e4;
  white-space:pre-wrap;word-break:break-word;max-height:220px;overflow:auto}

/* read-only config grid */
.dd-kv{display:grid;grid-template-columns:auto 1fr;gap:2px 16px;font-size:13px}
.dd-kv-row{display:contents}
.dd-kv-row .dd-k{color:var(--mut);padding:4px 0;border-bottom:1px solid rgba(123,176,200,.08)}
.dd-kv-row .dd-v{color:var(--ink);padding:4px 0;border-bottom:1px solid rgba(123,176,200,.08);
  word-break:break-word;font-variant-numeric:tabular-nums}

/* activity feed */
.dd-activity{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}
.dd-activity li{display:flex;align-items:center;gap:10px;padding:7px 0;font-size:13px;
  border-bottom:1px solid rgba(123,176,200,.08)}
.dd-activity li:last-child{border-bottom:0}
.dd-a-icon{width:20px;text-align:center;flex:none}
.dd-a-label{flex:1;color:var(--ink)}
.dd-a-when{color:var(--mut);font-size:12px;white-space:nowrap}
