:root {
  --void: #050404;
  --archive: #0C0B0A;
  --surface: #171514;
  --surface-soft: #201B1A;
  --ink: #D6D2CA;
  --ink-hot: #F1EEE6;
  --muted: #8F9A98;
  --muted-dark: #5B6664;
  --red: #9F1D24;
  --deep-red: #4A1014;
  --line: rgba(214, 210, 202, 0.12);
  --line-strong: rgba(214, 210, 202, 0.22);
  --red-line: rgba(159, 29, 36, 0.34);
  --red-glow: rgba(159, 29, 36, 0.12);
  --shadow: rgba(0, 0, 0, 0.52);
  --mono: "Consolas", "SFMono-Regular", "Courier New", monospace;
  --sans: "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--void);
  color: var(--ink);
  overflow-x: hidden;
}

body {
  min-height: 100svh;
  font-family: var(--sans);
  letter-spacing: 0;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  min-height: 44px;
  -webkit-tap-highlight-color: rgba(200, 4, 20, 0.18);
}

a,
input {
  -webkit-tap-highlight-color: rgba(200, 4, 20, 0.18);
}

.site {
  width: 100%;
  min-height: 100svh;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at 18% 14%, rgba(90, 68, 58, 0.14), transparent 30rem),
    radial-gradient(ellipse at 78% 82%, rgba(66, 82, 80, 0.1), transparent 28rem),
    linear-gradient(180deg, rgba(74, 16, 20, 0.13), transparent 32%),
    var(--void);
}

.gate-screen {
  min-height: 100svh;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 28%, rgba(74, 16, 20, 0.18), transparent 24rem),
    linear-gradient(90deg, rgba(5, 4, 4, 0.98), rgba(23, 21, 20, 0.7) 44%, rgba(5, 4, 4, 0.98)),
    var(--void);
}

.gate-screen::before,
.gate-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.gate-screen::before {
  border: 1px solid rgba(200, 4, 20, 0.18);
  opacity: 0.75;
}

.gate-screen::after {
  background:
    linear-gradient(180deg, transparent 0 18%, rgba(5, 4, 4, 0.24) 18% 100%),
    linear-gradient(90deg, transparent, rgba(214, 210, 202, 0.025) 49%, transparent 51%);
  mix-blend-mode: screen;
  opacity: 0.36;
}

.gate-link {
  width: min(82svw, 430px, calc((100svh - 96px) * 360 / 620));
  aspect-ratio: 360 / 620;
  display: block;
  position: relative;
  z-index: 1;
  color: inherit;
  text-decoration: none;
  transform: translateY(-1svh);
  -webkit-tap-highlight-color: transparent;
}

.gate-link:focus-visible {
  outline: 1px solid var(--red);
  outline-offset: 12px;
}

.gate-link img {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 12px 32px rgba(0, 0, 0, 0.34));
  transition: transform 360ms ease, filter 360ms ease, opacity 360ms ease;
}

.gate-link:hover img,
.gate-link:focus-visible img {
  transform: scale(1.018);
  filter: drop-shadow(0 14px 38px rgba(0, 0, 0, 0.44));
}

.gate-cta {
  position: absolute;
  left: 50%;
  bottom: 2.3%;
  translate: -50% 0;
  min-width: 11.5rem;
  padding: 0.5rem 0;
  border: 0;
  border-bottom: 1px solid rgba(159, 29, 36, 0.48);
  background: transparent;
  color: rgba(214, 210, 202, 0.72);
  font: 0.72rem/1 var(--sans);
  text-align: center;
  letter-spacing: 0;
  text-transform: lowercase;
}

.corner-readout {
  position: fixed;
  right: 18px;
  bottom: 16px;
  z-index: 2;
  display: grid;
  grid-auto-flow: column;
  gap: 14px;
  color: rgba(204, 210, 211, 0.46);
  font: 0.68rem/1.2 var(--mono);
  pointer-events: none;
}

.room-screen {
  min-height: 100svh;
  display: none;
  padding: 22px;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at 13% 8%, rgba(103, 80, 66, 0.13), transparent 28rem),
    radial-gradient(ellipse at 84% 18%, rgba(72, 90, 87, 0.1), transparent 24rem),
    linear-gradient(90deg, rgba(32, 27, 26, 0.72), rgba(14, 13, 12, 0.92) 55%, rgba(5, 4, 4, 0.98)),
    linear-gradient(180deg, rgba(74, 16, 20, 0.12), transparent 230px),
    var(--surface);
}

.site[data-state="room"] .gate-screen {
  display: none;
}

.site[data-state="room"] .room-screen {
  display: block;
  animation: room-in 420ms ease-out both;
}

.site[data-effect="fault"] .room-screen {
  background:
    repeating-linear-gradient(0deg, rgba(214, 210, 202, 0.035) 0 1px, transparent 1px 23px),
    var(--void);
}

.site[data-effect="fault"] .attachment-card,
.site[data-effect="fault"] .verification-summary {
  background: transparent;
  border-left-style: dashed;
}

.site[data-effect="mismatch"] .room-head {
  border-bottom-color: rgba(159, 29, 36, 0.46);
}

.room-head,
.record-index,
.record-detail,
.query-box,
.record-row,
.audit-log {
  font-family: var(--mono);
}

.room-head {
  width: min(100%, 1248px);
  min-height: 42px;
  margin-inline: auto;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line-strong);
  padding: 0 0 11px;
  color: rgba(204, 210, 211, 0.68);
  font-size: 0.72rem;
}

.back-gate {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--ink-hot);
  text-decoration: none;
  letter-spacing: 0;
  text-transform: uppercase;
  padding-right: 12px;
}

.back-gate:hover,
.back-gate:focus-visible {
  color: var(--red);
  outline: 0;
}

.room-layout {
  width: min(100%, 1248px);
  min-height: calc(100svh - 92px);
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(238px, 278px) minmax(0, 1fr) minmax(278px, 318px);
  gap: 0;
  padding-top: 18px;
  border-top: 1px solid rgba(214, 210, 202, 0.09);
  background:
    linear-gradient(90deg, rgba(23, 21, 20, 0.74), rgba(23, 21, 20, 0.34) 23%, rgba(5, 4, 4, 0.18) 63%, rgba(23, 21, 20, 0.58)),
    linear-gradient(180deg, rgba(214, 210, 202, 0.035), transparent 220px);
  box-shadow: inset 0 1px 0 rgba(159, 29, 36, 0.16);
}

.record-index,
.record-detail,
.query-box {
  width: 100%;
  min-width: 0;
}

.record-index {
  position: relative;
  padding: 0 18px 0 0;
  border-right: 1px solid var(--line);
}

.record-index::before {
  content: "";
  position: absolute;
  top: 34px;
  bottom: 0;
  left: 0;
  width: 1px;
  background: linear-gradient(rgba(159, 29, 36, 0.72), rgba(159, 29, 36, 0.08) 58%, transparent);
}

.index-title {
  min-height: 28px;
  margin-bottom: 12px;
  padding-left: 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: rgba(204, 210, 211, 0.48);
  font-size: 0.68rem;
}

.index-title b {
  color: var(--red);
  font-weight: 400;
}

.record-list {
  display: grid;
  gap: 1px;
  max-height: calc(100svh - 130px);
  overflow-y: auto;
  scrollbar-width: none;
}

.record-list::-webkit-scrollbar {
  display: none;
}

.record-row {
  width: 100%;
  min-height: 64px;
  position: relative;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: rgba(204, 210, 211, 0.78);
  text-align: left;
  padding: 12px 0 12px 18px;
  touch-action: manipulation;
  transition: background 180ms ease, color 180ms ease;
}

.record-row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 20px;
  width: 7px;
  height: 7px;
  border: 1px solid rgba(159, 29, 36, 0.48);
  background: var(--surface);
  transform: translateX(-3px);
}

.record-row[aria-pressed="true"] {
  background: linear-gradient(90deg, rgba(74, 16, 20, 0.34), rgba(74, 16, 20, 0.08) 54%, transparent);
  color: var(--ink-hot);
  box-shadow: inset 1px 0 0 var(--red);
}

.record-row[aria-pressed="true"]::before {
  background: var(--red);
}

.record-row:hover:not([disabled]) {
  background: linear-gradient(90deg, rgba(214, 210, 202, 0.05), transparent 72%);
  color: var(--ink-hot);
}

.record-row:focus-visible {
  outline: 1px solid var(--red);
  outline-offset: -1px;
}

.record-row[disabled] {
  color: rgba(204, 210, 211, 0.28);
  cursor: default;
}

.record-row[disabled]::before {
  border-color: rgba(204, 210, 211, 0.16);
  background: transparent;
}

.record-code {
  color: var(--red);
  font-size: 0.94rem;
  line-height: 1;
}

.record-copy {
  min-width: 0;
}

.record-copy b,
.record-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-copy b {
  color: inherit;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.82rem;
}

.record-copy small {
  color: rgba(204, 210, 211, 0.46);
  font-size: 0.65rem;
}

.record-tag {
  align-self: end;
  color: rgba(112, 135, 138, 0.74);
  font-size: 0.58rem;
  opacity: 0;
  transition: opacity 180ms ease;
}

.record-row:hover .record-tag,
.record-row[aria-pressed="true"] .record-tag {
  opacity: 1;
}

.record-detail {
  min-height: 520px;
  position: relative;
  padding: 0 36px 42px;
  overflow-wrap: anywhere;
}

.record-detail::before {
  content: "";
  position: absolute;
  top: 34px;
  bottom: 0;
  left: 0;
  width: 1px;
  background: linear-gradient(var(--red-line), transparent 48%);
}

.case-topline {
  min-height: 28px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  color: rgba(214, 210, 202, 0.48);
  font-size: 0.68rem;
}

.detail-kicker {
  color: rgba(214, 210, 202, 0.48);
}

.case-state {
  color: var(--muted);
  text-align: right;
}

.case-hero {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  margin: 32px 0 22px;
}

.case-code {
  color: var(--red);
  border-top: 1px solid rgba(159, 29, 36, 0.58);
  padding-top: 10px;
  font: 2.8rem/0.9 var(--mono);
}

.case-title-block {
  min-width: 0;
}

.record-detail h1 {
  margin: 0;
  color: var(--ink-hot);
  font: 600 clamp(2.35rem, 4.7vw, 4.8rem)/1.08 var(--sans);
  letter-spacing: 0;
  white-space: normal;
  word-break: keep-all;
}

.case-title {
  max-width: 720px;
  margin: 13px 0 0;
  color: rgba(214, 210, 202, 0.6);
  font: 0.88rem/1.55 var(--sans);
}

.case-summary {
  max-width: 760px;
  margin: 0 0 26px;
  color: rgba(214, 210, 202, 0.8);
  font: 1rem/1.72 var(--sans);
}

.attachment-card {
  max-width: 780px;
  margin: 0 0 24px;
  border: 0;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
  border-left: 1px solid rgba(159, 29, 36, 0.72);
  background:
    linear-gradient(90deg, rgba(74, 16, 20, 0.2), transparent 46%),
    var(--archive);
  box-shadow: none;
  padding: 18px 0 16px 18px;
}

.attachment-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: rgba(214, 210, 202, 0.46);
  font: 0.66rem/1.2 var(--mono);
}

.attachment-head b {
  color: var(--red);
  font-weight: 400;
}

.attachment-card h2 {
  margin: 18px 0 8px;
  color: var(--ink-hot);
  font: 600 1.22rem/1.32 var(--sans);
}

.attachment-card p {
  margin: 0;
  color: rgba(214, 210, 202, 0.72);
  font: 0.86rem/1.58 var(--sans);
}

.restored-line {
  margin-top: 18px;
  display: grid;
  gap: 5px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.restored-line span {
  color: var(--muted);
  font: 0.62rem/1 var(--mono);
}

.restored-line strong {
  color: rgba(243, 247, 247, 0.9);
  font: 400 0.78rem/1.45 var(--mono);
}

.meta-grid {
  max-width: 780px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin-top: 18px;
  border-top: 1px solid var(--line);
}

.meta-grid div {
  min-width: 0;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px 12px 0;
}

.meta-grid dt {
  color: var(--red);
  font-size: 0.66rem;
}

.meta-grid dd {
  margin: 5px 0 0;
  color: rgba(204, 210, 211, 0.78);
  font-size: 0.72rem;
  overflow-wrap: anywhere;
}

.query-box {
  min-width: 0;
  border-left: 1px solid var(--line);
  padding: 0 0 0 18px;
  background: linear-gradient(180deg, rgba(5, 4, 4, 0.22), rgba(5, 4, 4, 0.08));
}

.panel-kicker {
  min-height: 28px;
  color: rgba(204, 210, 211, 0.48);
  font-size: 0.68rem;
}

.verification-summary {
  min-height: 108px;
  display: grid;
  align-content: center;
  gap: 6px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  background:
    linear-gradient(90deg, rgba(74, 16, 20, 0.28), transparent 72%),
    rgba(5, 4, 4, 0.24);
  padding: 16px 0;
}

.verification-summary span {
  color: var(--red);
  font: 0.72rem/1 var(--mono);
}

.verification-summary b {
  color: var(--ink-hot);
  font: 400 1.32rem/1.18 var(--mono);
  overflow-wrap: anywhere;
}

.verification-summary small {
  color: var(--muted);
  font: 0.68rem/1.35 var(--mono);
}

.query-box label {
  display: block;
  margin-bottom: 8px;
  color: rgba(204, 210, 211, 0.5);
  font-size: 0.68rem;
}

.query-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px;
  gap: 0;
  border: 0;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
  background: transparent;
}

.query-row input {
  min-width: 0;
  min-height: 46px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 10px 12px;
  font-size: 16px;
  outline: 0;
}

.query-row input::placeholder {
  color: rgba(112, 135, 138, 0.58);
}

.query-row:focus-within {
  border-color: rgba(159, 29, 36, 0.62);
  box-shadow: none;
}

.query-row button {
  min-height: 46px;
  border: 0;
  border-left: 1px solid rgba(159, 29, 36, 0.58);
  background: transparent;
  color: var(--ink-hot);
  font: 0.78rem/1 var(--sans);
}

.query-row button:hover,
.query-row button:focus-visible {
  background: rgba(159, 29, 36, 0.28);
  outline: 0;
}

.audit-head {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 15px;
  color: rgba(204, 210, 211, 0.48);
  font: 0.68rem/1 var(--mono);
}

.audit-log {
  min-height: 164px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  color: rgba(204, 210, 211, 0.5);
  font-size: 0.7rem;
  line-height: 1.55;
}

.audit-log li {
  border-top: 1px solid rgba(204, 210, 211, 0.08);
  padding: 8px 0 8px 18px;
  position: relative;
}

.audit-log li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  width: 6px;
  height: 1px;
  background: var(--red);
}

.audit-log li:first-child {
  color: rgba(243, 247, 247, 0.78);
  animation: trace-in 180ms ease-out both;
}

.print-mark {
  display: none;
}

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

@keyframes trace-in {
  from {
    opacity: 0;
    transform: translateX(-6px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (max-width: 1160px) {
  .room-layout {
    grid-template-columns: minmax(218px, 252px) minmax(0, 1fr) minmax(250px, 294px);
  }

  .record-detail h1 {
    font-size: 3.6rem;
  }

  .case-code {
    font-size: 2.4rem;
  }
}

@media (max-width: 980px) {
  .gate-link {
    width: min(88svw, 410px, calc((100svh - 96px) * 360 / 620));
  }

  .room-screen {
    padding: 16px;
  }

  .room-layout {
    min-height: auto;
    grid-template-columns: 1fr;
    gap: 0;
  }

  .record-index {
    padding: 0 0 18px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .record-index::before {
    display: none;
  }

  .index-title {
    padding-left: 0;
  }

  .record-list {
    display: flex;
    max-height: none;
    gap: 8px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    padding-bottom: 4px;
  }

  .record-list::-webkit-scrollbar {
    display: none;
  }

  .record-row {
    min-width: 178px;
    min-height: 72px;
    scroll-snap-align: start;
    grid-template-columns: 52px minmax(0, 1fr);
    grid-template-rows: auto auto;
    border: 1px solid var(--line);
    padding: 12px;
  }

  .record-row::before {
    left: 12px;
    top: auto;
    bottom: 10px;
    transform: none;
  }

  .record-tag {
    grid-column: 2;
    opacity: 0.7;
  }

  .record-detail {
    min-height: auto;
    padding: 24px 0 28px;
  }

  .record-detail::before {
    display: none;
  }

  .query-box {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 20px 0 0;
  }
}

@media print {
  body {
    background: #fff;
    color: #111;
  }

  .gate-screen,
  .query-box,
  .record-index,
  .room-head {
    display: none !important;
  }

  .room-screen {
    display: block !important;
    background: #fff !important;
  }

  .room-layout {
    display: block;
  }

  .record-detail {
    color: #111;
    padding: 0;
  }

  .record-detail h1,
  .case-code,
  .meta-grid dt,
  .attachment-head b {
    color: #111;
  }

  .print-mark {
    display: block;
    position: fixed;
    right: 24px;
    bottom: 24px;
    border: 1px solid #111;
    padding: 8px 10px;
    color: #111;
    font: 12px/1.2 var(--mono);
  }
}

@media (max-width: 620px) {
  .room-screen {
    padding: 12px max(12px, env(safe-area-inset-right)) 16px max(12px, env(safe-area-inset-left));
  }

  .room-head {
    display: grid;
    gap: 4px;
    padding-bottom: 10px;
  }

  .corner-readout {
    right: 12px;
    bottom: 12px;
  }

  .gate-cta {
    min-width: 10rem;
    font-size: 0.68rem;
  }

  .case-topline {
    display: grid;
    gap: 8px;
  }

  .case-state {
    text-align: left;
  }

  .case-hero {
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 24px 0 18px;
  }

  .case-code {
    font-size: 2.6rem;
  }

  .record-detail h1 {
    font-size: 3rem;
  }

  .case-summary {
    font-size: 0.94rem;
  }

  .attachment-card {
    padding: 15px;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }

  .query-row {
    grid-template-columns: 1fr;
  }

  .query-row input {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}
