/* Theme variables */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #eef3fb;
  --text: #172033;
  --muted: #5d687a;
  --primary: #2357b7;
  --primary-strong: #183f89;
  --on-primary: #ffffff;
  --border: #d7deea;
  --danger: #b42318;
  --warning: #a15c05;
  --success: #157347;
  --focus: #f59e0b;
  --shadow: 0 16px 42px rgba(23, 32, 51, 0.12);
  --radius: 14px;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.25rem;
  --max-width: 1120px;
  --font-main: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

body.dark-theme {
  --bg: #101722;
  --surface: #192333;
  --surface-soft: #243247;
  --text: #f7fafc;
  --muted: #c8d1dc;
  --primary: #8ec5ff;
  --primary-strong: #b8dcff;
  --on-primary: #101722;
  --border: #3b4b63;
  --danger: #ffb4a8;
  --warning: #ffd28a;
  --success: #93e2b8;
  --focus: #fbbf24;
  --shadow: 0 16px 42px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-main);
  line-height: 1.6;
}

a {
  color: var(--primary);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
}

.nav-bar {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  width: min(var(--max-width), calc(100% - 2rem));
  margin: 0 auto;
  padding: var(--space-md) 0;
}

.brand {
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 850;
  text-decoration: none;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
}

.nav-links a,
.theme-toggle,
.secondary-button,
.history-filter,
.danger-button {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 750;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.75rem;
  text-decoration: none;
}

.theme-toggle,
.secondary-button,
.history-filter,
.danger-button {
  padding: 0.45rem 0.75rem;
}

.section-shell {
  width: min(var(--max-width), calc(100% - 2rem));
  margin: 0 auto;
}

.hero {
  display: grid;
  gap: var(--space-lg);
  padding: var(--space-xl) 0;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: var(--space-md);
  font-size: clamp(2.35rem, 12vw, 4.4rem);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 6vw, 2rem);
  line-height: 1.15;
}

h3 {
  margin-bottom: 0.35rem;
}

.hero-text {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.08rem;
}

.hero-panel,
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero-panel {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
  padding: var(--space-md);
}

.hero-panel span {
  padding: var(--space-md);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 800;
}

.app-grid,
.two-column {
  display: grid;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.card {
  padding: var(--space-lg);
}

.section-heading {
  margin-bottom: var(--space-lg);
}

.muted,
.section-heading + p {
  color: var(--muted);
}

.analyzer-form,
.form-field {
  display: grid;
  gap: var(--space-sm);
}

.analyzer-form {
  gap: var(--space-md);
}

label {
  color: var(--muted);
  font-weight: 750;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  padding: 0.7rem 0.8rem;
}

textarea {
  resize: vertical;
}

.validation-message {
  min-height: 1.6rem;
  margin: 0;
  color: var(--danger);
  font-weight: 750;
}

.feedback-panel {
  min-height: 1.6rem;
  margin: 0;
  color: var(--danger);
  font-weight: 750;
}

.feedback-panel p {
  margin-bottom: 0.45rem;
}

.feedback-panel ul {
  margin: 0;
  padding-left: 1.2rem;
}

.correct-feedback {
  color: var(--success);
}

.primary-button {
  min-height: 46px;
  border: 1px solid var(--primary);
  border-radius: 10px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 850;
}

.primary-button,
.secondary-button,
.theme-toggle,
.history-filter,
.danger-button,
.nav-links a {
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.primary-button:hover,
.secondary-button:hover,
.theme-toggle:hover,
.history-filter:hover,
.danger-button:hover,
.nav-links a:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

button:disabled:hover {
  transform: none;
  border-color: var(--border);
}

.score-meter {
  display: grid;
  place-items: center;
  width: 150px;
  height: 150px;
  margin-bottom: var(--space-md);
  border: 12px solid var(--success);
  border-radius: 50%;
  background: var(--surface-soft);
}

.score-meter span:first-child {
  font-size: 2.7rem;
  font-weight: 900;
  line-height: 1;
}

.medium-risk {
  border-color: var(--warning);
}

.high-risk {
  border-color: var(--danger);
}

.red-flag-list,
.history-list {
  display: grid;
  gap: var(--space-sm);
}

.red-flag-card,
.history-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  padding: var(--space-md);
}

.red-flag-card strong,
.history-item strong {
  display: block;
}

.empty-state {
  margin-bottom: 0;
  color: var(--muted);
}

.training-sample {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  padding: var(--space-md);
}

.sample-topline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 850;
  text-transform: uppercase;
}

.training-actions,
.history-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin: var(--space-md) 0;
}

.tip-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
}

.history-top {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.danger-button {
  color: var(--danger);
}

.active-filter {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--on-primary);
}

.history-meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.site-footer {
  width: min(var(--max-width), calc(100% - 2rem));
  margin: 0 auto;
  padding: var(--space-xl) 0;
  color: var(--muted);
}

@media (min-width: 700px) {
  .nav-bar,
  .history-top {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .hero {
    grid-template-columns: 1.5fr 0.8fr;
    align-items: center;
  }

  .two-column {
    grid-template-columns: 1.4fr 0.9fr;
  }
}

@media (min-width: 900px) {
  .app-grid {
    grid-template-columns: 1.15fr 0.85fr;
    align-items: start;
  }
}
