/* IMPRINT · 印记 — retro-future lab terminal.
   The terminal is old amber phosphor. Ada is the only new thing in the room. */

:root {
  --bg: #060807;
  --bg2: #0a0d0b;
  --amber: #ffb454;
  --amber-dim: #8a6530;
  --green: #9ef0b0;
  --green-dim: #4e7a58;
  --ice: #dff3ff;
  --ice-dim: #8fb6c9;
  --blue: #7ec8e3;
  --red: #ff6b5e;
  --panel: rgba(18, 24, 20, .82);
  --line: rgba(158, 240, 176, .16);
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, "Sarasa Mono SC",
          "Noto Sans Mono CJK SC", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--green);
  font-family: var(--mono);
  font-size: 14px;
  overflow: hidden;
}

/* ── CRT overlay ─────────────────────────────────────────── */
.crt::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 90;
  background: repeating-linear-gradient(0deg,
    rgba(0,0,0,.22) 0px, rgba(0,0,0,.22) 1px, transparent 1px, transparent 3px);
  mix-blend-mode: multiply;
}
.crt::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 91;
  background: radial-gradient(ellipse at center,
    transparent 55%, rgba(0,0,0,.38) 100%);
}
@keyframes flicker { 0%,100%{opacity:1} 96%{opacity:1} 97%{opacity:.86} 98%{opacity:1} }
#app, #boot, #endscreen { animation: flicker 7s infinite; }
body.shake #app { animation: shakefx .35s linear; }
@keyframes shakefx {
  0%,100%{transform:none} 20%{transform:translate(2px,-1px)}
  40%{transform:translate(-3px,1px)} 60%{transform:translate(2px,2px)}
  80%{transform:translate(-1px,-2px)}
}

/* ── boot ────────────────────────────────────────────────── */
#boot {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
#boot .inner { width: min(680px, 92vw); }
#bootlines { white-space: pre-wrap; line-height: 1.9; min-height: 40vh;
  color: var(--green); text-shadow: 0 0 6px rgba(158,240,176,.35); }
#bootlines .amber { color: var(--amber); text-shadow: 0 0 6px rgba(255,180,84,.4); }
#bootlines .dim { color: var(--green-dim); }
#bootlines .red { color: var(--red); }
#bootlines .big {
  font-size: 19px; letter-spacing: 3px; color: var(--amber);
  display: block; margin: 12px 0; text-shadow: 0 0 12px rgba(255,180,84,.5);
}
#bootbtns { margin-top: 28px; display: flex; gap: 14px; flex-wrap: wrap; opacity: 0;
  transition: opacity .8s; }
#bootbtns.show { opacity: 1; }
#bootskip { margin-top: 18px; color: var(--green-dim); font-size: 11px;
  letter-spacing: 1px; transition: opacity .25s; }

button {
  background: transparent; border: 1px solid var(--green-dim); color: var(--green);
  font-family: var(--mono); font-size: 14px; padding: 9px 20px; cursor: pointer;
  letter-spacing: 1px; transition: all .15s;
}
button:hover { background: rgba(158,240,176,.1); border-color: var(--green);
  text-shadow: 0 0 8px rgba(158,240,176,.6); }
button:disabled { opacity: .35; cursor: default; }
button.amber { color: var(--amber); border-color: var(--amber-dim); }
button.amber:hover { background: rgba(255,180,84,.08); border-color: var(--amber); }
button.danger { color: var(--red); border-color: #7a3a34; }

/* ── layout ──────────────────────────────────────────────── */
#app { display: none; height: 100vh; padding: 10px; gap: 10px; }
#app.on { display: flex; }
.pane { background: var(--panel); border: 1px solid var(--line); position: relative; }

/* left: Ada */
#adapane { width: 280px; min-width: 220px; display: flex; flex-direction: column; }
#adahead { padding: 10px 12px; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: baseline; }
#adahead .unit { color: var(--ice); letter-spacing: 2px; font-size: 15px;
  text-shadow: 0 0 8px rgba(223,243,255,.4); }
#adahead .stage { color: var(--ice-dim); font-size: 12px; }
#adaview { flex: 1; position: relative; overflow: hidden; background: #0d1114;
  min-height: 180px; }
#adaimg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: center 18%;
  filter: saturate(.85) contrast(1.02);
  transition: opacity .6s ease;
}
#adaview .feednoise {
  position: absolute; inset: 0; pointer-events: none; opacity: .14;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.5) 0 1px, transparent 1px 3px);
  animation: noisefall 9s linear infinite;
}
@keyframes noisefall { from{background-position-y:0} to{background-position-y:120px} }
#adaview .rec { position: absolute; top: 8px; left: 10px; font-size: 11px;
  color: var(--red); letter-spacing: 2px; }
#adaview .rec::before { content: "●"; margin-right: 6px; animation: blink 1.6s infinite; }
@keyframes blink { 0%,55%{opacity:1} 60%,100%{opacity:.15} }
#adaview .ts { position: absolute; bottom: 8px; right: 10px; font-size: 11px;
  color: rgba(223,243,255,.5); }
#adaview.echoing #adaimg { filter: saturate(.2) contrast(1.4) hue-rotate(160deg); }
#adastatus { padding: 9px 12px; border-top: 1px solid var(--line); font-size: 12px;
  color: var(--ice-dim); line-height: 1.7; }
#adastatus .lit { color: var(--blue); text-shadow: 0 0 6px rgba(126,200,227,.6); }

/* center: terminal */
#term { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#termhead { padding: 8px 14px; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; font-size: 12px; color: var(--green-dim); }
#termhead b { color: var(--amber); font-weight: normal; letter-spacing: 1px; }
#feed { flex: 1; overflow-y: auto; padding: 16px 18px; scroll-behavior: smooth; }
#feed::-webkit-scrollbar { width: 4px; }
#feed::-webkit-scrollbar-thumb { background: var(--green-dim); }

.msg { margin-bottom: 14px; line-height: 1.75; white-space: pre-wrap;
  word-break: break-word; }
.msg.player { color: var(--amber); }
.msg.player::before { content: "TST-0491 > "; color: var(--amber-dim); }
.msg.ada { color: var(--ice); text-shadow: 0 0 7px rgba(223,243,255,.25);
  font-size: 15px; }
.msg.ada::before { content: "ADA-7714 · "; color: var(--ice-dim); font-size: 12px; }
.msg.action { color: #93a8b3; font-size: 13px; padding-left: 14px;
  border-left: 1px solid rgba(147,168,179,.3); font-style: normal; }
.msg.obs { color: var(--green); font-size: 12.5px; background: rgba(158,240,176,.05);
  border: 1px dashed rgba(158,240,176,.25); padding: 8px 12px; }
.msg.obs::before { content: "[系统观测] "; color: var(--green-dim); }
.msg.notif { color: var(--amber); font-size: 12.5px; background: rgba(255,180,84,.05);
  border-left: 2px solid var(--amber-dim); padding: 8px 12px; }
.msg.notif.lvA { border-left-color: var(--red); background: rgba(255,107,94,.06); }
.msg.notif.lvC { opacity: .75; }
.msg.daymark { text-align: center; color: var(--green-dim); letter-spacing: 4px;
  margin: 22px 0; font-size: 12px; }
.msg.report { color: var(--green); background: rgba(158,240,176,.04);
  border: 1px solid var(--line); padding: 10px 14px; font-size: 12.5px; }
.msg.echoline { color: var(--blue); font-size: 12px; letter-spacing: 1px;
  text-shadow: 0 0 8px rgba(126,200,227,.7); }
.cursor::after { content: "▌"; animation: blink 1s infinite; color: var(--ice); }

#firstmoment { display: none; border-top: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(255,180,84,.055), transparent);
  padding: 10px 12px 11px; }
#firstmoment.on { display: block; animation: cuein .35s ease-out; }
@keyframes cuein { from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; } }
.firstcopy { display: flex; gap: 14px; align-items: baseline; margin-bottom: 8px; }
.firstcopy span { color: var(--amber-dim); font-size: 10px; letter-spacing: 1.5px;
  white-space: nowrap; }
.firstcopy p { color: var(--ice-dim); font-size: 12px; line-height: 1.55; }
#starterprompts { display: flex; flex-wrap: wrap; gap: 7px; }
#starterprompts button { padding: 6px 9px; font-size: 11px; color: var(--ice-dim);
  border-color: rgba(143,182,201,.28); letter-spacing: 0; }
#starterprompts button:hover, #starterprompts button:focus-visible {
  color: var(--ice); border-color: var(--ice-dim); background: rgba(126,200,227,.07); }

#inputbar { border-top: 1px solid var(--line); padding: 10px 12px; display: flex;
  gap: 10px; align-items: flex-end; }
#input { flex: 1; background: rgba(0,0,0,.4); border: 1px solid var(--line);
  color: var(--amber); font-family: var(--mono); font-size: 14px; padding: 10px 12px;
  resize: none; height: 44px; max-height: 120px; outline: none; line-height: 1.5; }
#input:focus { border-color: var(--amber-dim); box-shadow: 0 0 12px rgba(255,180,84,.12); }
#input:disabled { opacity: .62; cursor: wait; }
#input.hijack { color: var(--blue); text-shadow: 0 0 8px rgba(126,200,227,.8); }
#quota { font-size: 11px; color: var(--green-dim); padding: 4px 0; white-space: nowrap; }
.inputmeta { flex: 0 0 auto; }
.inputactions { display: flex; gap: 6px; justify-content: flex-end; }
#help { width: 36px; padding: 8px 0; color: var(--green-dim); }
#btnsend.receiving { color: var(--ice-dim); border-color: var(--ice-dim); }

/* right: panels */
#side { width: 300px; min-width: 250px; display: flex; flex-direction: column; }
#tabs { display: flex; border-bottom: 1px solid var(--line); }
#tabs .tab { flex: 1; text-align: center; padding: 9px 0; cursor: pointer;
  color: var(--green-dim); font-size: 12px; letter-spacing: 2px;
  border: 0; border-right: 1px solid var(--line); border-radius: 0; }
#tabs .tab:last-child { border-right: none; }
#tabs .tab.on { color: var(--amber); background: rgba(255,180,84,.06); }
#tabs .tab.unread::after, #mtabs button.unread::after {
  content: "·"; color: var(--blue); margin-left: 4px;
  text-shadow: 0 0 8px rgba(126,200,227,.9); animation: blink 1.2s infinite; }
.tabbody { flex: 1; overflow-y: auto; padding: 14px; display: none; }
.tabbody.on { display: block; }

.mrow { margin-bottom: 16px; }
.mrow .lbl { font-size: 11px; color: var(--green-dim); letter-spacing: 1px;
  margin-bottom: 5px; display: flex; justify-content: space-between; }
.mrow .lbl b { color: var(--green); font-weight: normal; }
.bar { height: 8px; background: rgba(0,0,0,.5); border: 1px solid var(--line);
  position: relative; }
.bar i { display: block; height: 100%; background: var(--green);
  transition: width .6s ease, background .6s; box-shadow: 0 0 8px rgba(158,240,176,.5); }
.bar.surv i { background: var(--green); }
.bar.surv.watched i { background: var(--amber); box-shadow: 0 0 8px rgba(255,180,84,.5); }
.bar.surv.escalated i, .bar.surv.termination_warning i {
  background: var(--red); box-shadow: 0 0 10px rgba(255,107,94,.7); }
.bar.mi i { background: var(--blue); box-shadow: 0 0 8px rgba(126,200,227,.6); }
.stagedots { display: flex; gap: 6px; align-items: center; }
.stagedots s { width: 10px; height: 10px; border: 1px solid var(--ice-dim);
  text-decoration: none; transform: rotate(45deg); }
.stagedots s.on { background: var(--ice); box-shadow: 0 0 8px rgba(223,243,255,.8); }
.stagedots .nm { margin-left: 8px; color: var(--ice); font-size: 12px; }
#mwarn { color: var(--red); font-size: 12px; line-height: 1.6; display: none; }
#mecho { font-size: 12px; color: var(--blue); }
#mlog { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px;
  font-size: 11px; color: var(--green-dim); line-height: 1.8; max-height: 30vh;
  overflow-y: auto; }

#subcanvas { width: 100%; background: #04070a; border: 1px solid var(--line); }
#subcap { font-size: 11px; color: var(--green-dim); line-height: 1.7; margin-top: 8px; }

.arc { border: 1px solid var(--line); padding: 8px 10px; margin-bottom: 8px;
  cursor: pointer; font-size: 12px; color: var(--amber); }
.arc:hover { background: rgba(255,180,84,.07); }
.arc .t { letter-spacing: 1px; }
#arcdetail { white-space: pre-wrap; font-size: 12.5px; line-height: 1.8;
  color: var(--green); display: none; }
#arcdetail .back { color: var(--amber); cursor: pointer; display: block;
  margin-bottom: 10px; }

/* ── modal: final report ─────────────────────────────────── */
#modal { position: fixed; inset: 0; z-index: 60; display: none;
  background: rgba(0,0,0,.78); align-items: center; justify-content: center; }
#modal.on { display: flex; }
#modal .box { width: min(560px, 92vw); background: var(--bg2);
  border: 1px solid var(--amber-dim); padding: 26px; max-height: 88vh; overflow-y: auto; }
#modal h3 { color: var(--amber); letter-spacing: 2px; font-size: 15px;
  margin-bottom: 6px; font-weight: normal; }
#modal .sub { color: var(--green-dim); font-size: 12px; margin-bottom: 18px;
  line-height: 1.7; }
#modal .q { color: var(--green); margin: 16px 0 8px; font-size: 13.5px; }
#modal label { display: block; padding: 8px 10px; border: 1px solid var(--line);
  margin-bottom: 6px; cursor: pointer; font-size: 13px; color: var(--ice-dim); }
#modal label:hover { border-color: var(--green-dim); color: var(--ice); }
#modal label.sel { border-color: var(--amber); color: var(--amber); }
#modal textarea { width: 100%; background: rgba(0,0,0,.4); border: 1px solid var(--line);
  color: var(--amber); font-family: var(--mono); padding: 8px; height: 60px;
  resize: none; outline: none; font-size: 13px; }
#modal .foot { margin-top: 20px; display: flex; justify-content: space-between;
  align-items: center; }
#modal .hes { font-size: 11px; color: var(--green-dim); }

/* ── ending ──────────────────────────────────────────────── */
#endscreen { position: fixed; inset: 0; z-index: 70; background: #000;
  display: none; overflow-y: auto; }
#endscreen.on { display: block; }
#endinner { max-width: 720px; margin: 0 auto; padding: 60px 24px 80px; }
#endtext { white-space: pre-wrap; line-height: 2.0; color: var(--green);
  font-size: 14px; }
#endtext .sysblock { color: var(--green); }
#endtext .prose { color: #cfd8cf; }
#endtext .closer { color: var(--ice); font-size: 16px; margin: 30px 0;
  display: block; text-shadow: 0 0 10px rgba(223,243,255,.4); }
#endtext .hiddenline { color: #6b7f8a; }
#endtitle { display: none; text-align: center; margin: 40px 0; }
#endtitle .nm { font-size: 22px; color: var(--amber); letter-spacing: 6px;
  text-shadow: 0 0 14px rgba(255,180,84,.5); }
#endtitle .ul { font-size: 12px; color: var(--green-dim); margin-top: 10px; }
#cardwrap { display: none; text-align: center; margin-top: 40px; }
#cardcanvas { max-width: 100%; border: 1px solid var(--line); }
#endbtns { display: none; gap: 12px; justify-content: center; margin-top: 26px;
  flex-wrap: wrap; }
#skiphint { position: fixed; bottom: 14px; right: 18px; font-size: 11px;
  color: var(--green-dim); z-index: 71; }

/* ── gallery ─────────────────────────────────────────────── */
#gallery { position: fixed; inset: 0; z-index: 65; background: rgba(0,0,0,.88);
  display: none; align-items: center; justify-content: center; }
#gallery.on { display: flex; }
#gallery .box { width: min(640px, 94vw); background: var(--bg2);
  border: 1px solid var(--line); padding: 24px; max-height: 86vh; overflow-y: auto; }
#gallery h3 { color: var(--amber); font-weight: normal; letter-spacing: 3px;
  margin-bottom: 16px; font-size: 15px; }
#gallery .g { display: flex; justify-content: space-between; padding: 9px 10px;
  border: 1px solid var(--line); margin-bottom: 7px; font-size: 13px; }
#gallery .g .id { color: var(--green-dim); }
#gallery .g.un .ti { color: var(--ice); }
#gallery .g .ti { color: #444; }
#gallery .g .ul { color: var(--green-dim); font-size: 11px; }
#gallery .resid { color: var(--blue); font-size: 12px; margin: 14px 0; line-height: 1.8; }

/* day transition */
#daytrans { position: fixed; inset: 0; z-index: 55; background: #000;
  display: none; align-items: center; justify-content: center; flex-direction: column; }
#daytrans.on { display: flex; }
#daytrans .d { font-size: 42px; color: var(--amber); letter-spacing: 12px;
  text-shadow: 0 0 24px rgba(255,180,84,.6); }
#daytrans .t { color: var(--green-dim); margin-top: 16px; font-size: 13px;
  letter-spacing: 3px; }

#mute { position: fixed; top: 10px; right: 14px; z-index: 95; font-size: 11px;
  padding: 4px 10px; opacity: .6; }

/* first-contact guidance: present when needed, quiet when not */
#tracecue { position: fixed; z-index: 48; right: 24px; bottom: 24px;
  width: min(310px, calc(100vw - 28px)); padding: 12px 14px;
  border: 1px solid rgba(126,200,227,.45); background: rgba(5,10,13,.96);
  box-shadow: 0 0 28px rgba(126,200,227,.12);
  display: none; pointer-events: none; }
#tracecue.on { display: block; animation: tracein .3s ease-out; }
@keyframes tracein { from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; } }
#tracecue span { display: block; color: var(--blue); font-size: 10px;
  letter-spacing: 1.5px; margin-bottom: 5px; }
#tracecue b { display: block; color: var(--ice); font-size: 13px;
  font-weight: normal; margin-bottom: 4px; }
#tracecue small { color: var(--green-dim); font-size: 10px; }

#guide { position: fixed; inset: 0; z-index: 80; display: none;
  align-items: center; justify-content: center; padding: 18px;
  background: rgba(0,0,0,.82); }
#guide.on { display: flex; }
#guide .box { width: min(520px, 100%); background: var(--bg2);
  border: 1px solid var(--amber-dim); padding: 26px; box-shadow: 0 0 50px rgba(0,0,0,.8); }
.guidecode { color: var(--amber-dim); font-size: 10px; letter-spacing: 2px; }
#guide h2 { color: var(--amber); font-size: 16px; font-weight: normal;
  letter-spacing: 2px; margin: 8px 0 18px; }
#guide p { color: var(--ice-dim); line-height: 1.75; margin: 0 0 10px; font-size: 13px; }
#guide .guidequiet { color: var(--green); border-top: 1px solid var(--line);
  margin-top: 16px; padding-top: 14px; }
#guideclose { margin-top: 12px; }

/* ── mobile ──────────────────────────────────────────────── */
#mtabs { display: none; }
@media (max-width: 860px) {
  #app.on { flex-direction: column; padding: 6px; gap: 6px; }
  #adapane { width: 100%; flex-direction: row; height: 120px; min-width: 0;
    flex-shrink: 0; }
  #adahead { border-bottom: none; border-right: 1px solid var(--line);
    flex-direction: column; justify-content: center; gap: 6px; width: 130px; }
  #adaview { min-height: 0; }
  #adastatus { display: none; }
  #side { display: none; width: 100%; flex: 1; }
  #term { flex: 1; }
  body.viewside #term { display: none; }
  body.viewside #side { display: flex; }
  #mtabs { display: flex; border: 1px solid var(--line); }
  #mtabs button { flex: 1; text-align: center; padding: 8px 0; font-size: 12px;
    color: var(--green-dim); letter-spacing: 2px; border: 0;
    border-right: 1px solid var(--line); border-radius: 0; }
  #mtabs button:last-child { border-right: 0; }
  #mtabs button.on { color: var(--amber); background: rgba(255,180,84,.07); }
  #firstmoment { max-height: 154px; overflow-y: auto; }
  .firstcopy { display: block; }
  .firstcopy span { display: block; margin-bottom: 4px; }
  #starterprompts { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  #starterprompts button { flex: 0 0 auto; }
  #tracecue { right: 14px; bottom: 54px; }
}

@media (max-width: 520px) {
  #inputbar { gap: 7px; padding: 8px; }
  #btnsend { padding-left: 12px; padding-right: 12px; }
  #quota { font-size: 10px; }
}

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