/* Pepper: the pen-dial world. Molded pen plastic, a magnified dose window, printed U-100 scales, one orange knob. */

:root {
  --body: #e9ecef;          /* pen plastic */
  --body-2: #dfe3e7;
  --rule: #c3cad1;
  --window: #ffffff;
  --ink: #1b1f24;
  --ink-2: #4f5861;         /* printed barrel text */
  --knob: #f26a1b;          /* dial knob: primary action, current page */
  --knob-ink: #1b1f24;
  --knob-deep: #c94f0b;
  --alarm: #b3122e;
  --good: #19704a;
  --liquid: #b9c6d1;
  --well: inset 0 2px 5px rgb(15 20 26 / .18), inset 0 0 0 1px rgb(15 20 26 / .08);
  --lift: 0 1px 1px rgb(15 20 26 / .06), 0 6px 18px -8px rgb(15 20 26 / .22);
  --r: 10px;
  --cond: "Barlow Condensed", "Arial Narrow", sans-serif;
  --sans: "Barlow", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --body: #17191c; --body-2: #1f2226; --rule: #343a41; --window: #0d0f11;
    --ink: #eef1f4; --ink-2: #a3adb7; --knob: #ff7a2e; --knob-deep: #ff9a5c;
    --alarm: #ff6b81; --good: #5fd39a; --liquid: #3c4a57;
    --well: inset 0 2px 6px rgb(0 0 0 / .6), inset 0 0 0 1px rgb(255 255 255 / .06);
    --lift: 0 1px 1px rgb(0 0 0 / .3), 0 8px 22px -10px rgb(0 0 0 / .7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--body); color: var(--ink);
  font: 400 1.0625rem/1.5 var(--sans); font-variant-numeric: tabular-nums;
}
::selection { background: var(--knob); color: var(--knob-ink); }
:focus-visible { outline: 3px solid var(--knob); outline-offset: 2px; border-radius: 4px; }
a { color: inherit; text-decoration-color: var(--knob); text-decoration-thickness: 2px; text-underline-offset: .2em; }
a:hover { color: var(--knob-deep); }
h1, h2, h3 { font-family: var(--cond); font-weight: 600; letter-spacing: .01em; line-height: 1.1; text-wrap: balance; margin: 2.2em 0 .6em; }
h1 { font-size: clamp(2rem, 5vw, 2.75rem); margin-top: .4em; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.3rem; }
main > h1:first-child, main > h2:first-child { margin-top: .4em; }
p { max-width: 68ch; }
small, .muted { color: var(--ink-2); }
.warn { color: var(--alarm); font-weight: 600; }
.ok { color: var(--good); font-weight: 600; }
.label, th, label, summary { font-family: var(--cond); letter-spacing: .03em; font-weight: 600; }
.barrel a, .btn, button { font-family: var(--cond); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }

/* ---------- barrel nav ---------- */
.barrel {
  position: sticky; top: 0; z-index: 5;
  background: var(--body);
  border-bottom: 1px solid var(--rule);
}
.barrel nav { display: flex; align-items: stretch; gap: 1.25rem; max-width: 72rem; margin: 0 auto; padding: 0 1rem; overflow-x: auto; scrollbar-width: none; }
.barrel nav::-webkit-scrollbar { display: none; }
.wordmark[aria-current="page"] { box-shadow: inset 0 -4px var(--knob); }
.wordmark { font: 700 1.5rem/1 var(--cond); letter-spacing: .02em; text-transform: none; text-decoration: none; display: flex; align-items: center; padding: .7rem 0; }
.barrel ul { display: flex; gap: 1.1rem; list-style: none; margin: 0; padding: 0; }
.barrel li { display: flex; }
.barrel ul a { display: flex; align-items: center; font-size: .95rem; text-decoration: none; color: var(--ink-2); white-space: nowrap; border-bottom: 4px solid transparent; padding-top: 4px; }
.barrel ul a:hover { color: var(--ink); }
.barrel ul a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--knob); }
.barrel .who { margin-left: auto; display: flex; align-items: center; gap: .8rem; white-space: nowrap; }
.barrel .who span { color: var(--ink-2); font-size: .95rem; }
.barrel form { margin: 0; }
@media (max-width: 760px) { /* wordmark + who on the first line, labels scroll on the second */
  .barrel nav { flex-wrap: wrap; gap: 0 1rem; overflow: visible; }
  .barrel .who { order: 2; }
  .barrel ul { order: 3; flex-basis: 100%; gap: 0 1rem; overflow-x: auto; scrollbar-width: none;
    mask-image: linear-gradient(90deg, #000 calc(100% - 1.5rem), transparent); padding-right: 1.5rem; }
  .barrel ul::-webkit-scrollbar { display: none; }
  .barrel ul a { min-height: 2.75rem; }
}

main, .page { max-width: 72rem; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
footer { max-width: 70rem; margin: 0 1rem; padding: 1.5rem 0 2.5rem; border-top: 1px solid var(--rule); color: var(--ink-2); font-size: .85rem; }

@media (min-width: 72rem) { footer { margin-inline: auto; } }

/* ---------- the dose window ---------- */
.window {
  position: relative; display: inline-flex; align-items: baseline; justify-content: flex-end; gap: .2em;
  min-width: 4.2em; padding: .15em .5em .1em 1em;
  background: var(--window); border-radius: var(--r); box-shadow: var(--well);
  font: 600 1.6rem/1.1 var(--sans); font-variant-numeric: tabular-nums;
}
.window::before { /* the pen's pointer */
  content: ""; position: absolute; left: .3em; top: 50%; translate: 0 -50%;
  border: .3em solid transparent; border-left: .42em solid var(--knob); border-right: 0;
}
.window small { font: 600 .5em/1 var(--cond); letter-spacing: .04em; color: var(--ink-2); }
.window.big { font-size: clamp(3.5rem, 12vw, 5.5rem); min-width: 3.4em; padding-left: .7em; border-radius: calc(var(--r) * 1.6); }
.window.big::before { left: .18em; border-width: .14em; border-left-width: .2em; }

/* printed U-100 scale */
.scale {
  height: 1.1rem; margin-top: .4rem;
  background:
    linear-gradient(90deg, var(--ink-2) 1px, transparent 1px) 0 0 / 10% 100% repeat-x,
    linear-gradient(90deg, var(--ink-2) 1px, transparent 1px) 0 100% / 2% 45% repeat-x;
  box-shadow: inset -1px 0 var(--ink-2);
  position: relative;
}
.scale i { position: absolute; top: -.25rem; bottom: -.1rem; width: 3px; background: var(--knob); left: min(var(--at, 0%), 100% - 3px); transition: left .35s cubic-bezier(.2, .8, .2, 1); }

/* cartridge: liquid drawn to the exact fraction of the pen's capacity, a tick every 10 units */
.cartridge {
  --ml: 3;
  position: relative; height: 1.5rem; border-radius: 999px; background: var(--window); box-shadow: var(--well); overflow: hidden; min-width: 8rem;
}
.cartridge::before { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--left, 0%); background: var(--liquid); }
.cartridge::after {
  content: ""; position: absolute; inset: 35% 0 0;
  background: repeating-linear-gradient(90deg, transparent 0 calc(100% - 1px), var(--ink-2) calc(100% - 1px) 100%) 0 0 / calc(100% / (var(--ml) * 10)) 100%;
  opacity: .55;
}

/* ---------- rows ---------- */
.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.rows > li { display: grid; gap: .4rem 1.25rem; padding: 1rem 0; border-bottom: 1px solid var(--rule); align-items: center; }
.due { grid-template-columns: minmax(10rem, 1.4fr) minmax(9rem, 1fr) 11rem 6rem 5.5rem; }
.due .window { font-size: 2.75rem; width: 100%; }
.due .scale { height: .8rem; }
.pens { grid-template-columns: minmax(10rem, 1.3fr) minmax(12rem, 2fr) 7rem 7rem; }
.who-what strong { font-size: 1.15rem; display: block; }
.stat { font-variant-numeric: tabular-nums; }
.stat .label { display: block; font-size: .9rem; color: var(--ink-2); }
.done { font: 600 1.05rem/1 var(--cond); letter-spacing: .06em; color: var(--ink-2); }
.done.ok { color: var(--good); }
.empty { padding: 1.4rem 0; color: var(--ink-2); border-bottom: 1px solid var(--rule); }
@media (max-width: 760px) {
  .due { grid-template-columns: 1fr auto; }
  .due .stat, .due .done { grid-column: 1; }
  .due .dial { grid-column: 2; grid-row: 1 / span 2; width: 9rem; }
  .due .window { font-size: 2.1rem; min-width: 0; }
  .due .act { grid-column: 2; }
  .pens { grid-template-columns: 1fr 1fr; }
  .pens .cartridge { grid-column: 1 / -1; grid-row: 2; }
}

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
@media (max-width: 760px) {
  .table-wrap table { min-width: 44rem; }
  .table-wrap td { white-space: nowrap; }
  /* dose records stack: every number whole, issues always visible */
  .table-wrap table.records { min-width: 0; }
  .records thead { display: none; }
  .records tr { display: grid; grid-template-columns: 1fr 1fr; gap: .15rem 1rem; padding: .8rem 0; border-bottom: 1px solid var(--rule); }
  .records td { border: 0; padding: 0; white-space: normal; }
  .records td[data-label]::before { content: attr(data-label); display: block; font: 600 .85rem/1.3 var(--cond); letter-spacing: .03em; color: var(--ink-2); }
  .records td.wide { grid-column: 1 / -1; }
  .records td:empty { display: none; }
  tr:hover td { background: none; }
}
table { width: 100%; border-collapse: collapse; font-size: .97rem; }
th { text-align: left; font-size: .9rem; color: var(--ink-2); padding: .5rem .75rem .45rem 0; border-bottom: 2px solid var(--ink); white-space: nowrap; }
td { padding: .6rem .75rem .6rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.facts th { width: 11rem; }
tbody th { border-bottom: 1px solid var(--rule); padding-top: .7rem; }
tr:hover td { background: color-mix(in srgb, var(--body-2) 60%, transparent); }

/* ---------- forms ---------- */
form > div, .field { margin-bottom: 1.1rem; }
label { display: block; font-size: .98rem; color: var(--ink-2); margin-bottom: .3rem; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; font: 500 1.1rem/1.3 var(--sans); color: var(--ink); font-variant-numeric: tabular-nums;
  background: var(--window); border: 0; border-radius: 8px; box-shadow: var(--well); padding: .7rem .8rem; min-height: 3rem;
}
textarea { min-height: 5.5rem; }
input, select, textarea { caret-color: var(--knob); accent-color: var(--knob); }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--knob); outline-offset: 1px; }
input[type=checkbox] { width: 1.3rem; height: 1.3rem; accent-color: var(--knob); vertical-align: middle; }
.helptext, form [id$="_helptext"] { display: block; font-size: .88rem; color: var(--ink-2); margin-top: .3rem; }
.errorlist { list-style: none; margin: .35rem 0; padding: 0; color: var(--alarm); font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0 1.25rem; }

.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em; min-height: 3rem; padding: .55rem 1.4rem;
  font-size: 1rem; color: var(--knob-ink); background: var(--knob); border: 0; border-radius: 999px; cursor: pointer; text-decoration: none;
  box-shadow: var(--lift); transition: translate .12s, box-shadow .12s, background .12s;
}
.btn:hover, button:hover { color: var(--knob-ink); background: color-mix(in srgb, var(--knob) 88%, white); }
.btn:active, button:active { translate: 0 1px; box-shadow: none; }
.btn.quiet, button.quiet { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--rule); }
.btn.quiet:hover, button.quiet:hover { box-shadow: inset 0 0 0 1.5px var(--ink-2); background: transparent; }
.btn.small, button.small { min-height: 2.4rem; padding: .3rem 1rem; font-size: .9rem; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: .8rem 0 1.4rem; }

/* ---------- misc ---------- */
.flash { background: var(--window); box-shadow: var(--lift); border-radius: var(--r); padding: .9rem 1.1rem; margin-bottom: 1.4rem; font-weight: 500; }
.flash::before { content: ""; display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: var(--good); margin-right: .6rem; }
details { border-bottom: 1px solid var(--rule); padding: .7rem 0; }
summary { cursor: pointer; font-size: 1rem; }
summary::marker { color: var(--knob); }
mark { background: none; color: inherit; }
.strip { display: flex; flex-wrap: wrap; gap: 3px; margin: .6rem 0; }
.strip span { width: .8rem; height: 1.1rem; border-radius: 2px; background: var(--good); }
.strip span.miss { background: transparent; box-shadow: inset 0 0 0 1.5px var(--alarm); }
.chart { max-height: 16rem; margin-bottom: 1rem; }

/* ---------- schedules ---------- */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0 1.25rem; max-width: 48rem; }
.tabs { display: flex; align-items: center; gap: 1.4rem; margin: .4rem 0 1.6rem; border-bottom: 1px solid var(--rule); }
.tabs a:not(.btn) { font: 600 1rem/1 var(--cond); text-transform: uppercase; letter-spacing: .08em; text-decoration: none; color: var(--ink-2); padding: .7rem 0; border-bottom: 4px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--knob); }
.tabs .btn { margin-left: auto; }
.cal-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 1rem; }
.cal-head h2 { margin: .2em 0; }
.cal-head .actions { margin: 0; }
.legend { display: flex; align-items: center; gap: .4rem 1rem; flex-wrap: wrap; font-size: .9rem; color: var(--ink-2); }
.mark { flex: none; display: inline-block; width: .8rem; height: 1.1rem; border-radius: 2px; box-shadow: inset 0 0 0 1.5px var(--ink-2); }
.mark.st-done, .st-done > .mark { background: var(--good); box-shadow: none; }
.mark.st-miss, .st-miss > .mark { box-shadow: inset 0 0 0 1.5px var(--alarm); }
.st-due > .mark { box-shadow: inset 0 0 0 2px var(--knob); }
.cal { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--rule); border-left: 1px solid var(--rule); }
.cal > li { border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: .45rem .5rem .6rem; min-width: 0; }
.cal .dow { font: 600 .9rem/1 var(--cond); color: var(--ink-2); padding: .55rem .5rem; }
.cal .day { min-height: 6.5rem; }
.cal.week .day { min-height: 14rem; }
.cal .other { background: color-mix(in srgb, var(--body-2) 70%, transparent); }
.cal .other .date { color: var(--ink-2); }
.cal .date { font: 600 1.05rem/1 var(--cond); display: block; margin-bottom: .35rem; }
.cal .date .wd { display: none; }
.cal .today { background: var(--window); box-shadow: inset 0 3px 0 var(--knob); }
.cal .today .date { color: var(--knob-deep); }
.cal ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.cal ul li { display: flex; gap: .4rem; align-items: flex-start; font-size: .88rem; line-height: 1.25; }
.cal ul .mark { margin-top: .1rem; width: .55rem; height: .85rem; }
.cal ul small { color: var(--ink-2); }
.cal.month ul li { font-size: .8rem; }
@media (max-width: 760px) { /* the grid becomes a day list; empty days drop out */
  .cal { display: block; border-left: 0; }
  .cal .dow, .cal .empty:not(.today) { display: none; }
  .cal > li { border-right: 0; display: grid; grid-template-columns: 4.5rem 1fr; gap: .8rem; padding: .8rem 0; min-height: 0 !important; }
  .cal .today { padding-inline: .6rem; }
  .cal .date .wd { display: inline; }
  .cal ul li, .cal.month ul li { font-size: 1rem; }
}

/* ---------- log dose ---------- */
.dial-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(18rem, 24rem); gap: 2.5rem; align-items: start; }
.dial-panel { position: sticky; top: 5rem; text-align: center; }
.dial-panel .scale { margin-inline: .3rem; }
.dial-panel .window.big { width: 100%; justify-content: center; }
.dial-panel .readout { font-size: 1.15rem; margin: .8rem 0 0; }
@media (max-width: 860px) {
  .dial-layout { grid-template-columns: 1fr; gap: 1rem; }
  .dial-panel { position: static; order: -1; }
}

/* ---------- landing + sign-in ---------- */
.door { min-height: 100svh; display: grid; place-items: center; padding: 2rem 1rem; }
.door > div { width: min(52rem, 100%); }
/* the pen, printed flat: one matte body value, a window, the orange knob as a plain colour band */
.pen { display: flex; align-items: center; }
.pen-body {
  flex: 1; display: flex; align-items: center; padding: clamp(.7rem, 2.2vw, 1.2rem) clamp(1rem, 3vw, 2rem);
  background: var(--body-2); border-radius: 999px .6rem .6rem 999px; box-shadow: var(--lift);
}
.pen-body .window { font: 700 clamp(2.1rem, 8vw, 4.6rem)/1 var(--cond); letter-spacing: .04em; padding: .1em .45em .05em .75em; min-width: 0; margin: 0; }
.pen-body .window::before { left: .2em; border-width: .14em; border-left-width: .2em; }
.knob { align-self: stretch; height: auto; min-height: 0; margin: clamp(.35rem, 1vw, .6rem) 0; padding: 0 clamp(1.1rem, 4vw, 2.4rem); border-radius: .3rem 999px 999px .3rem; font-size: clamp(.95rem, 2.4vw, 1.25rem); box-shadow: var(--lift); }
.door .tagline { margin: 1.4rem 0 0; color: var(--ink-2); font: 600 clamp(.85rem, 2vw, 1.05rem)/1.3 var(--cond); letter-spacing: .14em; text-transform: uppercase; text-align: center; max-width: none; }
.door .scale { width: min(36rem, 80%); margin: .8rem auto 0; opacity: .7; }

.door > .signin { width: min(26rem, 100%); }
.signin > .window { font: 700 2.4rem/1 var(--cond); padding-left: .8em; margin-bottom: 1.8rem; text-decoration: none; }
.signin h1 { font-size: 1.6rem; margin: 0 0 1rem; }
.signin button { width: 100%; margin-top: .4rem; }
.signin .aside { max-width: none; display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.4rem; padding-top: 1rem; border-top: 1px solid var(--rule); font-size: 1rem; }

@media print {
  .barrel, footer, form, .no-print, .actions { display: none !important; }
  body { background: #fff; }
  details { display: block; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
