/* NovLov Growth workbench. One layer: tokens, base, layout, components, views, responsive. */

:root {
  --ink: #1b2d2a;
  --ink-soft: #3d524b;
  --muted: #5a6b72;          /* ≥4.5:1 on white and on --page */
  --line: #dfe8e1;
  --line-soft: #edf1ed;
  --page: #eef3ef;
  --panel: #fff;
  --brand: #1f5749;
  --brand-hover: #193f36;
  --brand-tint: #e9f6f0;
  --brand-text: #1d6b4f;
  --lime: #d0f476;
  --warn-bg: #fff6df;
  --warn-text: #7a5300;
  --error-bg: #fff0e8;
  --error-text: #8a4322;
  --radius: 12px;
  --control: 40px;
  font-family: Inter, "Helvetica Neue", Arial, "PingFang SC", sans-serif;
  color: var(--ink);
  background: var(--page);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
body { margin: 0; }
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 480px); padding: 32px; }
.login-card h1 { font-size: 26px; margin-top: 28px; }
.login-card .hint { line-height: 1.6; }
.login-card .button-row { margin-bottom: 24px; }
[hidden] { display: none !important; }
a { color: inherit; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #48a78b88; outline-offset: 2px; }
h1, h2, h3 { letter-spacing: -.02em; }

label { display: block; font-size: 12px; font-weight: 700; color: var(--ink-soft); margin: 16px 0 6px; }
/* One control type size everywhere, including fields nested in a (small, bold) label. */
textarea, input, select {
  width: 100%; min-height: var(--control); padding: 9px 12px; border: 1px solid #d3dfdb; border-radius: 9px;
  background: #fff; color: #243a42; font-size: 14px; font-weight: 400; outline: none;
}
textarea:focus, input:focus, select:focus { border-color: #48a78b; box-shadow: 0 0 0 3px #48a78b22; }
textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
input:disabled, textarea:disabled, select:disabled { background: #f6f8f7; color: var(--muted); }

.check { display: flex; align-items: center; gap: 8px; margin: 10px 0; font-size: 13px; font-weight: 400; color: var(--ink); min-height: 28px; }
.check input { width: 18px; height: 18px; min-height: 0; margin: 0; flex: none; accent-color: #287456; }

/* ---------- buttons ---------- */
.primary, .secondary, .ghost, .danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--control);
  padding: 0 16px; border-radius: 9px; font-size: 13px; font-weight: 700; white-space: nowrap; text-decoration: none;
}
.primary { border: 1px solid var(--brand); background: var(--brand); color: #fff; }
.primary:hover { background: var(--brand-hover); }
.secondary { border: 1px solid #c9dad4; background: #fff; color: var(--brand-text); }
.ghost { border: 1px solid transparent; background: transparent; color: var(--brand-text); }
.secondary:hover, .ghost:hover { background: var(--brand-tint); }
.danger { border: 1px solid transparent; background: transparent; color: #a33b22; }
.danger:hover { background: var(--error-bg); }
button:disabled { cursor: default; opacity: .55; }
.link-button[aria-disabled=true] { pointer-events: none; opacity: .45; }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.icon-button { border: 0; background: transparent; color: var(--muted); font-size: 26px; line-height: 1; width: 44px; height: 44px; }

/* ---------- layout ---------- */
.app-header {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 24px;
  max-width: 1180px; margin: 0 auto; padding: 14px 24px; background: var(--page); border-bottom: 1px solid #dbe4dd;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.brand em { font-style: normal; font-weight: 400; color: var(--muted); }
.brand-mark { position: relative; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--ink); color: #cafa72; font-size: 20px; font-weight: 900; }
.brand-mark span { position: absolute; top: 3px; right: 4px; font-size: 9px; }

.main-nav { display: flex; gap: 4px; }
.main-nav button {
  display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; border: 0; border-radius: 9px;
  background: transparent; color: #4f625a; font-size: 13px; font-weight: 600;
}
.main-nav button:hover { background: #e2ebe5; }
.main-nav button[aria-current=page] { background: var(--ink); color: #fff; }
.main-nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.content { max-width: 1180px; margin: 0 auto; padding: 28px 24px 80px; }
.view > h1 { font-size: 28px; margin: 6px 0; }
.view > h1:focus { outline: none; }
.eyebrow { margin: 0; font-size: 12px; font-weight: 800; letter-spacing: .08em; color: #2f6b56; }
.intro { margin: 0 0 22px; font-size: 14px; line-height: 1.6; color: var(--muted); }
.hint { margin: 8px 0 0; font-size: 12px; line-height: 1.55; color: var(--muted); }
.empty-note, .empty-list { margin: 0; padding: 28px 16px; text-align: center; font-size: 13px; color: var(--muted); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; min-width: 0; margin-bottom: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line-soft); }
.panel-head h2 { margin: 0; font-size: 17px; }
.panel-head > div { display: flex; align-items: center; gap: 10px; min-width: 0; }
.panel-body { padding: 6px 22px 22px; }
.status, .count { flex: none; padding: 5px 10px; border-radius: 99px; background: #eef3f1; color: var(--ink-soft); font-size: 12px; white-space: nowrap; }

/* toast: fixed, so feedback shows wherever the operator acted */
#message:not(:empty) {
  position: fixed; left: 50%; bottom: 24px; z-index: 30; transform: translateX(-50%);
  width: max-content; max-width: min(560px, calc(100% - 32px)); padding: 12px 16px; border: 1px solid #f1d3c3;
  border-radius: 10px; background: var(--error-bg); color: var(--error-text); font-size: 13px; line-height: 1.5;
  box-shadow: 0 10px 30px #102d3826;
}
#message.success { background: var(--brand-tint); border-color: #c5e8d5; color: var(--brand-text); }

/* ---------- overview ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stats > div { padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.stats span { display: block; font-size: 12px; color: var(--muted); }
.stats strong { display: block; margin-top: 6px; font-size: 26px; letter-spacing: -.04em; overflow-wrap: anywhere; }
.stats small { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }
#dash-run { font-size: 18px; line-height: 1.35; letter-spacing: 0; }   /* a status word, not a count */
.stats small b { color: var(--ink); }
.next-steps { list-style: none; margin: 0; padding: 6px 22px 12px; }
.next-steps li { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.next-steps li:first-child { border-top: 0; }
.next-steps strong { display: block; font-size: 14px; }
.next-steps span { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); }
.recent-list { padding: 4px 22px 12px; }
.recent-item { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-soft); font-size: 13px; }
.recent-item:first-child { border-top: 0; }
.recent-item small { color: var(--muted); white-space: nowrap; }

/* ---------- discover ---------- */
.steps { list-style: none; margin: 0; padding: 0; }
.step-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 22px 0; }
.step-head > div { flex: 1; min-width: 0; }
.step-head h2 { margin: 2px 0 4px; font-size: 17px; }
.step-head p { margin: 0; font-size: 13px; color: var(--muted); }
.step-no { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--lime); font-weight: 800; font-size: 14px; }
.step-body { padding: 4px 22px 22px 64px; }
.discovery-options { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 28px; }
.discovery-options fieldset { margin: 14px 0 0; padding: 0; border: 0; }
.discovery-options legend { margin-bottom: 4px; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.discovery-options .check { display: inline-flex; margin: 4px 18px 4px 0; }
.discovery-options select { width: 180px; }
details > summary { cursor: pointer; padding: 10px 0; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
#account-settings, #dot-setup { margin-top: 12px; }
.account-row label { margin-top: 10px; }
.dot-task { padding: 16px; border: 1px solid #dce8d4; border-radius: var(--radius); background: #f4f9ef; }
.dot-task label { margin-top: 0; }
#dot-prompt { font-size: 13px; min-height: 96px; }

.scan-meta { margin: 6px 0; font-size: 13px; line-height: 1.6; color: var(--muted); overflow-wrap: anywhere; }
.scan-error { margin: 6px 0; font-size: 13px; line-height: 1.6; color: var(--error-text); }
.scan-warning { margin: 10px 0; padding: 10px 12px; border-radius: 9px; background: var(--warn-bg); color: var(--warn-text); font-size: 13px; line-height: 1.6; }
.platform-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 4px; border-bottom: 1px solid var(--line); }
.platform-tabs button {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; margin-bottom: -1px;
  border: 1px solid transparent; border-radius: 9px 9px 0 0; background: transparent; color: var(--ink-soft); font-size: 14px; font-weight: 700;
}
.platform-tabs button[aria-selected=true] { border-color: var(--line); border-bottom-color: #fff; background: #fff; color: var(--ink); }
.chip { padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #eef3f1; color: var(--ink-soft); }
.chip.ok { background: var(--brand-tint); color: var(--brand-text); }
.chip.active { background: #e6f0fb; color: #1f4f80; }
.chip.warn { background: var(--warn-bg); color: var(--warn-text); }
.chip.error { background: var(--error-bg); color: var(--error-text); }
.scan-result { padding-top: 8px; }
.hotspot-card { margin-top: 12px; padding: 16px; border: 1px solid #e1e9df; border-radius: var(--radius); background: #f7faf5; }
.hotspot-card > strong { font-size: 15px; overflow-wrap: anywhere; }
.hotspot-card > p { margin: 8px 0; font-size: 13px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.hotspot-card .hotspot-metric { color: #2f6b47; font-weight: 700; }
.hotspot-analysis { margin-top: 16px; padding: 16px; border-radius: var(--radius); background: #eff7e8; font-size: 14px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- reply ---------- */
.workspace { display: grid; grid-template-columns: minmax(260px, 34%) minmax(0, 1fr); gap: 18px; align-items: start; }
.topic-list { padding: 8px; }
.topic-item { display: block; width: 100%; padding: 14px; border: 0; border-radius: 10px; background: #fff; text-align: left; color: var(--ink); }
.topic-item + .topic-item { border-top: 1px solid var(--line-soft); }
.topic-item:hover, .topic-item.selected { background: var(--brand-tint); }
.topic-item strong { display: block; margin: 8px 0 4px; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.topic-item small { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.topic-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.platform { padding: 3px 8px; border-radius: 6px; background: var(--brand-tint); color: var(--brand-text); font-size: 12px; font-weight: 800; }
.topic-status { font-size: 12px; color: var(--muted); }
.empty-detail { padding: 72px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.empty-detail h3 { color: var(--ink); font-size: 16px; }
.empty-icon { display: grid; place-items: center; width: 48px; height: 48px; margin: auto; border-radius: 14px; background: var(--brand-tint); color: #168364; font-size: 22px; }
.source-card { margin: 18px 22px 0; padding: 14px 16px; border: 1px solid var(--line-soft); border-radius: 11px; background: #f6f9f8; }
.source-card > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.source-card a { font-size: 13px; color: var(--brand-text); }
.source-card p { margin: 10px 0 4px; font-size: 13px; line-height: 1.6; color: var(--ink-soft); white-space: pre-wrap; overflow-wrap: anywhere; }
.flow { display: flex; gap: 6px; margin: 18px 22px 0; padding: 0; list-style: none; counter-reset: flow; }
.flow li { flex: 1; padding: 8px 6px; border-radius: 8px; background: #f1f5f3; color: var(--muted); font-size: 12px; text-align: center; counter-increment: flow; }
.flow li::before { content: counter(flow) " "; font-weight: 800; }
.flow li.done { background: var(--brand-tint); color: var(--brand-text); }
.flow li.active { background: var(--ink); color: #fff; font-weight: 700; }
.form-section { margin-top: 20px; padding: 20px 22px 0; border-top: 1px solid var(--line-soft); }
.form-section > button { margin-top: 14px; }
.form-section:last-child { padding-bottom: 22px; }
.form-title { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.form-title h3 { margin: 0 0 3px; font-size: 15px; }
.form-title p { margin: 0; font-size: 12px; color: var(--muted); }
.round-number { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border: 1px solid #c9e5da; border-radius: 50%; background: #eef8f3; color: #208465; font-size: 13px; font-weight: 800; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
#body { min-height: 150px; }
.reply-feedback { margin: 12px 0 0; padding: 10px 12px; border-radius: 9px; background: var(--error-bg); color: var(--error-text); font-size: 13px; line-height: 1.5; }
.reply-feedback.success { background: var(--brand-tint); color: var(--brand-text); }
.prefill-panel { margin-top: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; }
.prefill-panel .button-row { margin-top: 10px; }
.prefill-state { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.5; }
.prefill-state.failed { color: var(--error-text); }
.versions { margin-top: 16px; }
.versions summary { font-size: 12px; font-weight: 600; color: var(--muted); }
.versions p { max-height: 120px; overflow: auto; margin: 8px 0; padding: 6px 12px; border-left: 2px solid #c9e6dc; font-size: 12px; line-height: 1.55; color: var(--ink-soft); white-space: pre-wrap; }

/* ---------- lists: originals, queue, effects ---------- */
.item-list > * + * { border-top: 1px solid var(--line-soft); }
.original-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 22px; }
.original-item > div { min-width: 0; }
.original-item strong, .queue-card strong, .effect-card strong { display: block; margin: 8px 0 4px; font-size: 14px; overflow-wrap: anywhere; }
.original-item small, .queue-card small, .effect-card small { display: block; font-size: 12px; color: var(--muted); }
.queue-card, .effect-card { padding: 18px 22px; }
.queue-card .button-row { margin-top: 12px; }
.effect-card a { display: inline-block; margin-top: 8px; font-size: 13px; color: var(--brand-text); }
.queue-filter { display: flex; align-items: center; gap: 10px; max-width: 440px; margin-bottom: 16px; }
.queue-filter label { flex: none; margin: 0; white-space: nowrap; }
.queue-filter input { flex: 1; width: auto; min-width: 0; }
.queue-form, .link-form { display: flex; align-items: flex-end; gap: 10px; margin-top: 12px; }
.queue-form label, .link-form label { flex: 1; margin: 0; }
.link-form { max-width: 640px; }
.queue-form input, .link-form input, .metric-form input { margin-top: 6px; }
.metric-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; align-items: end; gap: 8px; margin-top: 12px; }
.metric-form label { margin: 0; }

/* ---------- dialogs ---------- */
dialog { width: min(480px, calc(100% - 32px)); padding: 24px; border: 1px solid #dde8e4; border-radius: 16px; box-shadow: 0 25px 90px #102d3840; }
#original-dialog { width: min(620px, calc(100% - 32px)); max-height: calc(100vh - 40px); overflow: auto; }
#original-dialog #edit-body { min-height: 170px; }
dialog::backdrop { background: #102d3877; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head h2 { margin: 0; font-size: 19px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.review-controls { margin-top: 20px; padding-top: 14px; border-top: 1px solid #e5ece6; }

/* ---------- tablet and phone: bottom navigation ---------- */
@media (max-width: 960px) {
  .app-header { position: static; padding: 12px 16px; }
  .main-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; justify-content: space-around; gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-top: 1px solid #dbe5dc; background: #fff;
  }
  .main-nav button { flex-direction: column; gap: 2px; min-width: 52px; min-height: 52px; padding: 4px 6px; font-size: 11px; }
  .main-nav button[aria-current=page] { background: var(--brand-tint); color: var(--brand); }
  .content { padding: 20px 16px 110px; }
  #message:not(:empty) { bottom: 84px; }
  .workspace { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  :root { --control: 44px; }
  textarea, input, select { font-size: 16px; }   /* iOS zooms into focused fields under 16 px */
  .view > h1 { font-size: 23px; }
  .panel-head, .next-steps, .recent-list, .panel-body { padding-left: 16px; padding-right: 16px; }
  .step-head { padding: 16px 16px 0; }
  .step-body { padding: 4px 16px 18px; }
  .field-grid { grid-template-columns: 1fr; }
  .discovery-options select { width: 100%; }
  .discovery-options > div { width: 100%; }
  .source-card, .flow { margin-left: 16px; margin-right: 16px; }
  .form-section { padding-left: 16px; padding-right: 16px; }
  .flow li { font-size: 11px; padding: 8px 2px; }
  .original-item { align-items: flex-start; padding: 14px 16px; }
  .queue-card, .effect-card { padding: 16px; }
  .queue-filter, .queue-form, .link-form { flex-direction: column; align-items: stretch; max-width: none; }
  .queue-filter input { flex: none; width: 100%; }
  .queue-filter button, .queue-form button, .link-form button { align-self: flex-start; }
  .metric-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-form button { grid-column: 1 / -1; }
  .next-steps li { flex-direction: column; align-items: flex-start; }
  .check { min-height: 44px; }
}
