:root{
  --deep:#0a1a2f;
  --deeper:#06111f;
  --glow:#16375d;
  --ink:#e8eef6;
  --muted:#8ea4bf;
  --brass:#e0b568;
  --on-brass:#0a1a2f;
  --line:rgba(224,181,104,.22);
  --card:rgba(255,255,255,.035);
  --surface-border:rgba(255,255,255,.07);
  --surface-border-strong:rgba(255,255,255,.16);
  --surface-fill:rgba(255,255,255,.04);
  --surface-fill-hover:rgba(255,255,255,.06);
}
:root[data-theme="light"]{
  --deep:#eef4fb;
  --deeper:#ffffff;
  --glow:#d7e6f7;
  --ink:#132436;
  --muted:#5b6b80;
  --brass:#a6710f;
  --on-brass:#fffaf0;
  --line:rgba(166,113,15,.28);
  --card:rgba(19,36,54,.035);
  --surface-border:rgba(19,36,54,.09);
  --surface-border-strong:rgba(19,36,54,.18);
  --surface-fill:rgba(19,36,54,.03);
  --surface-fill-hover:rgba(19,36,54,.05);
}
*,*::before,*::after{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{
  margin:0;min-height:100vh;color:var(--ink);
  background:
    radial-gradient(1100px 700px at 50% -10%, var(--glow) 0%, transparent 60%),
    linear-gradient(180deg, var(--deep) 0%, var(--deeper) 100%);
  background-attachment:fixed;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Inter,Roboto,"Helvetica Neue",Arial,sans-serif;
  line-height:1.6;display:flex;flex-direction:column;
  transition:background-color .15s ease, color .15s ease;
}
a{color:var(--brass)}

/* ---- topbar shared across tool pages ---- */
.topbar{
  display:flex;align-items:center;justify-content:space-between;gap:1rem;
  max-width:40rem;margin:0 auto;padding:1.25rem 1.5rem;
}
.topbar-right{display:flex;align-items:center;gap:.85rem}
.brand{display:flex;align-items:center;gap:.5rem;text-decoration:none;color:var(--ink);font-weight:700;font-size:1.05rem}
.brand svg{width:26px;height:26px;color:var(--brass);flex:none}
.brand span{color:var(--brass);font-weight:300}
.back{color:var(--muted);text-decoration:none;font-size:.85rem;white-space:nowrap}
.back:hover{color:var(--brass)}

/* ---- theme toggle ---- */
.theme-toggle{
  display:inline-flex;align-items:center;justify-content:center;flex:none;
  width:2.1rem;height:2.1rem;padding:0;border-radius:.5rem;cursor:pointer;
  border:1px solid var(--surface-border-strong);background:var(--surface-fill);color:var(--muted);
}
.theme-toggle:hover{color:var(--brass);border-color:var(--line)}
.theme-toggle svg{width:17px;height:17px}
.theme-toggle .icon-moon{display:none}
:root[data-theme="light"] .theme-toggle .icon-sun{display:none}
:root[data-theme="light"] .theme-toggle .icon-moon{display:block}

main.page{width:100%;max-width:40rem;margin:0 auto;padding:0 1.5rem 4rem;flex:1 0 auto}
.eyebrow{font-size:.72rem;letter-spacing:.2em;text-transform:uppercase;color:var(--brass);margin:0 0 .5rem;font-weight:600}
h1.title{font-size:clamp(1.5rem,4.5vw,2.1rem);margin:0 0 .4rem;font-weight:600;letter-spacing:-.01em}
p.sub{color:var(--muted);margin:0 0 2rem;font-size:.97rem;max-width:34rem}

.card{
  background:var(--card);border:1px solid var(--surface-border);border-radius:.75rem;
  padding:1.25rem 1.5rem;margin-bottom:1.25rem;
}
.card h2{font-size:.72rem;letter-spacing:.16em;text-transform:uppercase;color:var(--brass);margin:0 0 1.1rem;font-weight:600}

.field-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(11rem,1fr));gap:1rem}
.field label{display:block;font-size:.8rem;color:var(--muted);margin-bottom:.35rem}
.field .row{display:flex;gap:.4rem}
.field .row select{flex:0 0 auto;width:auto}

input[type=number],input[type=text],input[type=email],select{
  width:100%;padding:.55rem .7rem;border-radius:.4rem;
  border:1px solid var(--surface-border-strong);background:var(--surface-fill);
  color:var(--ink);font:inherit;font-size:.95rem;
}
input::placeholder{color:var(--muted)}
select{cursor:pointer}
input:focus-visible,select:focus-visible,a:focus-visible,button:focus-visible{
  outline:2px solid var(--brass);outline-offset:2px;
}

.results{
  background:rgba(224,181,104,.06);border:1px solid var(--line);
  border-radius:.75rem;padding:1.25rem 1.5rem;
}
:root[data-theme="light"] .results{background:rgba(166,113,15,.05)}
.results h2{font-size:.72rem;letter-spacing:.16em;text-transform:uppercase;color:var(--brass);margin:0 0 1rem;font-weight:600}
.stat{display:flex;justify-content:space-between;align-items:baseline;gap:1rem;padding:.5rem 0;border-bottom:1px solid var(--surface-border)}
.stat:last-child{border-bottom:0}
.stat .k{color:var(--muted);font-size:.88rem}
.stat .v{font-size:1.15rem;font-weight:650;font-variant-numeric:tabular-nums;text-align:right}

.warn{color:#e7a15c;font-size:.85rem;margin-top:.9rem}
.note{color:var(--muted);font-size:.82rem;margin-top:1rem}

table.twelfths{width:100%;border-collapse:collapse;font-size:.87rem;margin-top:.25rem}
table.twelfths th,table.twelfths td{text-align:right;padding:.4rem .5rem;border-bottom:1px solid var(--surface-border);font-variant-numeric:tabular-nums}
table.twelfths th{color:var(--muted);font-weight:600;font-size:.78rem;text-transform:uppercase;letter-spacing:.04em}
table.twelfths th:first-child,table.twelfths td:first-child{text-align:left}

button.btn{
  padding:.5rem 1rem;border-radius:.4rem;border:0;flex:none;
  background:var(--brass);color:var(--on-brass);font:inherit;font-weight:650;
  font-size:.88rem;cursor:pointer;transition:filter .15s ease;
}
button.btn:hover{filter:brightness(1.08)}
button.btn.ghost{background:transparent;color:var(--muted);border:1px solid var(--surface-border-strong)}
button.btn.ghost:hover{color:var(--brass);border-color:var(--line)}

/* ---- saved waypoints ---- */
.wp-row{
  display:flex;flex-wrap:wrap;align-items:center;gap:.5rem .75rem;
  padding:.6rem 0;border-bottom:1px solid var(--surface-border);
}
.wp-row:last-child{border-bottom:0}
.wp-name{font-weight:600;font-size:.92rem;flex:1 1 8rem;min-width:0}
.wp-coord{color:var(--muted);font-size:.82rem;font-variant-numeric:tabular-nums;flex:1 1 12rem}
.wp-actions{display:flex;gap:.4rem;flex:none}
.wp-del{
  background:transparent;border:1px solid var(--surface-border-strong);color:var(--muted);
  border-radius:.4rem;width:1.8rem;height:1.8rem;cursor:pointer;font-size:.85rem;line-height:1;
}
.wp-del:hover{color:#e7a15c;border-color:#e7a15c}
.wp-save-row{display:flex;gap:.5rem;margin-top:.9rem;flex-wrap:wrap}
.wp-save-row input{flex:1 1 10rem}

footer.site{flex:none;text-align:center;padding:2rem 1.5rem 2.5rem;font-size:.82rem;color:var(--muted)}
footer.site a{color:var(--muted)}
