:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #d5d9e0;
  --text: #1c1f24;
  --muted: #667080;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #15803d;
  --error: #b91c1c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17191d;
    --surface: #1f2228;
    --border: #353a44;
    --text: #e8eaee;
    --muted: #98a1b0;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --success: #4ade80;
    --error: #f87171;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

main {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(720px, 100%);
  height: 100%;
  margin: 0 auto;
  padding: 24px;
}

h1 {
  margin: 0 0 2px;
  font-size: 20px;
  font-weight: 600;
}

header p,
.source {
  margin: 0;
  color: var(--muted);
}

.source a {
  color: var(--accent);
}

textarea {
  flex: 1;
  min-height: 180px;
  width: 100%;
  padding: 12px;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
  overflow: auto;
}

textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#counter {
  color: var(--muted);
}

button {
  padding: 8px 20px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

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

button:disabled {
  opacity: 0.45;
  cursor: default;
}

#status {
  min-height: 21px;
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
  user-select: text;
}

#status.success {
  color: var(--success);
}

#status.error {
  color: var(--error);
}
