/* ============================================================
   Nutridok — Light Lab
   Warm off-white canvas, near-black ink, acid lime signature.
   Bricolage Grotesque display · Geist body · JetBrains Mono data
   ============================================================ */

:root {
  --bg: #F7F5EE;
  --bg-2: #FFFFFF;
  --bg-3: #F0EDE0;
  --bg-hover: #E8E4D3;
  --border: #E2DCC8;
  --border-strong: #CAC3A8;
  --ink: #0F0F10;
  --ink-2: #3A3A35;
  --ink-3: #7A766A;
  --muted: #A6A194;

  --accent: #D8FA4A;
  --accent-2: #C4E534;
  --accent-deep: #0F4731;
  --accent-bg: rgba(216, 250, 74, 0.22);

  --success: #3B8F5B;
  --warning: #C68A1B;
  --danger: #C63B2A;
  --danger-bg: #FBE8E3;

  --font-display: 'Bricolage Grotesque', 'Inter', system-ui, sans-serif;
  --font: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Geist Mono', ui-monospace, Consolas, monospace;

  --max-col: 740px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(15, 15, 16, 0.04);
  --shadow-md: 0 10px 28px rgba(15, 15, 16, 0.06);
  --shadow-panel: 0 24px 60px rgba(15, 15, 16, 0.14);

  --easing: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'ss01', 'cv11';
}

body { overflow: hidden; position: relative; }

/* Welcome живёт в обычном document-скролле, без fixed-ловушки.
   Chat остаётся fixed, чтобы messages-area скроллилась внутри. */
body.welcome-mode { overflow-y: auto; overflow-x: hidden; position: static; height: auto; min-height: 100%; }
body.welcome-mode .screen.welcome {
  position: static;
  inset: auto;
  height: auto;
  min-height: 100vh;
  min-height: 100svh;
  overflow: visible;
}
body.welcome-mode .welcome {
  display: flex;
  flex-direction: column;
  height: auto;
  min-height: 100vh;
  min-height: 100svh;
}
body.welcome-mode .welcome-main {
  overflow: visible;
  min-height: auto;
  flex: 1 0 auto;
}

button { font: inherit; color: inherit; background: transparent; border: none; cursor: pointer; }
input, textarea, select, button { font-family: inherit; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
img, svg { display: block; max-width: 100%; }

.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: 1;
  background: var(--bg);
}
.screen.hidden { display: none; }
.drawer-error.hidden,
.drawer-footer.hidden { display: none !important; }

/* ============ BRAND ============ */
.brand {
  display: inline-flex; align-items: center;
  gap: 11px;
  color: var(--ink);
}
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
  overflow: hidden;
}
.brand-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variation-settings: 'opsz' 20, 'wght' 600;
}

/* ============ WELCOME ============ */
.welcome {
  background: var(--bg);
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100%;
  position: relative;
}

.grid-bg {
  position: absolute; inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(15, 15, 16, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 15, 16, 0.025) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 85% 75% at 55% 45%, black 40%, transparent 100%);
  z-index: 0;
}

.welcome-header {
  position: relative; z-index: 2;
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px clamp(24px, 4vw, 44px);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.welcome-meta {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: 0.02em;
}
.meta-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-deep);
  box-shadow: 0 0 0 0 rgba(15, 71, 49, 0.35);
  animation: pulseDot 2s infinite;
}
@keyframes pulseDot {
  0% { box-shadow: 0 0 0 0 rgba(15, 71, 49, 0.35); }
  60% { box-shadow: 0 0 0 7px rgba(15, 71, 49, 0); }
  100% { box-shadow: 0 0 0 0 rgba(15, 71, 49, 0); }
}

.welcome-main {
  position: relative; z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(32px, 4vw, 56px);
  padding: clamp(28px, 4vw, 56px) clamp(24px, 4vw, 44px);
  min-height: 0;
  overflow: hidden;
}

@media (max-width: 960px) {
  .welcome-main { gap: 28px; padding-top: 30px; padding-bottom: 30px; justify-content: flex-start; }
  .hero-right { max-width: 520px; }
}

/* На невысоких окнах и мобилках делаем welcome-main компактнее
   по вертикали, чтобы всё помещалось с комфортным скроллом */
@media (max-height: 820px), (max-width: 768px) {
  body.welcome-mode .welcome-main {
    padding-top: clamp(32px, 5vh, 56px);
    padding-bottom: clamp(32px, 5vh, 56px);
    gap: clamp(20px, 3vh, 36px);
  }
}

/* Уменьшаем крупные шрифты на невысоких окнах, чтобы hero помещался
   без агрессивного скролла и футер дышал */
@media (max-height: 820px) {
  .welcome-title { font-size: clamp(44px, 6.2vw, 76px); line-height: 0.96; }
  .welcome-sub { font-size: clamp(16px, 1.3vw, 18px); max-width: 560px; }
  .hero-left { gap: 18px; }
}
@media (max-height: 640px) {
  .welcome-title { font-size: clamp(36px, 5vw, 56px); letter-spacing: -0.035em; }
  .kicker { font-size: 11px; padding: 6px 12px 6px 10px; }
  .welcome-sub { font-size: 15px; }
}

/* На узких экранах тоже сжимаем заголовок, чтобы не выходил за колонку */
@media (max-width: 640px) {
  .welcome-title { font-size: clamp(40px, 10vw, 60px); }
}

.hero-left {
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-width: 880px;
  align-items: center;
  text-align: center;
}

.kicker {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-2);
  padding: 7px 14px 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-2);
  width: max-content;
}
.kicker::before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent-deep);
  margin-right: 10px;
}

.welcome-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(52px, 8.2vw, 104px);
  line-height: 0.95;
  letter-spacing: -0.042em;
  color: var(--ink);
  font-variation-settings: 'opsz' 96, 'wght' 500;
  text-wrap: balance;
}
.welcome-title .word-accent {
  font-style: italic;
  font-variation-settings: 'opsz' 96, 'wght' 600;
  background: var(--accent);
  color: var(--ink);
  padding: 0 0.12em 0.04em 0.12em;
  display: inline-block;
  transform: rotate(-1.5deg) translateY(-0.02em);
  border-radius: 6px;
  box-shadow: 4px 6px 0 rgba(15, 71, 49, 0.18);
  margin: 0 0.04em;
}

.welcome-sub {
  font-size: clamp(17px, 1.5vw, 20px);
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 620px;
  margin-top: 4px;
  text-wrap: pretty;
}

.hero-ctas {
  display: flex; align-items: center; justify-content: center; gap: 18px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.hero-hint {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-3);
  letter-spacing: 0.03em;
}

/* ============ HERO RIGHT — Readout panel ============ */
.hero-right {
  display: none;
  justify-content: center; align-items: center;
  min-width: 0;
}

.readout {
  width: 100%;
  max-width: 480px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  position: relative;
  box-shadow: var(--shadow-md);
  display: flex; flex-direction: column;
  gap: 20px;
  overflow: hidden;
}
.readout::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--accent);
}

.readout-top {
  display: flex; justify-content: space-between; align-items: center;
}
.readout-labels { display: inline-flex; align-items: center; gap: 10px; }
.readout-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  text-transform: uppercase;
  font-weight: 500;
}
.readout-tag.muted { color: var(--muted); }
.readout-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-deep);
}
.readout-id {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.readout-split {
  display: flex; align-items: center; gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px dashed var(--border);
}
.readout-split-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.readout-split-value {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.readout-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 22px;
}
.readout-cell { display: flex; flex-direction: column; gap: 6px; }
.cell-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.cell-value {
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1;
  font-feature-settings: 'tnum';
}
.cell-unit {
  font-size: 12px;
  color: var(--muted);
  margin-left: 3px;
  font-weight: 400;
}
.cell-bar {
  width: 100%;
  height: 3px;
  background: var(--bg-3);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 3px;
}
.cell-bar span {
  display: block;
  height: 100%;
  background: var(--accent-deep);
  border-radius: 999px;
  animation: fillBar 1.2s var(--easing) 0.3s both;
  transform-origin: left;
}
@keyframes fillBar { from { transform: scaleX(0); } }

.readout-focuses {
  display: flex; flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}
.readout-focuses li {
  display: flex; align-items: baseline; gap: 14px;
  font-size: 15px;
  color: var(--ink);
}
.focus-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-deep);
  letter-spacing: 0.08em;
  min-width: 20px;
  font-weight: 500;
}

.readout-footer {
  display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.pulse {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent-deep);
  box-shadow: 0 0 0 0 rgba(15, 71, 49, 0.45);
  animation: pulseDot 1.8s infinite;
}

/* ============ WELCOME FOOTER ============ */
.welcome-footer {
  position: relative; z-index: 2;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-top: 1px solid var(--border);
  padding: 18px clamp(24px, 4vw, 44px);
  background: var(--bg);
}
.foot-col {
  display: flex; flex-direction: column; gap: 5px;
  padding: 0 28px;
  border-right: 1px dashed var(--border);
}
.foot-col:first-child { padding-left: 0; }
.foot-col:last-child { border-right: none; padding-right: 0; }
.foot-num {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--accent-deep);
  text-transform: uppercase;
  font-weight: 500;
}
.foot-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.foot-desc { font-size: 13.5px; color: var(--ink-2); line-height: 1.45; }
.foot-disclaimer .foot-desc em { font-style: normal; color: var(--ink); font-weight: 600; }

@media (max-width: 960px) {
  .welcome-footer { grid-template-columns: repeat(2, 1fr); }
  .foot-col { padding: 12px 18px 12px 0; border-right: none; border-bottom: 1px dashed var(--border); }
  .foot-col:nth-child(1), .foot-col:nth-child(3) { padding-left: 0; }
  .foot-col:nth-child(2), .foot-col:nth-child(4) { padding-left: 18px; border-left: 1px dashed var(--border); }
  .foot-col:nth-child(3), .foot-col:nth-child(4) { border-bottom: none; }
}
@media (max-width: 520px) {
  .welcome-footer { grid-template-columns: 1fr; }
  .foot-col { padding: 12px 0 !important; border-left: none !important; border-right: none !important; border-bottom: 1px dashed var(--border) !important; }
  .foot-col:last-child { border-bottom: none !important; }
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center;
  gap: 10px;
  padding: 14px 22px;
  font-size: 15.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.08s ease, box-shadow 0.2s ease;
  white-space: nowrap;
  user-select: none;
  line-height: 1;
}
.btn:focus-visible { outline: 2px solid var(--accent-deep); outline-offset: 2px; }
.btn:active { transform: translateY(0.5px); }

.btn-primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.btn-primary:hover {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
}
.btn-primary[disabled] { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.btn-primary svg {
  width: 16px; height: 16px;
  stroke: currentColor; fill: none;
  transition: transform 0.18s ease;
}
.btn-primary:hover svg { transform: translateX(2px); }

.btn-ghost {
  background: transparent; color: var(--ink-2);
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--bg-3); color: var(--ink); }

.btn-danger {
  background: var(--danger); color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { filter: brightness(0.95); }

.btn-sm { padding: 9px 14px; font-size: 14px; }

.icon-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-2);
  border-radius: 10px;
  transition: background 0.12s, color 0.12s;
  border: 1px solid transparent;
}
.icon-btn:hover { background: var(--bg-3); color: var(--ink); }
.icon-btn:focus-visible { outline: 2px solid var(--accent-deep); outline-offset: 2px; }
.icon-btn svg { width: 18px; height: 18px; }

/* ============ CHAT ============ */
.chat { background: var(--bg); }

.chat-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 14px clamp(16px, 3vw, 28px);
  border-bottom: 1px solid var(--border);
  background: rgba(247, 245, 238, 0.88);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 5;
  height: 60px;
}
.chat-header .brand { justify-self: start; }
.chat-status { justify-self: center; }
.chat-actions { justify-self: end; display: flex; gap: 4px; }

.chat-status {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  letter-spacing: 0.02em;
}

.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-deep);
}
.chat-status.is-onboarding .status-dot { background: var(--warning); }
.chat-status.is-thinking .status-dot { background: var(--ink-3); animation: blink 1.2s infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.progress-bar {
  position: relative;
  height: 2px;
  background: var(--border);
  flex-shrink: 0;
}
.progress-bar.hidden { display: none; }
.progress-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--accent-deep);
  transition: width 0.45s var(--easing);
  width: 0%;
}
.progress-label {
  position: absolute;
  right: clamp(16px, 3vw, 28px);
  top: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  background: var(--bg-2);
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  text-transform: lowercase;
}

/* ============ MESSAGES ============ */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 36px clamp(16px, 3vw, 28px);
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.messages-col {
  max-width: var(--max-col);
  margin: 0 auto;
  display: flex; flex-direction: column;
  gap: 24px;
}

.msg {
  display: flex; flex-direction: column;
  max-width: 100%;
  animation: msgIn 0.3s var(--easing);
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-label { display: none; }

.msg-bot .msg-body {
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  word-wrap: break-word;
  overflow-wrap: anywhere;
  padding-left: 16px;
  border-left: 2px solid var(--border);
  position: relative;
}
.msg-bot.is-streaming .msg-body {
  border-left-color: var(--accent-deep);
}
.msg-bot .msg-body p { margin-bottom: 12px; }
.msg-bot .msg-body p:last-child { margin-bottom: 0; }
.msg-bot .msg-body strong { font-weight: 600; color: var(--ink); }
.msg-bot .msg-body em { font-style: italic; color: var(--accent-deep); }

.msg-bot .msg-body ul, .msg-bot .msg-body ol {
  margin: 10px 0 14px 0;
  padding-left: 0;
}
.msg-bot .msg-body ul li, .msg-bot .msg-body ol li {
  position: relative;
  padding-left: 24px;
  margin-bottom: 7px;
  line-height: 1.55;
}
.msg-bot .msg-body ul li::before {
  content: '';
  position: absolute; left: 0; top: 13px;
  width: 14px; height: 2px;
  background: var(--accent-deep);
}
.msg-bot .msg-body ol { counter-reset: listnum; }
.msg-bot .msg-body ol li { counter-increment: listnum; }
.msg-bot .msg-body ol li::before {
  content: counter(listnum, decimal-leading-zero);
  position: absolute; left: 0; top: 0;
  color: var(--accent-deep);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  font-feature-settings: 'tnum';
  line-height: 2;
  letter-spacing: 0.05em;
}

.msg-bot .msg-body h1, .msg-bot .msg-body h2, .msg-bot .msg-body h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  margin: 14px 0 8px;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.msg-bot .msg-body code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--bg-3);
  padding: 1px 7px;
  border-radius: 5px;
  border: 1px solid var(--border);
  color: var(--accent-deep);
}
.msg-bot .msg-body hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 18px 0;
}

.msg-bot.is-streaming .msg-body::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 17px;
  background: var(--accent-deep);
  vertical-align: -2px;
  margin-left: 3px;
  animation: cursor 0.9s steps(2) infinite;
}
@keyframes cursor { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* User bubble */
.msg-user {
  align-self: flex-end;
  max-width: 80%;
}
.msg-user .msg-body {
  background: var(--ink);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: 14px 14px 4px 14px;
  font-size: 16px;
  line-height: 1.5;
  font-weight: 400;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.msg-error .msg-body {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(198, 59, 42, 0.25);
  border-left: 3px solid var(--danger);
  font-size: 15px;
}

.msg-typing {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 8px 0 8px 16px;
  animation: msgIn 0.2s ease;
  border-left: 2px solid var(--accent-deep);
}
.msg-typing .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-deep);
  animation: dot 1.2s infinite ease-in-out;
}
.msg-typing .dot:nth-child(2) { animation-delay: 0.15s; }
.msg-typing .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ============ COMPOSER ============ */
.composer-wrap {
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding: 16px clamp(16px, 3vw, 28px) 16px;
  flex-shrink: 0;
}

.composer {
  max-width: var(--max-col);
  margin: 0 auto;
  width: 100%;
}

.composer-disclaimer {
  max-width: var(--max-col);
  margin: 10px auto 0;
  font-size: 12px;
  color: var(--ink-3);
  text-align: center;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}
.composer-disclaimer em { font-style: normal; color: var(--ink); font-weight: 500; }

.composer .input-row {
  display: flex; gap: 6px;
  align-items: flex-end;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 7px 7px 7px 16px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.composer .input-row:focus-within {
  border-color: var(--accent-deep);
  box-shadow: 0 0 0 3px rgba(15, 71, 49, 0.08);
}

.composer textarea {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  outline: none;
  padding: 8px 0;
  max-height: 170px;
  overflow-y: auto;
  font-family: var(--font);
}
.composer textarea::placeholder { color: var(--muted); }

.composer .send-btn {
  width: 36px; height: 36px;
  flex-shrink: 0;
  background: var(--ink);
  color: var(--bg);
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.12s, transform 0.1s, opacity 0.15s;
}
.composer .send-btn:hover { background: var(--accent-deep); }
.composer .send-btn:active { transform: scale(0.95); }
.composer .send-btn:disabled {
  background: var(--bg-3);
  color: var(--muted);
  cursor: not-allowed;
}
.composer .send-btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.composer .question-hint {
  font-size: 14px;
  color: var(--ink-3);
  margin-bottom: 12px;
}

.composer .choices {
  display: flex; flex-wrap: wrap;
  gap: 7px;
}

.choice-btn {
  padding: 10px 16px;
  background: var(--bg-2);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.08s;
}
.choice-btn:hover {
  background: var(--bg-3);
  border-color: var(--accent-deep);
  color: var(--ink);
}
.choice-btn:active { transform: translateY(0.5px); }
.choice-btn.selected {
  background: var(--accent);
  color: var(--ink);
  border-color: var(--accent);
  font-weight: 600;
}
.choice-btn.selected:hover { background: var(--accent-2); border-color: var(--accent-2); }

.composer .multi-actions {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.composer .multi-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

.composer .number-row {
  display: flex; align-items: stretch;
  gap: 6px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 5px 5px 5px 16px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.composer .number-row:focus-within {
  border-color: var(--accent-deep);
  box-shadow: 0 0 0 3px rgba(15, 71, 49, 0.08);
}
.composer .number-row input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 11px 0;
  font-size: 19px;
  font-family: var(--font-mono);
  color: var(--ink);
  outline: none;
  font-feature-settings: 'tnum';
}
.composer .number-row input::-webkit-outer-spin-button,
.composer .number-row input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.composer .number-row input[type="number"] { -moz-appearance: textfield; }

.composer .number-unit {
  align-self: center;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 14px;
  padding-right: 10px;
}

.composer .locked {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-2);
  color: var(--ink-2);
  font-size: 15px;
  display: flex; align-items: center; gap: 11px;
}
.composer .locked .mini-spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-deep);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.composer .validation {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--danger);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

/* ============ PROFILE DRAWER ============ */
.drawer {
  position: fixed; inset: 0;
  z-index: 150;
  pointer-events: none;
}
.drawer:not(.hidden) { pointer-events: auto; }

.drawer-overlay {
  position: absolute; inset: 0;
  background: rgba(15, 15, 16, 0.32);
  opacity: 0;
  transition: opacity 0.22s ease;
  backdrop-filter: blur(2px);
}
.drawer:not(.hidden) .drawer-overlay { opacity: 1; }

.drawer-panel {
  position: absolute; top: 0; bottom: 0; right: 0;
  width: min(460px, 100vw);
  background: var(--bg);
  box-shadow: var(--shadow-panel);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s var(--easing);
  border-left: 1px solid var(--border);
}
.drawer:not(.hidden) .drawer-panel { transform: translateX(0); }

.drawer-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}
.drawer-header-info { min-width: 0; }
.drawer-header-info p {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  margin-bottom: 3px;
}
.drawer-header h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.drawer-header-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
}
.drawer-empty {
  color: var(--ink-3);
  font-size: 15px;
  margin-top: 8px;
}

.drawer-section {
  margin-bottom: 28px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.drawer-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.drawer-form .drawer-section + .drawer-section {
  padding-top: 8px;
}

.drawer-section-title {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  margin-bottom: 20px;
  font-weight: 500;
}

.drawer-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 6px 0;
  gap: 16px;
}
.drawer-row-label { color: var(--ink-3); font-size: 14px; }
.drawer-row-value {
  color: var(--ink);
  font-weight: 500;
  font-size: 15px;
  text-align: right;
  word-break: break-word;
}
.drawer-row-value.mono {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum';
  font-weight: 500;
  color: var(--accent-deep);
}

.drawer-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.drawer-tag {
  font-size: 13px;
  padding: 4px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--ink-2);
}

.stat-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-2);
  margin-top: 8px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--accent);
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
}
.stat-cell {
  display: flex; flex-direction: column;
  padding: 2px 13px;
  border-left: 1px dashed var(--border);
}
.stat-cell:first-child { border-left: none; padding-left: 2px; }
.stat-cell-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 7px;
  font-weight: 500;
}
.stat-cell-value {
  font-family: var(--font-mono);
  font-size: 23px;
  font-weight: 500;
  color: var(--accent-deep);
  line-height: 1;
  letter-spacing: -0.015em;
  font-feature-settings: 'tnum';
}
.stat-cell-unit {
  font-size: 11px;
  color: var(--muted);
  margin-left: 3px;
  font-weight: 400;
}

/* edit mode */
.drawer-form { display: flex; flex-direction: column; gap: 22px; }
.drawer-form .drawer-section { display: flex; flex-direction: column; gap: 22px; }
.drawer-form .drawer-section-title { margin-bottom: 0; }
.drawer-form-row { display: flex; flex-direction: column; gap: 12px; }
.drawer-form-row label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 2px;
}
.drawer-form-row input[type="number"],
.drawer-form-row input[type="text"],
.drawer-form-row select,
.drawer-form-row textarea {
  width: 100%;
  padding: 11px 14px;
  font-size: 15px;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.drawer-form-row textarea { resize: vertical; min-height: 70px; font-family: var(--font); }
.drawer-form-row input:focus,
.drawer-form-row select:focus,
.drawer-form-row textarea:focus {
  border-color: var(--accent-deep);
  box-shadow: 0 0 0 3px rgba(15, 71, 49, 0.08);
}
.drawer-form-row select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'><path d='M7 8l3 3 3-3' stroke='%237A766A' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-position: right 12px center;
  background-repeat: no-repeat;
  padding-right: 38px;
}

.drawer-form-row .number-with-unit { position: relative; }
.drawer-form-row .number-with-unit input { padding-right: 48px; font-family: var(--font-mono); }
.drawer-form-row .number-with-unit .unit {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-3);
  pointer-events: none;
}

.drawer-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.drawer-chip {
  padding: 7px 12px;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.drawer-chip:hover { background: var(--bg-3); color: var(--ink); }
.drawer-chip.selected {
  background: var(--accent);
  color: var(--ink);
  border-color: var(--accent);
  font-weight: 500;
}

.drawer-footer {
  border-top: 1px solid var(--border);
  padding: 14px 22px;
  display: flex; gap: 10px; justify-content: flex-end;
  flex-shrink: 0;
  background: var(--bg);
}

.drawer-error {
  background: var(--danger-bg);
  border: 1px solid rgba(198, 59, 42, 0.3);
  color: var(--danger);
  font-size: 14px;
  padding: 11px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-family: var(--font-mono);
}

/* ============ CONFIRM DIALOG ============ */
.dialog {
  position: fixed; inset: 0;
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.dialog.hidden { display: none; }
.dialog-overlay {
  position: absolute; inset: 0;
  background: rgba(15, 15, 16, 0.45);
  backdrop-filter: blur(4px);
  animation: fade 0.15s ease;
}
.dialog-panel {
  position: relative;
  background: var(--bg-2);
  border-radius: 16px;
  max-width: 440px;
  width: 100%;
  padding: 26px;
  box-shadow: var(--shadow-panel);
  border: 1px solid var(--border);
  animation: pop 0.2s var(--easing);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }

.dialog-panel h3 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-bottom: 8px;
}
.dialog-panel p {
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 22px;
}
.dialog-actions {
  display: flex; gap: 10px; justify-content: flex-end;
}

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

/* mobile */
@media (max-width: 640px) {
  html, body { font-size: 16px; }
  .chat-header { grid-template-columns: 1fr auto; gap: 8px; height: 56px; }
  .chat-status { display: none; }
  .progress-label { right: 14px; font-size: 10.5px; padding: 2px 7px; }
  .msg-user { max-width: 88%; }
  .msg-bot .msg-body { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
