:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: #121933;
  --panel-2: #182244;
  --text: #e9eeff;
  --muted: #aeb8dc;
  --border: rgba(255, 255, 255, 0.12);
  --accent: #7c9cff;
  --accent-2: #8cf0d4;
  --danger: #ff8f8f;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(124, 156, 255, 0.16), transparent 25%),
    radial-gradient(circle at top right, rgba(140, 240, 212, 0.12), transparent 22%),
    linear-gradient(180deg, #09101f 0%, var(--bg) 100%);
  color: var(--text);
  min-height: 100vh;
}

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

.page {
  width: min(1200px, calc(100% - 32px));
  margin: 32px auto;
  display: grid;
  gap: 24px;
}

.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.015));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: start;
  padding: 28px;
}

.hero-copy {
  min-width: 0;
}

.hero-controls {
  min-width: min(100%, 420px);
}

.settings-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-2);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 12px;
  font-size: clamp(2rem, 3vw, 3rem);
}

h2 {
  margin-bottom: 0;
}

.lead {
  color: var(--muted);
  max-width: 65ch;
  line-height: 1.55;
}

.hero-badge {
  display: inline-flex;
  white-space: nowrap;
  border: 1px solid rgba(124, 156, 255, 0.3);
  color: var(--accent);
  background: rgba(124, 156, 255, 0.08);
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 700;
  margin-bottom: 12px;
}

.model-picker {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.model-hint {
  font-size: 0.9rem;
  line-height: 1.2;
  color: var(--muted);
  white-space: nowrap;
}

.grid.two-col {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
  gap: 24px;
}

.form-card,
.output-card {
  padding: 24px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 190px;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field span {
  color: var(--muted);
  font-size: 0.95rem;
}

input,
textarea,
select {
  width: 100%;
  color: var(--text);
  background: rgba(6, 10, 22, 0.75);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 15px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 260px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(124, 156, 255, 0.7);
  box-shadow: 0 0 0 4px rgba(124, 156, 255, 0.14);
}

.actions,
.top-actions,
.result-title-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.actions {
  margin-top: 8px;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

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

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

button[type="submit"] {
  background: linear-gradient(135deg, var(--accent), #9d7cff);
  color: white;
  font-weight: 700;
}

button.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--border);
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px dashed var(--border);
}

button.small {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.92rem;
}

.form-message {
  min-height: 1.4em;
  margin-top: 12px;
  color: var(--muted);
}

.settings-dialog {
  width: min(560px, calc(100% - 32px));
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
}

.settings-dialog::backdrop {
  background: rgba(3, 7, 18, 0.72);
  backdrop-filter: blur(4px);
}

.settings-panel {
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.settings-note {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.output-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 20px;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 36px 18px;
  text-align: center;
  color: var(--muted);
}

.usage-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 0;
  margin-bottom: 0;
}

.usage-item {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 6px;
  min-width: 0;
}

.usage-label {
  color: var(--muted);
  font-size: 0.85rem;
}

.usage-item strong {
  font-size: 1.1rem;
}

.usage-reset strong {
  font-size: 1rem;
}

.usage-note {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.results {
  display: grid;
  gap: 18px;
}

.hidden {
  display: none;
}

.recent-summaries {
  padding: 24px;
}

.recent-summaries-list {
  display: grid;
  gap: 12px;
}

.recent-summary-card {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255,255,255,0.03);
}

.recent-summary-open {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 6px;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--text);
}

.recent-summary-open strong {
  font-size: 1rem;
}

.recent-summary-open span {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-block {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
}

.result-title-row {
  justify-content: space-between;
  margin-bottom: 10px;
}

.result-list {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
}

.result-list li + li {
  margin-top: 10px;
}

.action-items {
  display: grid;
  gap: 12px;
}

.action-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: rgba(6, 10, 22, 0.45);
}

.action-card h4 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.92rem;
}

.meta span {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
}

@media (max-width: 920px) {
  .grid.two-col {
    grid-template-columns: 1fr;
  }

  .hero,
  .output-header {
    flex-direction: column;
  }

  .usage-panel {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
}

@media (max-width: 640px) {
  .page {
    width: min(100% - 20px, 1200px);
    margin: 16px auto 24px;
  }

  .hero,
  .form-card,
  .output-card {
    padding: 18px;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .usage-panel {
    grid-template-columns: 1fr;
  }

  .recent-summary-card {
    flex-direction: column;
    align-items: stretch;
  }
}
