:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #334155;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 600px at 50% -10%, #1e293b, var(--bg));
  display: flex;
  justify-content: center;
  padding: 2rem 1rem 3rem;
}

.app {
  width: 100%;
  max-width: 960px;
}

.app__header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.app__header h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.4rem, 3vw, 2rem);
}

.app__header p {
  margin: 0;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 720px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.controls,
.preview {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.field__label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: end;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="tel"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  color-scheme: dark;
}

textarea {
  resize: vertical;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="datetime-local"]:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.color-input {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.color-input input[type="color"] {
  width: 46px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  cursor: pointer;
}

.color-input input[type="text"] {
  flex: 1;
  text-transform: lowercase;
}

.field--checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0;
}

.field--checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-strong);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent-strong);
}

.hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.7rem;
  cursor: help;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.btn {
  flex: 1;
  min-width: 120px;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}

.btn:hover {
  background: #31435c;
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #04283a;
}

.btn--primary:hover {
  background: var(--accent);
}

.settings {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 0.9rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.btn--small {
  flex: 0 0 auto;
  min-width: 0;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}

.status {
  min-height: 1.2rem;
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.status--error {
  color: #f87171;
}

.status--ok {
  color: #4ade80;
}

.tip {
  margin: 1rem 0 0;
  padding: 0.7rem 0.85rem;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-strong);
  border-radius: 8px;
}

.tip strong {
  color: var(--text);
}

.preview {
  position: sticky;
  top: 1rem;
  text-align: center;
}

.preview__canvas-wrap {
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  /* Checkerboard to reveal transparency */
  background-color: #cbd5e1;
  background-image:
    linear-gradient(45deg, #94a3b8 25%, transparent 25%),
    linear-gradient(-45deg, #94a3b8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #94a3b8 75%),
    linear-gradient(-45deg, transparent 75%, #94a3b8 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

.preview__canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.preview__note {
  margin: 0.9rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.app__footer {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.app__footer p {
  margin: 0 0 0.9rem;
}

.app__footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.app__footer-links .btn {
  flex: 0 1 auto;
  text-decoration: none;
}

.btn--coffee {
  background: #ffdd00;
  border-color: #ffdd00;
  color: #1f1f1f;
}

.btn--coffee:hover {
  background: #ffe84d;
}

.app__footer-credit a {
  color: var(--accent);
}
