:root {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --panel-soft: #fffdf8;
  --ink: #181817;
  --muted: #64625d;
  --line: #ded9ce;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --warm: #d97706;
  --cool: #2563eb;
  --danger: #b42318;
  --button-bg: #181817;
  --button-text: #ffffff;
  --button-soft: #ffffff;
  --button-soft-text: #181817;
  --radius: 8px;
  --test-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --sample-size: 22px;
  --sample-weight: 500;
  --sample-line: 1.3;
}

body[data-theme="dark"] {
  --bg: #101110;
  --panel: #191b1a;
  --panel-soft: #202321;
  --ink: #f4f1e9;
  --muted: #aca69a;
  --line: #343832;
  --accent: #2dd4bf;
  --warm: #f59e0b;
  --cool: #60a5fa;
  --danger: #f87171;
  --button-bg: #2dd4bf;
  --button-text: #081412;
  --button-soft: #2a2e2b;
  --button-soft-text: #f4f1e9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.08), transparent 38%),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: var(--radius);
  background: var(--button-bg);
  color: var(--button-text);
  min-height: 42px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 750;
}

button:hover {
  filter: brightness(1.08);
}

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

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(420px, 1.1fr) minmax(360px, 0.9fr);
  min-height: 100vh;
}

.controls {
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  backdrop-filter: blur(18px);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--button-bg);
  color: var(--button-text);
  font-weight: 800;
  font-size: 22px;
}

h1,
h2,
p {
  margin: 0;
}

.brand h1 {
  font-size: 24px;
  line-height: 1;
}

.brand p,
.hint,
.status,
.meta-grid,
small,
.chart-head span {
  color: var(--muted);
}

.theme-toggle {
  display: grid;
  grid-template-columns: 1fr 42px 1fr;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  min-height: 44px;
  padding: 0 12px;
  margin: 0;
  text-align: center;
}

.theme-toggle span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.theme-toggle[aria-pressed="false"] span:first-child,
.theme-toggle[aria-pressed="true"] span:last-child {
  color: var(--ink);
}

.theme-toggle i {
  position: relative;
  width: 42px;
  height: 22px;
  border-radius: 999px;
  background: var(--line);
}

.theme-toggle i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--panel);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22);
  transition: transform 160ms ease, background 160ms ease;
}

.theme-toggle[aria-pressed="true"] i {
  background: var(--accent);
}

.theme-toggle[aria-pressed="true"] i::after {
  transform: translateX(20px);
}

label {
  display: block;
  font-size: 13px;
  font-weight: 750;
  margin-bottom: 8px;
}

.font-loader,
.panel,
.sliders {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 16px;
}

.input-row {
  display: flex;
  gap: 8px;
}

input[type="url"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--panel-soft);
}

input[type="url"] {
  min-height: 42px;
  padding: 0 12px;
}

.hint {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.35;
}

.font-search-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.font-search-links a {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--button-soft);
  color: var(--button-soft-text);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}

.font-search-links a:hover {
  filter: brightness(1.08);
}

.hint.warning {
  color: var(--danger);
}

.panel-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
}

.panel-title strong {
  text-align: right;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  margin-top: 14px;
  font-size: 14px;
}

.meta-grid b {
  color: var(--ink);
}

.history-controls {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.history-controls span {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.icon-button {
  min-height: 36px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
  background: var(--button-soft);
  color: var(--button-soft-text);
  border: 1px solid var(--line);
}

.history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.history-item {
  min-height: 30px;
  max-width: 100%;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--button-soft);
  color: var(--button-soft-text);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--button-text);
}

.active-url-box {
  margin-top: 12px;
}

.active-url-box label {
  margin-bottom: 6px;
}

.url-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.url-actions input {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--ink);
  padding: 0 9px;
  font-size: 12px;
}

.mini-button {
  min-height: 34px;
  padding: 0 9px;
  font-size: 12px;
  background: var(--button-soft);
  color: var(--button-soft-text);
  border: 1px solid var(--line);
}

.icon-only {
  display: grid;
  place-items: center;
  width: 34px;
  padding: 0;
}

.icon-only svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.sliders {
  display: grid;
  gap: 10px;
}

.sliders label:not(:first-child) {
  margin-top: 8px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.preview {
  padding: 24px;
  min-width: 0;
}

.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid transparent;
}

.secondary {
  border-color: var(--line);
  background: var(--button-soft);
  color: var(--button-soft-text);
}

.status {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  min-height: 42px;
  padding: 10px 12px;
  font-size: 14px;
}

.status:empty {
  display: none;
}

.preview-column {
  min-width: 0;
  padding: 18px;
}

.dashboard-column {
  border-right: 1px solid var(--line);
}

.text-column {
  display: grid;
  align-content: start;
  gap: 18px;
}

.font-surface {
  font-family: var(--test-font);
  font-size: var(--sample-size);
  font-weight: var(--sample-weight);
  line-height: var(--sample-line);
}

[data-editable-text="true"] {
  border-radius: 4px;
  outline: 0 solid transparent;
}

[data-editable-text="true"]:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

[data-editable-text="true"]:focus {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 38%, transparent);
}

.article-preview,
.dashboard,
.specimen {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(42, 37, 27, 0.10);
}

.article-preview {
  padding: clamp(22px, 4vw, 42px);
}

.eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 14px;
}

.article-preview h2 {
  font-size: clamp(34px, 5vw, 68px);
  line-height: 0.96;
  max-width: 820px;
  margin-bottom: 26px;
}

.article-preview p:not(.eyebrow) {
  max-width: 760px;
}

.article-body {
  color: var(--muted);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.55;
  margin-top: 18px;
}

.article-actions {
  display: flex;
  gap: 10px;
  margin-top: 34px;
}

.dashboard {
  padding: 18px;
}

.dash-header,
.chart-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.dash-header h2 {
  font-size: 30px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.metrics article,
.chart-panel,
.table-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--panel-soft);
}

.metrics span,
.metrics small {
  display: block;
  font-size: 14px;
}

.metrics strong {
  display: block;
  font-size: clamp(22px, 3vw, 36px);
  line-height: 1.05;
  margin: 10px 0 6px;
}

.dash-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.bars {
  height: 190px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 10px;
  margin-top: 22px;
  border-bottom: 1px solid var(--line);
}

.bars i {
  display: block;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--cool), var(--accent));
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
  font-size: 16px;
}

td {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

td:nth-child(2),
td:nth-child(3) {
  text-align: right;
}

.specimen {
  padding: clamp(20px, 3vw, 34px);
}

.glyph-row {
  font-size: clamp(56px, 8vw, 128px);
  line-height: 0.9;
  font-weight: 800;
  margin-bottom: 28px;
}

.alphabet {
  font-size: clamp(18px, 2.5vw, 30px);
  line-height: 1.35;
  padding: 22px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.sizes {
  margin-top: 24px;
}

.sizes p + p {
  margin-top: 16px;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  }

  .text-column {
    grid-column: 2;
  }

  .dashboard-column {
    border-right: 0;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .controls,
  .dashboard-column {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .text-column {
    grid-column: auto;
  }

  .input-row,
  .dash-header {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics,
  .dash-grid {
    grid-template-columns: 1fr;
  }
}
