:root {
  color-scheme: dark;
  --ink: #f1eee4;
  --muted: #9ca8a3;
  --line: rgba(196, 214, 205, 0.17);
  --panel: rgba(17, 27, 25, 0.88);
  --teal: #71b3a1;
  --teal-bright: #9fd1c2;
  --amber: #c49a57;
  --progress: 0%;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #08100f;
}

body {
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.atlas {
  position: relative;
  display: grid;
  grid-template-rows: 54px minmax(0, 1fr) 92px;
  width: 100%;
  height: 100dvh;
  min-height: 280px;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  background:
    radial-gradient(circle at 82% 18%, rgba(55, 111, 96, 0.16), transparent 33%),
    linear-gradient(135deg, #0b1312 0%, #07100e 70%);
}

.atlas::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: 0.2;
  background-image:
    linear-gradient(rgba(158, 199, 185, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(158, 199, 185, 0.05) 1px, transparent 1px);
  background-size: 64px 64px;
}

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(6, 13, 12, 0.8);
  backdrop-filter: blur(16px);
}

.identity,
.header-actions {
  display: flex;
  align-items: center;
}

.identity {
  gap: 11px;
  min-width: 0;
}

.identity-mark {
  width: 5px;
  height: 29px;
  border-radius: 6px;
  background: linear-gradient(var(--amber) 0 24%, var(--teal) 24% 100%);
  box-shadow: 0 0 20px rgba(113, 179, 161, 0.26);
}

.eyebrow,
.identity h1,
.observation-panel p {
  margin: 0;
}

.eyebrow {
  color: var(--amber);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.identity h1 {
  margin-top: 2px;
  overflow: hidden;
  color: var(--ink);
  font-family: "Songti SC", "STSong", serif;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  gap: 9px;
}

.case-badge {
  padding: 5px 10px;
  border: 1px solid rgba(113, 179, 161, 0.26);
  border-radius: 999px;
  color: var(--teal-bright);
  background: rgba(68, 128, 111, 0.1);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.ghost-button {
  padding: 5px 10px;
  border: 0;
  border-left: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
  font-size: 11px;
}

.stage {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(220px, 27vw, 320px);
  min-height: 0;
}

.image-panel {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: #eef0eb;
  touch-action: pan-y;
  user-select: none;
}

.image-wash {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(135deg, rgba(0, 20, 17, 0.06), transparent 38%);
}

#specimenImage {
  z-index: 1;
  align-self: center;
  justify-self: center;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 180ms ease;
}

#specimenImage.is-ready {
  opacity: 1;
}

.image-loading,
.image-error {
  position: absolute;
  z-index: 2;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  color: #49605a;
  font-size: 12px;
  letter-spacing: 0.1em;
}

.frame-button {
  position: absolute;
  z-index: 3;
  top: 50%;
  display: grid;
  place-items: center;
  width: 36px;
  height: 58px;
  padding: 0;
  transform: translateY(-50%);
  border: 1px solid rgba(226, 237, 232, 0.26);
  border-radius: 5px;
  color: white;
  background: rgba(5, 17, 14, 0.48);
  backdrop-filter: blur(7px);
}

.frame-button span {
  transform: translateY(-2px);
  font-family: Georgia, serif;
  font-size: 30px;
}

.frame-button:disabled {
  opacity: 0.22;
}

.frame-button--prev {
  left: 13px;
}

.frame-button--next {
  right: 13px;
}

.swipe-hint {
  position: absolute;
  z-index: 2;
  right: 12px;
  bottom: 9px;
  padding: 4px 7px;
  border-radius: 3px;
  color: rgba(232, 238, 234, 0.72);
  background: rgba(6, 16, 13, 0.54);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.observation-panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  padding: clamp(14px, 2.6vh, 25px) clamp(16px, 2.2vw, 25px) 14px;
  flex-direction: column;
  background: linear-gradient(155deg, rgba(25, 39, 35, 0.94), rgba(10, 20, 18, 0.98));
}

.observation-label {
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.18em;
}

.day-display {
  display: flex;
  align-items: baseline;
  margin: 2px 0 3px;
  color: var(--ink);
}

.day-display span {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(38px, 8.8vh, 72px);
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
}

.day-display small {
  margin-left: 7px;
  color: var(--amber);
  font-size: 12px;
  letter-spacing: 0.1em;
}

.rule {
  width: 34px;
  height: 2px;
  margin: 7px 0 11px;
  background: var(--teal);
}

.observation-text {
  display: -webkit-box;
  margin-top: 7px !important;
  overflow: hidden;
  color: #d8ddd9;
  font-size: clamp(11px, 1.55vw, 14px);
  line-height: 1.65;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}

.record-meta {
  display: flex;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: #71817b;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.08em;
}

.timeline-panel {
  position: relative;
  z-index: 2;
  padding: 12px 23px 10px;
  border-top: 1px solid var(--line);
  background: rgba(5, 13, 12, 0.94);
}

.timeline-topline {
  display: flex;
  justify-content: space-between;
  margin-bottom: 11px;
  color: #72837d;
  font-size: 9px;
  letter-spacing: 0.08em;
}

.timeline-topline span:nth-child(2) {
  color: var(--teal-bright);
}

.timeline-range {
  width: 100%;
  height: 26px;
  margin: 0;
  appearance: none;
  background: transparent;
  touch-action: none;
}

.timeline-range::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--teal) 0 var(--progress), #2a3935 var(--progress) 100%);
  box-shadow: 0 0 0 1px rgba(142, 188, 175, 0.08);
}

.timeline-range::-webkit-slider-thumb {
  width: 25px;
  height: 25px;
  margin-top: -10px;
  appearance: none;
  border: 3px solid #0c1715;
  border-radius: 50%;
  background: var(--teal-bright);
  box-shadow: 0 0 0 2px var(--teal), 0 0 18px rgba(113, 179, 161, 0.38);
}

.timeline-range::-moz-range-track {
  height: 5px;
  border: 0;
  border-radius: 999px;
  background: #2a3935;
}

.timeline-range::-moz-range-progress {
  height: 5px;
  border-radius: 999px;
  background: var(--teal);
}

.timeline-range::-moz-range-thumb {
  width: 21px;
  height: 21px;
  border: 3px solid #0c1715;
  border-radius: 50%;
  background: var(--teal-bright);
  box-shadow: 0 0 0 2px var(--teal);
}

.warning-layer,
.rotate-layer,
.closed-layer,
.fatal-layer {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
}

.warning-layer {
  z-index: 100;
  padding: 22px max(22px, env(safe-area-inset-right)) 22px max(22px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 50% 30%, rgba(43, 92, 79, 0.26), transparent 38%),
    rgba(4, 10, 9, 0.985);
}

.warning-card {
  width: min(560px, 92vw);
  max-height: 92vh;
  padding: clamp(22px, 4vw, 38px);
  overflow: auto;
  border: 1px solid rgba(185, 209, 199, 0.2);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(24, 40, 35, 0.96), rgba(10, 19, 17, 0.98));
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.44);
  text-align: center;
}

.warning-symbol {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  margin: 0 auto 14px;
  border: 1px solid var(--amber);
  border-radius: 50%;
  color: var(--amber);
  font-family: Georgia, serif;
  font-size: 25px;
}

.warning-card h2,
.rotate-card h2,
.closed-layer h2,
.fatal-layer h2 {
  margin: 8px 0 10px;
  font-family: "Songti SC", "STSong", serif;
  font-size: clamp(24px, 4vw, 34px);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.warning-card > p:not(.eyebrow) {
  margin: 0 auto;
  color: #b8c2bd;
  font-size: 13px;
  line-height: 1.8;
}

.warning-actions {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 10px;
  margin: 20px 0 12px;
}

.button {
  min-height: 43px;
  padding: 0 17px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.button--secondary {
  border: 1px solid rgba(200, 213, 207, 0.2);
  background: transparent;
}

.button--primary {
  border: 1px solid var(--teal);
  color: #06100d;
  background: var(--teal-bright);
}

.warning-card small {
  color: #6f7e78;
  font-size: 9px;
}

.rotate-layer {
  z-index: 90;
  display: none;
  padding: 28px;
  background: #08100f;
  text-align: center;
}

.rotate-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.phone-rotate {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 7px;
}

.phone-rotate::before {
  position: absolute;
  left: 25px;
  top: 12px;
  width: 30px;
  height: 52px;
  border: 2px solid var(--teal);
  border-radius: 6px;
  content: "";
  transform: rotate(-24deg);
  animation: rotate-phone 1.8s ease-in-out infinite alternate;
}

.phone-rotate::after {
  position: absolute;
  inset: 4px;
  border: 1px dashed rgba(113, 179, 161, 0.27);
  border-radius: 50%;
  content: "";
}

.closed-layer,
.fatal-layer {
  z-index: 110;
  padding: 30px;
  background: #08100f;
  text-align: center;
}

[hidden] {
  display: none !important;
}

@keyframes rotate-phone {
  to {
    transform: rotate(66deg);
  }
}

@media (orientation: portrait) {
  .rotate-layer {
    display: grid;
  }
}

@media (max-height: 410px) and (orientation: landscape) {
  .atlas {
    grid-template-rows: 46px minmax(0, 1fr) 76px;
  }

  .topbar {
    padding-inline: 13px;
  }

  .identity h1 {
    font-size: 14px;
  }

  .stage {
    grid-template-columns: minmax(0, 1fr) clamp(205px, 26vw, 270px);
  }

  .observation-panel {
    padding: 10px 15px 9px;
  }

  .rule {
    margin: 4px 0 7px;
  }

  .observation-text {
    margin-top: 4px !important;
    line-height: 1.5;
    -webkit-line-clamp: 3;
  }

  .timeline-panel {
    padding: 8px 18px 6px;
  }

  .timeline-topline {
    margin-bottom: 5px;
  }
}

@media (max-width: 720px) and (orientation: landscape) {
  .stage {
    grid-template-columns: minmax(0, 1fr) 194px;
  }

  .identity .eyebrow,
  .swipe-hint {
    display: none;
  }

  .case-badge {
    padding-inline: 8px;
  }

  .observation-text {
    font-size: 10px;
  }
}

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