/* TextVeda — hand-written stylesheet (no build step required) */
:root {
  --bg: #f7f4ee;
  --surface: #ffffff;
  --surface-2: #f1ede4;
  --ink: #1d1b16;
  --ink-2: #4a463d;
  --muted: #7a7466;
  --line: #e3ddd0;
  --brand: #d9622b;
  --brand-ink: #ffffff;
  --brand-soft: #fbe6da;
  --accent: #23463f;
  --ai: #c8402f;
  --ai-soft: #fadcd6;
  --mixed: #b7860b;
  --mixed-soft: #f8ecc5;
  --human: #2f7d4f;
  --human-soft: #d8efdf;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(29, 27, 22, .05), 0 8px 24px rgba(29, 27, 22, .06);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15140f; --surface: #1d1c17; --surface-2: #26241d; --ink: #f1ece1; --ink-2: #cfc8b9;
    --muted: #9b9484; --line: #353228; --brand: #ef7a43; --brand-soft: #3a2519; --accent: #8cc7b7;
    --ai: #f07563; --ai-soft: #3d201b; --mixed: #e2b443; --mixed-soft: #3a3016; --human: #6cc48f; --human-soft: #1c3426;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15140f; --surface: #1d1c17; --surface-2: #26241d; --ink: #f1ece1; --ink-2: #cfc8b9;
  --muted: #9b9484; --line: #353228; --brand: #ef7a43; --brand-soft: #3a2519; --accent: #8cc7b7;
  --ai: #f07563; --ai-soft: #3d201b; --mixed: #e2b443; --mixed-soft: #3a3016; --human: #6cc48f; --human-soft: #1c3426;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.6; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 4.5vw, 3.4rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
code, pre { font-family: var(--font-mono); font-size: .88em; }
pre { background: var(--surface-2); border: 1px solid var(--line); padding: 14px 16px; border-radius: var(--radius-sm); overflow-x: auto; }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: var(--font-mono); }
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* Buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 999px; border: 1px solid transparent; font: 600 14px/1.2 var(--font-body); cursor: pointer; transition: transform .08s ease, background .15s ease, opacity .15s; white-space: nowrap; }
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-dark { background: var(--ink); color: var(--bg); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; border-color: var(--ai); color: var(--ai); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 14px 26px; font-size: 16px; }
.btn-block { width: 100%; }
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--ink-2); }
.input, select.input, textarea.input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: 15px/1.5 var(--font-body); }
.input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
.field { margin-bottom: 16px; }
.field-error { color: var(--ai); font-size: 13px; margin-top: 4px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; font-size: 14px; color: var(--ink); }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }

/* Cards, badges, tables */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card-flat { box-shadow: none; }
.card h3 { margin-bottom: 10px; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--ink-2); }
.badge-ai { background: var(--ai-soft); color: var(--ai); }
.badge-mixed { background: var(--mixed-soft); color: var(--mixed); }
.badge-human { background: var(--human-soft); color: var(--human); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }
.alert-success { background: var(--human-soft); color: var(--human); }
.alert-error { background: var(--ai-soft); color: var(--ai); }
.alert-info { background: var(--brand-soft); color: var(--ink); }
.stat { padding: 18px; }
.stat .value { font-family: var(--font-display); font-size: 1.9rem; font-weight: 600; }
.stat .label { color: var(--muted); font-size: 13px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

/* Public layout */
.site-header { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 12px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; color: var(--ink); }
.logo:hover { text-decoration: none; }
.logo-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 16px; }
.nav { display: flex; gap: 22px; align-items: center; }
.nav a { color: var(--ink-2); font-weight: 600; font-size: 14px; }
@media (max-width: 720px) { .nav .hide-sm { display: none; } }
.hero { padding: 72px 0 40px; text-align: center; }
.hero p.lead { font-size: 1.15rem; color: var(--ink-2); max-width: 640px; margin: 0 auto 28px; }
.hero .eyebrow { display: inline-block; margin-bottom: 18px; }
.hero em { font-style: italic; color: var(--brand); }
.section { padding: 56px 0; }
.section-title { text-align: center; max-width: 640px; margin: 0 auto 32px; }
.feature-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-size: 20px; margin-bottom: 12px; }
.demo-window { max-width: 900px; margin: 36px auto 0; text-align: left; }
.demo-window .hl { padding: 1px 2px; border-radius: 4px; }
.site-footer { border-top: 1px solid var(--line); padding: 32px 0; margin-top: 40px; color: var(--muted); font-size: 14px; }
.site-footer .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.site-footer a { color: var(--ink-2); margin-left: 16px; }

/* Pricing */
.price-card { display: flex; flex-direction: column; position: relative; }
.price-card.featured { border: 2px solid var(--brand); }
.price-card .price { font-family: var(--font-display); font-size: 2.3rem; font-weight: 700; margin: 6px 0 2px; }
.price-card ul { list-style: none; padding: 0; margin: 16px 0 22px; flex: 1; }
.price-card li { padding: 6px 0 6px 24px; position: relative; font-size: 14px; }
.price-card li::before { content: "✓"; position: absolute; left: 0; color: var(--human); font-weight: 700; }
.price-card .ribbon { position: absolute; top: -12px; right: 18px; }

/* Auth */
.auth-wrap { min-height: calc(100vh - 64px); display: grid; place-items: center; padding: 40px 16px; }
.auth-card { width: 100%; max-width: 420px; }

/* App shell */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .logo { padding: 4px 10px 18px; }
.side-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 12px 6px; font-weight: 700; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 600; font-size: 14px; }
.side-link:hover { background: var(--surface-2); text-decoration: none; }
.side-link.active { background: var(--brand-soft); color: var(--brand); }
.side-foot { margin-top: auto; padding-top: 16px; }
.credit-box { background: var(--surface-2); border-radius: 12px; padding: 14px; font-size: 13px; }
.credit-box .num { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; color: var(--ink); }
.meter { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.meter > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.main { padding: 26px 28px 60px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 1.8rem; margin: 0; }
.mobile-bar { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 40; }
  .main { padding: 20px 16px 60px; }
}

/* Tool */
.tool-tabs { display: inline-flex; background: var(--surface-2); padding: 4px; border-radius: 999px; gap: 4px; }
.tool-tab { padding: 8px 18px; border-radius: 999px; border: 0; background: transparent; font: 700 14px var(--font-body); color: var(--ink-2); cursor: pointer; }
.tool-tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.tool-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; margin-top: 16px; }
@media (max-width: 1100px) { .tool-grid { grid-template-columns: 1fr; } }
.pane { display: flex; flex-direction: column; min-height: 460px; padding: 0; overflow: hidden; }
.pane-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); gap: 8px; flex-wrap: wrap; }
.pane-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.pane textarea { flex: 1; min-height: 360px; border: 0; resize: vertical; padding: 16px; font: 15px/1.7 var(--font-body); background: transparent; color: var(--ink); }
.pane textarea:focus { outline: none; }
.pane-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--surface-2); }
.options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.options label { font-size: 12px; margin-bottom: 4px; }
.options .input { padding: 7px 10px; font-size: 14px; }
@media (max-width: 640px) { .options { grid-template-columns: 1fr; } }
.result-scroll { flex: 1; overflow-y: auto; padding: 16px; max-height: 620px; }
.output-text { white-space: pre-wrap; line-height: 1.75; }
.hl { border-radius: 4px; padding: 1px 0; transition: background .15s; cursor: help; }
.hl.ai { background: var(--ai-soft); box-shadow: inset 0 -2px 0 var(--ai); }
.hl.mixed { background: var(--mixed-soft); box-shadow: inset 0 -2px 0 var(--mixed); }
.hl.human { background: transparent; }
.score-wrap { display: flex; align-items: center; gap: 16px; }
.ring { --p: 0; --c: var(--human); width: 92px; height: 92px; border-radius: 50%; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--line) 0); display: grid; place-items: center; flex-shrink: 0; }
.ring::before { content: ""; position: absolute; }
.ring > div { width: 72px; height: 72px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; text-align: center; line-height: 1.05; }
.ring strong { font-family: var(--font-display); font-size: 1.35rem; }
.ring small { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.signal { display: grid; grid-template-columns: 1fr 120px 42px; gap: 10px; align-items: center; font-size: 13px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.signal:last-child { border-bottom: 0; }
.signal .bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.signal .bar span { display: block; height: 100%; border-radius: 99px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.placeholder { flex: 1; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 30px; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.compare { display: flex; gap: 10px; align-items: center; font-weight: 700; }
.compare .arrow { color: var(--muted); }

/* Pagination */
.pagination { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 16px; }
.pagination a, .pagination span { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); font-size: 14px; color: var(--ink-2); background: var(--surface); }
.pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }
.pagination .disabled { opacity: .45; }

/* Admin chart */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-top: 10px; }
.bars .col { flex: 1; display: flex; flex-direction: column-reverse; gap: 1px; min-width: 0; position: relative; height: 100%; justify-content: flex-start; }
.bars .seg-d { background: var(--accent); border-radius: 3px 3px 0 0; }
.bars .seg-h { background: var(--brand); border-radius: 3px 3px 0 0; }
.bars .col:hover::after { content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); font-size: 11px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; z-index: 2; }
.token-box { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px dashed var(--brand); padding: 12px; border-radius: var(--radius-sm); word-break: break-all; }
.prose h2 { margin-top: 1.6em; }
.prose { max-width: 760px; }
