:root {
  color-scheme: light;
  --paper: #f8fafc;
  --paper-deep: #f1f5f9;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #475569;
  --line: #cbd5e1;
  --control-border: #64748b;
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-soft: #eef2ff;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --added: #dcfce7;
  --added-ink: #166534;
  --removed: #ffe4e6;
  --removed-ink: #9f1239;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius-large: 18px;
  --radius-medium: 14px;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 8% 4%, rgba(99, 102, 241, 0.09), transparent 30rem),
    radial-gradient(circle at 92% 14%, rgba(14, 165, 233, 0.06), transparent 24rem),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

[hidden] {
  display: none !important;
}

.legal-dialog {
  width: min(100% - 2rem, 620px);
  max-height: min(90vh, 760px);
  padding: clamp(1.4rem, 4vw, 2rem);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.25);
}

.legal-dialog::backdrop {
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(4px);
}

.legal-dialog h2 {
  margin: 0;
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  letter-spacing: -0.04em;
}

.legal-dialog > form > p:not(.section-kicker, .legal-dialog-error) {
  color: var(--muted);
}

.acceptance-check {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  margin-top: 0.75rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
}

.acceptance-check input {
  width: 1.1rem;
  height: 1.1rem;
  flex: 0 0 auto;
  margin-top: 0.15rem;
  accent-color: var(--accent);
}

.acceptance-check a,
.legal-dialog-note a {
  color: var(--accent-strong);
  font-weight: 700;
}

.legal-dialog-error {
  margin: 1rem 0;
  padding: 0.8rem 0.9rem;
  border: 1px solid #fecaca;
  border-radius: 11px;
  background: #fef2f2;
  color: #991b1b;
  font-size: 0.8rem;
  font-weight: 650;
}

.legal-dialog-note {
  font-size: 0.8rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  text-decoration: none;
  transform: translateY(-180%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.page-shell {
  width: min(100% - 2rem, 1240px);
  min-height: 100vh;
  margin-inline: auto;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 4.75rem;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  display: inline-flex;
  gap: 0.65rem;
  align-items: center;
  min-height: 2.75rem;
  color: var(--ink);
  font-weight: 750;
  letter-spacing: -0.025em;
  text-decoration: none;
}

.wordmark-mark {
  display: grid;
  width: 2.1rem;
  height: 2.1rem;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--accent), white 28%);
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-size: 0.8rem;
  font-weight: 800;
}

.site-nav {
  display: flex;
  align-items: center;
}

.site-nav a {
  display: inline-flex;
  min-height: 2.75rem;
  padding: 0.65rem 0.8rem;
  align-items: center;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
}

.site-nav a:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.hero {
  max-width: 850px;
  padding: clamp(3.75rem, 8vw, 6.5rem) 0 clamp(2.75rem, 5vw, 4rem);
}

.eyebrow,
.section-kicker {
  margin: 0 0 0.8rem;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 820px;
  margin: 0;
  font-family: var(--sans);
  font-size: clamp(2.65rem, 6vw, 5rem);
  font-weight: 760;
  letter-spacing: -0.05em;
  line-height: 1.02;
}

.hero-copy {
  max-width: 650px;
  margin: 1.5rem 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.8vw, 1.16rem);
  line-height: 1.6;
}

.editor-card,
.run-status,
.live-revision,
.results {
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  background: color-mix(in srgb, var(--surface), transparent 1%);
  box-shadow: var(--shadow);
}

.editor-heading h2,
.results-header h2,
.run-status h2 {
  margin: 0;
  font-family: var(--sans);
  font-weight: 720;
  letter-spacing: -0.035em;
}

.request-error {
  color: var(--danger);
  font-weight: 620;
}

.workspace {
  padding-bottom: 2rem;
}

.ai-use-notice {
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid #c7d2fe;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--muted);
  font-size: 0.84rem;
}

.ai-use-notice strong,
.ai-use-notice a {
  color: var(--accent-strong);
}

.editor-card {
  overflow: hidden;
}

.editor-heading,
.editor-footer,
.results-header,
.text-panel > header,
.score-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.editor-heading {
  padding: clamp(1.3rem, 3vw, 1.8rem) clamp(1.3rem, 3vw, 2rem) 1rem;
}

.editor-heading h2,
.results-header h2 {
  font-size: clamp(1.65rem, 3.5vw, 2.4rem);
}

.counter {
  color: var(--muted);
  font-size: 0.83rem;
  font-variant-numeric: tabular-nums;
}

#source-text {
  display: block;
  width: calc(100% - clamp(2.6rem, 6vw, 4.4rem));
  height: 310px;
  min-height: 300px;
  max-height: 70vh;
  margin: 0 clamp(1.3rem, 3vw, 2.2rem);
  padding: 1.2rem 0;
  overflow: auto;
  resize: vertical;
  border: 0;
  border-top: 1px solid var(--control-border);
  border-bottom: 1px solid var(--control-border);
  outline: 0;
  background: transparent;
  font-family: var(--sans);
  font-size: clamp(1rem, 1.4vw, 1.1rem);
  line-height: 1.65;
}

#source-text::placeholder {
  color: var(--muted);
}

#source-text:focus {
  border-color: color-mix(in srgb, var(--accent), white 20%);
}

.voice-field {
  padding: 1.1rem clamp(1.3rem, 3vw, 2.2rem) 0;
}

.voice-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.55rem;
}

.voice-heading label {
  font-size: 0.86rem;
  font-weight: 720;
}

.voice-heading label span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 500;
}

#voice-style {
  display: block;
  width: 100%;
  min-height: 98px;
  padding: 0.85rem 0.95rem;
  resize: vertical;
  border: 1px solid var(--control-border);
  border-radius: 12px;
  outline: 0;
  background: #f8fafc;
  font-size: 0.9rem;
  line-height: 1.55;
}

#voice-style::placeholder {
  color: var(--muted);
}

#voice-style:focus {
  border-color: var(--accent);
}

#voice-style[readonly] {
  color: var(--muted);
}

#voice-help {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.editor-footer {
  align-items: flex-end;
  padding: 1.1rem clamp(1.3rem, 3vw, 2.2rem) 1.4rem;
}

.editor-footer-content {
  min-width: 0;
  flex: 1;
}

.editor-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.research-contribution {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  max-width: 760px;
  min-height: 2.75rem;
  margin-top: 0.8rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--accent-soft);
  cursor: pointer;
}

.research-contribution input {
  width: 1.1rem;
  height: 1.1rem;
  flex: 0 0 auto;
  margin: 0.15rem 0 0;
  accent-color: var(--accent);
}

.research-contribution > span {
  display: grid;
  gap: 0.3rem;
}

.research-contribution strong {
  color: var(--ink);
  font-size: 0.84rem;
  line-height: 1.35;
}

.research-contribution small {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.5;
}

.research-contribution a {
  color: var(--accent-strong);
  font-weight: 700;
}

.research-contribution:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.65;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 2.75rem;
  padding: 0.72rem 1.05rem;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  transition: transform 150ms ease, background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

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

.button-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.18);
}

.button-primary:not(:disabled):hover {
  background: var(--accent-strong);
  box-shadow: 0 5px 14px rgba(79, 70, 229, 0.24);
}

.button-primary:disabled {
  opacity: 0.35;
}

.button-secondary {
  border-color: var(--control-border);
  background: var(--surface);
  color: var(--ink);
}

.button-secondary:hover {
  border-color: var(--accent);
  background: #f8fafc;
}

.button-large {
  min-height: 3.15rem;
  padding-inline: 1.4rem;
  background: var(--accent);
  color: white;
}

.button-large:not(:disabled):hover {
  background: var(--accent-strong);
}

.run-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 1.2rem;
  padding: 1.15rem 1.3rem;
  box-shadow: none;
  background: color-mix(in srgb, var(--accent-soft), white 50%);
}

.status-main {
  min-width: 0;
  flex: 1;
}

.status-copy,
.status-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.status-pulse {
  width: 0.75rem;
  height: 0.75rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.35);
  animation: pulse 1.8s infinite;
}

.run-status h2 {
  font-size: 1rem;
}

.run-status p {
  margin: 0.12rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.progress-row {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  margin-top: 0.85rem;
}

.progress-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
}

#generation-progress {
  flex: 1;
  width: 100%;
  height: 0.65rem;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--paper-deep);
  appearance: none;
  -webkit-appearance: none;
}

#generation-progress::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--paper-deep);
}

#generation-progress::-webkit-progress-value {
  border-radius: 999px;
  background: linear-gradient(90deg, #6366f1, #4f46e5);
  transition: width 300ms ease;
}

#generation-progress::-moz-progress-bar {
  border-radius: 999px;
  background: var(--accent);
}

#progress-percent {
  min-width: 3.2rem;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  font-weight: 720;
  text-align: right;
}

#elapsed-time {
  min-width: 3.4rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.live-revision {
  margin-top: 1.2rem;
  padding: 1.2rem 1.4rem;
  box-shadow: none;
}

.live-revision > header,
.result-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.live-revision h2 {
  margin: 0;
  font-family: var(--sans);
  font-size: 1.15rem;
  font-weight: 700;
}

#live-word-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.78rem;
}

.live-revision-text {
  max-height: 420px;
  margin-top: 1rem;
  padding: 1rem;
  overflow: auto;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #f8fafc;
  font-family: var(--sans);
  font-size: 0.96rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.request-error {
  margin: 1rem 0 0;
  padding: 1rem 1.2rem;
  border: 1px solid color-mix(in srgb, var(--danger), transparent 65%);
  border-radius: 14px;
  background: var(--danger-soft);
}

.request-error.is-neutral {
  border-color: var(--line);
  background: var(--paper-deep);
  color: var(--muted);
}

.results {
  margin-top: 2rem;
  padding: clamp(1.3rem, 3vw, 2.2rem);
}

.results-header {
  align-items: end;
  padding-bottom: 1.5rem;
}

.output-disclosure {
  display: flex;
  gap: 0.5rem 0.85rem;
  align-items: baseline;
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid #c7d2fe;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--muted);
  font-size: 0.8rem;
}

.output-disclosure strong {
  flex: 0 0 auto;
  color: var(--accent-strong);
}

.research-result {
  margin: 0 0 1rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.8rem;
}

.result-summary {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(0, 1.5fr);
  gap: 1rem;
  padding: 1rem 0 1.5rem;
  border-top: 1px solid var(--line);
}

.score-card,
.metrics {
  margin: 0;
  padding: 1.2rem;
  border-radius: var(--radius-medium);
  border: 1px solid color-mix(in srgb, var(--line), transparent 25%);
  background: #f8fafc;
}

.score-heading {
  align-items: baseline;
  font-size: 0.84rem;
  font-weight: 680;
}

.score-heading strong {
  font-family: var(--sans);
  font-size: 2rem;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.score-denominator {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 500;
}

.score-track {
  display: block;
  width: 100%;
  height: 0.65rem;
  margin-top: 0.75rem;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--paper-deep);
  appearance: none;
  -webkit-appearance: none;
}

.score-track::-webkit-meter-bar {
  border: 0;
  border-radius: 999px;
  background: var(--paper-deep);
  box-shadow: none;
}

.score-track::-webkit-meter-optimum-value,
.score-track::-webkit-meter-suboptimum-value,
.score-track::-webkit-meter-even-less-good-value {
  background: var(--accent);
  border-radius: 999px;
}

.score-track::-moz-meter-bar {
  background: var(--accent);
  border-radius: 999px;
}

.score-card p {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.metrics div {
  min-width: 0;
  padding-left: 1rem;
  border-left: 1px solid var(--line);
}

.metrics div:first-child {
  padding-left: 0;
  border-left: 0;
}

.metrics dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 680;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.metrics dd {
  margin: 0.45rem 0 0;
  font-family: var(--sans);
  font-size: clamp(1.05rem, 2vw, 1.45rem);
  font-variant-numeric: tabular-nums;
  font-weight: 720;
  line-height: 1.2;
}

.diff-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.broad-rewrite-notice {
  display: flex;
  gap: 0.5rem 0.75rem;
  align-items: baseline;
  margin: 0 0 1rem;
  padding: 0.8rem 0.95rem;
  border: 1px solid #c7d2fe;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.broad-rewrite-notice strong {
  flex: 0 0 auto;
  color: var(--accent-strong);
}

.view-switch {
  display: inline-flex;
  padding: 0.2rem;
  border: 1px solid var(--control-border);
  border-radius: 12px;
  background: #f1f5f9;
}

.view-switch-button {
  min-height: 2.75rem;
  padding: 0.55rem 0.85rem;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: normal;
}

.view-switch-button[aria-pressed="true"] {
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
  color: var(--accent-strong);
}

.view-switch-button:disabled {
  opacity: 0.4;
}

.diff-legend {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.74rem;
}

.legend-sample {
  padding: 0.08rem 0.25rem;
  border-radius: 3px;
  color: var(--ink);
}

.legend-removed {
  background: var(--removed);
  color: var(--removed-ink);
  text-decoration: line-through;
}

.legend-added {
  background: var(--added);
  color: var(--added-ink);
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

.comparison {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.text-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
}

.unified-panel,
.clean-panel {
  width: 100%;
}

.text-panel > header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.text-panel h3 {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 720;
}

.text-panel header span {
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.text-output {
  min-height: 360px;
  max-height: 680px;
  padding: 1.2rem;
  overflow: auto;
  font-family: var(--sans);
  font-size: 0.95rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.text-output del,
.text-output ins {
  border-radius: 3px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  color: inherit;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, currentColor, transparent 45%);
}

.text-output del {
  background: var(--removed);
  color: var(--removed-ink);
  text-decoration-color: var(--removed-ink);
}

.text-output ins {
  background: var(--added);
  color: var(--added-ink);
  text-decoration-color: var(--added-ink);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.12em;
}

.review-panel {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.025);
}

.review-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.2rem;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
}

.review-panel summary::-webkit-details-marker {
  display: none;
}

.review-panel summary::after {
  content: "+";
  margin-left: auto;
  font-size: 1.35rem;
  font-weight: 400;
  line-height: 1;
}

.review-panel[open] summary::after {
  content: "−";
}

.summary-hint {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 480;
}

.review-content {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(220px, 0.7fr);
  gap: 1.8rem;
  padding: 1.2rem;
  border-top: 1px solid var(--line);
}

.review-content h3 {
  margin: 0 0 0.6rem;
  font-size: 0.8rem;
}

.review-text {
  color: #334155;
  font-size: 0.9rem;
  line-height: 1.65;
  white-space: pre-wrap;
}

.warnings-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--danger);
  font-size: 0.86rem;
}

.warnings-list li + li {
  margin-top: 0.45rem;
}

.about {
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(0, 1.28fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  margin-top: 3.5rem;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-large);
  background:
    linear-gradient(135deg, rgba(238, 242, 255, 0.94), rgba(255, 255, 255, 0.98));
  box-shadow: var(--shadow);
}

.about-heading h2 {
  max-width: 390px;
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 760;
  letter-spacing: -0.045em;
  line-height: 1.05;
}

.about-copy {
  max-width: 720px;
}

.about-copy p {
  margin: 0;
  color: #334155;
  font-size: 0.96rem;
  line-height: 1.7;
}

.about-copy p + p {
  margin-top: 1rem;
}

.about-disclaimer {
  padding-left: 1rem;
  border-left: 3px solid var(--accent);
}

.about-disclaimer strong {
  color: var(--ink);
}

.history,
.contributions {
  margin-top: 3.5rem;
  padding-top: 2.25rem;
  border-top: 1px solid var(--line);
}

.contributions > p {
  color: var(--muted);
  font-size: 0.84rem;
}

.history-header,
.history-metadata,
.history-actions {
  display: flex;
  align-items: center;
}

.history-header {
  justify-content: space-between;
  gap: 1.5rem;
}

.history-header h2 {
  margin: 0;
  font-family: var(--sans);
  font-size: clamp(1.7rem, 3vw, 2.35rem);
  font-weight: 740;
  letter-spacing: -0.035em;
}

.history-settings > p,
.history-empty {
  color: var(--muted);
  font-size: 0.84rem;
}

.history-import {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.history-settings {
  max-width: 510px;
  text-align: right;
}

.history-settings > p {
  margin: 0.45rem 0 0;
}

.history-toggle {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 680;
  cursor: pointer;
  min-height: 2.75rem;
}

.history-toggle input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--accent);
}

.history-message {
  margin: 1rem 0 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-color: #c7d2fe;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--muted);
  font-size: 0.82rem;
}

.history-empty {
  margin: 1.3rem 0 0;
}

.history-list {
  display: grid;
  gap: 0.7rem;
  margin: 1.3rem 0 0;
  padding: 0;
  list-style: none;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.2rem;
  align-items: center;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.035);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.history-item:hover {
  border-color: #c3cfde;
  box-shadow: 0 5px 16px rgba(15, 23, 42, 0.055);
}

.history-item-content {
  min-width: 0;
}

.history-metadata {
  gap: 0.7rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.history-metadata span {
  padding-left: 0.7rem;
  border-left: 1px solid var(--line);
}

.history-item h3 {
  margin: 0.3rem 0 0;
  overflow: hidden;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item p {
  margin: 0.25rem 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-actions {
  gap: 0.5rem;
}

.history-actions .button {
  min-height: 2.75rem;
  padding: 0.58rem 0.8rem;
  font-size: 0.78rem;
}

.history-actions button:disabled {
  opacity: 0.45;
}

.history-delete {
  border-color: color-mix(in srgb, var(--danger), transparent 45%);
  background: var(--surface);
  color: var(--danger);
}

.history-delete:not(:disabled):hover {
  background: var(--danger-soft);
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 4rem;
  padding: 1.5rem 0 2.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
}

.site-footer p {
  margin: 0;
}

.site-footer nav {
  display: flex;
  gap: 0.5rem 0.8rem;
  flex-wrap: wrap;
}

.site-footer a {
  color: var(--muted);
}


input:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 5px var(--accent-strong);
}

.text-panel .text-output:focus-visible {
  outline: 2px solid transparent;
  outline-offset: -2px;
  box-shadow: inset 0 0 0 2px #ffffff, inset 0 0 0 5px var(--accent-strong);
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.35);
  }
  70%,
  100% {
    box-shadow: 0 0 0 10px rgba(79, 70, 229, 0);
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 1.2rem, 1240px);
  }

  .masthead {
    min-height: 4.5rem;
  }

  .hero {
    padding-top: 3rem;
    padding-bottom: 2.5rem;
  }

  #source-text {
    height: clamp(220px, 34vh, 260px);
    min-height: 220px;
    max-height: 260px;
    resize: none;
  }

  #voice-style {
    min-height: 84px;
  }

  .result-summary,
  .comparison,
  .review-content,
  .about {
    grid-template-columns: 1fr;
  }

  .diff-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .broad-rewrite-notice {
    align-items: flex-start;
    flex-direction: column;
  }

  .view-switch {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .view-switch-button {
    min-height: 2.75rem;
    padding-inline: 0.45rem;
  }

  .diff-legend {
    justify-content: flex-start;
  }

  .editor-footer,
  .run-status,
  .results-header,
  .result-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .editor-footer-content {
    width: 100%;
  }

  .research-contribution {
    max-width: none;
  }

  .voice-heading {
    align-items: flex-start;
  }

  .editor-footer .button,
  .results-header .button,
  .result-actions {
    width: 100%;
  }

  .status-actions {
    justify-content: space-between;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
    padding-inline: 0.8rem;
  }

  .metrics div {
    padding-left: 0.6rem;
  }

  .metrics div:last-child {
    grid-column: 1 / -1;
    padding-top: 0.75rem;
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .summary-hint {
    display: none;
  }

  .history-header,
  .history-item {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .history-header {
    flex-direction: column;
  }

  .history-settings {
    max-width: none;
    text-align: left;
  }

  .history-settings > p {
    margin: 0;
  }

  .history-import,
  .output-disclosure {
    align-items: flex-start;
    flex-direction: column;
  }

  .history-actions .button {
    flex: 1;
  }

  .text-output {
    min-height: 260px;
    max-height: 520px;
  }

  .text-output-unified,
  .clean-panel .text-output {
    min-height: 0;
    max-height: none;
    overflow: visible;
  }

  .site-footer {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
