:root {
  --ink: #172033;
  --muted: #667085;
  --line: #e4e7ec;
  --soft: #f7f8fa;
  --brand: #315bea;
  --brand-dark: #2447bd;
  --danger: #b42318;
  --sidebar: #111827;
  font-family: Inter, Pretendard, "Noto Sans KR", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: #fff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
input.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
body { margin: 0; min-height: 100vh; background: var(--soft); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.center-card { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: min(100%, 420px); background: white; border: 1px solid var(--line);
  border-radius: 22px; padding: 36px; box-shadow: 0 18px 50px rgba(16, 24, 40, .09);
}
.brand-mark {
  width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center;
  color: white; background: linear-gradient(145deg, #315bea, #7a5af8); font-weight: 800;
  box-shadow: 0 8px 24px rgba(49, 91, 234, .25);
}
.brand-mark.small { width: 34px; height: 34px; border-radius: 10px; font-size: 14px; }
.eyebrow { margin: 24px 0 5px; color: var(--brand); font-size: 13px; font-weight: 750; }
h1 { margin: 0 0 8px; font-size: 30px; letter-spacing: -.04em; }
.muted, .empty { color: var(--muted); line-height: 1.6; }
label { display: grid; gap: 7px; color: #344054; font-size: 13px; font-weight: 650; }
form { display: grid; gap: 16px; margin-top: 24px; }
input, select, textarea {
  width: 100%; border: 1px solid #d0d5dd; border-radius: 11px; padding: 11px 12px;
  color: var(--ink); background: white; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(49, 91, 234, .12); }
button { border: 0; border-radius: 11px; padding: 11px 15px; font-weight: 700; }
button:disabled { cursor: not-allowed; opacity: .55; }
.primary { background: var(--brand); color: white; }
.primary:hover:not(:disabled) { background: var(--brand-dark); }
.secondary { background: #fff; color: #344054; border: 1px solid #d0d5dd; }
.danger { color: var(--danger); background: #fff3f2; }
.full { width: 100%; }
.error { min-height: 20px; color: var(--danger); font-size: 13px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 270px 1fr; background: white; }
.sidebar { min-height: 100vh; background: var(--sidebar); color: white; padding: 22px 16px; display: flex; flex-direction: column; }
.brand-row { display: flex; align-items: center; gap: 10px; padding: 0 6px 20px; }
.sidebar .secondary { color: white; background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); }
.sidebar-title { margin: 24px 8px 10px; color: #98a2b3; font-size: 12px; font-weight: 750; text-transform: uppercase; }
#conversation-list { display: grid; gap: 5px; overflow-y: auto; }
.conversation-link { color: #e5e7eb; background: transparent; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversation-link:hover { background: rgba(255,255,255,.08); }
.sidebar .empty { padding: 0 8px; color: #98a2b3; font-size: 13px; }
.sidebar-foot { margin-top: auto; padding: 16px 8px 0; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-foot p { margin: 0 0 8px; }
.text-button { display: block; padding: 5px 0; color: #cbd5e1; background: transparent; font-size: 13px; }

.workspace { min-width: 0; min-height: 100vh; display: grid; grid-template-rows: auto auto 1fr auto auto; }
.toolbar { min-height: 72px; padding: 14px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.select-group { display: flex; gap: 10px; flex-wrap: wrap; }
.select-group label { display: flex; align-items: center; gap: 7px; }
.select-group select { width: auto; min-width: 135px; padding: 8px 10px; }
.notice { margin: 14px auto 0; width: min(860px, calc(100% - 32px)); padding: 11px 14px; border: 1px solid #b2ccff; border-radius: 12px; background: #eff4ff; color: #344054; font-size: 13px; line-height: 1.45; }
.messages { width: min(860px, 100%); margin: 0 auto; padding: 36px 24px; overflow-y: auto; }
.welcome { text-align: center; margin: 12vh auto 0; color: var(--muted); }
.welcome h2 { margin: 0 0 8px; color: var(--ink); font-size: 28px; letter-spacing: -.035em; }
.message { display: grid; grid-template-columns: 52px 1fr; gap: 12px; padding: 20px 0; border-bottom: 1px solid #f0f1f3; }
.message.user .message-text { background: #f2f4f7; border-radius: 16px; padding: 14px; }
.message-body { min-width: 0; }
.message-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
.activity-card {
  padding: 14px 16px; border: 1px solid #cdd8ff; border-radius: 14px;
  background: linear-gradient(135deg, #f8faff, #f3f6ff); color: #344054;
}
.activity-heading { display: flex; align-items: center; gap: 9px; }
.activity-heading strong { flex: 1; color: #253858; font-size: 14px; }
.activity-spinner {
  width: 15px; height: 15px; border: 2px solid #b9c6f8; border-top-color: var(--brand);
  border-radius: 50%; animation: activity-spin .8s linear infinite;
}
.activity-time { color: #667085; font-size: 12px; font-variant-numeric: tabular-nums; }
.activity-detail { margin: 9px 0 10px 24px; color: #475467; font-size: 13px; line-height: 1.45; }
.activity-steps {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px;
  margin: 0; padding: 0; list-style: none;
}
.activity-steps li {
  position: relative; padding: 7px 5px; border-radius: 8px; background: #e9edfa;
  color: #7a8499; text-align: center; font-size: 11px; font-weight: 700;
}
.activity-steps li.complete { background: #e7f6ed; color: #137a43; }
.activity-steps li.current { background: #dfe7ff; color: #2447bd; box-shadow: inset 0 0 0 1px #b8c7ff; }
.activity-note { margin: 9px 0 0; color: #7a8499; font-size: 10px; }
.streaming-text { margin-top: 14px; }
.streaming-text::after {
  content: ""; display: inline-block; width: 7px; height: 16px; margin-left: 3px;
  border-radius: 2px; background: var(--brand); vertical-align: -2px;
  animation: activity-blink .9s steps(2, start) infinite;
}
@keyframes activity-spin { to { transform: rotate(360deg); } }
@keyframes activity-blink { 50% { opacity: .2; } }
.composer { width: min(860px, calc(100% - 32px)); margin: 0 auto; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: end; gap: 10px; padding: 14px; border: 1px solid #d0d5dd; border-radius: 18px; box-shadow: 0 8px 30px rgba(16,24,40,.08); }
.composer-main { min-width: 0; display: grid; gap: 5px; }
.composer textarea { resize: none; border: 0; box-shadow: none; max-height: 180px; }
.attachment-button {
  display: flex; align-items: center; gap: 4px; min-height: 42px; padding: 9px 11px;
  border: 1px solid #d0d5dd; border-radius: 11px; color: #344054; background: #fff;
  cursor: pointer; font-size: 13px; font-weight: 700;
}
.attachment-button:hover { border-color: var(--brand); color: var(--brand); }
.attachment-button span:first-child { font-size: 19px; line-height: 1; }
.attachment-list { display: flex; flex-wrap: wrap; gap: 5px; }
.attachment-list:empty { display: none; }
.attachment-chip {
  min-width: 0; max-width: 100%; display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 7px 5px 9px; border-radius: 999px; background: #eff4ff;
  color: #344054; font-size: 11px;
}
.attachment-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-remove { flex: 0 0 auto; padding: 0 3px; color: #475467; background: transparent; font-size: 17px; line-height: 1; }
.attachment-help { margin: 0 10px; color: #667085; font-size: 10px; }
.status { min-height: 20px; width: min(860px, calc(100% - 32px)); margin: 6px auto; color: var(--muted); font-size: 12px; }
footer { padding: 0 18px 12px; text-align: center; color: #98a2b3; font-size: 11px; }

dialog { width: min(92vw, 420px); border: 0; border-radius: 18px; padding: 0; box-shadow: 0 24px 80px rgba(16,24,40,.24); }
dialog::backdrop { background: rgba(16,24,40,.45); }
.dialog-form { padding: 28px; margin: 0; }
.dialog-form h2 { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; padding: 12px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; }
  .brand-row { padding: 0; }
  .sidebar > .full, .sidebar-title, #conversation-list { display: none; }
  .sidebar-foot { margin: 0; padding: 0; border: 0; display: flex; align-items: center; gap: 10px; }
  .sidebar-foot p { margin: 0; }
  .toolbar { align-items: flex-start; padding: 10px 12px; }
  .select-group { gap: 6px; }
  .select-group label { font-size: 0; }
  .select-group select { min-width: 0; max-width: 150px; font-size: 12px; }
  .messages { padding: 20px 16px; }
  .message { grid-template-columns: 38px 1fr; }
  .activity-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .composer { bottom: 0; }
  .attachment-button span:last-child { display: none; }
  .attachment-button { padding-inline: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .activity-spinner, .streaming-text::after { animation: none; }
}
