@font-face {
  font-family: Pretendard;
  src: url("./assets/PretendardVariable.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Inside Serif";
  src: url("../assets/news-serif.woff2") format("woff2");
  font-weight: 200 900;
  font-display: swap;
}
@font-face {
  font-family: Newsreader;
  src: url("../assets/wordmark.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
  --canvas: #121414;
  --panel: #191c1b;
  --surface: #232725;
  --surface-hover: #303632;
  --text: #eeeae3;
  --muted: #c2c3b9;
  --rule: #353c38;
  --control-edge: #717970;
  --copper: #e2b494;
  color: var(--text);
  background: var(--canvas);
  --chat-width: 46rem;
  --chat-gutter: clamp(1.25rem, 4vw, 4rem);
}

*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, p { margin: 0; }
button, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--copper); outline-offset: 4px; }
::selection { color: #fff5e9; background: #604738; }

.layout {
  display: grid;
  grid-template-columns: clamp(19rem, 29vw, 25rem) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
}
.reading-pane { display: contents; }
.guide {
  grid-area: 1 / 1 / 3 / 2;
  overflow-y: auto;
  padding: 1.25rem clamp(1.5rem, 2.5vw, 2.5rem) 2rem;
  background: var(--panel);
  border-right: 1px solid var(--rule);
}
.back-link {
  display: inline-grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin-left: -.75rem;
  color: var(--muted);
  border-radius: .65rem;
}
.back-link:hover { color: var(--text); background: var(--surface-hover); }
.guide-inner { margin-top: clamp(1.5rem, 5.5vh, 3.75rem); }
.guide h2 {
  font-size: clamp(1.4rem, 1.7vw, 1.65rem);
  line-height: 1.35;
  letter-spacing: -.045em;
  font-weight: 710;
  word-break: keep-all;
}
.instruction, .reading-note p {
  margin-top: .9rem;
  color: var(--muted);
  font-size: .96rem;
  line-height: 1.7;
  word-break: keep-all;
}
.question, .reading-note { margin-top: 1.65rem; border-top: 1px solid var(--rule); padding-top: 1.5rem; }
.reading-note h3 { margin: 0; color: var(--copper); font-size: 1.05rem; line-height: 1.5; }
.question strong {
  font-size: 1.14rem;
  line-height: 1.6;
  font-weight: 620;
  letter-spacing: -.025em;
  word-break: keep-all;
}
.copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  min-height: 2.75rem;
  margin-top: 1.2rem;
  padding: .55rem .95rem;
  border: 1px solid var(--control-edge);
  border-radius: .65rem;
  color: var(--text);
  background: var(--surface);
  font-size: .9rem;
  font-weight: 570;
}
.copy:hover { border-color: var(--copper); background: var(--surface-hover); }

.thread {
  grid-area: 1 / 2 / 2 / 3;
  container-type: size;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  min-width: 0;
  min-height: 0;
  padding-bottom: .75rem;
}
.thread-masthead {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: clamp(1rem, 2.6cqi, 2.5rem);
  padding: clamp(.7rem, 3cqb, 1.75rem) clamp(1.15rem, 3.6cqi, 3.5rem);
  background: #1a201e;
  border-bottom: 1px solid var(--rule);
}
.thread-preface {
  flex: none;
  color: var(--muted);
  font-family: "Inside Serif", Georgia, serif;
  font-size: clamp(1rem, 2.4cqi, 2.25rem);
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: .06em;
  white-space: nowrap;
}
.thread-title {
  min-width: 0;
  color: #f2eade;
  font-family: "Inside Serif", Georgia, serif;
  font-weight: 560;
  font-size: clamp(1.5rem, 4.7vw, 5.75rem);
  font-size: min(clamp(1.55rem, 6.4cqi, 5.75rem), 25cqb);
  line-height: 1.2;
  letter-spacing: .145em;
  word-spacing: .07em;
}
.thread-title > span { display: inline-block; white-space: nowrap; }
.title-ai {
  color: var(--copper);
  font-family: Newsreader, Georgia, serif;
  font-size: 1.12em;
  font-weight: 500;
  font-optical-sizing: auto;
  letter-spacing: .12em;
}
@container (max-width: 36rem) {
  .thread-masthead {
    flex-direction: column;
    align-items: flex-start;
    gap: .15rem;
    padding-block: clamp(.25rem, 2cqb, .75rem);
  }
}
@container (max-width: 29rem) {
  .thread-title { font-size: min(clamp(1.45rem, 8.25cqi, 2.35rem), 23cqb); letter-spacing: .105em; }
}
.analysis-progress {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  width: min(var(--chat-width), calc(100% - 2 * var(--chat-gutter)));
  margin: 0 auto;
  padding: clamp(.25rem, 2.5cqb, 1.5rem) 0 .5rem;
  word-break: keep-all;
}
.analysis-progress:focus { outline: 0; }
.analysis-intro { color: var(--text); font-size: clamp(1rem, 1.7cqi, 1.23rem); line-height: 1.6; font-weight: 560; }
.analysis-progress[data-phase="typing"] #analysis-typed::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: .95em;
  margin-left: .12em;
  vertical-align: -.08em;
  background: var(--copper);
}
.analysis-status { margin-top: .65rem; font-size: .96rem; line-height: 1.6; color: var(--muted); }
#analysis-dots { display: inline-block; min-width: 1.4em; }
.analysis-progress[data-phase="complete"] .analysis-status { color: var(--copper); }
.analysis-result-link:not([hidden]) {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  min-height: 2.75rem;
  margin-top: .4rem;
  padding: .35rem .75rem;
  border: 1px solid var(--control-edge);
  border-radius: .6rem;
  background: var(--surface);
  color: var(--text);
  font-size: .9rem;
  text-decoration: none;
}
.analysis-result-link:focus-visible { outline-offset: -2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.result-page {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}
.result-bar {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem clamp(1.25rem, 4vw, 4rem);
  border-bottom: 1px solid var(--rule);
  background: #1a201e;
  color: var(--muted);
  font-family: "Inside Serif", Georgia, serif;
  letter-spacing: .045em;
}
.result-sheet {
  align-self: center;
  width: min(100%, 44rem);
  margin: 0 auto;
  padding: clamp(2rem, 7vh, 5rem) 1.25rem;
  text-align: center;
}
.result-kicker { color: var(--copper); font-size: .88rem; font-weight: 600; letter-spacing: .12em; }
.result-heading {
  margin: 1.65rem 0 1.25rem;
  color: #f2eade;
  font: 550 clamp(1.75rem, 4.25vw, 3.4rem)/1.25 "Inside Serif", Georgia, serif;
  letter-spacing: -.025em;
}
.result-heading > span { display: block; }
.result-verdict { white-space: nowrap; }
.result-verdict strong {
  display: inline-block;
  margin: .08em .09em 0 0;
  color: var(--copper);
  font: 530 clamp(5.5rem, 13vw, 10.25rem)/1 Newsreader, Georgia, serif;
}
.result-note {
  max-width: 30rem;
  margin: 0 auto;
  color: var(--muted);
  font-size: .98rem;
  line-height: 1.6;
  word-break: keep-all;
  text-wrap: balance;
}
.score-explanation, .result-breakdown { max-width: 32rem; margin-inline: auto; }
.result-portrait {
  width: 100%;
  max-width: 32rem;
  margin: 1.5rem auto 0;
  border: 1px solid var(--rule);
  background: var(--panel);
  text-align: left;
}
.result-portrait img { display: block; width: 100%; height: auto; }
.result-portrait figcaption { padding: .8rem 1rem 1rem; }
.portrait-title { color: var(--copper); font-size: .82rem; font-weight: 650; }
.result-portrait figcaption p {
  margin-top: .2rem;
  color: var(--text);
  font: 550 clamp(1.1rem, 2.5vw, 1.6rem)/1.5 "Inside Serif", Georgia, serif;
  letter-spacing: -.03em;
  word-break: keep-all;
}
.score-explanation { margin-top: 1.75rem; padding-top: 1.2rem; border-top: 1px solid var(--rule); text-align: left; }
.score-explanation h2 { font-size: 1.2rem; line-height: 1.45; }
#reason-overview, .score-reason p { margin-top: .4rem; color: var(--muted); font-size: .95rem; line-height: 1.65; }
.score-reason { margin-top: 1rem; text-align: left; word-break: keep-all; overflow-wrap: anywhere; }
.score-reason h3 { margin: 0; color: var(--copper); font-size: .98rem; line-height: 1.5; }
.score-reason blockquote { margin: .5rem 0; padding: .4rem .8rem; border-left: 2px solid var(--copper); background: var(--panel); font-size: .92rem; line-height: 1.6; white-space: pre-line; }
.result-breakdown { margin-top: 1rem; font-size: .9rem; }
.result-breakdown summary { width: fit-content; margin: 0 auto; color: var(--copper); cursor: pointer; }
.result-breakdown summary:focus-visible { outline: 2px solid var(--copper); outline-offset: 4px; }
.result-breakdown dl { margin: .85rem 0 0; border-top: 1px solid var(--rule); }
.result-breakdown dl div { display: flex; justify-content: space-between; gap: .7rem; padding: .45rem .1rem; border-bottom: 1px solid var(--rule); }
.result-breakdown dt { color: var(--muted); text-align: left; }
.result-breakdown dd { margin: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
.retry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  margin-top: 2rem;
  min-height: 2.9rem;
  padding: .65rem 1.3rem;
  border: 1px solid var(--control-edge);
  border-radius: .7rem;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.retry:hover { background: var(--surface-hover); border-color: var(--copper); }
.dock {
  grid-area: 2 / 2 / 3 / 3;
  padding: .75rem var(--chat-gutter) max(1.75rem, env(safe-area-inset-bottom));
}
.composer {
  display: flex;
  align-items: flex-end;
  gap: .6rem;
  width: 100%;
  max-width: var(--chat-width);
  margin: 0 auto;
  padding: .6rem;
  border: 1px solid var(--control-edge);
  border-radius: 1.8rem;
  background: var(--surface);
  box-shadow: 0 2px 9px #0003;
}
.composer:focus-within { border-color: var(--copper); }
.composer textarea {
  flex: 1;
  min-width: 0;
  min-height: 2.5rem;
  max-height: min(10rem, 30dvh);
  padding: .5rem .5rem .5rem .85rem;
  resize: none;
  border: 0;
  outline: 0;
  color: inherit;
  caret-color: var(--copper);
  background: transparent;
  font-size: 1rem;
  line-height: 1.5;
}
.composer textarea::placeholder { color: #b5b9b1; opacity: 1; }
.send {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid #a58b73;
  border-radius: 50%;
  color: #f6e0c5;
  background: #43392f;
}
.send:hover:enabled { background: #554537; }
.send:disabled { cursor: default; color: #9a9f96; background: #303532; border-color: transparent; }

@media (max-width: 720px) {
  .layout { display: flex; flex-direction: column; }
  .reading-pane { display: flex; flex-direction: column; flex: 1; min-height: 0; }
  .guide { flex: none; max-height: max(45%, calc(100% - 10rem)); overflow-y: auto; padding: .45rem 1.25rem 1.25rem; border: 0; border-bottom: 1px solid var(--rule); }
  .reading-pane:has(.analysis-progress:not([hidden])) .guide { max-height: max(20%, calc(100% - 16rem)); }
  .guide-inner { margin-top: .4rem; }
  .instruction, .reading-note p { margin-top: .55rem; }
  .question, .reading-note { margin-top: 1rem; padding-top: 1rem; }
  .question strong { font-size: 1.08rem; }
  .copy { margin-top: .85rem; }
  .thread { flex: 1; padding-bottom: .5rem; --chat-gutter: .85rem; }
  .dock { flex: none; padding: .5rem .85rem max(.85rem, env(safe-area-inset-bottom)); }
}

@media (max-width: 720px) and (max-height: 600px) {
  .guide { padding-bottom: .8rem; }
  .question, .reading-note { margin-top: .6rem; padding-top: .6rem; }
}


/* Topbar & Language Switch */
.guide-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .2rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--canvas);
  font-size: .78rem;
}
.lang-gate-btn, .lang-pill {
  padding: .28rem .62rem;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 560;
  white-space: nowrap;
}
.lang-gate-btn:hover, .lang-pill:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.lang-pill.active {
  color: #141210;
  background: var(--copper);
  font-weight: 700;
}
.result-lang-links {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: .84rem;
  letter-spacing: 0;
}
.result-lang-links a {
  color: var(--muted);
  text-decoration: none;
  padding: .25rem .55rem;
  border: 1px solid var(--rule);
  border-radius: .45rem;
  background: var(--panel);
}
.result-lang-links a:hover {
  color: var(--text);
  border-color: var(--copper);
}

/* Language Selection Gate Page */
.gate-page {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(circle at 50% 0%, #1e2522 0%, var(--canvas) 68%);
}
.gate-bar {
  justify-content: flex-start;
}
.gate-main {
  align-self: center;
  width: min(100%, 66rem);
  margin: 0 auto;
  padding: clamp(1.5rem, 4.5vh, 3.5rem) clamp(1rem, 3.5vw, 2.5rem) clamp(2.25rem, 5vh, 4rem);
}
.gate-header {
  text-align: center;
  margin-bottom: clamp(1.4rem, 3.5vh, 2.4rem);
}
.gate-kicker {
  color: var(--copper);
  font-size: .84rem;
  font-weight: 650;
  letter-spacing: .14em;
}
.gate-title {
  margin-top: .45rem;
  color: #f2eade;
  font-family: "Inside Serif", Georgia, serif;
  font-weight: 560;
  font-size: clamp(2rem, 5vw, 3.85rem);
  line-height: 1.18;
  letter-spacing: .08em;
}
.gate-title > span {
  display: inline-block;
}
.gate-subtitle {
  max-width: 36rem;
  margin: .75rem auto 0;
  color: var(--muted);
  font-size: clamp(.92rem, 1.4vw, 1.04rem);
  line-height: 1.6;
  word-break: keep-all;
}
.gate-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1rem, 2.5vw, 1.85rem);
}
.gate-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--rule);
  border-radius: 1rem;
  overflow: hidden;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
  box-shadow: 0 10px 28px #00000045;
}
.gate-card:hover {
  transform: translateY(-3px);
  border-color: var(--copper);
  box-shadow: 0 14px 36px #00000066;
}
.gate-thumb {
  position: relative;
  aspect-ratio: 3 / 2;
  background: #0e1010;
  overflow: hidden;
  border-bottom: 1px solid var(--rule);
}
.gate-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s ease;
}
.gate-card:hover .gate-thumb img {
  transform: scale(1.025);
}
.gate-badge {
  position: absolute;
  top: .85rem;
  left: .85rem;
  padding: .3rem .7rem;
  border-radius: 999px;
  border: 1px solid #e2b49466;
  background: #121414d9;
  backdrop-filter: blur(6px);
  color: var(--copper);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .08em;
}
.gate-card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: clamp(1.1rem, 2.2vw, 1.5rem);
}
.gate-card-body h2 {
  font-size: clamp(1.25rem, 2vw, 1.55rem);
  font-weight: 700;
  letter-spacing: -.02em;
  color: #f5efe6;
}
.gate-card-body p {
  margin-top: .55rem;
  color: var(--muted);
  font-size: .94rem;
  line-height: 1.62;
  word-break: keep-all;
  flex: 1;
}
.gate-cta {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.15rem;
  padding: .65rem 1rem;
  border: 1px solid var(--control-edge);
  border-radius: .65rem;
  background: var(--surface);
  color: #f6e4ce;
  font-size: .92rem;
  font-weight: 650;
  transition: background .15s ease, border-color .15s ease;
}
.gate-card:hover .gate-cta {
  background: #43392f;
  border-color: var(--copper);
}

@media (max-width: 720px) {
  .gate-grid {
    grid-template-columns: 1fr;
  }
  .lang-switch {
    font-size: .73rem;
  }
  .lang-gate-btn, .lang-pill {
    padding: .24rem .5rem;
  }
  .result-lang-links {
    gap: .4rem;
    font-size: .76rem;
  }
}
