:root {
  --orange: #FF8C03;
  --orange-light: #FFF3E0;
  --text: #1B1919;
  --muted: #555555;
  --faint: #999999;
  --border: #E8E6E1;
  --bg: #FAFAF8;
  --white: #FFFFFF;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,.07);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Layout ── */
.page-center {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 2.25rem;
  width: 100%;
  max-width: 480px;
}

.card-wide { max-width: 700px; }
.card-full { max-width: 100%; }

/* ── Typography ── */
h1 { font-size: 1.55rem; font-weight: 700; margin-bottom: .4rem; }
h2 { font-size: 1.2rem; font-weight: 600; margin-bottom: .75rem; }
h3 { font-size: 1rem; font-weight: 600; margin-bottom: .5rem; }
p  { color: var(--muted); font-size: .9rem; line-height: 1.7; }

.subtitle { color: var(--muted); font-size: .9rem; margin-bottom: 1.5rem; }
.url-label {
  font-size: .7rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--faint); margin-bottom: 1rem;
}
.section-label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 600; margin-bottom: .5rem;
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .4rem; padding: .65rem 1.4rem;
  border: none; border-radius: 8px; cursor: pointer;
  font-size: .9rem; font-weight: 600; text-decoration: none;
  transition: opacity .15s, box-shadow .15s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:not(:disabled):hover { opacity: .88; }

.btn-primary { background: var(--orange); color: #fff; }
.btn-dark    { background: var(--text);   color: #fff; }
.btn-ghost   { background: transparent;  color: var(--muted);
               border: 1px solid var(--border); }
.btn-sm      { padding: .4rem .9rem; font-size: .82rem; }
.btn-full    { width: 100%; }

/* ── Forms ── */
label {
  display: block; font-size: .85rem; font-weight: 500;
  margin-bottom: .35rem; color: var(--text);
}
input[type=text], input[type=number], select, textarea {
  width: 100%; padding: .6rem .85rem;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: .9rem; color: var(--text); background: var(--white);
  outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--orange);
}
textarea { resize: vertical; min-height: 80px; }
.form-group { margin-bottom: 1.1rem; }
.form-row {
  display: grid; gap: 1rem;
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }

/* ── Checkbox / check-row ── */
.check-row {
  display: flex; gap: .75rem; align-items: flex-start;
  margin-bottom: .9rem;
}
.check-row input[type=checkbox] {
  width: 1.1rem; height: 1.1rem; margin-top: .15rem; flex-shrink: 0;
  accent-color: var(--orange);
}
.check-row label { font-size: .88rem; font-weight: 400; margin: 0; }

/* ── Likert / YesNo ── */
.likert, .yesno {
  display: flex; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1rem;
}
.likert-opt, .yesno-opt {
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
}
.likert-opt input, .yesno-opt input { accent-color: var(--orange); }
.likert-opt label, .yesno-opt label { font-size: .82rem; font-weight: 400; }

/* ── Badges ── */
.badge {
  display: inline-block; padding: .2rem .55rem;
  border-radius: 20px; font-size: .72rem; font-weight: 600; letter-spacing: .02em;
}
.badge-domain   { background: #EEF2FF; color: #4F46E5; }
.badge-low      { background: #F0FDF4; color: #16A34A; }
.badge-medium   { background: #FFFBEB; color: #D97706; }
.badge-high     { background: #FFF1F2; color: #E11D48; }
.badge-orange   { background: var(--orange-light); color: var(--orange); }

/* ── Progress dots ── */
.progress-dots {
  display: flex; gap: .45rem; justify-content: center; margin-bottom: 1.5rem;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border); transition: background .2s;
}
.dot.active  { background: var(--orange); }
.dot.done    { background: var(--faint); }

/* ── Output box ── */
.output-box {
  background: #F9F9F7; border: 1px solid var(--border); border-radius: 8px;
  padding: 1rem 1.1rem; font-size: .875rem; line-height: 1.75;
  white-space: pre-wrap; word-break: break-word; max-height: 320px;
  overflow-y: auto; margin: .75rem 0;
}

/* ── Nav bar ── */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: .6rem 1.5rem; display: flex; align-items: center;
  justify-content: space-between; gap: 1rem;
}
.nav-brand { font-weight: 700; font-size: .95rem; color: var(--text); }
.nav-step  { font-size: .8rem; color: var(--muted); }

/* ── Task layout ── */
.task-layout {
  display: grid;
  grid-template-columns: 40% 60%;
  gap: 0;
  height: calc(100vh - 94px);
  overflow: hidden;
}
@media (max-width: 768px) {
  .task-layout { grid-template-columns: 1fr; height: auto; overflow: visible; }
}

.task-sidebar {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 1.25rem;
  background: var(--white);
}
.task-main {
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* ── Chat ── */
.chat-messages {
  flex: 1; overflow-y: auto; padding: 1.25rem;
  display: flex; flex-direction: column; gap: .75rem;
}
.msg {
  max-width: 92%; padding: .75rem 1rem;
  border-radius: 12px; font-size: .875rem; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
  animation: fadeUp .2s ease;
}
.msg-user {
  background: var(--orange); color: #fff;
  align-self: flex-end; border-bottom-right-radius: 4px;
}
.msg-assistant {
  background: var(--white); border: 1px solid var(--border);
  align-self: flex-start; border-bottom-left-radius: 4px;
}
.msg-system {
  background: var(--orange-light); color: var(--orange);
  align-self: center; font-size: .8rem; border-radius: 20px;
  padding: .3rem .9rem; font-weight: 500;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-input-bar {
  padding: .9rem 1.1rem 1.4rem;
  border-top: 1px solid var(--border);
  background: var(--white);
  display: flex; flex-direction: column; gap: .6rem;
}
.chat-row { display: flex; gap: .6rem; align-items: flex-end; }
#promptInput {
  flex: 1; resize: none; min-height: 44px; max-height: 160px;
  overflow-y: auto; padding: .6rem .85rem; line-height: 1.5;
}
.counter-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .78rem; color: var(--muted);
}

/* ── Timer bar ── */
.timer-bar {
  display: flex; align-items: center; gap: 1rem; padding: .55rem 1.1rem;
  border-bottom: 1px solid var(--border); background: var(--white);
  font-size: .82rem;
}
.timer-display {
  font-variant-numeric: tabular-nums; font-weight: 600; font-size: 1rem;
}
.timer-bar-fill {
  flex: 1; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden;
}
.timer-bar-fill-inner { height: 100%; background: var(--orange); transition: width .5s linear; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--white); border-radius: var(--radius);
  padding: 1.75rem 2rem; max-width: 440px; width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
}
.modal-box h2 { margin-bottom: .5rem; }
.modal-box p  { margin-bottom: 1rem; }
.radio-group { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.radio-row   { display: flex; gap: .6rem; align-items: center; font-size: .88rem; }
.radio-row input { accent-color: var(--orange); }

/* ── Misc ── */
hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.error-msg {
  background: #FFF1F2; color: #E11D48; border-radius: 8px;
  padding: .6rem .9rem; font-size: .85rem; margin-bottom: 1rem;
}
.notice-msg {
  background: #F0FDF4; color: #16A34A; border-radius: 8px;
  padding: .6rem .9rem; font-size: .85rem; margin-bottom: 1rem;
}

/* ── Tabs ── */
.tabs {
  display: flex; gap: .4rem; margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  flex: 1; background: none; border: none; cursor: pointer;
  padding: .6rem .5rem; font-size: .85rem; font-weight: 600;
  color: var(--muted); border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color .15s, border-color .15s;
}
.tab-btn.active {
  color: var(--orange); border-bottom-color: var(--orange);
}
.loading-spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid var(--border); border-top-color: var(--orange);
  border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.collapsible-toggle {
  cursor: pointer; font-size: .82rem; color: var(--orange);
  user-select: none; margin-bottom: .4rem; display: inline-block;
}
.collapsible-content { overflow: hidden; transition: max-height .3s ease; }
.collapsible-content.collapsed { max-height: 0 !important; }
