:root {
  color-scheme: dark;
  --bg: #0d0e11;
  --panel: #16181d;
  --line: #2a2d35;
  --text: #f2f2ef;
  --muted: #9b9ea6;
  --accent: #ffb000;
  font-family: system-ui, -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html,
body {
  margin: 0;
}
body {
  background: var(--bg);
  color: var(--text);
}
body.viewing {
  background: #000;
  overflow: hidden;
  cursor: none;
}

/* Marquee: two stacked canvases filling their host. */
.mq {
  position: relative;
  overflow: hidden;
}
.mq > canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.viewer {
  position: fixed;
  inset: 0;
}

/* Editor */
.editor {
  max-width: 680px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}
.brand {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.24em;
  color: var(--muted);
}
.preview {
  aspect-ratio: 2 / 1;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #000;
}
.controls {
  display: grid;
  gap: 20px;
  margin-top: 20px;
}
.field {
  display: grid;
  gap: 10px;
}
.field.row {
  grid-auto-flow: column;
  justify-content: space-between;
  align-items: center;
}
.label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}
.label output {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.field:has(:disabled) {
  opacity: 0.4;
}
textarea {
  width: 100%;
  resize: vertical;
  font: inherit;
  /* 16px or more, or iOS zooms the page when the field is focused. */
  font-size: 18px;
  line-height: 1.4;
  padding: 10px 12px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
}

.swatches {
  display: flex;
  gap: 10px;
  align-items: center;
}
.swatch,
input[type="color"] {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgb(255 255 255 / 0.15);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.swatch[aria-pressed="true"],
input[type="color"].picked {
  box-shadow:
    0 0 0 2px var(--bg),
    0 0 0 4px var(--text);
}
input[type="color"] {
  background: none;
}
input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}
input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}
input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 50%;
}
/* The custom text color sits in a color wheel ring, so it reads as "pick any" next to the presets. */
#fg {
  padding: 3px;
  border: none;
  background: conic-gradient(#ff3b30, #ffb000, #30d158, #0a84ff, #bf5af2, #ff3b30);
}

.switch {
  position: relative;
  flex: none;
  width: 46px;
  height: 28px;
  margin: 0;
  border-radius: 14px;
  background: var(--line);
  cursor: pointer;
  transition: background 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.switch::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.switch:checked {
  background: var(--accent);
}
.switch:checked::before {
  transform: translateX(18px);
}

.actions {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px;
}
.actions button {
  height: 48px;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}
.actions .primary {
  color: #111;
  background: var(--accent);
  border-color: transparent;
}
.actions button:active:not(:disabled) {
  transform: scale(0.98);
}
.actions button:disabled {
  opacity: 0.4;
  cursor: default;
}
.url {
  width: 100%;
  padding: 10px 12px;
  font: 13px ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}
