@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 300;
  src: url("fonts/SpaceGrotesk-300.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 500;
  src: url("fonts/SpaceGrotesk-500.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 700;
  src: url("fonts/SpaceGrotesk-700.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Space Mono";
  font-style: normal;
  font-weight: 400;
  src: url("fonts/SpaceMono-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Space Mono";
  font-style: normal;
  font-weight: 700;
  src: url("fonts/SpaceMono-700.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* ==========================================================================
   WALL DISPLAY — STYLE   (green · geometric · line-work · light & dark)
   Everything is sized in rem. The root font size is tied to the screen so
   the layout scales like a poster: 16px at 1024x768 (4:3 iPad landscape).
   Safari 12 safe: no aspect-ratio, no flex-gap, no min()/clamp(), no
   double-position gradient stops.
   Fonts: Space Grotesk + Space Mono (SIL Open Font License), in /fonts.
   ========================================================================== */

:root {
  /* ---- light theme (default) ---- */
  --bg-a: #f2fcf6;
  --bg-b: #c4ecd3;
  --bg-c: #86d3a6;
  --ink: #05301c;
  --muted: #3c6a53;
  --line: #0b4a2d;
  --line-soft: rgba(11, 74, 45, 0.24);
  --grid: rgba(11, 74, 45, 0.08);
  --card: rgba(255, 255, 255, 0.58);
  --card-solid: #f5fff9;
  --cell: rgba(255, 255, 255, 0.55);
  --accent: #00a35c;
  --accent-ink: #ffffff;
  --accent-soft: rgba(0, 163, 92, 0.16);
  --glow: rgba(0, 163, 92, 0.45);
  --warn: #b4540a;
  --sun: #e08a00;
  --shadow: rgba(5, 48, 28, 0.14);
  --scrim: rgba(5, 48, 28, 0.55);

  --font: "Space Grotesk", "DIN Alternate", "Avenir Next", -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Space Mono", Menlo, "Courier New", monospace;
}

:root[data-theme="dark"] {
  --bg-a: #03110a;
  --bg-b: #06241a;
  --bg-c: #0c4a2e;
  --ink: #e4fff0;
  --muted: #86c3a0;
  --line: #2fd07c;
  --line-soft: rgba(47, 208, 124, 0.26);
  --grid: rgba(47, 208, 124, 0.07);
  --card: rgba(3, 22, 14, 0.7);
  --card-solid: #04170e;
  --cell: rgba(47, 208, 124, 0.05);
  --accent: #2dff8f;
  --accent-ink: #03110a;
  --accent-soft: rgba(45, 255, 143, 0.16);
  --glow: rgba(45, 255, 143, 0.55);
  --warn: #ffb454;
  --sun: #ffd24a;
  --shadow: rgba(0, 0, 0, 0.45);
  --scrim: rgba(0, 10, 5, 0.72);
}

html {
  font-size: 1.5625vw;                 /* 1024px wide -> 16px */
  -webkit-text-size-adjust: 100%;
  height: 100%;
}
@media (min-aspect-ratio: 4/3) {
  html { font-size: 2.0833vh; }        /* wider than 4:3 -> size by height */
}

* {
  box-sizing: border-box;
  cursor: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
/* iOS will not let you type into a field that has user-select:none */
input, textarea {
  -webkit-user-select: text;
  user-select: text;
  cursor: auto;
}

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  top: 0; left: 0;
  touch-action: manipulation;
}

body {
  font-family: var(--font);
  font-weight: 500;
  color: var(--ink);
  background-color: var(--bg-b);
  /* line grid over a green gradient */
  background-image:
    -webkit-repeating-linear-gradient(0deg, var(--grid), var(--grid) 1px, transparent 1px, transparent 2.6rem),
    -webkit-repeating-linear-gradient(90deg, var(--grid), var(--grid) 1px, transparent 1px, transparent 2.6rem),
    -webkit-linear-gradient(top left, var(--bg-a), var(--bg-b) 55%, var(--bg-c));
  background-image:
    repeating-linear-gradient(0deg, var(--grid), var(--grid) 1px, transparent 1px, transparent 2.6rem),
    repeating-linear-gradient(90deg, var(--grid), var(--grid) 1px, transparent 1px, transparent 2.6rem),
    linear-gradient(150deg, var(--bg-a), var(--bg-b) 55%, var(--bg-c));
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 0;
  touch-action: manipulation;
}

/* ------------------------------------------------------------------ LAYOUT */

.dash {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  padding: 1.2rem;
  display: grid;
  grid-template-columns: 56fr 44fr;
  grid-template-rows: minmax(0, 1fr);
  grid-gap: 1.2rem;
}

.col {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-gap: 1.2rem;
}
.col-left  { grid-template-rows: auto minmax(0, 1fr); }
.col-right { grid-template-rows: minmax(0, 1fr) auto; }

/* Panels: hard square frame with heavier corner brackets */
.panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 1rem 1.3rem 1.1rem;
  background: var(--card);
  border: 2px solid var(--line);
  box-shadow: 0.45rem 0.45rem 0 var(--line-soft);
}
.panel:before, .panel:after,
.tile:before, .tile:after,
.card:before, .card:after {
  content: "";
  position: absolute;
  width: 1.5rem;
  height: 1.5rem;
  border: 0 solid var(--accent);
  pointer-events: none;
  z-index: 3;
}
.panel:before, .tile:before, .card:before { top: 0; left: 0; border-top-width: 0.32rem; border-left-width: 0.32rem; }
.panel:after, .tile:after, .card:after { right: 0; bottom: 0; border-right-width: 0.32rem; border-bottom-width: 0.32rem; }

.ph-head {
  display: flex;
  align-items: baseline;
  flex: none;
  margin-bottom: 0.65rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line-soft);
}
.ph-head h2 {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.ph-head h2:before {
  content: "";
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-right: 0.65rem;
  background: var(--accent);
  vertical-align: 0.02rem;
}
.range {
  margin-left: 1rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.status {
  margin-left: auto;
  padding-left: 0.8rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--accent);
  text-align: right;
  max-width: 55%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status.err { color: var(--warn); }
.status.err:before { content: "! "; }

/* ------------------------------------------------------------- CLOCK + TILE */

.topband {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2.5rem 10rem;
  grid-gap: 1rem;
  align-items: stretch;
}

.clock {
  position: relative;
  padding: 0.1rem 0 0 0.3rem;
  min-width: 0;
}
.time {
  font-size: 6.3rem;
  font-weight: 300;
  line-height: 1;
  letter-spacing: -0.045em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.time .ampm {
  margin-left: 0.5rem;
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--accent);
}
:root:not([data-theme="dark"]) .time .ampm { color: #007a45; }
.date {
  position: relative;
  margin-top: 0.7rem;
  padding-top: 0.75rem;
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.date:before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 5rem;
  height: 0.28rem;
  background: var(--accent);
}

/* Small square tool buttons, stacked at the clock's right edge */
.tools {
  padding-top: 0.2rem;
  width: 2.5rem;
}
.sq {
  position: relative;
  display: block;
  width: 2.5rem;
  height: 2.5rem;
  margin-bottom: 0.45rem;
  background: var(--line);
  -webkit-clip-path: polygon(20% 0, 100% 0, 100% 80%, 80% 100%, 0 100%, 0 20%);
  clip-path: polygon(20% 0, 100% 0, 100% 80%, 80% 100%, 0 100%, 0 20%);
}
.sq:before {
  content: "";
  position: absolute;
  top: 2px; left: 2px; right: 2px; bottom: 2px;
  background: var(--card-solid);
  -webkit-clip-path: polygon(20% 0, 100% 0, 100% 80%, 80% 100%, 0 100%, 0 20%);
  clip-path: polygon(20% 0, 100% 0, 100% 80%, 80% 100%, 0 100%, 0 20%);
}
.sq svg, .sq span {
  position: relative;
  z-index: 1;
}
.sq svg { display: block; width: 1.5rem; height: 1.5rem; margin: 0 auto; }
.sq span { display: block; font-family: var(--mono); font-size: 1.15rem; font-weight: 700; line-height: 2.5rem; color: var(--ink); }
.sq .ln { fill: none; stroke: var(--ink); stroke-width: 1.8; }
.sq .fl { fill: var(--accent); stroke: none; }
.sq:active:before { background: var(--accent-soft); }

.tile {
  position: relative;
  display: block;
  overflow: hidden;
  min-height: 9.5rem;
  border: 2px solid var(--line);
  background: var(--card);
  box-shadow: 0.45rem 0.45rem 0 var(--line-soft);
  -webkit-mask-image: -webkit-radial-gradient(white, black);
}
.tile:active { opacity: 0.85; }

.ph {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  -webkit-transition: opacity 1.2s ease;
  transition: opacity 1.2s ease;
}
.ph.on { opacity: 1; }
.tile .ph { object-fit: cover; }
.tile.fit-contain .ph { object-fit: contain; }

.tile-note {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  line-height: 1.4;
  text-align: center;
  color: var(--muted);
}
.tile-badge {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  width: 2rem;
  height: 2rem;
  background: var(--card-solid);
  border: 2px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.tile-badge svg { width: 1.1rem; height: 1.1rem; fill: var(--ink); }

/* ----------------------------------------------------------------- CALENDAR */

.cal-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr);
  grid-gap: 0.3rem;
}
.cal-dow {
  text-align: center;
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 0.1rem;
}
.cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 0.3rem 0.28rem;
  background: var(--cell);
  border: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
}
.cell.past { opacity: 0.5; }
.cell.today {
  background: var(--accent-soft);
  border: 2px solid var(--accent);
  box-shadow: 0 0 1.2rem var(--glow), inset 0 0 0.9rem var(--accent-soft);
}
.cell-top {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 1.7rem;
}
.dn {
  min-width: 1.7rem;
  height: 1.7rem;
  padding: 0 0.2rem;
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.7rem;
  text-align: center;
  white-space: nowrap;
}
.dn small { font-size: 0.58rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.cell.today .dn { background: var(--accent); color: var(--accent-ink); }
.more {
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--muted);
  padding-right: 0.15rem;
}
.evt {
  flex: none;
  height: 1.3rem;
  margin-top: 0.2rem;
  padding: 0 0.3rem;
  border-left: 0.25rem solid rgba(0, 0, 0, 0.3);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.3rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.evt.ghost { background: none !important; border-left-color: transparent; }

.cal-note {
  grid-column: 1 / span 7;
  align-self: center;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--muted);
}

/* ------------------------------------------------------------------ SPOTIFY */

.spotify { min-height: 0; }

.connect {
  flex: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.connect p {
  margin: 0 0 1.2rem;
  max-width: 20rem;
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--muted);
}
.btn-connect {
  position: relative;
  min-width: 15rem;
  height: 4rem;
  padding: 0 2rem;
  background: var(--accent);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-ink);
  -webkit-clip-path: polygon(1rem 0, 100% 0, 100% calc(100% - 1rem), calc(100% - 1rem) 100%, 0 100%, 0 1rem);
  clip-path: polygon(1rem 0, 100% 0, 100% calc(100% - 1rem), calc(100% - 1rem) 100%, 0 100%, 0 1rem);
}
.btn-connect:active { opacity: 0.8; }
.btn-connect[disabled] { opacity: 0.35; }

.s-off .connect { display: flex; }
.s-off .np,
.s-off .controls,
.s-off .notice,
.s-off .recent { display: none; }

.np {
  flex: none;
  display: flex;
  align-items: center;
  margin-top: 0.1rem;
}
.art {
  position: relative;
  flex: none;
  width: 7.4rem;
  height: 7.4rem;
  overflow: hidden;
  border: 2px solid var(--line);
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-mask-image: -webkit-radial-gradient(white, black);
}
.art img {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.art-note { font-size: 2.6rem; color: var(--muted); }
.np-text {
  flex: 1;
  min-width: 0;
  margin-left: 1.1rem;
}
.title {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  word-wrap: break-word;
}
.artist {
  margin-top: 0.3rem;
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.progress { margin-top: 0.75rem; }
.track {
  position: relative;
  height: 0.3rem;
  background: var(--line-soft);
}
.track i {
  position: relative;
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  -webkit-transition: width 0.5s linear;
  transition: width 0.5s linear;
}
.track i:after {
  content: "";
  position: absolute;
  right: -0.15rem;
  top: -0.3rem;
  width: 0.3rem;
  height: 0.9rem;
  background: var(--accent);
  box-shadow: 0 0 0.6rem var(--glow);
}
.times {
  display: flex;
  justify-content: space-between;
  margin-top: 0.4rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted);
}

.controls {
  flex: none;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  margin-top: 0.7rem;
}
.ctl {
  width: 7rem;
  margin: 0 0.4rem;
  text-align: center;
}
.ctl span {
  display: block;
  margin-top: 0.35rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.round {
  position: relative;
  display: block;
  margin: 0 auto;
  width: 4.2rem;
  height: 4.2rem;
  background: var(--line);
  -webkit-clip-path: polygon(22% 0, 100% 0, 100% 78%, 78% 100%, 0 100%, 0 22%);
  clip-path: polygon(22% 0, 100% 0, 100% 78%, 78% 100%, 0 100%, 0 22%);
}
.round:before {
  content: "";
  position: absolute;
  top: 2px; left: 2px; right: 2px; bottom: 2px;
  background: var(--card-solid);
  -webkit-clip-path: polygon(22% 0, 100% 0, 100% 78%, 78% 100%, 0 100%, 0 22%);
  clip-path: polygon(22% 0, 100% 0, 100% 78%, 78% 100%, 0 100%, 0 22%);
}
.round svg { position: relative; z-index: 1; width: 1.9rem; height: 1.9rem; fill: var(--ink); display: block; margin: 0 auto; }
.round:active:before { background: var(--accent-soft); }
.round.big {
  width: 5.2rem;
  height: 5.2rem;
  margin-top: -0.5rem;
  background: var(--accent);
  box-shadow: 0 0 1.4rem var(--glow);
}
.round.big:before { display: none; }
.round.big svg { width: 2.4rem; height: 2.4rem; fill: var(--accent-ink); }
.round.big:active { opacity: 0.8; }
.round .i-pause { display: none; }
.is-playing .round .i-play { display: none; }
.is-playing .round .i-pause { display: block; }

.notice {
  flex: none;
  min-height: 1.2rem;
  margin-top: 0.2rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 700;
  text-align: center;
  color: var(--warn);
}

.recent {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  margin-top: 0.3rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line-soft);
}
.recent h3 {
  margin: 0 0 0.3rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
.recent ul { margin: 0; padding: 0; list-style: none; }
.recent li {
  display: flex;
  align-items: center;
  height: 2.9rem;
  border-bottom: 1px solid var(--line-soft);
}
.recent li:last-child { border-bottom: 0; }
.recent .thumb {
  flex: none;
  width: 2.4rem;
  height: 2.4rem;
  background: var(--accent-soft);
  object-fit: cover;
}
.recent .rt { flex: 1; min-width: 0; margin-left: 0.8rem; }
.recent .rn {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recent .ra {
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.2;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recent .re { font-family: var(--mono); font-size: 0.85rem; color: var(--muted); }

/* ------------------------------------------------------------------ WEATHER */

.weather { padding-bottom: 0.9rem; }
.days {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.day {
  text-align: center;
  min-width: 0;
  padding: 0 0.2rem;
  border-left: 1px solid var(--line-soft);
}
.day:first-child { border-left: 0; }
.day .dname {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.day.first .dname { color: var(--accent); }
:root:not([data-theme="dark"]) .day.first .dname { color: #007a45; }
.day .icon { height: 3rem; margin: 0.2rem 0; }
.day .icon svg {
  display: block;
  width: 3rem;
  height: 3rem;
  margin: 0 auto;
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linecap: square;
  stroke-linejoin: miter;
}
.day .icon .s { stroke: var(--sun); }
.day .icon .a { stroke: var(--accent); }
.day .icon .c { fill: var(--card-solid); }
.day .hi { font-size: 1.6rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; }
.day .lo { font-family: var(--mono); font-size: 1rem; color: var(--muted); line-height: 1.25; }
.day .desc {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ----------------------------------------------------------------- OVERLAYS */

.show {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 50;
  background: #000;
  visibility: hidden;
  opacity: 0;
  -webkit-transform: scale(0.12);
  transform: scale(0.12);
  -webkit-transition: -webkit-transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.35s ease, visibility 0s linear 0.5s;
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.35s ease, visibility 0s linear 0.5s;
}
.show.open {
  visibility: visible;
  opacity: 1;
  -webkit-transform: scale(1);
  transform: scale(1);
  -webkit-transition-delay: 0s;
  transition-delay: 0s;
}
.show .ph { object-fit: contain; }
.show.fit-cover .ph { object-fit: cover; }
.show-hint {
  position: absolute;
  left: 50%;
  bottom: 1.2rem;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  padding: 0.5rem 1.2rem;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0;
}
.show.open .show-hint {
  -webkit-animation: hint 4s ease forwards;
  animation: hint 4s ease forwards;
}
@-webkit-keyframes hint { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes hint { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

.overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--scrim);
  visibility: hidden;
  opacity: 0;
  -webkit-transition: opacity 0.25s ease, visibility 0s linear 0.25s;
  transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}
.overlay.open {
  visibility: visible;
  opacity: 1;
  -webkit-transition-delay: 0s;
  transition-delay: 0s;
}
.card {
  position: relative;
  width: 56rem;
  max-width: 94%;
  max-height: 94%;
  overflow: hidden;
  padding: 1.5rem 2rem 1.2rem;
  border: 2px solid var(--line);
  background: var(--card-solid);
  box-shadow: 0.6rem 0.6rem 0 var(--line-soft);
}
.card h2 {
  margin: 0 0 1rem;
  font-size: 1.7rem;
  font-weight: 300;
  letter-spacing: -0.01em;
}
.card-close {
  margin-top: 1rem;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}
:root:not([data-theme="dark"]) .card-close { color: #007a45; }

.help-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-column-gap: 1.6rem;
  grid-row-gap: 0.65rem;
}
.help-list li { display: flex; align-items: flex-start; }
.help-list p { margin: 0 0 0 0.8rem; font-size: 0.86rem; line-height: 1.3; color: var(--muted); font-weight: 500; }
.help-list b { display: block; font-size: 1rem; color: var(--ink); }
.h-ico {
  flex: none;
  width: 2.4rem;
  height: 2.4rem;
  border: 2px solid var(--line);
  background: var(--card-solid);
  display: flex;
  align-items: center;
  justify-content: center;
}
.h-ico svg { width: 1.3rem; height: 1.3rem; fill: var(--ink); }
.h-ico svg .ln { fill: none; stroke: var(--ink); stroke-width: 1.8; }
.h-ico svg .fl { fill: var(--accent); }
.h-ico.t { font-family: var(--mono); font-size: 0.95rem; font-weight: 700; color: var(--ink); }
.h-ico.warn { color: var(--card-solid); background: var(--warn); border-color: var(--warn); }

/* ----------------------------------------------------------------- SETTINGS */

.set-card {
  width: 54rem;
  display: flex;
  flex-direction: column;
  padding: 1.2rem 1.6rem 1rem;
}
.set-card h2 { margin: 0; }
.set-head {
  flex: none;
  display: flex;
  align-items: baseline;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--line-soft);
}
.set-head span {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted);
}
.set-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin-right: -0.6rem;
  padding-right: 0.6rem;
}
.set-sec { padding: 0.9rem 0 0.4rem; border-bottom: 1px solid var(--line-soft); }
.set-sec:last-child { border-bottom: 0; }
.set-sec h3 {
  margin: 0 0 0.4rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
}
:root:not([data-theme="dark"]) .set-sec h3 { color: #007a45; }
.hint {
  margin: 0 0 0.6rem;
  font-size: 0.85rem;
  line-height: 1.35;
  color: var(--muted);
}
.hint.inline { margin: 0 0 0 1rem; }
.set-card label {
  display: block;
  margin: 0.55rem 0 0.25rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.set-card .row label { margin: 0 0.8rem 0 0; }
.set-card .row label.gap-l { margin-left: 2rem; }
.row { display: flex; align-items: center; margin: 0.3rem 0 0.5rem; }

input[type="text"], input[type="number"], textarea {
  display: block;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0 0.8rem;
  height: 3rem;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--card-solid);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 1.1rem;           /* 16px+ stops iOS zooming into the field */
  -webkit-appearance: none;
  appearance: none;
  outline: none;
}
input.short { width: 7rem; }
textarea { height: auto; padding: 0.6rem 0.8rem; line-height: 1.35; resize: none; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.row input[type="text"] { flex: 1; }

.btn {
  flex: none;
  height: 3rem;
  margin-left: 0.7rem;
  padding: 0 1.4rem;
  border: 2px solid var(--line);
  background: var(--card-solid);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.row .btn:first-child { margin-left: 0; }
.btn:active { background: var(--accent-soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:active { opacity: 0.8; }
.btn.quiet { border-color: var(--line-soft); color: var(--muted); }
.btn[disabled] { opacity: 0.4; }

.seg { display: flex; }
.seg button {
  height: 2.6rem;
  padding: 0 1.1rem;
  border: 2px solid var(--line);
  margin-left: -2px;
  background: var(--card-solid);
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
}
.seg button:first-child { margin-left: 0; }
.seg button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); position: relative; z-index: 1; }

.results { margin-bottom: 0.4rem; }
.results button {
  display: block;
  width: 100%;
  margin-top: -2px;
  padding: 0.7rem 0.9rem;
  border: 2px solid var(--line-soft);
  background: var(--card-solid);
  text-align: left;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}
.results button small { font-family: var(--mono); font-size: 0.74rem; font-weight: 400; color: var(--muted); margin-left: 0.5rem; }
.results button:active { background: var(--accent-soft); }
.results .none { font-family: var(--mono); font-size: 0.82rem; color: var(--warn); }
.current { font-family: var(--mono); font-size: 0.82rem; color: var(--muted); margin-bottom: 0.4rem; }
.current b { color: var(--ink); }
.mono-box {
  padding: 0.7rem 0.8rem;
  border: 2px dashed var(--line);
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--ink);
  word-wrap: break-word;
  -webkit-user-select: text;
  user-select: text;
}
.thumbs { display: flex; flex-wrap: wrap; margin: 0 -0.2rem 0.5rem; }
.thumbs button {
  position: relative;
  width: 4.4rem;
  height: 4.4rem;
  margin: 0.2rem;
  border: 2px solid var(--line);
  background-size: cover;
  background-position: center;
}
.thumbs button:after {
  content: "\00d7";
  position: absolute;
  right: 0; top: 0;
  width: 1.3rem;
  height: 1.3rem;
  background: var(--warn);
  color: #fff;
  font-size: 1rem;
  line-height: 1.2rem;
  text-align: center;
}
.set-foot {
  flex: none;
  display: flex;
  align-items: center;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line-soft);
}
.set-foot .grow { flex: 1; }
.set-foot .btn { margin-left: 0.7rem; }
.set-foot .btn:first-child { margin-left: 0; }

.rotate {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--bg-b);
  color: var(--ink);
  font-size: 2rem;
  font-weight: 300;
  line-height: 1.4;
}
@media (orientation: portrait) {
  .rotate { display: flex; }
}
