/* Frame Atlas — deep-indigo glass over a full-bleed sky, amber accent. */
:root {
  --ink: #0b0d17;
  --glass: rgba(16, 19, 36, .80);
  --glass-solid: #12152a;
  --field: rgba(255, 255, 255, .06);
  --field-hover: rgba(255, 255, 255, .10);
  --line: rgba(255, 255, 255, .10);
  --text: #ece9f6;
  --muted: #9d9bb6;
  --accent: #ffb454;
  --accent-ink: #2b1700;
  --danger: #ff7a90;
  --ring: #ffd9a0;
  --dock-w: 376px;
  --font: "Segoe UI Variable Text", "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --mono: "Cascadia Mono", "SF Mono", ui-monospace, Consolas, monospace;
}
/* red-only palette for use at the eyepiece / telescope without losing dark adaptation */
:root[data-theme="night"] {
  --ink: #050000;
  --glass: rgba(24, 4, 3, .84);
  --glass-solid: #180403;
  --field: rgba(255, 70, 40, .08);
  --field-hover: rgba(255, 70, 40, .14);
  --line: rgba(255, 90, 60, .22);
  --text: #ff9a80;
  --muted: #b65a48;
  --accent: #ff4b2b;
  --accent-ink: #1c0400;
  --danger: #ff8a70;
  --ring: #ff7a5c;
}
:root[data-theme="night"] #aladin-lite-div canvas.aladin-imageCanvas { filter: grayscale(1) sepia(1) saturate(5) hue-rotate(-45deg) brightness(.72) contrast(1.05); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--text); font: 14px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hint, .sub, small { color: var(--muted); font-size: 12px; }
.hint { margin: 6px 0 0; }
.only-mobile { display: none !important; }   /* wins over .round's inline-grid */

.app { position: fixed; inset: 0; }
.viewer { position: absolute; inset: 0; overflow: hidden; }
#aladin-lite-div { position: absolute; inset: 0; }

/* ---------- controls ---------- */
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
input[type=text], input[type=number], input[type=password], input[type=email], select, textarea {
  background: var(--field); border: 1px solid transparent; border-radius: 10px; padding: 9px 12px; min-width: 0; width: 100%;
  transition: background .15s, border-color .15s;
}
input:hover, select:hover, textarea:hover { background: var(--field-hover); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); background: var(--field-hover); }
select { appearance: none; padding-right: 30px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
select option { background: var(--glass-solid); color: var(--text); }

.btn { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px; padding: 8px 18px; font-weight: 700; cursor: pointer; white-space: nowrap; transition: transform .1s, filter .15s; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 600; }
.btn.ghost:hover { background: var(--field); filter: none; }
.btn.wide { width: 100%; margin-top: 12px; }
.round { width: 38px; height: 38px; flex: none; display: inline-grid; place-items: center; border-radius: 50%; background: var(--field); border: 1px solid var(--line); cursor: pointer; padding: 0; color: var(--text); transition: background .15s; }
.round:hover { background: var(--field-hover); }
a.round { text-decoration: none; }
.round[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.round.sm { width: 30px; height: 30px; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 15px; padding: 0 4px; }

/* switch */
.switch { display: flex; gap: 12px; align-items: flex-start; margin-top: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { flex: none; width: 36px; height: 20px; margin-top: 1px; border-radius: 999px; background: var(--field-hover); border: 1px solid var(--line); position: relative; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + .track { background: var(--accent); border-color: transparent; }
.switch input:checked + .track::after { transform: translateX(16px); background: var(--accent-ink); }
.switch input:focus-visible + .track { outline: 2px solid var(--ring); outline-offset: 2px; }
.switch small { display: block; }

.row { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.row select { flex: 1; }

/* ---------- top bar ---------- */
.topbar { position: absolute; z-index: 30; top: 12px; left: 64px; right: calc(var(--dock-w) + 36px); max-width: 720px;
  display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 14px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35); transition: right .25s; }
.dock-collapsed .topbar { right: 64px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--accent); flex: none; }
.brand h1 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: .06em; color: var(--text); white-space: nowrap; }
.search { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; }
.search input { padding-left: 34px; padding-right: 40px; border-radius: 999px; background: var(--field); height: 38px; }
.search-ico { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.go { position: absolute; right: 4px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 800; cursor: pointer; }
.results { position: absolute; left: 0; right: 0; top: calc(100% + 8px); margin: 0; padding: 6px; list-style: none; background: var(--glass-solid); border: 1px solid var(--line); border-radius: 16px; max-height: 340px; overflow-y: auto; box-shadow: 0 14px 40px rgba(0, 0, 0, .5); }
.results li { padding: 8px 10px; border-radius: 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.results li:hover, .results li.active { background: var(--field-hover); }
.results .sub { white-space: nowrap; }
.results .alias { color: var(--muted); font-size: 12px; margin-left: 4px; }
.toast { position: absolute; z-index: 25; top: 64px; left: 78px; margin: 0; max-width: min(520px, calc(100vw - 500px)); padding: 3px 12px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); font-size: 12px; color: var(--muted); backdrop-filter: blur(10px); }
.toast:empty { display: none; }

/* always-visible credit line (CC BY needs the credit to be clear and readable) */
.credit-strip { position: absolute; z-index: 20; left: 50%; bottom: 8px; transform: translateX(-50%); max-width: calc(100vw - 560px);
  display: flex; align-items: center; gap: 8px; padding: 2px 4px 2px 12px; border-radius: 12px;
  background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  font-size: 10.5px; line-height: 1.5; color: var(--text); }
#credit-text { min-width: 0; overflow-wrap: anywhere; }
.credit-btn { flex: none; background: var(--field-hover); color: var(--accent); border: 0; border-radius: 999px; padding: 1px 9px; font-size: 10.5px; font-weight: 700; cursor: pointer; }
.credit-btn:hover { background: var(--accent); color: var(--accent-ink); }
.dock-collapsed .credit-strip { max-width: calc(100vw - 260px); }

.readout { position: absolute; z-index: 20; left: 50%; bottom: 44px; transform: translateX(-50%); padding: 4px 14px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); font: 12px var(--mono); font-variant-numeric: tabular-nums; letter-spacing: .02em; pointer-events: none; backdrop-filter: blur(10px); white-space: nowrap; }

/* ---------- dock ---------- */
.dock { position: absolute; z-index: 30; top: 62px; right: 12px; bottom: 52px; width: var(--dock-w);
  display: flex; flex-direction: column; border-radius: 22px; overflow: hidden;
  background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3);
  box-shadow: 0 14px 44px rgba(0, 0, 0, .45); transition: transform .25s, opacity .25s; }
.dock-collapsed .dock { transform: translateX(calc(100% + 24px)); opacity: 0; pointer-events: none; }
.dock-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 0; }
.tabs { display: flex; flex: 1; gap: 2px; padding: 3px; border-radius: 999px; background: var(--field); }
.tab { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 8px; border: 0; border-radius: 999px; background: none; color: var(--muted); font-weight: 600; cursor: pointer; transition: background .15s, color .15s; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.dock-body { flex: 1; overflow-y: auto; padding: 6px 16px 22px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.group { padding-top: 16px; }
.group + .group { border-top: 1px solid var(--line); margin-top: 16px; }
.group-title { margin: 14px 0 8px; font-size: 11px; font-weight: 700; letter-spacing: .14em; color: var(--muted); }
.group > .group-title { margin-top: 0; }

/* angle */
.seg { display: flex; padding: 3px; border-radius: 999px; background: var(--field); margin-bottom: 12px; }
.seg button { flex: 1; padding: 6px 10px; border: 0; border-radius: 999px; background: none; color: var(--muted); font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--field-hover); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.angle-row { display: flex; align-items: center; gap: 12px; }
input[type=range] { flex: 1; appearance: none; height: 4px; border-radius: 4px; background: var(--field-hover); padding: 0; border: 0; }
input[type=range]::-webkit-slider-thumb { appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 3px solid var(--glass-solid); box-shadow: 0 0 0 1px var(--accent); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 3px solid var(--glass-solid); cursor: pointer; }
.angle-box { position: relative; width: 74px; }
.angle-box input { padding-right: 20px; text-align: right; font-family: var(--mono); }
.angle-box i { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--muted); }

/* cameras */
.cams { display: flex; flex-direction: column; gap: 10px; }
.cam { position: relative; padding: 10px 12px 10px 15px; border-radius: 14px; background: var(--field); overflow: hidden; }
.cam::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.cam-fields { display: grid; grid-template-columns: 1fr 1.7fr auto; gap: 8px; align-items: end; }
.cam-fields .cap { display: block; font-size: 10.5px; letter-spacing: .1em; color: var(--muted); margin-bottom: 3px; }
.num { display: flex; align-items: center; gap: 4px; }
.num input { padding: 6px 8px; text-align: right; font-family: var(--mono); background: rgba(0, 0, 0, .25); }
.num i { font-style: normal; color: var(--muted); font-size: 12px; }
.cam .del { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; padding: 6px; border-radius: 8px; }
.cam .del:hover:not(:disabled) { color: var(--danger); background: rgba(255, 122, 144, .12); }
.cam .del:disabled { opacity: .3; cursor: default; }
.switch:has(input:disabled) { opacity: .45; cursor: default; }
.cam-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.dims { font: 600 15px var(--mono); font-variant-numeric: tabular-nums; color: var(--c); }
.cam-angle { display: none; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.cam-angle input { width: 64px; padding: 4px 8px; text-align: right; font-family: var(--mono); background: rgba(0, 0, 0, .25); }
.independent .cam .cam-angle { display: inline-flex; }
.add-row { display: flex; gap: 8px; margin-top: 12px; }
.add-row select { flex: 1; }

/* layers */
.kinds { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.kinds label { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px 5px 10px; border-radius: 999px; background: var(--field); border: 1px solid transparent; cursor: pointer; font-size: 13px; user-select: none; }
.kinds label:has(input:checked) { border-color: var(--line); background: var(--field-hover); }
.kinds label:not(:has(input:checked)) { opacity: .5; }
.kinds input { position: absolute; opacity: 0; pointer-events: none; }
.kinds .dot { width: 9px; height: 9px; border-radius: 50%; }
.sub-title { margin-top: 18px; }
.dens-hint { margin: -4px 0 0; }
.credits { margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.7; }
.credits p { margin: 0 0 6px; }

/* frames */
.login { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.auth-lead { margin: 0 0 12px; line-height: 1.6; }
.auth-lead b { color: var(--text); }
.login .link.left { align-self: flex-start; padding: 0; font-size: 12.5px; }
.hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; opacity: 0; pointer-events: none; }   /* honeypot for bots */
.account-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; margin-bottom: 12px; border-radius: 12px; background: var(--field); }
.account-row .who { min-width: 0; overflow-wrap: anywhere; font-size: 12.5px; }
.account-row .who small { display: block; color: var(--muted); font-size: 11px; }
.btn.small { padding: 4px 12px; font-size: 12px; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn.danger:hover { background: rgba(255, 122, 144, .12); filter: none; }
.account-settings { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 10px; }
.account-settings summary { cursor: pointer; color: var(--muted); font-size: 12.5px; padding: 4px 0; }
.account-settings .login { margin-top: 14px; }
.account-settings .login + .login { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); }
.danger-title { color: var(--danger); }
#fr-filter { margin-top: 12px; }
.tagbar { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.clear-link { margin-top: 8px; padding: 0; font-size: 12px; }
.tag { background: var(--field); color: var(--muted); border: 1px solid transparent; border-radius: 999px; padding: 2px 11px; font-size: 12px; cursor: pointer; }
.tag:hover { color: var(--text); }
.tag.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.frames { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.frames > .hint { grid-column: 1 / -1; }
.frame { display: flex; flex-direction: column; border-radius: 14px; overflow: hidden; background: var(--field); border: 1px solid var(--line); }
.frame-open { display: flex; flex-direction: column; align-items: stretch; width: 100%; padding: 0; border: 0; background: none; color: inherit; text-align: left; cursor: pointer; }
.thumb { width: 100%; height: auto; aspect-ratio: 8 / 5; object-fit: cover; background: #06070d; display: block; }
.thumb.none { visibility: hidden; }
.frame-info { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 0; min-width: 0; }
.frame-info strong { font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.frame-open:hover strong { color: var(--accent); }
.frame .sub { font-size: 10.5px; line-height: 1.4; overflow-wrap: anywhere; }
.frame-tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 10px 0; }
.chip { background: var(--field-hover); color: var(--muted); border-radius: 999px; padding: 0 8px; font-size: 10.5px; }
.frame-note { margin: 6px 10px 0; font-size: 11.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.frame-actions { display: flex; gap: 4px; justify-content: flex-end; padding: 6px 8px 8px; margin-top: auto; }
.mini { background: none; border: 0; color: var(--muted); border-radius: 8px; padding: 2px 7px; font-size: 11.5px; cursor: pointer; white-space: nowrap; }
.mini:hover { color: var(--text); background: var(--field-hover); }
a.mini { text-decoration: none; display: inline-block; }
.frame-actions { flex-wrap: wrap; gap: 0; justify-content: space-between; }
.frame-actions .mini { padding: 2px 5px; }
.season-link { display: block; margin-top: 14px; padding: 10px 14px; border-radius: 12px; background: var(--field); border: 1px solid var(--line); color: var(--text); text-decoration: none; font-weight: 600; }
.season-link:hover { background: var(--field-hover); border-color: var(--accent); }
.season-link small { display: block; font-weight: 400; margin-top: 2px; }
.mini.danger:hover { color: var(--danger); }
.export { margin-top: 22px; padding-top: 4px; border-top: 1px solid var(--line); }
.export .group-title { margin-top: 14px; }

/* ---------- dialog ---------- */
dialog { background: var(--glass-solid); color: var(--text); border: 1px solid var(--line); border-radius: 22px; padding: 22px; width: min(92vw, 440px); box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
dialog::backdrop { background: rgba(4, 5, 12, .7); backdrop-filter: blur(3px); }
dialog h3 { margin: 0 0 12px; font-size: 16px; letter-spacing: .04em; }
dialog form { display: flex; flex-direction: column; gap: 12px; }
dialog label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
dialog label.switch { flex-direction: row; color: var(--text); font-size: 13px; margin-top: 0; }
dialog #fr-preview { width: 100%; height: auto; aspect-ratio: 8 / 5; object-fit: cover; border-radius: 12px; background: #06070d; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }
dialog.wide-dialog { width: min(94vw, 760px); max-height: 88vh; padding: 0; }
.credits-body { padding: 22px; max-height: 88vh; overflow-y: auto; font-size: 12.5px; line-height: 1.7; }
.credits-body h4 { margin: 18px 0 6px; font-size: 11px; letter-spacing: .14em; color: var(--muted); }
.credits-body ul { margin: 0; padding-left: 18px; }
.credits-body li { margin-bottom: 8px; }
.credits-body .ack { display: block; color: var(--muted); font-size: 11.5px; }
.credits-body .dialog-actions { margin-top: 14px; }

/* Aladin's own controls sit in the corners; keep them clear of our bars */
#aladin-lite-div .aladin-logo-container { z-index: 5; }

/* ---------- small screens: the dock becomes a bottom sheet ---------- */
@media (max-width: 760px) {
  :root { --dock-w: 100%; }
  .only-mobile { display: inline-grid !important; }
  .topbar { left: 56px; right: 8px; top: 8px; padding-left: 10px; gap: 6px; }
  .brand h1 { display: none; }
  .toast { left: 64px; top: 58px; max-width: calc(100vw - 80px); }
  .dock { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; height: min(66vh, 560px); transform: translateY(calc(100% + 24px)); opacity: 1; }
  .dock.open { transform: none; }
  .dock-collapsed .dock { transform: translateY(calc(100% + 24px)); }
  .dock-collapsed .dock.open { transform: none; opacity: 1; pointer-events: auto; }
  .dock-collapsed .topbar { right: 8px; }
  .readout { left: 8px; bottom: 40px; transform: none; font-size: 11px; }
  .credit-strip { left: 8px; right: 8px; bottom: 6px; transform: none; max-width: none; }
  .dock { bottom: 40px; height: min(60vh, 520px); }
  .frames { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* language switch: a small round button in the top bar; on phones the switch lives in the Display tab instead */
.lang-toggle { font: 700 11px/1 system-ui, sans-serif; letter-spacing: .04em; }
@media (max-width: 760px) { .lang-toggle { display: none !important; } }

/* Aladin's own coordinate read-out sat (half hidden) under our top bar; we show the centre coordinates ourselves */
#aladin-lite-div .aladin-location { display: none !important; }
.fs-toggle[hidden] { display: none !important; }
@media (max-width: 760px) { .fs-toggle { display: none !important; } }
