:root {
  color-scheme: light;
  --bg: #f5f7f3;
  --panel: #ffffff;
  --ink: #1f2722;
  --muted: #667168;
  --line: #d8dfd6;
  --accent: #146c5c;
  --accent-strong: #0e574a;
  --accent-soft: #e2f2ed;
  --warn: #7a4e11;
  --shadow: 0 18px 46px rgba(25, 45, 35, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 18px;
  align-items: stretch;
}

.editor-panel,
.preview-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.editor-panel {
  padding: 22px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 56px);
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.7rem, 2.8vw, 2.6rem);
  line-height: 1.05;
}

h2 {
  font-size: 1rem;
}

.count,
.preview-badge {
  flex: 0 0 auto;
  color: var(--muted);
  background: #f0f3ee;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 0.84rem;
  white-space: nowrap;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px;
  margin-bottom: 12px;
  background: #f8faf7;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.symbol-tray {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(42px, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}

.tool-button,
.style-chip,
.symbol-button,
.secondary-action,
.primary-action {
  border-radius: 7px;
  border: 1px solid var(--line);
  min-height: 40px;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.tool-button {
  width: 42px;
  background: #ffffff;
  color: var(--ink);
}

.style-chip {
  padding: 0 14px;
  background: #ffffff;
  color: var(--ink);
  font-size: 0.92rem;
}

.symbol-button {
  min-width: 42px;
  background: #ffffff;
  color: var(--ink);
  font-size: 1.08rem;
}

.tool-button:hover,
.style-chip:hover,
.symbol-button:hover,
.secondary-action:hover {
  background: var(--accent-soft);
  border-color: #a8ccc1;
}

.tool-button.is-active,
.style-chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.26);
}

.tool-button:active,
.style-chip:active,
.symbol-button:active,
.secondary-action:active,
.primary-action:active {
  transform: translateY(1px);
}

.divider {
  width: 1px;
  height: 28px;
  background: var(--line);
  margin: 0 2px;
}

.underline-icon {
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 420px;
  flex: 1 1 auto;
  resize: vertical;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  line-height: 1.55;
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 108, 92, 0.14);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.primary-action {
  padding: 0 18px;
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

.primary-action:hover {
  background: var(--accent-strong);
}

.secondary-action {
  padding: 0 14px;
  background: #ffffff;
  color: var(--ink);
}

.status {
  color: var(--accent-strong);
  font-size: 0.92rem;
  min-height: 1.2em;
}

.preview-panel {
  min-height: calc(100vh - 56px);
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

#previewOutput {
  flex: 1 1 auto;
  min-height: 280px;
  margin: 0;
  padding: 16px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
  line-height: 1.55;
  font-family: Arial, Helvetica, sans-serif;
}

.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;
}

@media (max-width: 850px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: min(100% - 20px, 720px);
    padding: 10px 0;
  }

  .editor-panel,
  .preview-panel {
    min-height: auto;
    padding: 16px;
  }

  .topbar {
    display: block;
  }

  .count {
    display: inline-block;
    margin-top: 12px;
  }

  textarea {
    min-height: 340px;
  }
}

@media (max-width: 460px) {
  .toolbar,
  .actions,
  .symbol-tray {
    gap: 7px;
  }

  .style-chip {
    padding: 0 10px;
  }

  .primary-action,
  .secondary-action {
    flex: 1 1 100%;
  }
}
