:root {
  color-scheme: dark;
  --font-sans: "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-display: "Georgia", "Times New Roman", serif;
  --page-max: 1480px;
  --radius-sm: 16px;
  --radius-md: 22px;
  --radius-lg: 30px;
  --shadow-soft: 0 22px 60px rgba(1, 5, 16, 0.28);
  --shadow-card: 0 18px 48px rgba(1, 5, 16, 0.22);
  --shadow-focus: 0 0 0 3px rgba(89, 163, 255, 0.24);
  --transition-fast: 160ms ease;
  --transition-base: 220ms ease;
  --bg: #0d0717;
  --bg-ambient: #171024;
  --bg-ambient-strong: rgba(150, 92, 255, 0.18);
  --surface: rgba(18, 12, 33, 0.94);
  --surface-elevated: rgba(25, 16, 43, 0.98);
  --surface-subtle: rgba(34, 24, 57, 0.9);
  --surface-strong: rgba(42, 31, 71, 0.94);
  --text: #f4f7fb;
  --text-strong: #ffffff;
  --text-muted: #9caecf;
  --text-soft: #7e93b8;
  --border: rgba(183, 154, 236, 0.18);
  --border-strong: rgba(207, 171, 255, 0.3);
  --accent: #b24cff;
  --accent-soft: rgba(178, 76, 255, 0.16);
  --accent-soft-strong: rgba(178, 76, 255, 0.28);
  --cta: linear-gradient(135deg, #a23cff 0%, #7f2dff 100%);
  --cta-text: #fefefe;
  --success: #57d39f;
  --warning: #f1b24b;
  --danger: #ff7f7f;
  --danger-soft: rgba(255, 127, 127, 0.16);
  --grammar: #c08bff;
  --grammar-soft: rgba(192, 139, 255, 0.18);
  --style: #f1c56a;
  --style-soft: rgba(241, 197, 106, 0.18);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5efff;
  --bg-ambient: #ebe1ff;
  --bg-ambient-strong: rgba(162, 60, 255, 0.14);
  --surface: rgba(255, 255, 255, 0.92);
  --surface-elevated: rgba(255, 255, 255, 0.98);
  --surface-subtle: rgba(247, 241, 255, 0.96);
  --surface-strong: rgba(240, 232, 252, 0.98);
  --text: #211437;
  --text-strong: #180d2b;
  --text-muted: #6a568c;
  --text-soft: #826da4;
  --border: rgba(145, 99, 204, 0.22);
  --border-strong: rgba(145, 99, 204, 0.34);
  --accent: #8f37f0;
  --accent-soft: rgba(143, 55, 240, 0.12);
  --accent-soft-strong: rgba(143, 55, 240, 0.2);
  --cta: linear-gradient(135deg, #a23cff 0%, #7f2dff 100%);
  --cta-text: #ffffff;
  --success: #1c9b68;
  --warning: #b67e17;
  --danger: #d65a5a;
  --danger-soft: rgba(214, 90, 90, 0.14);
  --grammar: #8f37f0;
  --grammar-soft: rgba(143, 55, 240, 0.14);
  --style: #ad7a11;
  --style-soft: rgba(173, 122, 17, 0.16);
  --shadow-soft: 0 24px 54px rgba(22, 35, 63, 0.08);
  --shadow-card: 0 18px 42px rgba(22, 35, 63, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 1120px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(circle at top left, var(--bg-ambient-strong), transparent 30%),
    radial-gradient(circle at 92% 8%, rgba(178, 76, 255, 0.09), transparent 18%),
    linear-gradient(180deg, var(--bg-ambient) 0%, var(--bg) 28%, var(--bg) 100%);
  transition: background-color var(--transition-base), color var(--transition-base);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
select,
textarea,
input {
  font: inherit;
}

button,
select,
textarea,
input {
  transition:
    background-color var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast),
    box-shadow var(--transition-fast),
    transform var(--transition-fast),
    opacity var(--transition-fast);
}

button:focus-visible,
select:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.site-shell {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 26px 28px 56px;
}

.site-shell--compact {
  padding-bottom: 28px;
}

.site-header {
  position: relative;
  overflow: hidden;
  padding: 26px 30px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0)), var(--surface);
  box-shadow: var(--shadow-soft);
}

.site-header--compact {
  padding: 24px 28px;
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(95, 163, 255, 0.22), rgba(72, 208, 164, 0.16));
  border: 1px solid var(--border-strong);
  color: var(--text-strong);
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.brand-copy {
  display: grid;
  gap: 4px;
}

.brand-copy strong {
  color: var(--text-strong);
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-copy span {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0;
  min-height: 52px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(14px);
}

.status-pill strong {
  color: var(--text-strong);
  font-size: 0.92rem;
}

.status-pill[data-state="ready"] strong {
  color: var(--success);
}

.status-pill[data-state="error"] strong {
  color: var(--danger);
}

.status-pill[data-state="loading"] strong {
  color: var(--warning);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0;
  min-height: 52px;
  width: 52px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-strong);
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.08);
}

.theme-toggle__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.95rem;
}

.theme-toggle__text {
  display: none;
}

.page-main {
  margin-top: 22px;
}

.toolbar {
  position: sticky;
  top: 14px;
  z-index: 12;
  display: grid;
  grid-template-columns: minmax(250px, 1fr) repeat(2, auto);
  gap: 14px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)), var(--surface-elevated);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-card);
}

.toolbar-group {
  display: grid;
  gap: 6px;
}

.toolbar-group label {
  color: var(--text-soft);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

select,
textarea,
input[type="text"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-strong);
  color: var(--text-strong);
}

select,
input[type="text"] {
  min-height: 50px;
  padding: 0 14px;
}

select:hover,
textarea:hover,
input[type="text"]:hover {
  border-color: var(--border-strong);
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 18px;
  border-radius: 14px;
  border: 1px solid transparent;
  cursor: pointer;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none;
}

.primary {
  background: var(--cta);
  color: var(--cta-text);
  box-shadow: 0 14px 32px rgba(127, 45, 255, 0.28);
}

.secondary {
  background: var(--surface-subtle);
  border-color: var(--border);
  color: var(--text-strong);
}

.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

.summary-cta {
  min-width: 220px;
  justify-content: space-between;
  background: var(--surface-subtle);
  border-color: var(--border);
  color: var(--text-strong);
  box-shadow: none;
}

.summary-cta:hover:not(:disabled) {
  border-color: var(--border-strong);
}

.summary-cta[data-state="ok"] {
  color: var(--success);
}

.summary-cta[data-state="issues"] {
  color: var(--warning);
}

.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0)), var(--surface);
  box-shadow: var(--shadow-card);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  margin-top: 20px;
  align-items: stretch;
}

.workspace--single {
  min-height: 760px;
}

.editor-panel {
  padding: 24px;
  height: 100%;
}

.editor-panel {
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-header h2 {
  margin: 0;
  color: var(--text-strong);
}

.panel-header p {
  margin: 8px 0 0;
  color: var(--text-muted);
  line-height: 1.68;
}

.editor-shell {
  position: relative;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent), var(--surface-strong);
}

.editor-shell:focus-within {
  border-color: var(--accent-soft-strong);
  box-shadow: 0 0 0 3px rgba(178, 76, 255, 0.16);
}

.editor-highlights,
.editor {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 24px 24px 28px;
  font-family: var(--font-display);
  font-size: 1.08rem;
  line-height: 1.84;
  white-space: pre-wrap;
  word-break: break-word;
  tab-size: 4;
}

.editor-highlights {
  position: absolute;
  inset: 0;
  overflow: auto;
  color: var(--text);
  pointer-events: none;
  z-index: 2;
}

.editor {
  position: relative;
  z-index: 1;
  resize: none;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: var(--text-strong);
  -webkit-text-fill-color: transparent;
  overflow: auto;
}

.editor::selection {
  background: rgba(178, 76, 255, 0.22);
}

.editor:focus {
  outline: none;
}

.editor-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 14px;
  color: var(--text-soft);
  font-size: 0.9rem;
  line-height: 1.55;
}

.highlight {
  border-radius: 8px;
  padding: 0 2px;
  pointer-events: auto;
  cursor: pointer;
}

.highlight.spelling {
  background: var(--danger-soft);
  box-shadow: inset 0 -2px 0 rgba(255, 127, 127, 0.34);
}

.highlight.grammar {
  background: var(--grammar-soft);
  box-shadow: inset 0 -2px 0 rgba(136, 186, 255, 0.34);
}

.highlight.style {
  background: var(--style-soft);
  box-shadow: inset 0 -2px 0 rgba(241, 197, 106, 0.34);
}

.highlight.active {
  outline: 2px solid var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 -2px 0 rgba(178, 76, 255, 0.4);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.badge.spelling {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.grammar {
  background: var(--grammar-soft);
  color: var(--grammar);
}

.badge.style {
  background: var(--style-soft);
  color: var(--style);
}

.excerpt,
.suggestions,
.finding-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.86rem;
}

.suggestion-btn {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: none;
}

.suggestion-btn:hover {
  background: var(--accent-soft-strong);
}

.empty-state {
  padding: 20px;
  border-radius: 18px;
  border: 1px dashed var(--border);
  background: var(--surface-subtle);
  color: var(--text-muted);
  line-height: 1.68;
}

.issue-popover {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 4;
  width: min(340px, calc(100% - 24px));
  padding: 16px;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0)), var(--surface-elevated);
  box-shadow: var(--shadow-card);
}

.issue-popover[hidden] {
  display: none;
}

.issue-popover__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.issue-popover__title {
  color: var(--text-strong);
  font-weight: 700;
}

.issue-popover__body {
  display: grid;
  gap: 10px;
}

.issue-popover__body p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.55;
}

@media (max-width: 1240px) {
  html {
    min-width: 1024px;
  }

  .site-shell {
    padding-left: 20px;
    padding-right: 20px;
  }

  .toolbar {
    grid-template-columns: minmax(220px, 1fr) repeat(2, auto);
  }
}
