/* 와이즈과학학원 노션 비서 — Brand Standard Final 적용
   tokens.css / fonts.css 를 전제로 한다. 순백·그라데이션·800 웨이트 금지. */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font: var(--wise-type-body);
  background: var(--wise-paper);
  color: var(--wise-ink);
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2 { margin: 0; color: var(--wise-deep); }

.eyebrow {
  display: inline-block;
  padding: 5px 12px;
  border-radius: var(--wise-radius-pill);
  background: var(--wise-green-soft);
  color: var(--wise-primary);
  font: var(--wise-type-caption);
  font-weight: var(--wise-weight-label);
  margin: 0 0 var(--wise-space-2);
}
.lede {
  margin: 0 0 var(--wise-space-3);
  font: var(--wise-type-body-sm);
  color: var(--wise-ink-2);
}

/* ── Atoms: brand / buttons / fields / badges ── */
.brand-lockup {
  display: block;
  font-family: var(--wise-font-head);
  font-weight: 600; font-size: 18px; color: var(--wise-primary);
  letter-spacing: -0.01em;
  line-height: 1.4;
  margin: 0 0 8px;
}
.nav .brand-lockup { margin: 0; }
.form-org .eyebrow { display: inline-block; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--wise-font-body);
  font-size: 14px; font-weight: var(--wise-weight-label);
  padding: 11px 20px; border-radius: var(--wise-radius-btn);
  border: 1px solid transparent; line-height: 1; white-space: nowrap;
}
.btn.primary { background: var(--wise-primary); color: #fff; }
.btn.primary:hover { background: var(--wise-primary-hover); }
.btn.primary:active { background: var(--wise-primary-press); }
.btn.primary:disabled { background: var(--wise-gray-200); color: #fff; cursor: not-allowed; }
.btn.secondary { background: var(--wise-green-soft); color: var(--wise-primary); }
.btn.secondary:hover { background: #D6E9DD; }
.btn.secondary:active { background: #C8E0D2; }
.btn.ghost { background: transparent; color: var(--wise-primary); border-color: var(--wise-green-border); }
.btn.ghost:hover { background: var(--wise-green-softer); }
.btn.ghost:active { background: var(--wise-green-soft); }

.field { margin-bottom: var(--wise-space-2); }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block; font-size: 12.5px; font-weight: var(--wise-weight-label);
  color: var(--wise-ink-2); margin-bottom: 7px;
}
.field label .req { color: var(--wise-error); margin-left: 2px; }
.inp {
  width: 100%;
  font: var(--wise-type-body-sm);
  color: var(--wise-ink);
  background: var(--wise-surface);
  border: 1px solid var(--wise-gray-200);
  border-radius: var(--wise-radius-btn);
  padding: 11px 14px;
}
.inp::placeholder { color: var(--wise-muted-2); }
.inp:focus {
  outline: none;
  border-color: var(--wise-primary);
  box-shadow: var(--wise-ring-focus);
}
.help { font: var(--wise-type-caption); color: var(--wise-muted); margin: 6px 0 0; }
.help.error { color: var(--wise-error); }
.help.ok { color: var(--wise-success); }

.bdg {
  font-size: 11.5px; font-weight: 600; border-radius: var(--wise-radius-pill);
  padding: 5px 12px; background: var(--wise-line-soft); color: var(--wise-gray-600);
}
.bdg.primary { background: var(--wise-green-soft); color: var(--wise-primary); }
.bdg.deep-soft { background: var(--wise-green-soft); color: var(--wise-deep); }
.bdg.solid { background: var(--wise-primary); color: #fff; }

.card {
  background: var(--wise-surface);
  border: 1px solid var(--wise-line);
  border-radius: var(--wise-radius-card);
  box-shadow: var(--wise-shadow-md);
}

/* ── Organism: 입장 폼 ── */
.gate {
  min-height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: var(--wise-space-4);
}
.form-org {
  width: 100%; max-width: 420px;
  padding: var(--wise-space-4);
}
.form-org h1 {
  font: var(--wise-type-h1);
  letter-spacing: -0.02em;
  margin-bottom: var(--wise-space-1);
}
.form-actions {
  margin-top: var(--wise-space-3);
  padding-top: var(--wise-space-3);
  border-top: 1px solid var(--wise-line);
}
.form-actions .btn.primary { width: 100%; }

/* ── Organism: 헤더 ── */
.app { height: 100%; display: flex; flex-direction: column; }
.nav {
  display: flex; align-items: center; gap: var(--wise-space-2);
  padding: 14px 24px;
  background: var(--wise-surface);
  border-bottom: 1px solid var(--wise-line);
  box-shadow: var(--wise-shadow-sm);
}
.nav-title {
  font-family: var(--wise-font-head);
  font-weight: 600; font-size: 15px; color: var(--wise-deep);
  padding-left: var(--wise-space-2);
  border-left: 1px solid var(--wise-line);
}
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.nav-right .btn { padding: 8px 14px; font-size: 13px; }

/* ── Chat ── */
.chat {
  flex: 1; overflow-y: auto;
  padding: var(--wise-space-4) var(--wise-space-3) var(--wise-space-2);
}
.warn {
  max-width: 720px; margin: 0 auto var(--wise-space-2);
  background: var(--wise-error-soft); color: var(--wise-error);
  border-radius: var(--wise-radius-btn);
  padding: 10px 14px; font: var(--wise-type-body-sm);
}
.welcome {
  max-width: 640px; margin: var(--wise-space-6) auto var(--wise-space-3);
  text-align: center;
}
.welcome h2 {
  font: var(--wise-type-h1);
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}
.welcome .lede { max-width: 440px; margin-left: auto; margin-right: auto; }

.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip {
  background: var(--wise-surface);
  border: 1px solid var(--wise-line);
  border-radius: var(--wise-radius-pill);
  padding: 8px 14px;
  font-size: 13.5px; font-weight: var(--wise-weight-label);
  color: var(--wise-gray-600);
}
.chip:hover { border-color: var(--wise-green-border); color: var(--wise-primary); background: var(--wise-green-softer); }

.log { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--wise-space-2); }

.msg { display: flex; flex-direction: column; gap: 8px; }
.msg.user { align-items: flex-end; }
.bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--wise-radius-card);
  word-break: break-word;
}
.msg.user .bubble {
  background: var(--wise-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.bot .bubble {
  background: var(--wise-surface);
  border: 1px solid var(--wise-line);
  box-shadow: var(--wise-shadow-sm);
  border-bottom-left-radius: 4px;
}
.msg.bot .bubble.md p { margin: 0 0 8px; }
.msg.bot .bubble.md p:last-child { margin-bottom: 0; }
.msg.bot .bubble.md ul, .msg.bot .bubble.md ol { margin: 0 0 8px; padding-left: 1.2em; }
.msg.bot .bubble.md code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  background: var(--wise-green-softer);
  color: var(--wise-deep);
  padding: 1px 5px; border-radius: 4px;
}
.msg.bot .bubble.md pre {
  background: var(--wise-gray-50);
  border: 1px solid var(--wise-line-soft);
  padding: 10px 12px; border-radius: 8px; overflow-x: auto;
}
.msg.bot .bubble.md table { border-collapse: collapse; width: 100%; font: var(--wise-type-body-sm); }
.msg.bot .bubble.md th, .msg.bot .bubble.md td {
  border: 1px solid var(--wise-line); padding: 4px 8px; text-align: left;
}

.trace {
  display: flex; flex-direction: column; gap: 7px;
  max-width: 85%; padding: 2px 2px 4px;
}
.step {
  display: flex; align-items: flex-start; gap: 8px;
  font: var(--wise-type-body-sm);
  color: var(--wise-muted);
}
.step.live { color: var(--wise-ink-2); }
.step.ok { color: var(--wise-muted); }
.step.err { color: var(--wise-error); }
.step .dot {
  width: 7px; height: 7px; border-radius: 999px; flex: none;
  margin-top: 7px; background: var(--wise-gray-200);
}
.step.live .dot {
  background: var(--wise-primary);
  box-shadow: 0 0 0 3px var(--wise-green-soft);
  animation: pulse 1.1s ease-in-out infinite;
}
.step.ok .dot { background: var(--wise-secondary); }
.step.err .dot { background: var(--wise-error); }
.step .txt { flex: 1; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}
.msg.bot .bubble:empty { display: none; }

.err-banner {
  background: var(--wise-error-soft); color: var(--wise-error);
  border-radius: var(--wise-radius-btn);
  padding: 10px 12px; font: var(--wise-type-body-sm);
}

.composer-bar {
  background: var(--wise-surface);
  border-top: 1px solid var(--wise-line);
}
.composer {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 12px 24px calc(16px + env(safe-area-inset-bottom));
  max-width: 768px; width: 100%; margin: 0 auto;
}
.composer textarea { resize: none; max-height: 160px; line-height: 1.45; }
.composer .btn { height: 44px; flex: none; }

@media (max-width: 640px) {
  .nav { padding: 10px 14px; flex-wrap: wrap; }
  .nav-title { border: 0; padding: 0; font-size: 13px; color: var(--wise-muted); }
  .nav-right .btn:first-of-type { display: none; }
  .nav-right #semester { display: none; }
  .chat { padding: var(--wise-space-3) 14px 12px; }
  .welcome { margin-top: var(--wise-space-4); }
  .welcome h2 { font-size: 24px; }
  .composer { padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); }
  .form-org { padding: var(--wise-space-3); }
}
