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

:root {
  --bg: #f8f4ee;
  --surface: #fffefa;
  --surface-dim: #f1ece4;
  --border: #e0d9cf;
  --border-light: #ebe5dc;

  --ink: #1f1a14;
  --ink-secondary: #6b6159;
  --ink-tertiary: #9e9489;
  --ink-faint: #c4bbaf;

  --ai: #bf3520;
  --ai-soft: rgba(191, 53, 32, 0.07);
  --ai-medium: rgba(191, 53, 32, 0.14);

  --human: #167a6f;
  --human-soft: rgba(22, 122, 111, 0.07);
  --human-medium: rgba(22, 122, 111, 0.14);

  --amber: #b8860b;
  --amber-soft: rgba(184, 134, 11, 0.06);
  --amber-medium: rgba(184, 134, 11, 0.12);

  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(to right, var(--human), var(--amber) 50%, var(--ai));
}

main {
  max-width: 680px;
  margin: 0 auto;
  padding: clamp(40px, 8vw, 100px) clamp(20px, 5vw, 40px) 80px;
}

/* ── Hero ───────────────────────────────────── */

.hero {
  margin-bottom: clamp(36px, 6vw, 64px);
  animation: enter 600ms var(--ease-out) both;
}

h1 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: clamp(2.4rem, 1.8rem + 3vw, 3.6rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.05;
  color: var(--ink);
}

h1 em {
  font-style: italic;
  font-weight: 700;
}

.tagline {
  margin-top: 14px;
  font-size: clamp(0.95rem, 0.88rem + 0.35vw, 1.1rem);
  color: var(--ink-secondary);
  line-height: 1.6;
}

/* ── Workspace ──────────────────────────────── */

.workspace {
  animation: enter 600ms var(--ease-out) 80ms both;
}

.controls {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.control label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-tertiary);
}

select {
  appearance: none;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 7px 30px 7px 10px;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%239e9489' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 150ms;
}

select:focus {
  outline: none;
  border-color: var(--ink-tertiary);
}

input[type="password"],
input[type="text"] {
  appearance: none;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 7px 10px;
  font-family: inherit;
  font-size: 0.85rem;
  min-width: 200px;
  transition: border-color 150ms;
}

input[type="password"]:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--ink-tertiary);
}

.control.hidden { display: none; }

/* ── Input ──────────────────────────────────── */

.input-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 200ms var(--ease-out), box-shadow 200ms var(--ease-out);
}

.input-group:focus-within {
  border-color: var(--ink-faint);
  box-shadow: 0 2px 16px rgba(31, 26, 20, 0.06);
}

textarea {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--ink);
  padding: 18px 20px 14px;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.7;
  resize: vertical;
  min-height: 280px;
}

textarea.hidden { display: none; }

textarea::placeholder {
  color: var(--ink-faint);
}

textarea:focus {
  outline: none;
}

/* Highlighted text replaces textarea after per-segment analysis */
.highlighted-text {
  display: block;
  width: 100%;
  min-height: 280px;
  max-height: 600px;
  overflow-y: auto;
  border: none;
  background: transparent;
  color: var(--ink);
  padding: 18px 20px 14px;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-wrap: break-word;
  cursor: text;
}

.highlighted-text.hidden { display: none; }

.highlighted-text mark {
  color: inherit;
  border-radius: 2px;
  padding: 1px 0;
  position: relative;
  cursor: default;
  transition: opacity 150ms;
}

.highlighted-text mark:hover {
  opacity: 0.8;
}

.highlighted-text mark::after {
  content: attr(data-score);
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  background: var(--ink);
  color: var(--surface);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 150ms, transform 150ms;
  z-index: 10;
}

.highlighted-text mark:hover::after {
  opacity: 1;
  transform: translateY(0);
}

.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 10px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--surface-dim);
}

.hint {
  font-size: 0.75rem;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* ── Button ─────────────────────────────────── */

button#analyze-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--surface);
  background: var(--ink);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 150ms, opacity 150ms;
}

button#analyze-btn:hover {
  background: #0f0c08;
}

button#analyze-btn:active {
  transform: scale(0.98);
}

button#analyze-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

button#analyze-btn kbd {
  font-family: inherit;
  font-size: 0.65rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.12);
  padding: 2px 5px;
  border-radius: 3px;
  line-height: 1;
}

/* ── Progress ───────────────────────────────── */

.progress {
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress.hidden { display: none; }

.progress-track {
  flex: 1;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--ink-secondary);
  border-radius: 2px;
  transition: width 150ms var(--ease-out);
  width: 0%;
}

.progress-label {
  font-size: 0.75rem;
  color: var(--ink-tertiary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ── Verdict ────────────────────────────────── */

.verdict {
  margin-top: clamp(32px, 5vw, 52px);
  padding-top: clamp(28px, 4vw, 44px);
  border-top: 1px solid var(--border);
}

.verdict.hidden { display: none; }

.verdict-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
}

.verdict-eyebrow {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-tertiary);
}

.verdict-timing {
  font-size: 0.75rem;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.verdict-score {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.verdict-number {
  font-family: 'Fraunces', Georgia, serif;
  font-size: clamp(3.2rem, 2.6rem + 3vw, 5rem);
  font-weight: 300;
  font-style: italic;
  line-height: 1;
  letter-spacing: -0.03em;
  transition: color 400ms var(--ease-out);
}

.verdict-desc {
  font-size: clamp(1rem, 0.92rem + 0.4vw, 1.2rem);
  color: var(--ink-secondary);
}

/* ── Gauge ──────────────────────────────────── */

.gauge {
  margin-bottom: 8px;
}

.gauge-track {
  position: relative;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--human), var(--amber) 50%, var(--ai));
  opacity: 0.55;
}

.gauge-marker {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2.5px solid var(--bg);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.18);
  transform: translate(-50%, -50%);
  transition: left 600ms var(--ease-out-expo), background-color 400ms var(--ease-out);
}

.gauge-ends {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.gauge-human { color: var(--human); }
.gauge-ai { color: var(--ai); }

.verdict-detail {
  margin-top: 18px;
  font-size: 0.85rem;
  color: var(--ink-secondary);
  line-height: 1.6;
}

.verdict-detail.hidden { display: none; }

.verdict-detail strong {
  font-weight: 600;
}

/* ── Status ─────────────────────────────────── */

.status {
  margin-top: 20px;
  font-size: 0.85rem;
  color: var(--amber);
  min-height: 1.4em;
}

/* ── Animations ─────────────────────────────── */

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Reduced motion ─────────────────────────── */

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

/* ── Mobile ─────────────────────────────────── */

@media (max-width: 480px) {
  .controls {
    flex-direction: column;
    gap: 12px;
  }

  .control {
    width: 100%;
  }

  select {
    width: 100%;
  }

  .verdict-score {
    flex-direction: column;
    gap: 4px;
  }

  button#analyze-btn kbd {
    display: none;
  }
}
