/* Clear Night Planner
   Palette: deep Prussian sky rather than black, starlight ink, three forecast states.
   Night-vision mode swaps the whole palette to dim reds. */
:root {
  --sky: #10203A;
  --sky-2: #162A49;
  --rule: #2B4369;
  --ink: #ECE7DA;
  --muted: #9EAFCA;
  --clear: #6FD3B0;
  --mixed: #E2B35A;
  --cloud: #D9776F;
  --moon: #F3E6B5;
  --day: #3A5784;
  --twilight: #22385C;
  --focus: #9CC9FF;

  --f: 'Barlow Semi Condensed', 'Arial Narrow', system-ui, sans-serif;
  --s-1: .8125rem; --s0: 1rem; --s1: 1.25rem; --s2: 1.6rem; --s3: 2.6rem;
  --gap: clamp(16px, 3vw, 32px);
  color-scheme: dark;
}
html[data-night] {
  --sky: #140404; --sky-2: #1C0707; --rule: #3A1010;
  --ink: #E0574A; --muted: #A33A30; --clear: #E0574A; --mixed: #9E352B; --cloud: #5C1A14;
  --moon: #C9463A; --day: #3A0D0A; --twilight: #250807; --focus: #FF7A6B;
}

* { box-sizing: border-box; }
html { background: var(--sky); }
body {
  margin: 0; background: var(--sky); color: var(--ink);
  font: 400 var(--s0)/1.45 var(--f); font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
svg { width: 1.25em; height: 1.25em; flex: none; }
h1, h2, h3 { font-weight: 500; margin: 0; line-height: 1.15; }
h2 { font-size: var(--s2); font-weight: 400; }
.small { font-size: var(--s-1); color: var(--muted); }
.hint { color: var(--muted); max-width: 62ch; margin: .35rem 0 0; }

/* ---------- bar */
.bar {
  display: flex; align-items: center; gap: .75rem;
  padding: 14px var(--gap); border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; background: var(--sky); z-index: 5;
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 600; font-size: var(--s1); text-decoration: none; margin-right: auto; }
.brand-mark { width: 1.6em; height: 1.6em; color: var(--moon); }
button, .loc {
  font: inherit; color: inherit; background: transparent; cursor: pointer;
  border: 1px solid var(--rule); border-radius: 999px; padding: .4rem .85rem;
  display: inline-flex; align-items: center; gap: .45rem; min-height: 40px;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--ink); color: var(--sky); border-color: var(--ink); font-weight: 600; }
button.danger { color: var(--cloud); border-color: color-mix(in srgb, var(--cloud) 50%, transparent); }
.icon-btn { padding: .4rem; width: 40px; justify-content: center; }
.toggle[aria-pressed="true"] { background: var(--ink); color: var(--sky); }
@media (max-width: 560px) { .toggle span, .loc span { max-width: 9ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .toggle span { display: none; } }

main { padding: 0 var(--gap); max-width: 1240px; margin: 0 auto; }

/* ---------- hero: the verdict and the sky ribbon are the page */
.hero { padding: clamp(28px, 6vw, 64px) 0 28px; }
.date { color: var(--muted); margin: 0 0 .5rem; font-size: var(--s1); }
.hero h1 { font-size: clamp(2rem, 5.2vw, 3.6rem); font-weight: 300; max-width: 24ch; letter-spacing: -.01em; }
.facts { color: var(--muted); font-size: var(--s1); margin: .9rem 0 0; display: flex; flex-wrap: wrap; gap: .35rem 1.5rem; }
.facts b { color: var(--ink); font-weight: 500; }
.ribbon-wrap { margin: 28px 0 0; }
.ribbon { width: 100%; overflow-x: auto; scrollbar-width: thin; }
.ribbon svg { width: 100%; min-width: 760px; height: auto; display: block; }
.ribbon text { font: 500 11px var(--f); fill: var(--muted); }
.ribbon .now-label { fill: var(--ink); }
.legend { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; color: var(--muted); font-size: var(--s-1); margin-top: .6rem; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: .4rem; vertical-align: -1px; }
.sw-clear { background: var(--clear); } .sw-cloud { background: color-mix(in srgb, var(--ink) 55%, transparent); }
.sw-moon { background: var(--moon); height: 4px; vertical-align: 2px; } .sw-dark { background: var(--sky); outline: 1px solid var(--rule); }

/* ---------- readouts: one ruled strip, not four boxes */
.readouts {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.readout { padding: 20px 20px 22px 0; }
.readout + .readout { padding-left: 20px; border-left: 1px solid var(--rule); }
.readout h3 { font-size: var(--s0); color: var(--muted); font-weight: 400; display: flex; align-items: center; gap: .4rem; }
.readout .big { font-size: var(--s3); font-weight: 300; line-height: 1.1; margin: .35rem 0 .25rem; }
.readout .big small { font-size: var(--s1); color: var(--muted); margin-left: .2rem; }
.readout p { margin: .15rem 0; color: var(--muted); }
.readout p b { color: var(--ink); font-weight: 500; }
.readout .moonfig { width: 46px; height: 46px; float: right; }
.lvl-high { color: var(--cloud) !important; } .lvl-med { color: var(--mixed) !important; } .lvl-low { color: var(--clear) !important; }
@media (max-width: 900px) {
  .readouts { grid-template-columns: 1fr 1fr; }
  .readout:nth-child(3) { padding-left: 0; border-left: 0; }
  .readout:nth-child(n+3) { border-top: 1px solid var(--rule); }
}
@media (max-width: 480px) {
  .readouts { grid-template-columns: 1fr; }
  .readout + .readout { padding-left: 0; border-left: 0; border-top: 1px solid var(--rule); }
}

/* ---------- rigs */
.rigs { padding: 48px 0 16px; }
.rig-picker { display: flex; gap: 10px; margin: 24px 0 0; overflow-x: auto; padding-bottom: 6px; }
.rig-tab {
  flex: none; border-radius: 14px; padding: 12px 16px 10px; min-width: 150px;
  flex-direction: column; align-items: flex-start; gap: 6px; text-align: left;
}
.rig-tab svg { width: 52px; height: 52px; }
.rig-tab span { font-weight: 500; line-height: 1.2; }
.rig-tab[aria-selected="true"] { background: var(--sky-2); border-color: var(--ink); }
.rig-tab.add { border-style: dashed; color: var(--muted); justify-content: center; align-items: center; }
.rig-detail {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem 1.5rem;
  margin: 18px 0 6px; padding: 14px 0; border-bottom: 1px solid var(--rule); color: var(--muted);
}
.rig-detail b { color: var(--ink); font-weight: 500; }
.rig-detail .edit { margin-left: auto; }

.targets { list-style: none; margin: 0; padding: 0; }
.target { display: grid; grid-template-columns: 44px minmax(0, 1fr) 132px; gap: 6px 18px; padding: 18px 0; border-bottom: 1px solid var(--rule); }
.target > svg.type { width: 40px; height: 40px; color: var(--muted); margin-top: 2px; }
.target h3 { font-size: var(--s1); }
.target h3 .id { color: var(--muted); font-weight: 400; margin-left: .35rem; }
.target .meta { color: var(--muted); margin: .2rem 0 .5rem; display: flex; flex-wrap: wrap; gap: .2rem 1.1rem; }
.target .meta b { color: var(--ink); font-weight: 500; }
.target ul { margin: 0; padding-left: 1.1rem; max-width: 72ch; }
.target li { margin: .15rem 0; }
.target li::marker { color: var(--muted); }
.score { display: flex; align-items: center; gap: .5rem; margin-top: .15rem; }
.score .meter { flex: 1; max-width: 160px; height: 6px; border-radius: 3px; background: var(--rule); overflow: hidden; }
.score .meter i { display: block; height: 100%; background: var(--clear); }
.score.mixed .meter i { background: var(--mixed); } .score.poor .meter i { background: var(--cloud); }
.frame { justify-self: end; text-align: center; }
.frame svg { width: 132px; height: auto; display: block; }
.frame figcaption { font-size: var(--s-1); color: var(--muted); margin-top: 4px; }
.empty { padding: 28px 0; color: var(--muted); max-width: 60ch; }
@media (max-width: 640px) {
  .target { grid-template-columns: 36px minmax(0, 1fr); }
  .target > svg.type { width: 32px; height: 32px; }
  .frame { grid-column: 2; justify-self: start; }
}

/* ---------- hourly table */
.hourly { padding: 40px 0 24px; }
.table-scroll { overflow-x: auto; margin-top: 16px; border-top: 1px solid var(--rule); }
table { border-collapse: collapse; font-size: var(--s-1); white-space: nowrap; }
th, td { padding: 6px 9px; text-align: center; border-bottom: 1px solid var(--rule); }
th[scope="row"] { text-align: left; position: sticky; left: 0; background: var(--sky); color: var(--muted); font-weight: 400; }
thead th { font-weight: 500; }
td.dim, th.dim { opacity: .45; }
td.c { color: var(--sky); font-weight: 600; }
td.dayline, th.dayline { border-left: 1px solid var(--muted); }

.foot { padding: 28px var(--gap) 48px; color: var(--muted); border-top: 1px solid var(--rule); max-width: 1240px; margin: 24px auto 0; }

/* ---------- dialogs */
dialog {
  border: 1px solid var(--rule); border-radius: 18px; padding: 0; color: var(--ink);
  background: var(--sky-2); width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
}
dialog::backdrop { background: rgb(4 8 16 / .7); }
.dlg { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.dlg.wide { width: 100%; }
dialog:has(.wide) { width: min(760px, calc(100vw - 24px)); }
.dlg label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); }
.dlg label.check { flex-direction: row; align-items: center; gap: .5rem; color: var(--ink); align-self: end; min-height: 40px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--sky); border: 1px solid var(--rule);
  border-radius: 10px; padding: .5rem .65rem; min-height: 40px; width: 100%;
}
input[type="checkbox"], input[type="radio"], input[type="range"] { width: auto; min-height: 0; padding: 0; accent-color: var(--clear); }
fieldset { border: 1px solid var(--rule); border-radius: 12px; padding: 10px 12px 12px; margin: 0; }
legend { color: var(--muted); padding: 0 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.span2 { grid-column: span 2; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } .span2 { grid-column: auto; } }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; } .row.between { justify-content: space-between; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checks label { flex-direction: row; align-items: center; gap: .4rem; color: var(--ink); }
.icon-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-choices label { position: relative; }
.icon-choices input { position: absolute; opacity: 0; }
.icon-choices span { display: grid; place-items: center; width: 58px; height: 58px; border: 1px solid var(--rule); border-radius: 12px; color: var(--ink); }
.icon-choices svg { width: 40px; height: 40px; }
.icon-choices input:checked + span { border-color: var(--ink); background: var(--sky); }
.icon-choices input:focus-visible + span { outline: 2px solid var(--focus); }
.results { list-style: none; padding: 0; margin: 0; }
.results button { width: 100%; justify-content: flex-start; border-radius: 10px; margin-top: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: var(--sky); padding: .6rem 1rem; border-radius: 999px; font-weight: 500;
  transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- outfit location & mount mode */
.rig-tab small { color: var(--muted); font-size: var(--s-1); }
.modes { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; padding: 2px; }
.modes button { border: 0; min-height: 34px; padding: .25rem .8rem; }
.modes button[aria-pressed="true"] { background: var(--ink); color: var(--sky); font-weight: 600; }
.modes button:disabled { opacity: .4; cursor: not-allowed; }
.rig-detail .where { display: inline-flex; align-items: center; gap: .35rem; }
.rig-detail .where svg { color: var(--muted); }

/* ---------- imaging settings on each target */
.settings {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px 18px; margin: .4rem 0 .7rem; padding: 10px 0; border-top: 1px dashed var(--rule); border-bottom: 1px dashed var(--rule);
  max-width: 760px;
}
.settings div { min-width: 0; }
.settings dt { color: var(--muted); font-size: var(--s-1); }
.settings dd { margin: 0; font-weight: 500; }
.settings dd small { display: block; color: var(--muted); font-weight: 400; font-size: var(--s-1); line-height: 1.3; }

/* ---------- location picker */
.picker { display: flex; flex-direction: column; gap: 12px; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; border: 1px solid var(--rule); border-radius: 12px; padding: 3px; }
.seg button { flex: 1 1 auto; border: 0; border-radius: 9px; min-height: 36px; justify-content: center; }
.seg button[aria-selected="true"] { background: var(--ink); color: var(--sky); font-weight: 600; }
.row.nowrap { flex-wrap: nowrap; }
.row.nowrap input { flex: 1; }
.results button[aria-pressed="true"] { border-color: var(--ink); background: var(--sky); }
.picker .sel { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--sky); color: var(--muted); }
.picker .sel b { color: var(--ink); font-weight: 500; }
.picker .msg { margin: 0; min-height: 1em; }
.picker code { color: var(--ink); }
#locForm label.check { align-self: flex-start; }

/* ---------- accounts */
.acct { padding: .3rem .8rem .3rem .3rem; }
.acct:not(.in) { padding-left: .85rem; }
.acct:not(.in) .avatar { display: none; }
.avatar {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--moon); color: var(--sky); font-weight: 600; font-size: var(--s-1); letter-spacing: .02em;
}
.avatar.big { width: 52px; height: 52px; font-size: var(--s1); }
@media (max-width: 560px) { .acct.in #acctLabel { display: none; } .acct.in { padding: .3rem; } }

.store-note { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin: 10px 0 0; color: var(--muted); font-size: var(--s-1); }
.store-note svg { width: 1em; height: 1em; }
.store-note b { color: var(--ink); font-weight: 500; }
button.link { border: 0; padding: 0; min-height: 0; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; border-radius: 2px; }

.dlg .msg { margin: 0; min-height: 1.2em; color: var(--cloud); font-size: var(--s-1); }
.dlg .msg:empty { min-height: 0; }
.who { display: flex; align-items: center; gap: 14px; }
.who h2 { font-size: var(--s1); }
.who p { margin: .15rem 0 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.stack button { justify-content: center; }
details { border-top: 1px solid var(--rule); padding-top: 12px; }
details[open] { display: flex; flex-direction: column; gap: 10px; }
summary { cursor: pointer; color: var(--muted); }
.pw { display: flex; gap: 6px; }
.pw input { flex: 1; }
.pw .reveal { flex: none; min-width: 64px; justify-content: center; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.admin-table { border-top: 0; margin: 0; }
.admin-table table { width: 100%; white-space: normal; }
.admin-table th, .admin-table td { text-align: left; vertical-align: top; padding: 8px 8px 8px 0; }
.admin-table thead th { color: var(--muted); font-weight: 400; }
.admin-table .actions { white-space: nowrap; text-align: right; }
.admin-table .actions button { min-height: 32px; padding: .2rem .65rem; font-size: var(--s-1); }
.new-user { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
@media (max-width: 560px) { .new-user { grid-template-columns: 1fr; } }
.notice { border: 1px solid var(--clear); border-radius: 12px; padding: 12px 14px; }
.notice p { margin: .2rem 0; }
.notice .temp { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.notice code { font-size: var(--s1); color: var(--ink); letter-spacing: .04em; }
@media (max-width: 560px) {
  .bar { gap: .4rem; padding-left: 12px; padding-right: 12px; }
  .brand { font-size: 0; gap: 0; }
  .brand-mark { width: 28px; height: 28px; }
}
.dlg > label.check { align-self: flex-start; }
