:root {
  --bg: #f5f3ee;
  --panel: #fffdf8;
  --ink: #252525;
  --muted: #696862;
  --line: #ddd7cd;
  --accent: #495d4f;
  --accent-dark: #35463a;
  --student: #e8edf6;
  --plato: #f3eee2;
  --warn: #7d442d;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans KR", sans-serif; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; border: 0; border-radius: 11px; padding: 10px 14px; }
button:disabled { cursor: not-allowed; opacity: .55; }
.primary { background: var(--accent); color: white; }
.primary:hover { background: var(--accent-dark); }
.secondary { background: #ece8df; color: var(--ink); }
.ghost { background: transparent; border: 1px solid var(--line); }
.hidden { display: none !important; }
.wrap { max-width: 920px; margin: auto; padding: 18px; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
h1 { font-size: 1.25rem; margin: 14px 0; }
h2 { margin-top: 0; }
.badge { font-size: .78rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 5px 9px; background: white; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 8px 24px #0000000a; }
.start, .summary, .teacher { padding: 24px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { display: block; color: var(--muted); font-size: .9rem; margin-bottom: 6px; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: white; color: var(--ink); }
textarea { resize: vertical; min-height: 58px; }
.actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 16px; }
.notice { font-size: .86rem; color: var(--muted); line-height: 1.55; }
.notice.warn { color: var(--warn); }
.topic-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 18px 0 20px; }
.topic-option { display: flex; min-height: 150px; flex-direction: column; align-items: flex-start; gap: 7px; padding: 15px; border: 1px solid var(--line); background: white; color: var(--ink); text-align: left; }
.topic-option:not(:disabled):hover { border-color: var(--accent); }
.topic-option.is-selected { border: 2px solid var(--accent); background: #f1f5f1; padding: 14px; }
.topic-option:disabled { opacity: .72; }
.topic-option-title { font-weight: 700; }
.topic-option-question { line-height: 1.4; }
.topic-option-description { color: var(--muted); font-size: .82rem; line-height: 1.45; }
.topic-option-status { margin-top: auto; border-radius: 999px; padding: 3px 7px; background: #ece8df; color: var(--muted); font-size: .75rem; }
.chat { height: calc(100vh - 86px); min-height: 620px; display: flex; flex-direction: column; overflow: hidden; }
.chathead { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.chathead-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.chathead-actions button { white-space: nowrap; }
.meta { font-size: .82rem; color: var(--muted); }
.progress { height: 7px; width: 220px; max-width: 46vw; background: #ece8df; border-radius: 999px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; width: 3%; background: var(--accent); transition: width .25s ease; }
.messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 80%; padding: 11px 13px; border-radius: 14px; line-height: 1.58; white-space: pre-wrap; }
.msg.plato { align-self: flex-start; background: var(--plato); border-bottom-left-radius: 4px; }
.msg.student { align-self: flex-end; background: var(--student); border-bottom-right-radius: 4px; }
.msg.system { align-self: center; color: var(--muted); font-size: .84rem; background: transparent; padding: 4px; }
.msg.transient-pause {
  min-width: 48px;
  color: var(--muted);
  letter-spacing: .14em;
  text-align: center;
  opacity: 0;
  pointer-events: none;
}
.msg.transient-pause.is-pulsing {
  animation: transient-pause-pulse var(--transient-pulse-duration, 1500ms) ease-in-out 1;
}
@keyframes transient-pause-pulse {
  0%, 100% { opacity: 0; transform: translateY(2px); }
  30%, 70% { opacity: .72; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .msg.transient-pause.is-pulsing { animation: none; opacity: .72; }
}
.msg.typing { cursor: pointer; }
.typing-text { min-height: 1em; }
.skip-typing { display: block; width: max-content; margin-top: 8px; padding: 4px 8px; border: 1px solid #cfc8bb; border-radius: 6px; background: #fffdf8; color: var(--muted); font-size: .76rem; }
.summary-gate { align-self: flex-start; margin-top: 2px; }
.summary-gate button { border-radius: 7px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.composer { border-top: 1px solid var(--line); padding: 12px; display: flex; gap: 9px; align-items: flex-end; }
.composer textarea { max-height: 150px; }
.composer button { min-width: 84px; }
.thinking { display: inline-flex; gap: 4px; align-items: center; }
.thinking span { width: 6px; height: 6px; border-radius: 50%; background: #777; animation: pulse 1.2s infinite ease-in-out; }
.thinking span:nth-child(2) { animation-delay: .15s; }
.thinking span:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { 0%, 80%, 100% { opacity: .25; transform: scale(.85); } 40% { opacity: 1; transform: scale(1); } }
@keyframes viewEnter { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.view-enter { animation: viewEnter .2s ease-out both; }
.sumblock { border: 1px solid var(--line); background: white; border-radius: 13px; padding: 12px; margin: 10px 0; }
.sumblock h3 { font-size: .9rem; color: var(--muted); margin: 0 0 7px; }
.transcript-section { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.transcript-section > h3 { margin: 0 0 10px; font-size: 1rem; }
.transcript-panel { margin-top: 14px; }
.transcript-list { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.transcript-message { width: fit-content; max-width: 86%; padding: 11px 13px; border-radius: 14px; line-height: 1.58; }
.transcript-message.plato { align-self: flex-start; background: var(--plato); border-bottom-left-radius: 4px; }
.transcript-message.student { align-self: flex-end; background: var(--student); border-bottom-right-radius: 4px; }
.transcript-message strong { display: block; margin-bottom: 4px; font-size: .8rem; color: var(--muted); }
.transcript-message p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { border-bottom: 1px solid #e6e1d8; padding: 9px; text-align: left; vertical-align: top; }
.teacher {
  position: relative;
  left: 50%;
  width: min(1280px, calc(100vw - 36px));
  transform: translateX(-50%);
}

.experiment-marker {
  border-color: #5b6fb0;
  background: #eef1ff;
  color: #34447c;
  font-size: .78rem;
}

.dialogue-retry {
  margin-top: 10px;
}
.teacher-table-region { margin-top: 16px; }
.teacher-table-scroll {
  max-height: min(62vh, 620px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  scrollbar-gutter: stable;
}
.teacher-table {
  width: 2420px;
  min-width: 2420px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  font-size: .84rem;
}
.teacher-table th,
.teacher-table td {
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.teacher-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f3efe6;
  box-shadow: 0 1px 0 #d9d2c6;
  white-space: nowrap;
}
.teacher-sticky-col {
  position: sticky;
  z-index: 1;
  background: var(--panel);
}
.teacher-sticky-col--group { left: 0; }
.teacher-sticky-col--code { left: 76px; }
.teacher-sticky-col--name { left: 166px; }
.teacher-table th.teacher-sticky-col {
  z-index: 3;
  background: #f3efe6;
}
.teacher-sticky-col--name::after {
  position: absolute;
  top: 0;
  right: -1px;
  width: 1px;
  height: 100%;
  background: #d4ccbf;
  box-shadow: 3px 0 5px #0000001f;
  content: "";
  pointer-events: none;
}
.teacher-cell--nowrap {
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
}
.teacher-cell--group { min-width: 76px; }
.teacher-cell--code { min-width: 90px; }
.teacher-cell--name { min-width: 110px; }
.teacher-cell--topic { min-width: 140px; }
.teacher-cell--status { min-width: 105px; }
.teacher-cell--date { min-width: 118px; }
.teacher-cell--summary-edited { min-width: 95px; }
.teacher-cell--confirmation { min-width: 110px; }
.teacher-cell--action { min-width: 70px; text-align: center; }
.teacher-col--group { width: 76px; }
.teacher-col--code { width: 90px; }
.teacher-col--name { width: 110px; }
.teacher-col--topic { width: 140px; }
.teacher-col--status { width: 105px; }
.teacher-col--date { width: 118px; }
.teacher-col--thought { width: 300px; }
.teacher-col--summary-edited { width: 95px; }
.teacher-col--confirmation { width: 110px; }
.teacher-col--action { width: 70px; }
.teacher-thought-preview {
  display: -webkit-box;
  overflow: hidden;
  line-height: 1.5;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.teacher-action-button {
  min-width: 62px;
  padding: 8px 10px;
  white-space: nowrap;
}
.teacher-auth { margin-top: 16px; }
.inline-controls { display: grid; grid-template-columns: minmax(220px, 1fr) auto; gap: 9px; }
.teacher-filters { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 10px; margin-top: 16px; }
.detail-actions { display: flex; justify-content: flex-end; margin-top: 12px; }
.danger { color: #8b2f28; border-color: #cda7a2; }
.raw { white-space: pre-wrap; background: #f7f4ed; padding: 12px; border-radius: 10px; overflow: auto; }
.dialogue-detail { margin-top: 16px; }
.statusline { min-height: 20px; padding: 0 14px 10px; }
.save-toast, .save-warning {
  position: fixed;
  right: 18px;
  bottom: 96px;
  z-index: 30;
  max-width: min(320px, calc(100vw - 32px));
  border-radius: 10px;
  box-shadow: 0 6px 18px #0000001f;
  font-size: .82rem;
  line-height: 1.45;
  pointer-events: none;
}
.save-toast {
  padding: 8px 11px;
  background: #35463ae8;
  color: white;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .16s ease, transform .16s ease;
}
.save-toast.is-visible { opacity: 1; transform: translateY(0); }
.save-warning {
  padding: 10px 12px;
  background: #fff4ee;
  color: var(--warn);
  border: 1px solid #ddb7a5;
}
.save-warning[hidden] { display: none; }
@media (max-width: 650px) {
  .wrap { padding: 8px; }
  .grid { grid-template-columns: 1fr; }
  .topic-list { grid-template-columns: 1fr; }
  .teacher-filters { grid-template-columns: 1fr; }
  .inline-controls { grid-template-columns: 1fr; }
  .chat { height: calc(100vh - 54px); min-height: 0; border-radius: 12px; }
  .chathead { align-items: flex-start; }
  .chathead-actions { flex-direction: column; }
  .msg { max-width: 92%; }
  .transcript-message { max-width: 92%; }
  .start, .summary, .teacher { padding: 18px; }
  .chathead { align-items: flex-start; }
  .save-toast, .save-warning { right: 10px; bottom: 88px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
