:root {
  --bg: #05070f;
  --bg-2: #0b1020;
  --ink: #eef1fa;
  --ink-2: #aab2c8;
  --ink-3: #6e7791;
  --gold: #ffd47a;
  --gold-2: #ffb347;
  --line: rgba(255, 255, 255, 0.10);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--sans);
  -webkit-font-smoothing: antialiased; overscroll-behavior: none; -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--gold); }

/* ---------- intro ---------- */
.stars-bg {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(1px 1px at 12% 18%, #fff 60%, transparent 61%),
    radial-gradient(1.5px 1.5px at 78% 12%, #fff 60%, transparent 61%),
    radial-gradient(1px 1px at 34% 62%, #fff 60%, transparent 61%),
    radial-gradient(1px 1px at 88% 48%, #fff 60%, transparent 61%),
    radial-gradient(1.2px 1.2px at 56% 82%, #fff 60%, transparent 61%),
    radial-gradient(1px 1px at 22% 88%, #fff 60%, transparent 61%),
    radial-gradient(1px 1px at 66% 34%, #fff 60%, transparent 61%),
    radial-gradient(0.8px 0.8px at 44% 28%, #fff 60%, transparent 61%),
    radial-gradient(1px 1px at 8% 50%, #fff 60%, transparent 61%),
    radial-gradient(1.3px 1.3px at 92% 80%, #fff 60%, transparent 61%),
    radial-gradient(ellipse at 50% 110%, #1a2140 0%, transparent 60%),
    var(--bg);
  opacity: 0.9;
}
.intro {
  position: relative; z-index: 1; min-height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 48px 24px 32px;
}
.card { width: 100%; max-width: 440px; }
.eyebrow { font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 18px; }
.star-name {
  font-family: var(--serif); font-weight: 400; font-size: clamp(56px, 16vw, 84px); line-height: 1; margin: 0; letter-spacing: -0.01em;
  color: var(--ink);
}
.star-name .glyph { color: var(--gold); font-size: 0.55em; vertical-align: 0.35em; margin-left: 0.1em; text-shadow: 0 0 24px rgba(255, 212, 122, 0.6); }
.dedication { font-family: var(--serif); font-size: 20px; color: var(--ink-2); margin: 10px 0 0; }
.message { font-family: var(--serif); font-style: italic; font-size: 19px; line-height: 1.5; color: var(--ink); margin: 26px 0 0; padding-left: 14px; border-left: 2px solid var(--gold); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; margin: 32px 0 0; padding: 20px 0 0; border-top: 1px solid var(--line); }
.facts dt { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 4px; }
.facts dd { margin: 0; font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; }
.facts dd.mono { font-family: var(--mono); font-size: 13px; }
.actions { margin-top: 32px; display: grid; gap: 10px; }
.btn {
  border: 0; border-radius: 14px; padding: 16px 20px; font-size: 17px; font-weight: 600; width: 100%;
  background: rgba(255, 255, 255, 0.06); color: var(--ink); transition: transform 0.12s ease, background 0.2s;
}
.btn:active { transform: scale(0.985); }
.btn.primary { background: linear-gradient(180deg, var(--gold), var(--gold-2)); color: #1a1200; box-shadow: 0 8px 30px rgba(255, 190, 90, 0.25); }
.btn.ghost { background: transparent; color: var(--ink-2); font-weight: 500; }
.foot { margin-top: 28px; text-align: center; font-size: 13px; color: var(--ink-3); }
.foot a { color: var(--ink-2); text-decoration: none; border-bottom: 1px solid var(--line); }
details.how { margin-top: 22px; color: var(--ink-2); font-size: 14px; line-height: 1.55; }
details.how summary { cursor: pointer; color: var(--ink-2); list-style: none; }
details.how summary::-webkit-details-marker { display: none; }
details.how summary::before { content: "+ "; color: var(--gold); }
details.how[open] summary::before { content: "− "; }
details.how p { margin: 10px 0 0; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 50;
  background: rgba(20, 24, 40, 0.92); color: var(--ink); padding: 10px 16px; border-radius: 12px; font-size: 14px;
  border: 1px solid var(--line); backdrop-filter: blur(10px); opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* ---------- finder ---------- */
.finder {
  position: fixed; inset: 0; z-index: 10; overflow: hidden;
  background: radial-gradient(ellipse at 50% 120%, #17203d 0%, #0a0e1c 45%, var(--bg) 100%);
  user-select: none;
}
.finder video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.4s; }
.finder.camera video { opacity: 1; }
.finder canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.finder.camera canvas { opacity: 0.85; }
.finder .vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(0, 0, 0, 0.55) 100%); }

.hud-top {
  z-index: 5;
  position: absolute; top: 0; left: 0; right: 0; padding: calc(env(safe-area-inset-top) + 14px) 16px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent);
}
.hud-title { text-align: center; flex: 1; min-width: 0; }
.hud-title .name { font-family: var(--serif); font-size: 20px; }
.hud-title .name .glyph { color: var(--gold); }
.hud-title .status { font-size: 12px; color: var(--ink-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: rgba(10, 12, 24, 0.55);
  display: grid; place-items: center; backdrop-filter: blur(8px); flex: 0 0 auto;
}
.icon-btn svg { width: 20px; height: 20px; stroke: var(--ink); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.on { border-color: var(--gold); }
.icon-btn.on svg { stroke: var(--gold); }

.reticle {
  position: absolute; left: 50%; top: 50%; width: 132px; height: 132px; margin: -66px 0 0 -66px; border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.45); pointer-events: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.reticle::before, .reticle::after { content: ""; position: absolute; background: rgba(255, 255, 255, 0.45); }
.reticle::before { left: 50%; top: -10px; width: 1px; height: 12px; margin-left: -0.5px; box-shadow: 0 130px 0 rgba(255, 255, 255, 0.45); }
.reticle::after { top: 50%; left: -10px; height: 1px; width: 12px; margin-top: -0.5px; box-shadow: 130px 0 0 rgba(255, 255, 255, 0.45); }
.finder.locked .reticle { border-color: var(--gold); box-shadow: 0 0 0 6px rgba(255, 212, 122, 0.15), 0 0 40px rgba(255, 212, 122, 0.45); }

.arrow { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; }
.arrow .chev {
  position: absolute; left: -22px; top: -118px; width: 44px; height: 44px;
  display: grid; place-items: center; color: var(--gold);
  filter: drop-shadow(0 0 10px rgba(255, 212, 122, 0.7));
  animation: nudge 1.2s ease-in-out infinite;
}
.arrow .chev svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.marker { position: absolute; left: 0; top: 0; pointer-events: none; will-change: transform; }
.marker .dot {
  position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 14px 4px rgba(255, 212, 122, 0.55), 0 0 40px 12px rgba(255, 212, 122, 0.2);
}
.marker .ring { position: absolute; left: -26px; top: -26px; width: 52px; height: 52px; border-radius: 50%; border: 1.5px solid rgba(255, 212, 122, 0.8); animation: ring 1.8s ease-out infinite; }
@keyframes ring { 0% { transform: scale(0.5); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }
.marker .label { position: absolute; left: 20px; top: -10px; font-family: var(--serif); font-size: 17px; color: var(--gold); white-space: nowrap; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8); }

.hud-bottom {
  z-index: 3;
  position: absolute; left: 0; right: 0; bottom: 0; padding: 20px 20px calc(env(safe-area-inset-bottom) + 22px);
  text-align: center; background: linear-gradient(0deg, rgba(0, 0, 0, 0.7), transparent);
}
.sep { font-size: 54px; font-weight: 300; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.sep small { font-size: 16px; color: var(--ink-2); font-weight: 400; margin-left: 4px; }
.guide { font-size: 18px; margin-top: 8px; min-height: 24px; }
.pointing { font-size: 13px; color: var(--ink-3); margin-top: 8px; font-variant-numeric: tabular-nums; }
.found { display: none; font-family: var(--serif); font-size: 26px; color: var(--gold); }
.found .msg { display: block; font-size: 16px; font-style: italic; color: var(--ink); margin-top: 8px; line-height: 1.45; }
.finder.locked .sep, .finder.locked .guide { display: none; }
.finder.locked .found { display: block; }
.finder.locked .arrow { display: none; }

.notice {
  z-index: 4;
  position: absolute; left: 16px; right: 16px; top: calc(env(safe-area-inset-top) + 78px);
  background: rgba(20, 24, 40, 0.85); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px;
  font-size: 13px; line-height: 1.45; color: var(--ink-2); backdrop-filter: blur(10px); text-align: center;
}
.notice strong { color: var(--ink); }

/* ---------- desk / no-sensor mode ---------- */
.desk {
  z-index: 2;
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 80px 24px 40px; text-align: center; gap: 18px;
}
.desk h2 { font-family: var(--serif); font-weight: 400; font-size: 26px; margin: 0; }
.desk p { margin: 0; color: var(--ink-2); font-size: 15px; line-height: 1.5; max-width: 380px; }
.rose { width: 180px; height: 180px; }
.rose .needle { transform-origin: 50% 50%; transition: transform 0.6s ease; }
.desk .big { font-size: 22px; color: var(--ink); }
.desk code { font-family: var(--mono); font-size: 12px; color: var(--ink-2); word-break: break-all; }

/* ---------- location fallback ---------- */
.sheet {
  z-index: 6;
  position: absolute; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 16px);
  background: rgba(14, 18, 32, 0.96); border: 1px solid var(--line); border-radius: 16px; padding: 18px;
}
.sheet h3 { margin: 0 0 6px; font-size: 16px; }
.sheet p { margin: 0 0 12px; font-size: 13px; color: var(--ink-2); }
.sheet .row { display: flex; gap: 8px; }
.sheet input { flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: #0a0d1a; color: var(--ink); }
.sheet .btn { margin-top: 10px; padding: 12px; font-size: 15px; }

/* ---------- create page ---------- */
.create { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; padding: 40px 20px 80px; }
.create h1 { font-family: var(--serif); font-weight: 400; font-size: 36px; margin: 0 0 6px; }
.create .lead { color: var(--ink-2); margin: 0 0 28px; line-height: 1.5; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; font: inherit; font-size: 16px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: #0a0d1a; color: var(--ink);
}
.field textarea { min-height: 80px; resize: vertical; }
.field .hint { font-size: 12px; color: var(--ink-3); margin-top: 6px; line-height: 1.4; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.result { margin-top: 28px; padding: 18px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); }
.result .url { font-family: var(--mono); font-size: 12px; color: var(--ink-2); word-break: break-all; margin: 0 0 12px; line-height: 1.5; }
.result .row { display: flex; gap: 10px; }
.result .row .btn { padding: 12px; font-size: 15px; }
.preview { margin-top: 18px; font-family: var(--serif); color: var(--ink-2); font-size: 15px; line-height: 1.5; }
.preview b { color: var(--ink); font-weight: 400; font-size: 22px; }
.preview .glyph { color: var(--gold); }
.err { color: #ff9b9b; font-size: 13px; margin-top: 8px; }

/* desk mode: no aiming UI */
.finder.desk-mode .arrow, .finder.desk-mode .reticle, .finder.desk-mode .hud-bottom, .finder.desk-mode .marker { display: none; }
