/* ────────────────────────────────────────────────────────────────
   AI Office — premium control-panel palette.
   Light = warm cream (not white), dark = deep navy (not black). The
   scheme is picked from Telegram's colorScheme signal, but the actual
   values are ours — app.js pushes them back to Telegram's own chrome
   via setHeaderColor/setBackgroundColor so the host matches us,
   rather than us inheriting an arbitrary host theme.
   ──────────────────────────────────────────────────────────────── */
:root {
  --bg: #F7F1E4;
  --bg-raised: #FDFBF5;
  --card: #FFFFFF;
  --card-2: #EFE7D4;
  --border: rgba(28, 22, 8, 0.09);
  --border-strong: rgba(28, 22, 8, 0.14);
  --text: #211C12;
  --text-dim: #6C6353;
  --hint: #948A76;
  --accent: #4453D6;
  --accent-text: #FFFFFF;
  --accent-tint: rgba(68, 83, 214, 0.11);
  --ok: #1F9A5A;
  --ok-tint: rgba(31, 154, 90, 0.13);
  --warn: #B5750E;
  --warn-tint: rgba(181, 117, 14, 0.14);
  --danger: #C43D2F;
  --danger-tint: rgba(196, 61, 47, 0.13);
  --shadow-card: 0 1px 2px rgba(28, 22, 8, 0.05), 0 1px 1px rgba(28, 22, 8, 0.04);
  --shadow-sheet: 0 -12px 32px rgba(28, 22, 8, 0.16);
  --shadow-float: 0 8px 20px rgba(28, 22, 8, 0.12), 0 2px 6px rgba(28, 22, 8, 0.08);

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-full: 999px;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0B0F1D;
    --bg-raised: #101528;
    --card: #141A30;
    --card-2: #1C2340;
    --border: rgba(226, 231, 255, 0.09);
    --border-strong: rgba(226, 231, 255, 0.16);
    --text: #EEF0FA;
    --text-dim: #A7ACC9;
    --hint: #767C9E;
    --accent: #7C8CFF;
    --accent-text: #0B0F1D;
    --accent-tint: rgba(124, 140, 255, 0.16);
    --ok: #3FD088;
    --ok-tint: rgba(63, 208, 136, 0.16);
    --warn: #F0AC3E;
    --warn-tint: rgba(240, 172, 62, 0.16);
    --danger: #FF6E5E;
    --danger-tint: rgba(255, 110, 94, 0.16);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 1px rgba(0, 0, 0, 0.24);
    --shadow-sheet: 0 -12px 32px rgba(0, 0, 0, 0.5);
    --shadow-float: 0 10px 24px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.3);
  }
}
[data-theme="dark"] {
  --bg: #0B0F1D;
  --bg-raised: #101528;
  --card: #141A30;
  --card-2: #1C2340;
  --border: rgba(226, 231, 255, 0.09);
  --border-strong: rgba(226, 231, 255, 0.16);
  --text: #EEF0FA;
  --text-dim: #A7ACC9;
  --hint: #767C9E;
  --accent: #7C8CFF;
  --accent-text: #0B0F1D;
  --accent-tint: rgba(124, 140, 255, 0.16);
  --ok: #3FD088;
  --ok-tint: rgba(63, 208, 136, 0.16);
  --warn: #F0AC3E;
  --warn-tint: rgba(240, 172, 62, 0.16);
  --danger: #FF6E5E;
  --danger-tint: rgba(255, 110, 94, 0.16);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 1px rgba(0, 0, 0, 0.24);
  --shadow-sheet: 0 -12px 32px rgba(0, 0, 0, 0.5);
  --shadow-float: 0 10px 24px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { height: 100%; background: var(--bg); }

body {
  margin: 0;
  /* Anchored to the visual viewport instead of flowing height:100% — on iOS WebKit
     (Telegram's in-app browser included), the layout viewport doesn't reliably shrink
     when the keyboard opens, which is what makes fixed-position elements (the tabbar)
     appear to "jump". Fixed+inset:0 pins the whole app shell to the actual visible area. */
  position: fixed;
  inset: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background-color .2s ease, color .2s ease;
}

button, input, textarea, select { font-family: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
button:disabled { cursor: default; }

.offline-banner {
  background: var(--warn-tint);
  color: var(--warn);
  font-size: 12.5px;
  line-height: 1.4;
  padding: var(--sp-3) var(--sp-4);
  text-align: center;
  border-bottom: 1px solid var(--border);
}

/* ── Views / nav ─────────────────────────────────────────────── */
.view { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.view.active { display: flex; }
.scroll-area { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: var(--sp-2) var(--sp-4) calc(78px + env(safe-area-inset-bottom)); }

.view-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-4) var(--sp-4) var(--sp-2);
  flex-shrink: 0;
}
.view-header-title { font-weight: 700; font-size: 20px; letter-spacing: -0.01em; }
.header-action {
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  width: 40px; height: 40px; border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-card);
  transition: transform .12s ease, background-color .15s ease;
}
.header-action:active { transform: scale(0.92); background: var(--card-2); }
.header-spacer { width: 40px; height: 40px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; background: var(--bg-raised);
  background: color-mix(in srgb, var(--bg-raised) 92%, transparent);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 40;
}
.tab-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 0 7px; background: none; border: none; color: var(--hint);
  font-size: 10.5px; font-weight: 500; min-height: 52px;
  transition: color .15s ease;
}
.tab-item .icon { transition: transform .18s cubic-bezier(.16,1,.3,1); }
.tab-item.active { color: var(--accent); }
.tab-item.active .icon { transform: translateY(-1px) scale(1.06); }
.tab-item:active .icon { transform: scale(0.9); }

/* ── Home ─────────────────────────────────────────────────────── */
#view-home .scroll-area { padding-top: 0; }
.home-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-5) var(--sp-4) var(--sp-3); flex-shrink: 0;
}
.home-title { font-size: 22px; font-weight: 700; letter-spacing: -0.015em; }
.home-sub { color: var(--text-dim); font-size: 13px; margin-top: 1px; }
.home-live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-tint); flex-shrink: 0;
}

.status-banner {
  display: flex; align-items: center; gap: var(--sp-3);
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-4); margin: 0 0 var(--sp-3);
  box-shadow: var(--shadow-card);
  text-align: left; width: 100%;
  transition: transform .12s ease;
}
.status-banner:active { transform: scale(0.985); }
.status-icon-chip {
  width: 42px; height: 42px; border-radius: var(--r-md); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.status-ok .status-icon-chip { background: var(--ok-tint); color: var(--ok); }
.status-warn .status-icon-chip { background: var(--warn-tint); color: var(--warn); }
.status-busy .status-icon-chip { background: var(--accent-tint); color: var(--accent); }
.status-banner-title { font-weight: 600; font-size: 15px; }
.status-banner-sub { color: var(--text-dim); font-size: 12.5px; margin-top: 2px; }
.status-banner-chevron { margin-left: auto; color: var(--hint); flex-shrink: 0; }

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: var(--sp-2) 2px var(--sp-2);
}
.section-title { font-size: 13px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }
.section-link { font-size: 13px; font-weight: 500; color: var(--accent); background: none; border: none; display: flex; align-items: center; gap: 2px; padding: 10px 2px; margin: -10px -2px; }

.team-row { display: flex; gap: var(--sp-3); overflow-x: auto; padding: var(--sp-1) 2px var(--sp-3); scrollbar-width: none; }
.team-row::-webkit-scrollbar { display: none; }
.chip-row { scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.team-avatar { position: relative; background: none; border: none; padding: 0; flex-shrink: 0; }
.team-avatar svg, .team-avatar img { border-radius: 50%; display: block; box-shadow: var(--shadow-card); }
.team-avatar:active { transform: scale(0.94); }
.team-dot {
  position: absolute; right: 2px; bottom: 2px; width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid var(--bg);
}
.dot-ok { background: var(--ok); }
.dot-degraded { background: var(--warn); }
.dot-down { background: var(--danger); }
.dot-unknown { background: var(--hint); }
.dot-stale { background: var(--hint); opacity: .55; }

.stat-strip {
  display: flex; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-lg); margin-bottom: var(--sp-3); box-shadow: var(--shadow-card); overflow: hidden;
}
.stat-cell { flex: 1; text-align: center; padding: var(--sp-3) 2px; position: relative; }
.stat-cell + .stat-cell::before {
  content: ""; position: absolute; left: 0; top: 20%; bottom: 20%; width: 1px; background: var(--border);
}
.stat-value { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat-label { color: var(--hint); font-size: 10px; margin-top: 3px; text-transform: uppercase; letter-spacing: .04em; }

.ask-chief {
  display: flex; align-items: center; gap: var(--sp-2);
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-full);
  padding: 11px var(--sp-2) 11px var(--sp-4); margin-bottom: var(--sp-5);
  color: var(--text-dim); font-size: 14px; box-shadow: var(--shadow-card);
  width: 100%; text-align: left;
  transition: transform .12s ease;
}
.ask-chief:active { transform: scale(0.985); }
.ask-chief span.ask-chief-label { flex: 1; }
.ask-chief-icon {
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-text);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.new-task-cta {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px; margin-top: var(--sp-2); margin-bottom: var(--sp-2);
  background: var(--accent); color: var(--accent-text); border: none; border-radius: var(--r-md);
  font-size: 15px; font-weight: 600; box-shadow: var(--shadow-float);
  transition: transform .12s ease, box-shadow .12s ease;
}
.new-task-cta:active { transform: scale(0.98); box-shadow: var(--shadow-card); }

/* ── Cards (tasks / activity / agents) ───────────────────────── */
.cards { display: flex; flex-direction: column; gap: var(--sp-2); }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4); font-size: 14px; box-shadow: var(--shadow-card);
}
.empty-card { text-align: center; color: var(--hint); padding: 40px var(--sp-4); font-size: 14px; }
.empty-card .icon { display: block; margin: 0 auto 10px; color: var(--border-strong); }
.row { display: flex; justify-content: space-between; align-items: center; }
.muted-line { color: var(--text-dim); font-size: 12.5px; margin-top: 3px; }
.muted { color: var(--hint); }

.task-card { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3); transition: transform .1s ease; }
.task-card:active { transform: scale(0.985); background: var(--card-2); }
.task-card-body { flex: 1; min-width: 0; }
.task-num { color: var(--hint); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.task-title { font-weight: 550; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.task-card-chevron { color: var(--hint); flex-shrink: 0; }
.task-card-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.task-card-badges { display: flex; align-items: center; gap: 6px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: var(--r-full);
  background: var(--card-2); color: var(--text-dim); white-space: nowrap;
}
.badge-done, .badge-health-ok { background: var(--ok-tint); color: var(--ok); }
.badge-failed, .badge-blocked, .badge-health-down { background: var(--danger-tint); color: var(--danger); }
.badge-review, .badge-waiting, .badge-health-degraded { background: var(--warn-tint); color: var(--warn); }
.badge-in_progress, .badge-planned { background: var(--accent-tint); color: var(--accent); }
.badge-cancelled, .badge-health-unknown { background: var(--card-2); color: var(--hint); }

.segmented { display: flex; gap: 4px; padding: 0 var(--sp-4) var(--sp-3); flex-shrink: 0; }
.segmented-item {
  flex: 1; background: var(--card); border: 1px solid var(--border); color: var(--text-dim);
  padding: 9px; border-radius: var(--r-sm); font-size: 13px; font-weight: 500;
  transition: background-color .15s ease, color .15s ease;
}
.segmented-item.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.chip-row { display: flex; gap: var(--sp-2); padding: 0 var(--sp-4) var(--sp-3); overflow-x: auto; flex-shrink: 0; }
.chip {
  flex-shrink: 0; background: var(--card); border: 1px solid var(--border); color: var(--text-dim);
  padding: 7px 14px; border-radius: var(--r-full); font-size: 12.5px; font-weight: 500;
  transition: background-color .15s ease, color .15s ease;
}
.chip.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.activity-card { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3); }
.activity-icon-chip {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--card-2); color: var(--text-dim);
}
.activity-icon-chip.cat-tasks { background: var(--accent-tint); color: var(--accent); }
.activity-icon-chip.cat-approvals { background: var(--warn-tint); color: var(--warn); }
.activity-icon-chip.cat-system { background: var(--card-2); color: var(--text-dim); }
.activity-body { flex: 1; min-width: 0; padding-top: 2px; }
.activity-text { font-size: 13.5px; }
.activity-time { color: var(--hint); font-size: 11.5px; margin-top: 2px; font-variant-numeric: tabular-nums; }

.agent-card { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3); transition: transform .1s ease; }
.agent-card:active { transform: scale(0.985); background: var(--card-2); }
.agent-avatar-wrap { position: relative; flex-shrink: 0; }
.agent-avatar-wrap svg { display: block; border-radius: 50%; }
.agent-avatar-photo { display: block; border-radius: 50%; object-fit: cover; }
.agent-card-body { flex: 1; min-width: 0; }
.agent-card-name { font-weight: 600; }
.agent-card-meta { color: var(--hint); font-size: 11.5px; text-align: right; flex-shrink: 0; }

/* ── Overlays (bottom sheets) ─────────────────────────────────── */
.overlay {
  display: none; position: fixed; inset: 0; background: rgba(10, 8, 2, .45); z-index: 50;
  align-items: flex-end; backdrop-filter: blur(2px);
}
[data-theme="dark"] .overlay, :root:not([data-theme="light"]) .overlay { background: rgba(0, 0, 0, .6); }
.overlay.open { display: flex; }
.overlay-sheet {
  background: var(--bg-raised); width: 100%; max-height: 86vh; overflow-y: auto;
  border-radius: var(--r-lg) var(--r-lg) 0 0; padding: var(--sp-2) var(--sp-5) calc(var(--sp-6) + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-sheet);
  display: flex; flex-direction: column;
}
.overlay-handle { width: 36px; height: 4px; background: var(--border-strong); border-radius: 3px; margin: 10px auto 12px; flex-shrink: 0; }
.overlay-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-3); }
.overlay-title { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.overlay-close {
  background: var(--card-2); border: none; color: var(--text-dim);
  width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: transform .12s ease;
}
.overlay-close:active { transform: scale(0.9); }

.detail-row { display: flex; justify-content: space-between; gap: var(--sp-3); padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.detail-row:last-child { border-bottom: none; }
.detail-row span:first-child { color: var(--text-dim); }
.detail-row span:last-child { text-align: right; }
.detail-section { color: var(--hint); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin: var(--sp-5) 0 var(--sp-1); }
.detail-block { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); font-size: 13.5px; margin-top: var(--sp-3); white-space: pre-wrap; }
.detail-block b { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); display: block; margin-bottom: 4px; font-weight: 600; }
.detail-error { background: var(--danger-tint); color: var(--danger); border-color: transparent; }
.detail-error b { color: var(--danger); opacity: .8; }

/* ── Full-page detail views (agent / task) ───────────────────── */
.detail-page { padding: var(--sp-2) var(--sp-4) calc(var(--sp-6) + env(safe-area-inset-bottom)); }

.agent-hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: var(--sp-3) 0 var(--sp-4); }
.agent-hero svg { box-shadow: var(--shadow-float); border-radius: 50%; margin-bottom: var(--sp-3); }
.agent-hero img { box-shadow: var(--shadow-float); border-radius: 28px; margin-bottom: var(--sp-3); }
.agent-hero-name { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.agent-hero-role { color: var(--text-dim); font-size: 13.5px; margin-top: 2px; }

.status-pill-row { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: var(--sp-3); }

.task-hero { padding: var(--sp-2) 0 var(--sp-3); }
.task-hero .overlay-title { line-height: 1.3; }
.task-hero-meta { display: flex; align-items: center; gap: 10px; margin-top: var(--sp-3); }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border-radius: var(--r-full);
  font-size: 12.5px; font-weight: 600;
}
.status-pill.is-active { background: var(--ok-tint); color: var(--ok); }
.status-pill.is-inactive { background: var(--card-2); color: var(--hint); }
.status-pill-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.typing-pill { background: var(--accent-tint); color: var(--accent); }
.typing-pill .icon { animation: typing-pulse 1.1s ease-in-out infinite; }

.detail-new-task-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 13px; margin-top: var(--sp-4);
  background: var(--accent); color: var(--accent-text); border: none; border-radius: var(--r-md);
  font-size: 14.5px; font-weight: 600; box-shadow: var(--shadow-card);
  transition: transform .12s ease;
}
.detail-new-task-btn:active { transform: scale(0.98); }

/* Priority — deliberately not the status-badge color language, so the two never read
   as the same signal sitting side by side. */
.priority-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; color: var(--text-dim); }
.priority-chip.priority-high { color: var(--danger); }
.priority-chip.priority-low { color: var(--hint); }

.delegation-row { display: flex; align-items: center; gap: 8px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.delegation-who { display: flex; align-items: center; gap: 6px; min-width: 0; }
.delegation-who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.delegation-row .icon { color: var(--hint); flex-shrink: 0; }
.parent-task-link {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--sp-3); font-size: 13.5px; margin-top: var(--sp-3); color: var(--text);
  transition: transform .1s ease;
}
.parent-task-link:active { transform: scale(0.985); background: var(--card-2); }
.parent-task-link .icon:first-child { color: var(--accent); flex-shrink: 0; }
.parent-task-link .icon:last-child { color: var(--hint); margin-left: auto; flex-shrink: 0; }

.task-cancel-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  background: var(--danger-tint); border: none; border-radius: var(--r-md);
  padding: 13px; margin-top: var(--sp-4); color: var(--danger); font-size: 14.5px; font-weight: 600;
  transition: transform .12s ease;
}
.task-cancel-btn:active:not(:disabled) { transform: scale(0.98); }
.task-cancel-btn:disabled { opacity: .55; }
/* Retry is a safe, constructive action — same shape as cancel, accent instead of danger. */
.task-cancel-btn.task-retry-btn { background: var(--accent-tint); color: var(--accent); }

.agent-recent-tasks { margin-top: var(--sp-2); }
.auth-checking { margin-top: 8px; }

.auth-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); margin-top: var(--sp-3); }
.auth-card-head { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; }
.auth-card-head .icon { flex-shrink: 0; }
.auth-card-head.is-ok .icon { color: var(--ok); }
.auth-card-head.is-warn .icon { color: var(--warn); }
.auth-card-head.is-unknown .icon { color: var(--hint); }
.auth-card-detail { color: var(--text-dim); font-size: 12.5px; margin: 3px 0 var(--sp-2); }
.auth-card .detail-row { padding: 7px 0; font-size: 12.5px; }

@keyframes typing-pulse {
  0%, 60%, 100% { opacity: .35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-1px); }
}

.field-label { display: block; color: var(--text-dim); font-size: 12.5px; font-weight: 500; margin: var(--sp-4) 0 6px; }
.field-select, .field-textarea {
  width: 100%; background: var(--card); border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text); padding: 11px 12px; font-size: 14.5px; font-family: inherit;
}
.field-select:focus, .field-textarea:focus, #chat-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.field-textarea { resize: vertical; }
.field-submit {
  width: 100%; margin-top: var(--sp-5); padding: 13px; border: none; border-radius: var(--r-sm);
  background: var(--accent); color: var(--accent-text); font-size: 15px; font-weight: 600;
  transition: transform .12s ease;
}
.field-submit:active:not(:disabled) { transform: scale(0.98); }
.field-submit:disabled { opacity: .55; }

/* ── Chat overlay ─────────────────────────────────────────────── */
#overlay-chat .overlay-sheet { height: 82vh; max-height: 82vh; padding-bottom: env(safe-area-inset-bottom); }
.chat-log { flex: 1; display: flex; flex-direction: column; gap: var(--sp-2); overflow-y: auto; padding: 4px 2px var(--sp-4); }
.chat-empty { margin: auto; text-align: center; color: var(--hint); font-size: 13.5px; padding: var(--sp-6); }
.chat-empty .icon { display: block; margin: 0 auto 10px; color: var(--border-strong); }
.msg { max-width: 86%; padding: 10px 13px; border-radius: var(--r-md); font-size: 14px; white-space: pre-wrap; line-height: 1.42; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 4px; }
.msg.chief { align-self: flex-start; background: var(--card); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.pending { opacity: 0.55; }
.chat-form { display: flex; gap: var(--sp-2); padding-top: var(--sp-2); border-top: 1px solid var(--border); flex-shrink: 0; }
#chat-input {
  flex: 1; padding: 11px 14px; border-radius: var(--r-full); border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: 15px;
}
.chat-send {
  width: 42px; height: 42px; border-radius: 50%; border: none; background: var(--accent); color: var(--accent-text);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: transform .12s ease;
}
.chat-send:active { transform: scale(0.9); }
.chat-send:disabled { opacity: .5; }

@keyframes spin { to { transform: rotate(360deg); } }
.icon-spin { animation: spin 1s linear infinite; }

/* ── Drafts ───────────────────────────────────────────────────── */
.draft-card { display: flex; flex-direction: column; gap: 8px; padding: var(--sp-3) var(--sp-4); }
.draft-card-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.draft-card-channel { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-dim); }
.draft-card-channel .icon { color: var(--accent); }
.draft-card-text { font-size: 13.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; white-space: pre-wrap; }
.draft-card-meta { font-size: 11.5px; color: var(--hint); }
.draft-card-actions { display: flex; gap: 8px; margin-top: 2px; }
.draft-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--card-2);
  color: var(--text); font-size: 13px; font-weight: 600; transition: transform .1s ease, opacity .15s ease;
}
.draft-btn:active:not(:disabled) { transform: scale(0.97); }
.draft-btn:disabled { opacity: .5; }
.draft-btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.draft-btn-ghost { background: transparent; }
.badge-scheduled { background: var(--accent-tint); color: var(--accent); }
.badge-published { background: var(--ok-tint); color: var(--ok); }

/* ── Wheel picker (schedule sheet) ───────────────────────────────
   Native CSS scroll-snap, no JS library — each column is its own
   snap-scroller; app.js reads the centered item on scroll settle. */
.wheel-picker { position: relative; display: flex; height: 216px; margin: var(--sp-3) 0 var(--sp-2); }
.wheel-col {
  flex: 1.6; overflow-y: auto; scroll-snap-type: y mandatory; scrollbar-width: none;
  -webkit-overflow-scrolling: touch; padding: 88px 0;
}
.wheel-col::-webkit-scrollbar { display: none; }
.wheel-col-narrow { flex: 1; }
.wheel-item {
  height: 40px; display: flex; align-items: center; justify-content: center;
  scroll-snap-align: center; font-size: 17px; font-variant-numeric: tabular-nums;
  color: var(--hint); transition: color .15s ease, opacity .15s ease;
}
.wheel-item.is-selected { color: var(--text); font-weight: 700; }
.wheel-colon { display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 700; color: var(--hint); width: 12px; }
.wheel-highlight {
  position: absolute; left: 0; right: 0; top: 88px; height: 40px;
  background: var(--accent-tint); border-radius: var(--r-sm); pointer-events: none; z-index: -1;
}

.document-row { display:flex; gap:8px; align-items:stretch; margin:8px 0; }
.document-row .document-download { flex:1; min-width:0; margin:0; }
.document-send { flex:none; min-height:44px; padding:10px 12px; border:1px solid var(--border, #c1693b); border-radius:12px; background:transparent; color:inherit; cursor:pointer; }
.document-send:disabled { opacity:.6; cursor:wait; }
.document-download { display:block; min-height:44px; max-width:100%; margin:8px 0; padding:10px 14px; border:1px solid var(--border, #c1693b); border-radius:12px; background:transparent; color:inherit; text-align:left; overflow-wrap:anywhere; cursor:pointer; }
.document-download:disabled { opacity:.6; cursor:wait; }
