@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@400;500&display=swap");

:root {
  --font-sans: "Manrope", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;

  --bg: #0d1520;
  --bg-accent: rgba(76, 183, 255, 0.12);
  --bg-warm: rgba(255, 122, 89, 0.1);
  --surface: rgba(15, 23, 36, 0.94);
  --surface-strong: #121c29;
  --surface-subtle: #162233;
  --surface-muted: #101926;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(76, 183, 255, 0.28);
  --text: #edf2f8;
  --muted: #97a6bb;
  --muted-strong: #c7d2df;
  --accent: #ff7a59;
  --accent-strong: #ff6a45;
  --accent-soft: rgba(255, 122, 89, 0.12);
  --accent-cool: #4cb7ff;
  --accent-cool-soft: rgba(76, 183, 255, 0.1);
  --success: #44c27c;
  --success-soft: rgba(68, 194, 124, 0.13);
  --warning: #d8a72b;
  --warning-soft: rgba(216, 167, 43, 0.13);
  --danger: #e66b7d;
  --danger-soft: rgba(230, 107, 125, 0.14);
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
}

body[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7fb;
  --bg-accent: rgba(76, 183, 255, 0.12);
  --bg-warm: rgba(255, 122, 89, 0.08);
  --surface: rgba(255, 255, 255, 0.94);
  --surface-strong: #ffffff;
  --surface-subtle: #f7f9fc;
  --surface-muted: #eef3f7;
  --border: rgba(15, 23, 42, 0.1);
  --border-strong: rgba(76, 183, 255, 0.24);
  --text: #132033;
  --muted: #5b6c82;
  --muted-strong: #334155;
  --accent: #d85d37;
  --accent-strong: #bf4d2c;
  --accent-soft: rgba(216, 93, 55, 0.1);
  --accent-cool: #0d81b3;
  --accent-cool-soft: rgba(13, 129, 179, 0.09);
  --success: #178a52;
  --success-soft: rgba(23, 138, 82, 0.12);
  --warning: #a97700;
  --warning-soft: rgba(169, 119, 0, 0.12);
  --danger: #be4459;
  --danger-soft: rgba(190, 68, 89, 0.12);
  --shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-sans);
  background:
    radial-gradient(circle at top left, var(--bg-accent), transparent 28%),
    radial-gradient(circle at top right, var(--bg-warm), transparent 24%),
    var(--bg);
  transition: background-color 180ms ease, color 180ms ease;
}

body[data-theme="light"] {
  color-scheme: light;
}

::selection {
  background: var(--accent-soft);
}

.app-container {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 18px;
  margin-bottom: 18px;
}

.hero-copy,
.hero-metrics,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  transition:
    background-color 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.hero-copy {
  padding: 24px 24px 22px;
}

.hero-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-cool);
}

.hero-copy h1 {
  margin: 0;
  font-size: clamp(30px, 4.4vw, 46px);
  line-height: 1.02;
  letter-spacing: -0.03em;
}

.hero-text {
  margin: 14px 0 0;
  max-width: 640px;
  color: var(--muted-strong);
  font-size: 15px;
  line-height: 1.7;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  flex-shrink: 0;
}

.theme-btn {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.theme-btn:hover:not(:disabled) {
  transform: none;
  color: var(--text);
}

.theme-btn.active {
  background: var(--accent-soft);
  border-color: rgba(255, 122, 89, 0.15);
  color: var(--accent);
}

.hero-metrics {
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.hero-chip {
  padding: 15px 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
}

.hero-chip span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hero-chip strong {
  display: block;
  font-size: 17px;
  line-height: 1.3;
}

.hero-chip small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.main-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(0, 0.94fr);
  gap: 18px;
}

.panel {
  padding: 18px;
}

.panel-header,
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.panel-header h2,
.section-header h3,
.output-card h3 {
  margin: 0;
}

.panel-header p,
.section-header p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.mono {
  font-family: var(--font-mono);
  color: var(--accent-cool);
}

.editor-shell {
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
}

.editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
}

.sample-group,
.toolbelt {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

textarea,
input,
select,
button {
  font: inherit;
}

textarea {
  width: 100%;
  min-height: 310px;
  border: 0;
  resize: vertical;
  padding: 16px 18px;
  background: transparent;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.68;
}

textarea::placeholder,
input::placeholder {
  color: var(--muted);
}

textarea:focus,
input:focus,
select:focus {
  outline: none;
}

.controls,
.history-filters {
  display: grid;
  gap: 12px;
}

.controls {
  margin-top: 14px;
  grid-template-columns: minmax(0, 1fr) 210px 190px;
}

.controls.provider-locked {
  grid-template-columns: minmax(0, 1fr) 190px;
}

.history-filters {
  margin: 14px 0;
  grid-template-columns: minmax(0, 1.3fr) repeat(4, minmax(0, 1fr));
}

input,
select {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text);
  transition: border-color 160ms ease, background-color 160ms ease;
}

input:focus,
select:focus {
  border-color: var(--border-strong);
  background: var(--surface-strong);
}

button {
  min-height: 46px;
  padding: 0 15px;
  border-radius: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 120ms ease,
    box-shadow 160ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

#analyze-btn {
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: #fff;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(255, 122, 89, 0.18);
}

#analyze-btn:hover:not(:disabled) {
  box-shadow: 0 14px 28px rgba(255, 122, 89, 0.22);
}

.chip-btn,
.secondary-btn,
.ghost-btn {
  min-height: 38px;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 700;
}

.chip-btn {
  background: var(--accent-cool-soft);
  border-color: rgba(76, 183, 255, 0.16);
  color: var(--accent-cool);
}

.secondary-btn {
  background: var(--surface-subtle);
  border-color: var(--border);
  color: var(--text);
}

.ghost-btn {
  background: transparent;
  border-color: var(--border);
  color: var(--muted-strong);
}

.status-message {
  margin-top: 14px;
  min-height: 48px;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid rgba(76, 183, 255, 0.18);
  background: var(--accent-cool-soft);
  color: var(--muted-strong);
  line-height: 1.55;
}

.status-message.is-error {
  border-color: rgba(230, 107, 125, 0.22);
  background: var(--danger-soft);
  color: var(--danger);
}

.history-section {
  margin-top: 18px;
}

#history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 520px;
  overflow-y: auto;
}

#history-list::-webkit-scrollbar {
  width: 10px;
}

#history-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

.history-item,
.history-empty {
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
}

.history-item {
  padding: 14px 15px;
  cursor: pointer;
}

.history-item:hover {
  border-color: rgba(255, 122, 89, 0.22);
}

.history-item.active {
  border-color: rgba(255, 122, 89, 0.3);
  box-shadow: inset 3px 0 0 var(--accent);
}

.history-empty {
  padding: 18px;
  color: var(--muted);
}

.history-item-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.history-summary {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
}

.history-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.history-signal {
  margin-top: 8px;
  color: var(--muted-strong);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
}

.history-severity,
.severity-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.snapshot-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric-card,
.highlight-card,
.output-card {
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
}

.metric-card {
  padding: 14px;
}

.metric-card span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

.highlight-card {
  margin-bottom: 14px;
  padding: 18px;
  border-left: 4px solid var(--accent-cool);
}

.highlight-head,
.highlight-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.highlight-label {
  color: var(--accent-cool);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.highlight-meta,
.highlight-footer {
  color: var(--muted);
  font-size: 12px;
}

.highlight-card p {
  margin: 12px 0 0;
  color: var(--text);
  font-family: var(--font-mono);
  line-height: 1.72;
}

.output-card {
  padding: 18px;
  margin-bottom: 12px;
}

.output-card h3 {
  margin-bottom: 8px;
  font-size: 15px;
}

.output-card p {
  margin: 0;
  color: var(--muted-strong);
  line-height: 1.72;
}

.placeholder {
  color: var(--muted);
}

.severity-low {
  background: var(--success-soft);
  border: 1px solid rgba(68, 194, 124, 0.18);
  color: var(--success);
}

.severity-medium {
  background: var(--warning-soft);
  border: 1px solid rgba(216, 167, 43, 0.2);
  color: var(--warning);
}

.severity-high {
  background: rgba(255, 122, 89, 0.12);
  border: 1px solid rgba(255, 122, 89, 0.2);
  color: var(--accent);
}

.severity-critical {
  background: var(--danger-soft);
  border: 1px solid rgba(230, 107, 125, 0.2);
  color: var(--danger);
}

@media (max-width: 1160px) {
  .hero,
  .main-layout {
    grid-template-columns: 1fr;
  }

  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .controls.provider-locked {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #analyze-btn {
    grid-column: 1 / -1;
  }

  .history-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .snapshot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-container {
    width: min(100% - 20px, 100%);
    padding-top: 14px;
  }

  .hero-copy,
  .hero-metrics,
  .panel {
    border-radius: 18px;
    padding: 16px;
  }

  .hero-topbar,
  .editor-toolbar,
  .panel-header,
  .section-header,
  .highlight-head,
  .highlight-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-metrics,
  .controls,
  .controls.provider-locked,
  .history-filters,
  .snapshot-grid {
    grid-template-columns: 1fr;
  }

  .sample-group,
  .toolbelt {
    flex-direction: column;
  }

  .theme-toggle {
    width: 100%;
    justify-content: space-between;
  }

  .theme-btn,
  button,
  .chip-btn,
  .secondary-btn,
  .ghost-btn {
    width: 100%;
  }

  textarea {
    min-height: 260px;
  }
}
