/* 별씨 키우기 — always a night palette; "light" variant is only a softer dusk */
:root {
  --sky1: #0E1030; --sky2: #1C1B4A; --sky3: #3A2A63;
  --ink: #EDEBFF; --mut: #A9A6D6; --line: rgba(255, 255, 255, .12); --panel: rgba(255, 255, 255, .07);
  --accent: #FFE08A; --accent-ink: #1A1640; --warn: #FFB4C2;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { --sky1: #1E2257; --sky2: #3B3A7A; --sky3: #6B4E8E; }
}
:root[data-theme="light"] { --sky1: #1E2257; --sky2: #3B3A7A; --sky3: #6B4E8E; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; color: var(--ink); overflow-x: hidden;
  background: linear-gradient(180deg, var(--sky1) 0%, var(--sky2) 55%, var(--sky3) 100%) fixed, var(--sky1);
  font: 16px/1.6 "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}
#sky { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.02em; }
h3 { margin: 22px 0 8px; font-size: 16px; }
.muted { color: var(--mut); margin: 0 0 12px; }
.small { font-size: 13px; }
.center { text-align: center; justify-content: center; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--panel); padding: 1px 6px; border-radius: 6px; }

.shell {
  position: relative; z-index: 1; max-width: 560px; margin: 0 auto; min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 10px) 16px calc(env(safe-area-inset-bottom) + 88px);
}
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.who { display: flex; align-items: center; gap: 8px; }
.who strong { font-size: 20px; letter-spacing: -.02em; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; white-space: nowrap;
  background: var(--panel); border: 1px solid var(--line); font-size: 13px; font-weight: 600; backdrop-filter: blur(6px);
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: #6E6A99; }
body.robot .chip .dot { background: #7BE0A8; box-shadow: 0 0 8px #7BE0A8; }

/* home */
.view { animation: fade .4s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }
#v-home { display: flex; flex-direction: column; align-items: center; }
.speech {
  min-height: 3.2em; margin: 14px 0 0; text-align: center; color: #F6F3FF; font-size: 16px; max-width: 420px;
  text-shadow: 0 0 12px rgba(180, 170, 255, .5); transition: opacity .4s;
}
.spirit-wrap { width: min(68vw, 290px); aspect-ratio: 1; cursor: pointer; -webkit-tap-highlight-color: transparent; }
@media (max-height: 720px) { .spirit-wrap { width: min(52vw, 220px); } }
.growth { width: 100%; margin-top: 4px; }
.growth-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--mut); margin-bottom: 6px; }
.track { display: block; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.track b { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #A9C1FF, #FFE08A); box-shadow: 0 0 10px #FFE08A; transition: width .8s ease; }
.lights { list-style: none; padding: 0; margin: 14px 0 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; width: 100%; }
.lights li { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); font-size: 12px; }
.lights .orb { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; position: relative; }
.lights .orb::before { content: ""; position: absolute; inset: -4px; border-radius: 50%; background: radial-gradient(circle, var(--c) 0%, transparent 70%); opacity: var(--a); }
.lights li b { font-size: 11px; color: var(--mut); font-weight: 600; font-variant-numeric: tabular-nums; }
.lights li.full b { color: var(--accent); }
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; margin-top: 12px; }
.actions button {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 4px; min-height: 72px; border-radius: 18px;
  background: var(--panel); border: 1px solid var(--line); font-size: 13px; font-weight: 700; backdrop-filter: blur(6px);
}
.actions button span { font-size: 22px; }
.actions button:active { transform: scale(.97); }
.actions button.done { opacity: .55; }
.mic {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 54px; margin-top: 10px;
  border-radius: 999px; border: 1px solid rgba(255, 224, 138, .5); background: rgba(255, 224, 138, .12); font-weight: 800;
}
.mic.on { background: rgba(255, 180, 194, .25); border-color: var(--warn); animation: glow 1.4s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 22px rgba(255, 180, 194, .6); } }
.heard { margin: 6px 0 0; color: var(--mut); font-size: 13px; min-height: 1.4em; text-align: center; }
.demo-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; margin-top: 10px; padding: 8px 12px; border-radius: 14px; border: 1px dashed rgba(255, 224, 138, .5); font-size: 13px; color: var(--accent); }
.demo-bar button { background: none; border: 1px solid rgba(255, 224, 138, .5); border-radius: 999px; padding: 6px 12px; color: var(--accent); font-weight: 700; }

/* panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 14px 16px; backdrop-filter: blur(8px); }
#v-stars, #v-dex, #v-settings { padding-top: 18px; }
#constellation { width: 100%; height: auto; display: block; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 12px; }
.stats div { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; }
.stats b { display: block; font-size: 20px; }
.stats small { color: var(--mut); }
.total { display: grid; grid-template-columns: 70px 1fr 40px; align-items: center; gap: 8px; font-size: 14px; margin: 6px 0; }
.total i { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.total i b { display: block; height: 100%; border-radius: inherit; }
.total em { font-style: normal; color: var(--mut); text-align: right; font-size: 12px; }
.dex { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.dex article { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 10px; text-align: center; }
.dex .mini { width: 110px; height: 110px; margin: 0 auto; }
.dex h4 { margin: 4px 0 0; font-size: 15px; }
.dex p { margin: 0; color: var(--mut); font-size: 12px; }
.dex.hints article { opacity: .75; }
.dex.hints .q { font-size: 44px; filter: grayscale(1) brightness(.6); height: 70px; display: grid; place-items: center; }
.empty { color: var(--mut); grid-column: 1 / -1; text-align: center; padding: 18px; }

/* forms */
.field { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 700; margin-bottom: 10px; }
.field input, .row input, textarea {
  min-width: 0; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, .25); min-height: 44px;
}
.field input { flex: 1; max-width: 220px; }
textarea { width: 100%; resize: vertical; margin: 10px 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row input { flex: 1; }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 700; min-height: 44px; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }
.shell button:not(.linklike):not(.chip), dialog button, .overlay button {
  min-height: 44px; padding: 10px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); font-weight: 700;
}
.primary { background: var(--accent) !important; color: var(--accent-ink) !important; border-color: transparent !important; box-shadow: 0 0 18px rgba(255, 224, 138, .35); }
.ghost { background: transparent !important; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.ok { margin: 0 0 8px; font-weight: 700; word-break: break-all; }
.warn { color: var(--warn); font-size: 14px; margin: 8px 0 0; }
.warn:empty { display: none; }
.when-on { display: none; }
body.robot .when-on { display: block; }
body.robot .when-off { display: none; }

/* tabs */
.tabs {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 10px); transform: translateX(-50%); z-index: 3;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; width: min(528px, calc(100vw - 32px));
  padding: 6px; border-radius: 22px; background: rgba(14, 16, 48, .75); border: 1px solid var(--line); backdrop-filter: blur(12px);
}
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 0; border: 0 !important; background: none !important; font-size: 12px; font-weight: 700; color: var(--mut); padding: 6px 0 !important; min-height: 52px !important; }
.tabs button span { font-size: 20px; }
.tabs button.on { color: var(--ink); background: rgba(255, 255, 255, .1) !important; }

/* dialogs & overlays */
dialog {
  width: min(480px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); border: 1px solid var(--line); border-radius: 24px;
  padding: 20px; color: var(--ink); background: linear-gradient(180deg, #23215A, #171640); box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
}
dialog::backdrop { background: rgba(6, 6, 24, .65); backdrop-filter: blur(3px); }
.onboard-art, .evolve-art { width: 160px; height: 160px; margin: 0 auto 6px; }
.evolve-art { width: 220px; height: 220px; }
.modes { border: 0; padding: 0; margin: 6px 0 14px; display: grid; gap: 8px; }
.modes legend { font-weight: 700; margin-bottom: 6px; }
.modes label { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; }
.modes label:has(input:checked) { border-color: var(--accent); }
.modes span { display: flex; flex-direction: column; }
.modes small { color: var(--mut); }
.modes input { accent-color: var(--accent); width: 18px; height: 18px; }
.grow-btn { flex: 1; }
.moods { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 10px; }
.moods button { display: flex; flex-direction: column; align-items: center; font-size: 30px; padding: 8px 0 !important; }
.moods button small { font-size: 12px; color: var(--mut); }
.moods button.picked { border-color: var(--accent) !important; background: rgba(255, 224, 138, .15) !important; }
.row.center { justify-content: center; }
dialog .row { justify-content: flex-end; }

.overlay {
  position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px;
  background: rgba(8, 8, 30, .82); backdrop-filter: blur(6px);
}
.focus-box { width: min(420px, 100%); display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.ring { position: relative; width: min(72vw, 260px); aspect-ratio: 1; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 8; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round; filter: drop-shadow(0 0 6px var(--accent)); transition: stroke-dashoffset 1s linear; }
.ring-in { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.focus-spirit { width: 55%; aspect-ratio: 1; }
.ring-in strong { font-size: 28px; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.big-num { font-size: 64px; font-weight: 900; margin: 0; font-variant-numeric: tabular-nums; text-shadow: 0 0 20px rgba(123, 224, 168, .6); }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 92px); transform: translate(-50%, 16px); z-index: 9;
  padding: 10px 16px; border-radius: 14px; background: #F4F1FF; color: #1A1640; font-weight: 700; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .3s; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
