:root {
  color-scheme: dark;
  --void: #000000;
  --space: #05060a;
  --panel: #0c0e15;
  --panel-raised: #121522;
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #f4f5f7;
  --text-soft: #b8bbc6;
  --text-muted: #8e94a6;
  --orange: #f0873e;
  --orange-hot: #ffb06a;
  --blue: #a8b4ff;
  --error: #ff6b7a;
  --unknown: #9aa3b8;
  --success: #7ad7ff;
  --header-h: 72px;
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.56);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --font-display: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-body: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-label: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--space);
}

body {
  min-width: 320px;
  min-height: 100svh;
  margin: 0;
  overflow: hidden;
  background: var(--space);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
}

body::selection {
  background: var(--orange);
  color: #05060a;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
a,
select,
input[type="checkbox"],
input[type="radio"] {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--orange-hot);
  outline-offset: 3px;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

[hidden] {
  display: none !important;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 12px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--text);
  color: var(--space);
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-140%);
  transition: transform 180ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  min-height: 100svh;
  background:
    radial-gradient(ellipse 65% 48% at 72% 48%, rgba(100, 116, 210, 0.12), transparent 68%),
    radial-gradient(ellipse 45% 35% at 16% 80%, rgba(240, 135, 62, 0.06), transparent 70%),
    var(--space);
}

.app-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;
  display: flex;
  min-height: var(--header-h);
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(5, 6, 10, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(168, 180, 255, 0.58);
  border-radius: 50%;
  background: radial-gradient(circle, var(--orange) 0 3px, transparent 4px);
  box-shadow: 0 0 24px rgba(168, 180, 255, 0.12);
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 8px 2px;
  border: 1px solid rgba(240, 135, 62, 0.74);
  border-radius: 50%;
  transform: rotate(-20deg);
}

.brand-mark::after {
  inset: 3px 11px;
  border-color: rgba(168, 180, 255, 0.48);
  transform: rotate(34deg);
}

.brand-copy {
  display: grid;
  min-width: 0;
}

.brand-copy strong {
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy small {
  color: var(--text-muted);
  font-family: var(--font-label);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.icon-button,
.control-button,
.close-button {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-soft);
  transition: border-color 180ms ease, background 180ms ease, color 180ms ease, transform 180ms var(--ease-out);
}

.icon-button:hover,
.control-button:hover,
.close-button:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.icon-button:active,
.control-button:active,
.close-button:active {
  transform: scale(0.97);
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.icon-button[aria-pressed="true"] {
  border-color: rgba(240, 135, 62, 0.58);
  background: rgba(240, 135, 62, 0.12);
  color: var(--orange-hot);
}

.button-label {
  font-family: var(--font-label);
  font-size: 0.72rem;
  font-weight: 700;
}

.orbit-main {
  position: fixed;
  inset: var(--header-h) 0 0;
}

.orbit-stage {
  position: relative;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(rgba(255, 255, 255, 0.012) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.012) 1px, transparent 1px),
    var(--space);
  background-size: 44px 44px;
  overscroll-behavior: contain;
}

.stage-ambient {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 48%, rgba(168, 180, 255, 0.09), transparent 26%),
    radial-gradient(circle at 50% 48%, transparent 0 34%, rgba(240, 135, 62, 0.035) 42%, transparent 57%);
}

.orbit-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.orbit-canvas--interactive {
  z-index: 2;
  pointer-events: auto;
  touch-action: none;
}

.stage-intro {
  position: absolute;
  top: clamp(20px, 4vh, 42px);
  left: clamp(18px, 4vw, 52px);
  z-index: 4;
  max-width: min(560px, calc(100% - 36px));
  pointer-events: none;
}

.eyebrow,
.notice-kicker,
.dialog-kicker {
  margin: 0 0 10px;
  color: var(--orange);
  font-family: var(--font-label);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.stage-intro h1 {
  max-width: 12ch;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.4vw, 3.6rem);
  font-weight: 650;
  letter-spacing: -0.045em;
  line-height: 1.1;
  text-wrap: balance;
}

.stage-summary {
  max-width: 42ch;
  margin: 16px 0 0;
  color: var(--text-soft);
  font-size: 0.9rem;
  line-height: 1.7;
}

.time-controls {
  position: absolute;
  top: clamp(20px, 4vh, 42px);
  right: clamp(18px, 4vw, 52px);
  z-index: 5;
  display: grid;
  justify-items: end;
  gap: 10px;
}

.segmented-control {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(5, 6, 10, 0.82);
  backdrop-filter: blur(14px);
}

.segment {
  min-width: 58px;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-label);
  font-size: 0.76rem;
  font-weight: 700;
}

.segment:hover {
  color: var(--text);
}

.segment.is-active {
  background: var(--text);
  color: var(--space);
}

.period-selectors {
  display: flex;
  gap: 8px;
}

.period-selectors label {
  display: grid;
  grid-template-columns: auto minmax(74px, auto);
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.period-selectors select {
  min-height: 44px;
  padding: 0 30px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
}

.empty-state {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 6;
  width: min(420px, calc(100% - 40px));
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(12, 14, 21, 0.88);
  text-align: center;
  transform: translate(-50%, -48%);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.sample-stars {
  position: relative;
  width: 124px;
  height: 62px;
  margin: 0 auto 16px;
}

.sample-stars::before {
  content: "";
  position: absolute;
  inset: 12px 4px;
  border: 1px solid rgba(168, 180, 255, 0.28);
  border-radius: 50%;
  transform: rotate(-8deg);
}

.sample-stars i {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--unknown);
  box-shadow: 0 0 14px rgba(154, 163, 184, 0.5);
}

.sample-stars i:nth-child(1) { top: 8px; left: 24px; }
.sample-stars i:nth-child(2) { top: 38px; left: 60px; }
.sample-stars i:nth-child(3) { top: 16px; right: 18px; }

.empty-state h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.42rem;
}

.empty-state p {
  margin: 8px 0 20px;
  color: var(--text-soft);
}

.legend {
  position: absolute;
  bottom: 64px;
  left: clamp(18px, 4vw, 52px);
  z-index: 5;
  width: min(290px, calc(100% - 36px));
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(12, 14, 21, 0.82);
  backdrop-filter: blur(14px);
}

.legend-toggle {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font-family: var(--font-label);
  font-size: 0.74rem;
  font-weight: 700;
}

.legend-toggle svg {
  width: 16px;
  transition: transform 180ms ease;
}

.legend-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.legend-content {
  padding: 0 14px 14px;
  border-top: 1px solid var(--line);
}

.legend-content p {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 0;
  color: var(--text-soft);
  font-size: 0.78rem;
}

.legend-star {
  position: relative;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
}

.legend-star::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: currentColor;
}

.legend-star--mood {
  color: var(--orange);
  box-shadow: 0 0 10px rgba(240, 135, 62, 0.45);
}

.legend-star--unknown {
  border: 1px dashed var(--unknown);
  color: var(--unknown);
}

.legend-cluster {
  display: inline-grid;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--blue);
  border-radius: 50%;
  color: var(--text);
  font-size: 0.64rem;
}

.legend-line {
  flex: 0 0 26px;
  width: 26px;
  height: 2px;
  background: #676e9d;
}

.camera-controls {
  position: absolute;
  right: clamp(18px, 4vw, 52px);
  bottom: 72px;
  z-index: 5;
  display: grid;
  gap: 8px;
}

.pan-grid {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 44px);
  gap: 8px;
}

.pan-up { grid-area: 1 / 2; }
.pan-left { grid-area: 2 / 1; }
.pan-reset { grid-area: 2 / 2; }
.pan-right { grid-area: 2 / 3; }
.pan-down { grid-area: 3 / 2; }

.control-button {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 13px;
  background: rgba(12, 14, 21, 0.82);
  backdrop-filter: blur(12px);
}

.control-button svg {
  width: 18px;
  height: 18px;
}

.zoom-row {
  display: flex;
  gap: 8px;
}

.stage-status {
  position: absolute;
  bottom: 16px;
  left: 50%;
  z-index: 5;
  display: flex;
  max-width: calc(100% - 340px);
  min-height: 36px;
  align-items: center;
  gap: 16px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(5, 6, 10, 0.78);
  color: var(--text-muted);
  font-family: var(--font-label);
  font-size: 0.68rem;
  white-space: nowrap;
  transform: translateX(-50%);
  backdrop-filter: blur(12px);
}

.stage-status strong {
  color: var(--text);
}

.record-button {
  position: absolute;
  right: clamp(18px, 4vw, 52px);
  bottom: 18px;
  z-index: 6;
  display: inline-flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--text);
  color: var(--space);
  font-weight: 750;
  box-shadow: 0 14px 42px rgba(255, 255, 255, 0.14), 0 0 0 1px rgba(255, 255, 255, 0.3);
  transition: transform 180ms var(--ease-out), box-shadow 180ms ease;
}

.record-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 50px rgba(240, 135, 62, 0.22), 0 0 0 1px var(--orange-hot);
}

.record-button:active {
  transform: scale(0.98);
}

.record-button svg {
  width: 18px;
  height: 18px;
}

.skip-animation-button {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 9;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(5, 6, 10, 0.88);
  color: var(--text);
  transform: translate(-50%, 72px);
}

.signal-animation {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 8;
  width: 160px;
  height: 160px;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.signal-animation::before,
.signal-animation::after,
.signal-animation i {
  content: "";
  position: absolute;
  inset: 50%;
  border: 1px solid var(--orange-hot);
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.08);
  animation: signal-pulse var(--signal-wave-duration, 720ms) var(--ease-out) forwards;
}

.signal-animation::after { animation-delay: var(--signal-step-delay, 120ms); border-color: var(--blue); }
.signal-animation i:nth-child(1) { animation-delay: calc(var(--signal-step-delay, 120ms) * 2); }
.signal-animation i:nth-child(2) { animation-delay: calc(var(--signal-step-delay, 120ms) * 3); border-color: var(--blue); }
.signal-animation i:nth-child(3) { animation-delay: calc(var(--signal-step-delay, 120ms) * 4); }

@keyframes signal-pulse {
  0% { inset: 50%; opacity: 0; transform: translate(-50%, -50%) scale(0.08); }
  18% { opacity: 0.95; }
  100% { inset: 0; opacity: 0; transform: translate(0, 0) scale(1); }
}

.privacy-notice {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 25;
  display: grid;
  width: min(520px, calc(100% - 40px));
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 20px;
  padding: 20px;
  border: 1px solid rgba(240, 135, 62, 0.32);
  border-radius: var(--radius-lg);
  background: rgba(12, 14, 21, 0.96);
  box-shadow: var(--shadow);
}

.privacy-notice h2 {
  margin: 0;
  font-size: 1.06rem;
}

.privacy-notice p:not(.notice-kicker) {
  margin: 7px 0 0;
  color: var(--text-soft);
  font-size: 0.84rem;
}

.primary-button,
.secondary-button,
.danger-button,
.text-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border-radius: 999px;
  font-weight: 700;
  text-decoration: none;
  transition: transform 180ms var(--ease-out), background 180ms ease, border-color 180ms ease, color 180ms ease;
}

.primary-button {
  border: 1px solid var(--text);
  background: var(--text);
  color: var(--space);
}

.primary-button:hover:not(:disabled) {
  border-color: var(--orange-hot);
  background: var(--orange-hot);
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
}

.secondary-button:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.09);
}

.danger-button {
  border: 1px solid rgba(255, 107, 122, 0.48);
  background: rgba(255, 107, 122, 0.08);
  color: #ff9da8;
}

.danger-button:hover:not(:disabled) {
  background: var(--error);
  color: #090a0e;
}

.text-button {
  min-height: 36px;
  justify-content: flex-start;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--orange-hot);
  font-size: 0.78rem;
}

.primary-button:active,
.secondary-button:active,
.danger-button:active {
  transform: scale(0.98);
}

.app-dialog {
  width: min(720px, calc(100% - 32px));
  max-width: none;
  max-height: min(88svh, 920px);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.app-dialog[open] {
  animation: dialog-in 220ms var(--ease-out);
}

.app-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.app-dialog > form,
.app-dialog > section,
.app-dialog > article {
  display: grid;
  min-height: 100%;
}

.dialog-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 14, 21, 0.95);
  backdrop-filter: blur(16px);
}

.dialog-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2vw, 1.7rem);
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.dialog-kicker {
  margin-bottom: 5px;
}

.close-button {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
}

.close-button svg {
  width: 19px;
  height: 19px;
}

.dialog-footer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  background: rgba(12, 14, 21, 0.95);
  backdrop-filter: blur(16px);
}

.form-dialog {
  width: min(760px, calc(100% - 32px));
}

.step-indicator {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 20px 24px 0;
  padding: 0;
  list-style: none;
}

.step-indicator li {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.76rem;
}

.step-indicator span {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.7rem;
}

.step-indicator li.is-current {
  border-color: rgba(240, 135, 62, 0.45);
  background: rgba(240, 135, 62, 0.08);
  color: var(--text);
}

.step-indicator li.is-current span,
.step-indicator li.is-complete span {
  background: var(--orange);
  color: #05060a;
}

.error-summary,
.draft-restored {
  margin: 18px 24px 0;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
}

.error-summary {
  border: 1px solid rgba(255, 107, 122, 0.45);
  background: rgba(255, 107, 122, 0.08);
  color: #ffc5cb;
}

.error-summary ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.error-summary a {
  color: inherit;
}

.draft-restored {
  border: 1px solid rgba(122, 215, 255, 0.32);
  background: rgba(122, 215, 255, 0.08);
  color: #bcecff;
  font-size: 0.84rem;
}

.form-step {
  min-width: 0;
  margin: 0;
  padding: 24px;
  border: 0;
}

.form-step legend {
  padding: 0;
  font-family: var(--font-display);
  font-size: 1.22rem;
  font-weight: 700;
}

.step-help {
  margin: 4px 0 22px;
  color: var(--text-soft);
  font-size: 0.86rem;
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 20px;
}

.field:first-of-type {
  margin-top: 0;
}

.field label,
.field-label,
.settings-group > label,
.data-section > label,
.import-preview > label {
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 700;
}

.field label span,
.field-label small {
  margin-left: 5px;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 500;
}

input[type="text"],
input[type="search"],
input[type="date"],
textarea,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
}

input[type="text"],
input[type="search"],
input[type="date"],
textarea {
  padding: 11px 13px;
}

textarea {
  min-height: 150px;
  resize: vertical;
  line-height: 1.65;
}

select {
  padding: 0 38px 0 13px;
}

input::placeholder,
textarea::placeholder {
  color: #747b8e;
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--error);
  box-shadow: 0 0 0 1px var(--error);
}

.field-error {
  min-height: 1.2em;
  margin: 0;
  color: #ff9da8;
  font-size: 0.78rem;
}

.field-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  color: var(--text-muted);
  font-size: 0.76rem;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.choice-grid label {
  position: relative;
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  cursor: pointer;
}

.choice-grid input,
.rating input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.choice-grid label:has(input:focus-visible),
.rating label:has(input:focus-visible) {
  outline: 3px solid var(--orange-hot);
  outline-offset: 3px;
}

.choice-grid label:has(input:checked) {
  border-color: var(--orange-hot);
  background: rgba(240, 135, 62, 0.09);
  color: var(--text);
}

.mood-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 12px currentColor;
}

.mood-warm { color: #f0873e; }
.mood-calm { color: #7ad7ff; }
.mood-joy { color: #ffd166; }
.mood-sad { color: #a8b4ff; }
.mood-tense { color: #ff7a90; }
.mood-neutral { color: #f4f5f7; }

.rating {
  display: grid;
  grid-template-columns: repeat(5, minmax(44px, 1fr));
  gap: 8px;
}

.rating label {
  position: relative;
  display: grid;
  min-width: 44px;
  min-height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-soft);
  cursor: pointer;
}

.rating label:has(input:checked) {
  border-color: var(--orange-hot);
  background: var(--orange);
  color: #05060a;
}

.privacy-inline {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 26px;
  padding: 14px;
  border: 1px solid rgba(168, 180, 255, 0.24);
  border-radius: var(--radius-sm);
  background: rgba(168, 180, 255, 0.05);
}

.privacy-inline svg {
  flex: 0 0 20px;
  width: 20px;
  margin-top: 2px;
  color: var(--blue);
}

.privacy-inline p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.82rem;
}

.form-footer {
  justify-content: flex-start;
}

.form-footer .draft-status {
  margin-right: auto;
  color: var(--text-muted);
  font-size: 0.76rem;
}

.detail-dialog {
  position: fixed;
  inset: var(--header-h) 0 0 auto;
  width: min(420px, 100%);
  height: calc(100svh - var(--header-h));
  max-height: none;
  margin: 0;
  border-width: 0 0 0 1px;
  border-radius: 0;
}

.detail-dialog[open] {
  animation: drawer-in 220ms var(--ease-out);
}

@keyframes drawer-in {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

.detail-body {
  padding: 24px;
  overflow-wrap: anywhere;
}

.detail-date {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-family: var(--font-label);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 22px;
}

.detail-meta div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.detail-meta dt {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.detail-meta dd {
  margin: 4px 0 0;
  color: var(--text);
  font-weight: 700;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 22px;
}

.detail-tag {
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-soft);
  font-size: 0.72rem;
}

.detail-text {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.85;
  white-space: pre-wrap;
}

.list-dialog {
  width: min(980px, calc(100% - 32px));
  max-height: calc(100svh - 32px);
}

.list-tabs {
  display: flex;
  gap: 8px;
  padding: 18px 24px 0;
}

.list-tabs button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text-soft);
}

.list-tabs button[aria-selected="true"] {
  border-color: var(--text);
  background: var(--text);
  color: var(--space);
  font-weight: 700;
}

.list-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 210px) auto auto;
  align-items: end;
  gap: 12px;
  padding: 18px 24px;
}

.list-toolbar > button[hidden] {
  display: none;
}

.list-toolbar label {
  display: grid;
  gap: 6px;
  color: var(--text-soft);
  font-size: 0.76rem;
}

.list-result-meta {
  margin: 0 24px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.memory-results {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 18px 24px 24px;
  list-style: none;
}

.memory-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.025);
}

.memory-item-main {
  min-width: 0;
}

.memory-item h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 0.98rem;
}

.memory-item time,
.memory-item p {
  color: var(--text-muted);
  font-size: 0.76rem;
}

.memory-item p {
  display: -webkit-box;
  margin: 6px 0 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.memory-item-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.memory-item-actions button {
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  font-size: 0.76rem;
}

.memory-item-actions button:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.08);
}

.list-empty {
  padding: 42px 24px;
  text-align: center;
}

.list-empty h3 {
  margin: 0;
}

.list-empty p {
  margin: 8px 0 18px;
  color: var(--text-soft);
}

.list-pagination {
  justify-content: center;
}

.list-pagination span {
  min-width: 100px;
  color: var(--text-soft);
  text-align: center;
}

.settings-dialog {
  width: min(620px, calc(100% - 32px));
}

.settings-group,
.data-section {
  display: grid;
  gap: 10px;
  margin: 0 24px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.settings-group:last-child,
.data-section:last-child {
  border-bottom: 0;
}

.settings-group h3,
.data-section h3,
.data-section h4 {
  margin: 0;
  font-size: 1rem;
}

.settings-group p,
.data-section p,
.export-dialog form > p,
.confirm-dialog form > p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.84rem;
}

.action-stack .secondary-button {
  justify-content: flex-start;
}

.danger-zone {
  padding-bottom: 28px;
}

.data-dialog {
  width: min(760px, calc(100% - 32px));
}

.warning-box {
  padding: 14px;
  border: 1px solid rgba(255, 176, 106, 0.38);
  border-radius: var(--radius-sm);
  background: rgba(240, 135, 62, 0.08);
}

.warning-box strong {
  color: var(--orange-hot);
}

.warning-box p {
  margin-top: 5px;
}

.warning-box--quiet {
  margin: 0 24px 20px;
  border-color: rgba(168, 180, 255, 0.3);
  background: rgba(168, 180, 255, 0.06);
}

.warning-box--quiet strong {
  color: var(--blue);
}

.check-row {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.check-row input {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  accent-color: var(--orange);
}

.file-picker {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.025);
}

.file-picker input {
  max-width: 100%;
}

.import-preview {
  display: grid;
  gap: 14px;
  margin-top: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.025);
}

.import-preview dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.import-preview dl div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.import-preview dt {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.import-preview dd {
  margin: 2px 0 0;
  font-weight: 750;
}

.import-errors {
  padding: 12px;
  border: 1px solid rgba(255, 107, 122, 0.45);
  border-radius: var(--radius-sm);
  background: rgba(255, 107, 122, 0.08);
  color: #ffc5cb;
  font-size: 0.8rem;
  white-space: pre-wrap;
}

.import-preview fieldset {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.import-preview fieldset label {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
}

.replace-backup {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(255, 176, 106, 0.32);
  border-radius: var(--radius-sm);
}

.export-dialog {
  width: min(620px, calc(100% - 32px));
}

.export-dialog form > p {
  padding: 20px 24px 0;
}

.export-options {
  display: grid;
  gap: 4px;
  padding: 16px 24px 20px;
}

.compact-results {
  max-height: 60svh;
  overflow: auto;
}

.confirm-dialog {
  width: min(480px, calc(100% - 32px));
}

.confirm-dialog form > p {
  padding: 24px;
  font-size: 0.94rem;
}

.date-change-notice {
  position: fixed;
  top: calc(var(--header-h) + 12px);
  left: 50%;
  z-index: 26;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  border: 1px solid rgba(168, 180, 255, 0.38);
  border-radius: 999px;
  background: rgba(12, 14, 21, 0.96);
  color: var(--text-soft);
  font-size: 0.78rem;
  transform: translateX(-50%);
  box-shadow: var(--shadow);
}

.date-change-notice button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
}

.toast-region {
  position: fixed;
  top: calc(var(--header-h) + 16px);
  left: 50%;
  z-index: 80;
  display: grid;
  width: min(420px, calc(100% - 32px));
  gap: 8px;
  pointer-events: none;
  transform: translateX(-50%);
}

.toast {
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: rgba(12, 14, 21, 0.98);
  color: var(--text);
  font-size: 0.84rem;
  text-align: center;
  box-shadow: var(--shadow);
  animation: toast-in 200ms var(--ease-out);
}

.toast.is-error {
  border-color: rgba(255, 107, 122, 0.48);
  color: #ffc5cb;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1023px) {
  .stage-intro {
    max-width: min(470px, calc(100% - 300px));
  }

  .stage-intro h1 {
    font-size: clamp(1.8rem, 4.2vw, 2.8rem);
  }

  .button-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

@media (max-width: 767px) {
  :root {
    --header-h: 64px;
  }

  .app-header {
    gap: 8px;
    padding-inline: 12px;
  }

  .brand {
    gap: 9px;
  }

  .brand-mark {
    flex-basis: 32px;
    width: 32px;
    height: 32px;
  }

  .brand-copy small {
    display: none;
  }

  .header-actions {
    gap: 8px;
  }

  .icon-button {
    width: 44px;
    padding: 0;
  }

  .stage-intro {
    top: 16px;
    left: 16px;
    max-width: calc(100% - 32px);
    text-align: center;
  }

  .stage-intro h1 {
    max-width: 15ch;
    margin-inline: auto;
    font-size: clamp(1.65rem, 7.6vw, 2.35rem);
  }

  .stage-summary {
    max-width: 34ch;
    margin: 8px auto 0;
    font-size: 0.78rem;
  }

  .time-controls {
    top: 152px;
    right: 50%;
    width: calc(100% - 28px);
    justify-items: center;
    transform: translateX(50%);
  }

  .segmented-control {
    width: 100%;
  }

  .segment {
    flex: 1;
    min-width: 0;
  }

  .period-selectors {
    width: 100%;
    justify-content: center;
  }

  .period-selectors label {
    grid-template-columns: auto minmax(72px, 1fr);
    min-width: 0;
  }

  .period-selectors select {
    min-width: 0;
  }

  .legend {
    bottom: 82px;
    left: 12px;
    width: 116px;
  }

  .legend-content {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    width: min(280px, calc(100vw - 24px));
    padding: 4px 14px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(12, 14, 21, 0.96);
  }

  .camera-controls {
    right: 12px;
    bottom: 82px;
  }

  .pan-grid {
    display: none;
  }

  .stage-status {
    bottom: 18px;
    left: 12px;
    display: grid;
    max-width: calc(100% - 184px);
    min-height: 52px;
    align-content: center;
    gap: 0;
    padding: 7px 11px;
    border-radius: 14px;
    white-space: normal;
    transform: none;
  }

  .stage-status span:nth-child(2) {
    display: none;
  }

  .record-button {
    right: 12px;
    bottom: 18px;
    min-height: 52px;
    padding: 0 15px;
  }

  .record-button span {
    font-size: 0.78rem;
  }

  .privacy-notice {
    right: 12px;
    bottom: 12px;
    width: calc(100% - 24px);
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .app-dialog {
    width: calc(100% - 16px);
    max-height: calc(100svh - 16px);
    border-radius: 20px;
  }

  .dialog-header {
    padding: 18px 18px 14px;
  }

  .dialog-footer {
    padding: 13px 18px max(13px, env(safe-area-inset-bottom));
  }

  .step-indicator {
    margin: 16px 18px 0;
  }

  .step-indicator li {
    justify-content: center;
    padding: 0 8px;
    font-size: 0;
  }

  .step-indicator span {
    font-size: 0.7rem;
  }

  .form-step {
    padding: 20px 18px;
  }

  .error-summary,
  .draft-restored {
    margin-inline: 18px;
  }

  .choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-footer {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-footer .draft-status {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .form-footer button {
    width: 100%;
  }

  .detail-dialog {
    inset: auto 0 0;
    width: 100%;
    height: min(72svh, 720px);
    max-height: min(72svh, 720px);
    border-width: 1px 0 0;
    border-radius: 22px 22px 0 0;
  }

  .detail-dialog[open] {
    animation: sheet-in 220ms var(--ease-out);
  }

  @keyframes sheet-in {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: translateY(0); }
  }

  .list-toolbar {
    grid-template-columns: 1fr;
    padding-inline: 18px;
  }

  .list-result-meta {
    margin-inline: 18px;
  }

  .memory-results {
    padding-inline: 18px;
  }

  .memory-item {
    grid-template-columns: 1fr;
  }

  .memory-item-actions {
    justify-content: flex-start;
  }

  .settings-group,
  .data-section {
    margin-inline: 18px;
  }

  .import-preview dl {
    grid-template-columns: 1fr;
  }

  .export-dialog form > p,
  .export-options {
    padding-inline: 18px;
  }

  .warning-box--quiet {
    margin-inline: 18px;
  }

  .date-change-notice {
    top: calc(var(--header-h) + 8px);
    width: calc(100% - 24px);
    justify-content: space-between;
    border-radius: var(--radius-md);
  }
}

@media (max-width: 390px) {
  .brand-copy strong {
    max-width: 6em;
  }

  .stage-intro h1 {
    font-size: clamp(1.55rem, 7.4vw, 1.9rem);
  }

  .stage-summary {
    max-width: 31ch;
  }

  .time-controls {
    top: 176px;
  }

  .period-selectors label > span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .period-selectors label {
    display: block;
    flex: 1;
  }

  .stage-status {
    font-size: 0.62rem;
  }

  .record-button span {
    max-width: 5em;
    line-height: 1.2;
  }

  .dialog-header h2 {
    font-size: 1.25rem;
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .stage-intro {
    top: 12px;
    max-width: 42%;
    text-align: left;
  }

  .stage-intro h1 {
    margin: 0;
    font-size: 1.55rem;
  }

  .stage-summary {
    margin-top: 6px;
    font-size: 0.72rem;
  }

  .time-controls {
    top: 12px;
    right: 12px;
    width: auto;
    transform: none;
  }

  .segmented-control {
    width: auto;
  }

  .period-selectors {
    justify-content: flex-end;
  }

  .legend {
    bottom: 66px;
  }

  .camera-controls {
    right: 12px;
    bottom: 112px;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .pan-grid {
    display: flex;
    grid-template: none;
    gap: 8px;
  }

  .pan-up,
  .pan-left,
  .pan-reset,
  .pan-right,
  .pan-down {
    grid-area: auto;
  }

  .detail-dialog {
    inset: var(--header-h) 0 0 auto;
    width: min(420px, 58%);
    height: calc(100svh - var(--header-h));
    max-height: none;
    border-width: 0 0 0 1px;
    border-radius: 0;
  }

  .detail-dialog[open] {
    animation: drawer-in 220ms var(--ease-out);
  }
}

@media (hover: none) {
  .icon-button:hover,
  .control-button:hover,
  .close-button:hover,
  .record-button:hover {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .signal-animation,
  .stage-ambient {
    animation: none !important;
  }
}
