/* Zitat des Tages: mobile first, light and dark from the system setting. No web fonts, no CDN -
   everything here is uploadable as it is. */

:root {
  color-scheme: light dark;
  --bg: #f1f0ed;
  --surface: #fff;
  --surface-2: #f6f5f2;
  --ink: #1b1b19;
  --muted: #5e5c57;
  --line: #e2e0da;
  --accent: #b45309;
  --on-accent: #fff;
  --accent-ink: #9a4508;
  --accent-soft: #fbebd6;
  --ok: #1c7a3a;
  --ok-soft: #e2f2e7;
  --error: #b3261e;
  --error-soft: #fce9e7;
  --panel: #0d0d0c;
  --panel-edge: #2b2a27;
  --led: #ffb224;
  --led-off: #2b241a;
  --shadow: 0 1px 2px rgb(27 27 25 / .05), 0 6px 18px rgb(27 27 25 / .05);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M8 12.5l2.8 2.8L16 9.8'/%3E%3C/svg%3E");
  --icon-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3.5L2.8 19.5h18.4z'/%3E%3Cpath d='M12 10v4'/%3E%3Cpath d='M12 16.8v.2'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111110;
    --surface: #1b1b19;
    --surface-2: #232321;
    --ink: #edebe6;
    --muted: #a6a39c;
    --line: #2e2d2a;
    --accent: #f5a524;
    --on-accent: #1c1204;
    --accent-ink: #f7b54a;
    --accent-soft: #3a2a10;
    --ok: #63c981;
    --ok-soft: #14281b;
    --error: #ff8d80;
    --error-soft: #3b1915;
    --panel: #050505;
    --panel-edge: #2e2d2a;
    --led-off: #221d15;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 44rem;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

code { font: 13px var(--mono); color: var(--ink); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Header ------------------------------------------------------------------------------- */

.head { display: flex; align-items: center; gap: 12px; padding: 4px 0 18px; }
.head h1 { margin: 0; font-size: 22px; line-height: 1.15; letter-spacing: -.01em; font-weight: 750; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.mark {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--panel-edge);
}

/* --- Messages ----------------------------------------------------------------------------- */

.messages { display: grid; gap: 10px; margin-bottom: 14px; }
.msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 550;
}
.msg code { color: inherit; font-weight: 700; }
.msg::before, .warn::before, .conflict strong::before {
  content: "";
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  background: currentColor;
  -webkit-mask: var(--icon-alert) center / contain no-repeat;
  mask: var(--icon-alert) center / contain no-repeat;
}
.msg.ok { background: var(--ok-soft); color: var(--ok); }
.msg.ok::before { -webkit-mask-image: var(--icon-check); mask-image: var(--icon-check); }
.msg.error { background: var(--error-soft); color: var(--error); }

/* --- "Jetzt an der Tür" ------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.now { padding: 14px 14px 12px; }
.now h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 2px 10px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}
.live { width: 8px; height: 8px; border-radius: 50%; background: var(--led); box-shadow: 0 0 0 3px rgb(255 178 36 / .22); }
.live.off { background: var(--line); box-shadow: none; }

/* Mimics the 64x64 panel: amber capitals on black (the firmware's font has no lowercase), with a
   dot grid of unlit LEDs behind the text and a mask in front that breaks the glyphs into dots. */
.led {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 18px 16px;
  border-radius: 12px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--panel-edge);
  color: var(--led);
  font: 700 17px/1.6 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgb(255 178 36 / .5);
  overflow-wrap: anywhere;
}
.led::before, .led::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.led::before { z-index: -1; background: radial-gradient(circle, var(--led-off) .9px, transparent 1.4px) 0 0 / 4px 4px; }
.led::after { z-index: 1; background: radial-gradient(circle, transparent 1.1px, var(--panel) 1.9px) 0 0 / 4px 4px; opacity: .5; }
.led.off { color: #5a564e; text-shadow: none; }

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin: 12px 2px 2px;
  font-size: 14px;
  color: var(--muted);
}
.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}
.next { display: inline-flex; align-items: center; gap: 5px; }

.jump {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  margin-top: 12px;
  padding: 0 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 15px;
  font-weight: 650;
  text-decoration: none;
}
.jump:hover { border-color: var(--accent); }
.jump span { flex: 1; }
.jump .ji { flex: none; color: var(--accent-ink); }
.jump .jc { flex: none; color: var(--muted); }

/* --- Sections and day rows ---------------------------------------------------------------- */

.sec { margin-top: 30px; }
.sec h2 { margin: 0; font-size: 19px; font-weight: 750; letter-spacing: -.005em; }
.hint { margin: 4px 0 12px; color: var(--muted); font-size: 14.5px; }

.days { display: grid; gap: 8px; }

.list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  scroll-margin: 16px;
}
.list.today { border-color: var(--accent); }

.list summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 9px 12px 9px 9px;
  cursor: pointer;
  list-style: none;
}
.list summary::-webkit-details-marker { display: none; }
.list summary:focus-visible { outline-offset: -2px; border-radius: 16px; }
@media (hover: hover) {
  .list summary:hover { background: var(--surface-2); }
}

/* A small calendar page: weekday, day, month. */
.tile {
  width: 46px;
  height: 50px;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  line-height: 1;
}
.tile .wd, .tile .mo { font-weight: 750; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tile .wd { font-size: 10.5px; }
.tile .dn { font-size: 19px; font-weight: 750; margin: 3px 0 2px; font-variant-numeric: tabular-nums; }
.tile .mo { font-size: 10px; font-weight: 650; }
.weekend .tile .wd { color: var(--accent-ink); }
.today .tile { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.today .tile .wd, .today .tile .mo { color: var(--on-accent); }
.standard .tile { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }

.lbody { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cap { font-size: 11.5px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; color: var(--accent-ink); }
.preview { font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview.empty { color: var(--muted); font-style: italic; }
.badge {
  flex: none;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12.5px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.chev { flex: none; color: var(--muted); transition: transform .2s; }
details[open] .chev { transform: rotate(90deg); }

/* --- Editing a day ------------------------------------------------------------------------ */

.list form { display: grid; gap: 10px; padding: 12px; border-top: 1px solid var(--line); }

textarea {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* 16px keeps iOS from zooming in on focus */
  line-height: 1.55;
  resize: vertical;
}
/* Where supported, the field grows with its text instead of scrolling inside a scrolling page. */
@supports (field-sizing: content) {
  textarea { field-sizing: content; min-height: calc(3lh + 22px); max-height: 70vh; }
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.feedback { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.feedback:empty { display: none; }
.feedback li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 8px; align-items: center; }
.feedback .led {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.bytes {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.bytes.over { background: var(--error-soft); border-color: transparent; color: var(--error); }
.warn {
  grid-column: 1 / -1;
  display: flex;
  gap: 6px;
  align-items: flex-start;
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
}
.warn::before { width: 15px; height: 15px; margin-top: 1px; }
.warn.bad { color: var(--error); font-weight: 600; }

.conflict { padding: 12px 14px; border-radius: 12px; background: var(--error-soft); font-size: 14.5px; }
.conflict strong { display: flex; gap: 8px; align-items: center; color: var(--error); }
.conflict strong::before { width: 17px; height: 17px; margin-top: 0; }
.conflict p { margin: 6px 0 0; }
.conflict ol { margin: 6px 0 0; padding-left: 22px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }

button {
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-size: 15.5px;
  font-weight: 650;
  cursor: pointer;
}
.actions button:first-child { flex: 1 1 auto; }
button.quiet { background: transparent; color: var(--muted); border: 1px solid var(--line); }
button.quiet:hover { color: var(--error); border-color: var(--error); }

/* --- Footer ------------------------------------------------------------------------------- */

.foot {
  display: grid;
  gap: 16px;
  margin-top: 34px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}
.foot p { margin: 0; }
.foot .foot-h { margin-bottom: 6px; font-size: 12px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.url {
  display: block;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  line-height: 1.4;
  word-break: break-all;
}
.keys { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: middle; }
.keys code {
  display: inline-block;
  min-width: 24px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface);
  font-weight: 700;
  text-align: center;
}

/* --- Wider screens ------------------------------------------------------------------------ */

@media (min-width: 600px) {
  .actions button:first-child { flex: 0 0 auto; padding: 0 22px; }
}

/* Two columns: the door's state, the fallback pool and the footer on the left, the days on the
   right. The source order stays the phone's order. */
@media (min-width: 960px) {
  .wrap {
    max-width: 1120px;
    padding: 40px 32px 56px;
    display: grid;
    grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
    grid-template-rows: auto auto auto auto 1fr;
    column-gap: 48px;
    align-items: start;
  }
  .head { grid-area: 1 / 1; padding-bottom: 22px; }
  .messages { grid-area: 2 / 1; margin-bottom: 16px; }
  .now { grid-area: 3 / 1; }
  .standard-sec { grid-area: 4 / 1; }
  .foot { grid-area: 5 / 1; margin-top: 30px; }
  .days-sec { grid-column: 2; grid-row: 1 / 6; margin-top: 6px; }

  .head h1 { font-size: 26px; letter-spacing: -.015em; }
  .mark { width: 48px; height: 48px; border-radius: 13px; }
  .now { padding: 16px 16px 14px; }
  .now > .led { display: flex; align-items: center; min-height: 132px; padding: 26px 20px; font-size: 20px; }
  .list summary { gap: 14px; padding-right: 14px; }
}
