:root {
  color-scheme: light;
  font-family: Arial, sans-serif;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #64748b;
  --border: #cbd5e1;
  --accent: #2f7d50;
  --accent-hover: #25683f;
  --shadow: rgba(15, 23, 42, 0.08);
}

body.dark {
  color-scheme: dark;
  --bg: #171717;
  --surface: #222222;
  --text: #f5f5f5;
  --muted: #bdbdbd;
  --border: #4a4a4a;
  --accent: #3f8f63;
  --accent-hover: #32704f;
  --shadow: rgba(0, 0, 0, 0.35);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
  padding: 24px;
  transition: background 0.2s ease, color 0.2s ease;
}

.container {
  width: min(720px, 100%);
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 10px 25px var(--shadow);
  padding: 24px;
}

.top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

h1 {
  margin-top: 0;
  font-size: 1.6rem;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.toolbar button {
  margin-top: 0;
}

.template-card {
  border: 2px solid var(--border);
  padding: 16px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 4px 10px var(--shadow);
  margin-bottom: 14px;
}

.template-card + .template-card {
  margin-top: 16px;
  border-top: 3px solid var(--accent);
}

.template-card:first-of-type {
  border-top: 3px solid var(--accent);
  padding-top: 16px;
}

.template-field-row {
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 8px;
  background: rgba(47, 125, 80, 0.06);
}

body.dark .template-field-row {
  background: rgba(255, 255, 255, 0.04);
}

label {
  font-weight: 600;
}

input,
select,
textarea,
button {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

textarea {
  min-height: 180px;
}

#messagePreview {
  min-height: 180px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  overflow-wrap: anywhere;
  overflow: visible;
}

button {
  cursor: pointer;
  background: var(--accent);
  color: white;
  border: none;
  margin-top: 8px;
}

button:hover {
  background: var(--accent-hover);
}

.hint {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 16px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--muted);
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.slider {
  width: 42px;
  height: 24px;
  background: var(--border);
  border-radius: 999px;
  position: relative;
  transition: background 0.2s ease;
}

.slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.switch input:checked + .slider {
  background: var(--accent);
}

.switch input:checked + .slider::before {
  transform: translateX(18px);
}

#themeToggle {
  font-size: 1.2rem;
  padding: 6px 12px;
  background: transparent;
  box-shadow: 0 5px 5px var(--shadow);
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.field-group > .text-link {
  margin-left: auto;
}

.text-link:hover {
  background: rgba(47, 125, 80, 0.1);
  color: var(--accent-hover);
  transform: translateY(-1px);
}

body.dark .text-link:hover {
  background: rgba(255, 255, 255, 0.08);
}