/* Oblaček: colours are the Inky panel's own inks, on e-ink paper grey. */
:root {
  /* Oblaček: a lovers' palette taken from the e-ink panel's own inks.
     Rose = the panel's red ink, plum-black = its black, on blush e-ink paper. */
  --paper: #EEE8E6;
  --surface: #F9F6F5;
  --ink: #2E252C;
  --muted: #6A5B63;
  --line: #DED3D2;
  --accent: #9C484B;          /* panel red: rose ink */
  --on-accent: #FFF8F6;
  --ink-green: #3A5B46;       /* in the cloud */
  --ink-yellow: #D0BE47;      /* on its way */
  --ink-red: #9C484B;         /* problems, delete */
  --dot-off: #B3A6AC;
  --bezel: #FBF8F7;           /* the printed stand: matte white */
  --bezel-edge: rgba(46, 37, 44, .09);
  --panel: #FFFFFF;
  --shadow: rgba(60, 30, 40, .36);
  --backdrop: rgba(31, 23, 28, .45);
  --focus: #9C484B;
  --heart: #F9F6F5;

  --font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
  --mono: "DM Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --radius: .9rem;
  --gutter: 16px;
  --stand-ratio: 5 / 8;
  --stand-hw: 1.56;           /* drawn stand's height ÷ width, bezel included (set by app.js) */
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1F171C; --surface: #2A2026; --ink: #F1E8E6; --muted: #B5A3AB; --line: #3E3038;
    --accent: #E39A9D; --on-accent: #1F171C; --ink-green: #8DBB98; --ink-red: #EBA2A5;
    --dot-off: #6F5F68; --bezel: #F1EDEC; --shadow: rgba(0, 0, 0, .7); --backdrop: rgba(0, 0, 0, .6);
    --focus: #E39A9D; --heart: #1F171C; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #1F171C; --surface: #2A2026; --ink: #F1E8E6; --muted: #B5A3AB; --line: #3E3038;
  --accent: #E39A9D; --on-accent: #1F171C; --ink-green: #8DBB98; --ink-red: #EBA2A5;
  --dot-off: #6F5F68; --bezel: #F1EDEC; --shadow: rgba(0, 0, 0, .7); --backdrop: rgba(0, 0, 0, .6);
  --focus: #E39A9D; --heart: #1F171C; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* --- brand ------------------------------------------------------------- */
.mark { width: 1.6em; height: 1em; fill: var(--accent); flex: none; }
.mark--big { --heart: #FFFFFF; }
.wordmark {
  margin: 0;
  font-family: var(--display);
  font-style: italic;
  font-weight: 600;
  font-size: 1.65rem;
  font-variation-settings: "SOFT" 100, "WONK" 1;
  letter-spacing: -0.01em;
  line-height: 1;
}
.label {
  margin: 0;
  font: 500 .72rem/1.2 var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* --- buttons + fields -------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 3rem; padding: 0 1.25rem;
  border: 1px solid transparent; border-radius: var(--radius);
  background: none; cursor: pointer;
  font-weight: 600; font-size: 1rem; letter-spacing: -0.005em;
  text-decoration: none; white-space: nowrap; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; cursor: default; transform: none; }
.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--ghost { border-color: var(--line); background: var(--surface); }
.btn--danger { border-color: var(--line); background: var(--surface); color: var(--ink-red); }
.btn--text { padding: 0 .5rem; color: var(--ink); }
.btn--small { min-height: 2.5rem; padding: 0 1.1rem; }
.btn__icon { width: 1.25rem; height: 1.25rem; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; fill: none; }
.btn--send:focus-within { outline: 2px solid var(--focus); outline-offset: 3px; }

.stack { display: grid; gap: .9rem; }
.field { display: grid; gap: .35rem; font-weight: 500; font-size: .92rem; }
.field input, .field select {
  min-height: 3rem; width: 100%;
  padding: 0 .9rem;
  border: 1px solid var(--line); border-radius: .7rem;
  background: var(--surface);
  font-size: 1rem; font-weight: 400;
}
.field small { color: var(--muted); font-weight: 400; font-size: .82rem; }
.field--inline { grid-template-columns: 1fr auto; align-items: center; }
.field--inline select { width: auto; min-width: 10rem; }
.form-error { margin: 0; color: var(--ink-red); font-size: .92rem; }

/* --- sign in ----------------------------------------------------------- */
.login {
  max-width: 24rem; margin: 0 auto;
  padding: calc(14vh + env(safe-area-inset-top)) var(--gutter) 2rem;
}
.login__mark { display: flex; align-items: center; gap: .6rem; }
.login__mark .mark { font-size: 2.2rem; }
.login__mark .wordmark { font-size: 2.6rem; }
.login__lead { margin: 1rem 0 2rem; color: var(--muted); font-size: 1.05rem; }
.login .btn--primary { margin-top: .4rem; }

/* --- home -------------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 30rem; margin: 0 auto;
  padding: calc(.9rem + env(safe-area-inset-top)) var(--gutter) .5rem;
}
.brand { display: flex; align-items: center; gap: .45rem; }
.avatar {
  width: 2.5rem; height: 2.5rem; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; cursor: pointer;
}
.home {
  max-width: 30rem; margin: 0 auto;
  padding: .5rem var(--gutter) calc(7rem + env(safe-area-inset-bottom));
}

/* The stand: a drawing of the real thing, showing what the e-ink shows. */
.stand { position: relative; width: min(64%, 15.5rem); margin: 1rem auto 2.4rem; }
.stand::after {                         /* its shadow on the shelf */
  content: ""; position: absolute; left: 6%; right: 6%; bottom: -1.1rem; height: 1.2rem;
  background: radial-gradient(closest-side, var(--shadow), transparent);
  opacity: .55; z-index: -1;
}
.stand__bezel {
  padding: 9% 7.5% 11%;
  background: var(--bezel);
  border-radius: 7px;
  box-shadow: inset 0 0 0 1px var(--bezel-edge), 0 1px 0 rgba(255, 255, 255, .6) inset,
              0 22px 26px -22px var(--shadow);
}
.stand__window {
  position: relative; overflow: hidden;
  aspect-ratio: var(--stand-ratio);
  background: var(--panel);
  box-shadow: inset 0 1px 3px rgba(43, 37, 44, .22);
}
.stand__window canvas { display: block; width: 100%; height: 100%; }
.stand__empty {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: .6rem;
  color: #393039; font: 500 .78rem var(--mono);
}
.mark--big { font-size: 3.2rem; fill: #9C484B; }

@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
}

.hero__text { text-align: center; display: grid; gap: .3rem; }
.hero__title { margin: 0; font-weight: 600; font-size: 1.12rem; letter-spacing: -0.015em; }
.status {
  margin: 0; text-align: center; text-wrap: balance;
  font: 400 .8rem/1.4 var(--mono); color: var(--muted);
}
.dot {
  display: inline-block; vertical-align: .05em; margin-right: .45rem;
  width: .5rem; height: .5rem; border-radius: 50%; background: var(--dot-off);
}
.thumb__badge .dot { margin-right: 0; }
.dot--on { background: var(--ink-green); }
.dot--waiting { background: var(--ink-yellow); }
.dot--bad { background: var(--ink-red); }

.history { margin-top: 2.6rem; }
.history__none { color: var(--muted); font-size: .92rem; }
.grid {
  list-style: none; margin: .8rem 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem .6rem;
}
.thumb {
  display: grid; gap: .35rem; width: 100%; padding: 0; border: 0; background: none;
  text-align: left; cursor: pointer;
}
.thumb__img {
  position: relative; display: block; aspect-ratio: var(--stand-ratio);
  border-radius: 5px; overflow: hidden; background: var(--line);
}
.thumb__img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb__badge {
  position: absolute; left: .35rem; bottom: .35rem;
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .15rem .45rem .15rem .35rem; border-radius: 99px;
  background: rgba(246, 246, 243, .92); color: #2B252C;
  font: 500 .64rem/1.3 var(--mono);
}
.thumb__meta {
  font: 400 .72rem/1.25 var(--mono); color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.thumb__meta b { font-weight: 500; color: var(--ink); }

.sendbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 1.6rem var(--gutter) calc(.9rem + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--paper) 40%);
}
.btn--send { display: flex; width: 100%; max-width: calc(30rem - 2 * var(--gutter)); margin: 0 auto; min-height: 3.4rem; font-size: 1.05rem; }

/* --- composer ------------------------------------------------------------ */
.composer {
  width: 100%; height: 100%; max-width: 100%; max-height: 100%;
  margin: 0; padding: 0; border: 0; overflow-y: auto;      /* very short screens scroll instead of overlapping */
  background: var(--paper); color: var(--ink);
}
.composer[open] { display: flex; flex-direction: column; }
.composer__bar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: calc(.6rem + env(safe-area-inset-top)) .6rem .4rem;
}
.composer__bar > :first-child { justify-self: start; }
.composer__bar > :last-child { justify-self: end; }
.composer__title { margin: 0; font-size: 1rem; font-weight: 600; }
/* The stage takes whatever height is left after the bar and the controls; the
   stand is sized from that space (container units), so it never spills over them. */
.composer__stage {
  flex: 1; min-height: 13rem; display: grid; place-items: center;
  padding: .5rem var(--gutter); container-type: size;
}
.stand--large {
  width: min(70vw, 22rem, calc((100dvh - 26rem) / var(--stand-hw)));            /* fallback */
  width: min(100cqw, 22rem, calc((100cqh - 1.4rem) / var(--stand-hw)));
  margin: 0 auto 1.2rem;
}
.stand--mini { width: 100%; margin: 0 0 .7rem; }
.stand--mini .stand__bezel { padding: 8% 7% 10%; border-radius: 5px; }
.stand--large .stand__window { touch-action: none; cursor: grab; }
.stand--large .stand__window:active { cursor: grabbing; }
.composer__controls {
  display: grid; gap: .9rem; justify-items: center;
  padding: .4rem var(--gutter) calc(1rem + env(safe-area-inset-bottom));
}
.segmented {
  display: inline-grid; grid-auto-flow: column; padding: .25rem; gap: .25rem;
  border-radius: 99px; background: var(--surface); border: 1px solid var(--line);
}
.segmented button {
  border: 0; background: none; padding: .55rem 1.1rem; border-radius: 99px; cursor: pointer;
  font-weight: 500; font-size: .92rem; color: var(--muted);
}
.segmented button[aria-checked="true"] { background: var(--accent); color: var(--on-accent); }
.hint { margin: 0; color: var(--muted); font-size: .82rem; text-align: center; max-width: 22rem; }

.tabs { display: flex; justify-content: center; gap: 1.6rem; }
.tabs button {
  border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer;
  padding: .3rem .1rem; font-weight: 600; font-size: .92rem; color: var(--muted);
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tool {
  display: grid; align-content: start; justify-items: center; gap: .5rem;
  width: min(100%, 22rem); min-height: 9.4rem;
}
.tool__actions { display: flex; justify-content: center; gap: .4rem; }
.btn__icon--fill { fill: currentColor; stroke: none; }

.slider {
  display: grid; grid-template-columns: 5.6rem 1fr 2.8rem; align-items: center; gap: .6rem;
  width: 100%; font-size: .85rem; color: var(--muted);
}
.slider input { width: 100%; margin: 0; accent-color: var(--accent); }
.slider output { font: 400 .74rem var(--mono); text-align: right; color: var(--muted); }
.slider--stack {
  grid-template-columns: 1fr auto; grid-template-areas: "name value" "range range"; row-gap: .1rem;
}
.slider--stack span { grid-area: name; }
.slider--stack output { grid-area: value; }
.slider--stack input { grid-area: range; }

/* --- sheets -------------------------------------------------------------- */
.sheet {
  width: 100%; max-width: 30rem; max-height: 92dvh;
  margin: auto auto 0; padding: .6rem var(--gutter) calc(1.2rem + env(safe-area-inset-bottom));
  border: 0; border-radius: 1.2rem 1.2rem 0 0; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); color: var(--ink);
}
.sheet::backdrop, .composer::backdrop { background: var(--backdrop); }
.sheet[open] { display: grid; gap: 1.1rem; animation: sheet-up .22s ease-out; }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet[open] { animation: none; } }
.sheet__grip { width: 2.4rem; height: .3rem; border-radius: 99px; background: var(--line); justify-self: center; }
.sheet__title { margin: 0; font-size: 1.2rem; font-weight: 600; }
.sheet__photo {
  justify-self: center; max-width: 100%; max-height: 52dvh;
  aspect-ratio: var(--stand-ratio); object-fit: cover; border-radius: 6px; background: var(--line);
}
.sheet .hero__title, .sheet .status { justify-self: center; text-align: center; }
.sheet__actions { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.sheet__actions:has(> :only-child) { grid-template-columns: 1fr; }
.sheet__confirm { display: grid; gap: .8rem; }
.sheet__confirm p { margin: 0; text-align: center; }
.look { display: grid; gap: .8rem; padding-bottom: 1.1rem; border-bottom: 1px solid var(--line); }
.look__body { display: grid; grid-template-columns: 36% 1fr; gap: 1.1rem; align-items: center; }
.look__body:has(> .stand[hidden]) { grid-template-columns: 1fr; }
.look__sliders { display: grid; gap: .75rem; }
.look__help { margin: 0; color: var(--muted); font-size: .82rem; }
.standinfo { display: grid; gap: .4rem; }
.standinfo__text { margin: 0; font: 400 .78rem/1.5 var(--mono); color: var(--muted); white-space: pre-line; }

/* --- toast --------------------------------------------------------------- */
.toast {
  position: fixed; z-index: 20; inset: auto auto calc(5.6rem + env(safe-area-inset-bottom)) 50%;
  transform: translateX(-50%); margin: 0; border: 0;
  width: max-content; max-width: calc(100% - 2 * var(--gutter));
  padding: .7rem 1rem; border-radius: .8rem;
  background: var(--ink); color: var(--paper);
  font-size: .92rem; box-shadow: 0 10px 30px -12px var(--shadow);
}
.toast--bad { background: var(--ink-red); color: #fff; }
