:root {
  color-scheme: light;
  --text: oklch(0.25 0.01 20);
  --muted: oklch(0.5 0.01 20);
  --line: oklch(0.88 0.006 20);
  --field: oklch(0.995 0.002 20);
  --soft: oklch(0.955 0.004 20);
  --page: oklch(0.985 0.003 20);
  --accent: #fa5c5c; /* itch.io red */
  --accent-text: oklch(0.52 0.19 23); /* the same red, dark enough for text and links */
  --danger: oklch(0.5 0.18 25);
  --font: Lato, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Spacing: tight inside a field, looser between fields, generous between groups. */
  --space-2xs: 4px;
  --space-xs: 6px;
  --space-sm: 12px;
  --space-md: 20px;
  --space-lg: 32px;
  --space-xl: 48px;
  --radius: 4px;
  accent-color: var(--accent);
}

* { box-sizing: border-box; }

body {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--space-lg) 16px var(--space-xl);
  background: var(--page);
  color: var(--text);
  font: 17px/1.5 var(--font);
}

header { display: flex; justify-content: space-between; align-items: center; gap: var(--space-sm); flex-wrap: wrap; margin-bottom: var(--space-xl); }
.dirty { display: flex; align-items: center; gap: var(--space-sm); color: var(--muted); font-size: 0.95rem; }
.dirty button { padding: 4px 12px; }
header h1 { margin: 0; }
header a { color: inherit; text-decoration: none; }

h1 { margin: 0 0 var(--space-xs); font-size: 1.75rem; font-weight: 900; line-height: 1.1; }
h2 { margin: 0; font-size: 1.25rem; font-weight: 900; line-height: 1.2; }
/* Three tiers: h2 group headings, bold field labels, small muted hints. */
label, figcaption, #look > summary, details details > summary, .extras summary { font-size: 1rem; font-weight: 700; color: var(--text); }
label { display: block; }
p { margin: 0; }
a { color: var(--accent-text); }

/* Groups: each one a heading and its controls, separated by space and a hairline. */
main > section { display: grid; gap: var(--space-sm); padding-block: var(--space-xl); border-top: 1px solid var(--line); }
main > section:first-child { padding-top: 0; border-top: 0; }

/* Inside a group, a label hugs its control; separate fields get more room. */
.fields { gap: var(--space-md); }
.fields > h2 { margin-bottom: calc(var(--space-sm) - var(--space-md)); }
.field { display: grid; gap: var(--space-xs); }

input, select, textarea, button { font: inherit; font-weight: 400; color: inherit; }
input[type="text"], input[type="url"], input[type="number"], input[type="date"], input[type="time"], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
}
textarea { resize: vertical; }
input[type="color"] { display: block; width: 48px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--field); }

button {
  justify-self: start;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
button:disabled { opacity: 0.45; cursor: default; }
button.primary { padding: 10px 22px; border-color: var(--accent); background: var(--accent); color: #fff; }
button.primary.armed { border-color: var(--danger); background: var(--danger); }
button.primary:disabled { border-color: var(--line); background: var(--soft); color: var(--muted); opacity: 1; }
button.link, .link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font-weight: 400;
  text-decoration: underline;
  cursor: pointer;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.row { display: flex; gap: var(--space-xs); align-items: center; }
.row > input { flex: 1; min-width: 0; }

.hint { color: var(--muted); font-size: 0.9rem; }
.hint:empty, .error:empty { display: none; }
.error { color: var(--danger); }

/* home */
.home { padding-top: 20vh; }
.home p { margin-bottom: var(--space-md); color: var(--muted); }
.home .error { margin-top: var(--space-sm); }
.home .source { margin-top: var(--space-xl); font-size: 0.9rem; }
.home .source a { color: var(--muted); }

.share { gap: var(--space-xl); }
.block { display: grid; gap: var(--space-xs); }
.edit-url { padding: var(--space-md); border: 2px solid var(--accent); border-radius: var(--radius); }
.fatal { display: grid; gap: var(--space-sm); justify-items: start; }
.fatal p { font-size: 1.125rem; font-weight: 700; }
.block > h2 + .hint { margin-top: calc(-1 * var(--space-2xs)); }
.block .row, .block .code-block { margin-top: var(--space-xs); }
.edit-url input { font-family: var(--mono); font-size: 0.85rem; }

/* text + images */
.image-field { display: grid; gap: var(--space-xs); justify-items: start; }
.image-field:has(.thumb:not([hidden])) { margin-top: var(--space-xs); }
.thumb { max-width: 100%; max-height: 90px; border: 1px solid var(--line); }
.file-button { position: relative; font-size: 0.95rem; }
.file-button input { position: absolute; inset: 0; width: 1px; height: 1px; opacity: 0; }
.file-button:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

/* previews: the real 920px embed, scaled to the column */
.previews { gap: var(--space-md); }
.previews h2 { margin-bottom: calc(var(--space-sm) - var(--space-md)); }
figure { display: grid; gap: var(--space-xs); margin: 0; }
.stage { position: relative; height: 80px; border: 1px dashed var(--line); overflow: hidden; }
.stage iframe { position: absolute; top: 0; left: 0; width: 920px; border: 0; transform-origin: 0 0; }
.measure { position: absolute; top: 0; left: -10000px; width: 920px; height: 10px; border: 0; visibility: hidden; }

/* reveal time: inputs and their readback read as one unit */
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-sm); flex-wrap: wrap; }
.section-head .link { font-size: 0.95rem; }
.time-group { display: grid; gap: var(--space-xs); }
.time-fields { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-xs); }
.tz-row { display: flex; align-items: center; gap: var(--space-sm); }
.tz-row label { flex: none; }
.tz-row select { flex: 1; min-width: 0; }
.readback { margin-top: var(--space-xs); padding: var(--space-sm); border-radius: var(--radius); background: var(--soft); }
.readback .when { font-weight: 700; }
.readback .sub { color: var(--muted); }
.readback .warn, .readback.error { color: var(--danger); font-weight: 700; }

/* style */
summary { cursor: pointer; }
.details-body { display: grid; gap: var(--space-xs); padding-top: var(--space-md); }
.details-body > .look-grid { margin-top: var(--space-md); }
.look-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-md) var(--space-sm); }
.look-grid label { display: grid; gap: var(--space-xs); align-content: start; }
.look-grid .span-2 { grid-column: span 2; }
.preview-bg { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs) var(--space-sm); margin-top: calc(var(--space-xs) - var(--space-md)); }
.preview-bg input { width: 36px; height: 28px; }
.preview-bg .hint { flex-basis: 100%; }
.details-body > details { margin-top: var(--space-md); }
.check { display: flex; gap: var(--space-xs); align-items: center; }

/* save */
.save-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm); }
.save-row .height-note { flex-basis: 100%; }
#status { color: var(--muted); }
#status.error { color: var(--danger); font-weight: 700; }

/* embed code: the code and its copy button are one object */
.code-block { position: relative; }
.code-block button { position: absolute; top: var(--space-xs); right: var(--space-xs); padding: 4px 10px; font-size: 0.9rem; background: var(--field); }
.code {
  margin: 0;
  padding: var(--space-sm);
  border-radius: var(--radius);
  background: var(--soft);
  font: 0.85rem/1.5 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.code-block .code { padding-right: 80px; }
.extras { display: grid; gap: var(--space-sm); margin-top: var(--space-sm); }
.extras .details-body { padding-top: var(--space-sm); }

[hidden] { display: none !important; }
