:root {
  --bg: #F6F2E9;
  --card: #FFFFFF;
  --ink: #1C1C1C;
  --muted: #6E6A61;
  --accent: #2E4E6B;
  --border: #D9D2C4;
  --danger: #8C3B33;
}

@font-face {
  font-family: "Atkinson";
  src: url("vendor/AtkinsonHyperlegible-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Atkinson";
  src: url("vendor/AtkinsonHyperlegible-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding: 20px 16px 32px;
  max-width: 560px;
  margin-inline: auto;
}

h1 { font-size: 22px; margin: 0; }

.page-head { margin-bottom: 14px; }

.sub { color: var(--muted); font-size: 15px; margin: 6px 0 0; }

.card {
  margin-top: 14px; padding: 16px;
  background: var(--card); border: 1.5px solid var(--border); border-radius: 12px;
}

.card[hidden] { display: none; }

/* The message the clock reports as shown right now, read straight from the
 * device. It is only shown while a different draft is being written; otherwise
 * the preview already shows the same text. */
.current { border-color: #C9D6C6; background: #F6FAF5; }
.current h2 { color: #23563A; }
.current-text {
  margin: 0; font-size: 17px; line-height: 1.45;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.current-meta { margin-top: 8px; }

.card h2 { font-size: 17px; margin: 0 0 10px; }

label { display: block; font-size: 15px; font-weight: 600; margin: 14px 0 6px; }

.card > label:first-of-type, .card .row label { margin-top: 14px; }

textarea, input, select {
  width: 100%; font: inherit; font-size: 17px; padding: 12px;
  border: 1.5px solid var(--border); border-radius: 10px; background: var(--card);
  color: var(--ink);
}

textarea { min-height: 120px; resize: vertical; line-height: 1.4; }

.row { display: flex; gap: 12px; margin-top: 4px; }
.row > div { flex: 1; }

/* Native date/time picker, shown full width only for the custom expiry option. */
.expiry-at { margin-top: 8px; color-scheme: light; }

.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

/* Transient "sent to the clock" feedback. The hint text is restored after a
 * few seconds, so the language row always explains what the selector does. */
.note.ok { color: #2A5B39; }
.note.err { color: var(--danger); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar h1 { font-size: 22px; margin: 0; }

.lang-select {
  width: auto; flex: 0 0 auto; max-width: 46%;
  padding: 8px 10px; font-size: 15px; border-radius: 10px;
}

.clock-settings {
  margin-top: 14px; padding: 0 16px 12px;
}

.clock-settings summary {
  padding: 14px 0; font-size: 17px; font-weight: 600; cursor: pointer;
}

.clock-settings[open] summary { padding-bottom: 6px; }

.switchrow {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 0; border-top: 1px solid var(--border);
}

.switchrow label { margin: 0; font-size: 16px; }
.switchrow input { width: 24px; height: 24px; accent-color: var(--accent); flex: 0 0 auto; }

/* Emulated 800x480 clock. Everything is positioned in cqw, so the whole
 * screen scales with the phone width and keeps the device's proportions. */
.preview h2 { margin-bottom: 10px; }

.screen {
  container-type: inline-size;
  position: relative;
  width: 100%;
  aspect-ratio: 800 / 480;
  overflow: hidden;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Atkinson", system-ui, sans-serif;
}

/* Optional season picture, matching the clock's shared background setting.
 * Same files as the firmware (tools/make_backgrounds.py). */
.screen.season-bg {
  background-size: cover;
  background-position: center;
}
.screen.season-bg[data-season="forar"] { background-image: url("backgrounds/foraar.jpg"); }
.screen.season-bg[data-season="sommer"] { background-image: url("backgrounds/sommer.jpg"); }
.screen.season-bg[data-season="efterar"] { background-image: url("backgrounds/efteraar.jpg"); }
.screen.season-bg[data-season="vinter"] { background-image: url("backgrounds/vinter.jpg"); }

.screen-date {
  position: absolute; top: 1.25cqw; left: 0; width: 100%;
  font-size: 5cqw; line-height: 5.375cqw; text-align: center;
}

.screen-time {
  position: absolute; top: 9.75cqw; left: 0; width: 100%;
  display: flex; align-items: flex-end; justify-content: center; gap: 1.2cqw;
}

.screen-time > #screen-time {
  font-size: 23.75cqw; line-height: 16.5cqw; font-weight: 700;
  letter-spacing: -0.01em;
}

.screen-ampm {
  font-size: 4.25cqw; line-height: 6cqw; font-weight: 700;
  padding-bottom: 1.2cqw;
}

.screen-facts {
  position: absolute; top: 27.25cqw; left: 0; width: 100%; height: 9cqw;
  display: flex; align-items: center; justify-content: center; gap: 2cqw;
  font-size: 4.25cqw; line-height: 4.625cqw; font-weight: 700;
  color: var(--accent);
}

.screen-dot { color: var(--muted); font-weight: 400; }

.screen-season-icon { width: 9cqw; height: 9cqw; border-radius: 1.6cqw; }

.screen-card {
  position: absolute; top: 37cqw; left: 3cqw; width: 94cqw; height: 21.5cqw;
  display: flex; flex-direction: column;
  padding: 1cqw; border: 0.25cqw solid var(--border); border-radius: 2.25cqw;
  background: var(--card);
}

.screen-msg {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3;
  overflow: hidden;
  width: 100%; height: 13.875cqw;
  font-size: 4.25cqw; line-height: 4.625cqw; color: var(--ink);
  overflow-wrap: normal; word-break: normal;
}

.screen-msg.empty { color: var(--muted); }

.screen-meta {
  margin-top: auto; align-self: flex-end;
  font-size: 2.75cqw; line-height: 3.125cqw; color: var(--muted);
  white-space: nowrap;
}

/* Without a message the clock uses the freed card area: 260 px time, 46 px
 * facts and a 96 px season icon, centered between the date and the bottom. */
.screen.no-message .screen-time { top: 14.625cqw; }
.screen.no-message #screen-time { font-size: 32.5cqw; line-height: 22.625cqw; }
.screen.no-message .screen-ampm {
  font-size: 5.75cqw; line-height: 6.5cqw; padding-bottom: 1.6cqw;
}
.screen.no-message .screen-facts {
  top: 40.125cqw; height: 12cqw;
  font-size: 5.75cqw; line-height: 6.5cqw; gap: 2.5cqw;
}
.screen.no-message .screen-season-icon {
  width: 12cqw; height: 12cqw; border-radius: 2.1cqw;
}
.screen.no-message .screen-card { display: none; }

/* "Is the clock on?" card. Big, calm and readable at arm's length. */
.device {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border-radius: 12px;
  background: var(--card); border: 1.5px solid var(--border);
}

.device-dot {
  flex: 0 0 auto; width: 14px; height: 14px; margin-top: 6px;
  border-radius: 50%; background: #B4AFA4;
}

.device-body { display: flex; flex-direction: column; gap: 2px; }
.device-body strong { font-size: 17px; line-height: 1.3; }
.device-body span { font-size: 14px; color: var(--muted); line-height: 1.35; }

.device[data-state="on"] { border-color: #B9D3BF; background: #EFF6F0; }
.device[data-state="on"] .device-dot { background: #2A7A45; }
.device[data-state="on"] strong { color: #23563A; }

.device[data-state="off"] { border-color: #E3C3BF; background: #FBEFEE; }
.device[data-state="off"] .device-dot { background: var(--danger); }
.device[data-state="off"] strong { color: var(--danger); }

.actions { display: flex; gap: 12px; margin-top: 16px; }

button {
  font: inherit; font-size: 18px; font-weight: 600; padding: 15px 20px;
  border-radius: 12px; border: 0; cursor: pointer;
}

button.primary { background: var(--accent); color: #fff; flex: 1; }
button.secondary { background: transparent; color: var(--danger); border: 1.5px solid var(--border); flex: 1; }
button:disabled { opacity: .45; cursor: default; }

.foot { margin-top: 14px; }

.linkish {
  display: block; background: none; border: 0; color: var(--accent);
  font-size: 14px; padding: 6px 0; margin-top: 6px;
  text-decoration: underline; cursor: pointer;
}

.linkish.danger { color: var(--danger); margin-top: 18px; }

.status {
  font-size: 14px; padding: 10px 12px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--border); color: var(--muted);
  overflow-wrap: anywhere;
}

@media (max-width: 430px) {
  .actions button { font-size: 16px; padding: 14px 12px; }
  .row { flex-direction: column; gap: 0; }
  .row > div { flex: 0 0 auto; }
  .device-body strong { font-size: 16px; }
}

.status.ok { color: #2A5B39; border-color: #B9D3BF; background: #EFF6F0; }
.status.err { color: var(--danger); border-color: #E3C3BF; background: #FBEFEE; }

dialog {
  border: 0; border-radius: 16px; padding: 22px; width: min(92vw, 480px);
  background: var(--card); color: var(--ink);
}

dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h2 { margin: 0 0 6px; font-size: 20px; }
dialog .sub { margin-bottom: 12px; }
