:root {
  --bg: #f5f6f8;
  --panel-bg: #ffffff;
  --text: #1a1d23;
  --muted: #5b6270;
  --border: #d8dce3;
  --accent: #3b5bdb;
  --accent-text: #ffffff;
  --error: #c0392b;
  --error-bg: #fdecea;
  --success: #1e8e5a;
  --success-bg: #e7f7ef;
  --editor-bg: #fbfbfd;
  --shadow: rgba(20, 24, 33, 0.06);
}

:root[data-theme="dark"] {
  --bg: #14161a;
  --panel-bg: #1c1f26;
  --text: #e7e9ee;
  --muted: #9aa1ad;
  --border: #2d323c;
  --accent: #6d8bff;
  --accent-text: #0c0e12;
  --error: #ff6b5e;
  --error-bg: #3a2020;
  --success: #4fd88f;
  --success-bg: #17301f;
  --editor-bg: #14161a;
  --shadow: rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --panel-bg: #1c1f26;
    --text: #e7e9ee;
    --muted: #9aa1ad;
    --border: #2d323c;
    --accent: #6d8bff;
    --accent-text: #0c0e12;
    --error: #ff6b5e;
    --error-bg: #3a2020;
    --success: #4fd88f;
    --success-bg: #17301f;
    --editor-bg: #14161a;
    --shadow: rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  position: relative;
  padding: 1.75rem 1.5rem 1.25rem;
  text-align: center;
}

.site-header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.icon-btn {
  position: absolute;
  top: 1.25rem;
  right: 1.5rem;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  width: 2.25rem;
  height: 2.25rem;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.icon-btn:hover {
  background: var(--border);
}

.app {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: stretch;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 0 1.5rem 1.5rem;
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 1px 3px var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 420px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.panel-header label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.output-label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.spacer {
  flex: 1;
}

.editor {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: var(--editor-bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  padding: 1rem;
  width: 100%;
  min-height: 340px;
}

.editor::placeholder {
  color: var(--muted);
}

.status {
  min-height: 2.25rem;
  padding: 0.4rem 0.9rem;
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

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

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

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1rem 0.25rem;
  min-width: 150px;
}

.controls-arrow {
  font-size: 1.25rem;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  width: 100%;
}

.field label {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

select,
.btn,
.checkbox-field {
  font-family: inherit;
  font-size: 0.85rem;
}

select {
  background: var(--panel-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  cursor: pointer;
  width: 100%;
}

.btn {
  background: var(--panel-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.05s ease;
}

.btn:hover {
  background: var(--border);
}

.btn:active {
  transform: scale(0.98);
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  width: 100%;
  font-weight: 600;
  padding: 0.65rem 0.9rem;
}

.btn.primary:hover {
  filter: brightness(1.08);
}

.site-footer {
  text-align: center;
  padding: 1rem 1.5rem 1.75rem;
  color: var(--muted);
  font-size: 0.8rem;
}

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

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

  .controls {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    padding: 0.5rem;
  }

  .controls-arrow {
    display: none;
  }

  .field,
  .btn.primary,
  .checkbox-field {
    width: auto;
  }
}
