/*
 * Evelyn — a steno pad on a secretary's desk, 1961.
 *
 * The page is the pad: eye-ease green paper, blue rules on a 28px line, and the
 * red margin rule that splits *when* (left of it) from *what* (right of it).
 * Evelyn's own words are typed (Courier Prime); the interface speaks in
 * Franklin, the face of American offices and forms of the period. Pink is the
 * "While You Were Out" slip and means one thing only: this needs you.
 */

:root {
  --paper: #edf2e4;
  --paper-deep: #e1e9d5;
  --rule: #a9c1d1;
  --rule-faint: rgb(169 193 209 / 0.55);
  --margin: #c8544f;
  --ink: #1e2a3e;
  --ink-soft: #4d5a6e;
  --ink-faint: #7a8596;
  --slip: #f6c9d3;
  --slip-edge: #e9a3b3;
  --slip-ink: #8a1c3e;
  --ok: #2f6b4f;
  --focus: #2f5fa8;
  --line: 28px;
  --gutter: 64px;
  --radius: 3px;
  --franklin: 'Libre Franklin', 'Franklin Gothic', 'Helvetica Neue', Arial, sans-serif;
  --typed: 'Courier Prime', 'Courier New', monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121a16;
    --paper-deep: #19241e;
    --rule: #2b3a44;
    --rule-faint: rgb(64 86 99 / 0.45);
    --margin: #b0504c;
    --ink: #dfe7da;
    --ink-soft: #aab6a8;
    --ink-faint: #7e8b80;
    --slip: #4a1f2b;
    --slip-edge: #6d2c3e;
    --slip-ink: #f6c9d3;
    --ok: #79b894;
    --focus: #8fb4ee;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/var(--line) var(--franklin);
  font-feature-settings: 'lnum' 1;
}

/* The pad: ruled lines everywhere, one red margin rule. */
.pad {
  min-height: 100vh;
  min-height: 100dvh;
  background-image:
    linear-gradient(to right, transparent calc(var(--gutter) - 2px), var(--margin) calc(var(--gutter) - 2px), var(--margin) var(--gutter), transparent var(--gutter)),
    repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--line) - 1px), var(--rule-faint) calc(var(--line) - 1px), var(--rule-faint) var(--line));
  background-attachment: local;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

main:focus, main:focus-visible { outline: none; }

main {
  padding: var(--line) 16px calc(var(--line) * 2) calc(var(--gutter) + 14px);
  max-width: 820px;
  outline: none;
}

a { color: inherit; }

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

/* ------------------------------------------------------------------ tabs */

.tabs {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 5;
  display: flex;
  justify-content: space-around;
  background: var(--paper-deep);
  border-top: 1px solid var(--rule);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}

.tabs a {
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  line-height: 20px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--ink-soft);
}

.tabs a[aria-current='page'] { color: var(--ink); background: var(--paper); box-shadow: inset 0 -2px 0 var(--margin); }
.tabs .brand { display: none; }

@media (min-width: 900px) {
  .pad { padding-bottom: 0; }
  .tabs {
    inset: 0 auto 0 0;
    width: 180px;
    flex-direction: column;
    justify-content: flex-start;
    gap: 2px;
    border-top: 0;
    border-right: 1px solid var(--rule);
    padding: var(--line) 0 0 0;
  }
  .tabs a { padding: 6px 20px; border-radius: 0; font-size: 15px; line-height: var(--line); }
  .tabs a[aria-current='page'] { box-shadow: inset 3px 0 0 var(--margin); }
  .tabs .brand {
    display: block;
    font-family: var(--typed);
    font-weight: 700;
    font-size: 22px;
    color: var(--ink);
    margin-bottom: var(--line);
  }
  .pad { padding-left: 180px; background-position: 180px 0, 0 0; }
  .pad { --gutter-offset: 180px; }
  main { padding-left: calc(var(--gutter) + 22px); }
}

/* ------------------------------------------------------------------ type */

h1 {
  font-weight: 700;
  font-size: 30px;
  line-height: calc(var(--line) * 1.5);
  letter-spacing: -0.01em;
  margin: 0 0 calc(var(--line) / 2);
}

h2 {
  font-weight: 600;
  font-size: 19px;
  line-height: var(--line);
  margin: calc(var(--line) * 1.5) 0 calc(var(--line) / 2);
}

p { margin: 0 0 var(--line); max-width: 68ch; }

.quiet { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.small { font-size: 14px; }
.typed { font-family: var(--typed); }

/* The margin: times, dates, marks — to the left of the red rule. */
.row {
  position: relative;
  min-height: var(--line);
  padding: 0;
}

.row .when {
  position: absolute;
  right: calc(100% + 22px);
  width: var(--gutter);
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (min-width: 900px) { .row .when { right: calc(100% + 32px); width: 80px; font-size: 14px; } }

.agenda .row { padding-bottom: calc(var(--line) / 2); }
.agenda .title { font-weight: 600; }
.agenda .meta { font-size: 14px; color: var(--ink-soft); }
.agenda .busy .title { font-weight: 400; color: var(--ink-faint); }
.agenda .row.now::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--margin);
}

/* ---------------------------------------------------------------- slips */

.slip {
  background: var(--slip);
  color: var(--slip-ink);
  border: 1px solid var(--slip-edge);
  border-top: 2px dashed var(--slip-edge);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 10px 14px 12px;
  margin: 0 0 var(--line);
  max-width: 560px;
  line-height: 22px;
}

.slip strong { font-weight: 700; }
.slip .typed { font-size: 15px; }
.slip .actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

/* -------------------------------------------------------------- controls */

button, .button {
  font: 500 15px/20px var(--franklin);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink-soft);
  border-radius: var(--radius);
  padding: 7px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

button.primary, .button.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
button.quietly { border-color: transparent; background: transparent; color: var(--ink-soft); padding: 4px 6px; }
button.danger { color: var(--margin); border-color: var(--margin); }
button:disabled { opacity: 0.5; cursor: default; }
.slip button, .slip .button { background: transparent; color: var(--slip-ink); border-color: var(--slip-ink); }
.slip button.primary { background: var(--slip-ink); color: var(--slip); }

input, select, textarea {
  font: 400 16px/22px var(--franklin);
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--ink-soft);
  border-radius: 0;
  padding: 3px 2px;
  width: 100%;
}

input:focus, select:focus, textarea:focus { outline: none; border-bottom: 2px solid var(--focus); }
select { background: var(--paper); }
textarea { resize: vertical; border: 1px solid var(--rule); border-radius: var(--radius); padding: 8px; }

label.field { display: block; margin: 0 0 14px; max-width: 460px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); line-height: 18px; }
label.field .hint { display: block; font-size: 13px; color: var(--ink-faint); line-height: 18px; margin-top: 3px; }
.error { color: var(--margin); font-size: 14px; line-height: 20px; }
.inline { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.inline > * { flex: 1 1 160px; }
.inline > button { flex: 0 0 auto; }

/* ------------------------------------------------------------------ lists */

.group { margin-bottom: calc(var(--line) * 1.5); }
.group-head { display: flex; align-items: baseline; gap: 12px; }
.group-head h2 { margin-bottom: 0; }
.group-head .count { font-size: 14px; color: var(--ink-faint); }

.item { display: flex; align-items: flex-start; gap: 10px; }
.item .tick {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-top: 4px;
  border: 1.5px solid var(--ink-soft);
  border-radius: 2px;
  background: transparent;
  padding: 0;
}
.item .tick[aria-pressed='true'] { background: var(--ink); border-color: var(--ink); }
.item .body { flex: 1; min-width: 0; }
.item .text { cursor: pointer; }
.item .text:hover { text-decoration: underline; text-decoration-color: var(--rule); }
.item.done .text { color: var(--ink-faint); text-decoration: line-through; }
.item .remind { font-size: 13px; line-height: 20px; color: var(--ink-soft); }
.item .body .small { line-height: 20px; }
.item .remind.soon { color: var(--slip-ink); font-weight: 600; }
.item .overdue { color: var(--margin); font-weight: 600; }
.add-line input { border-bottom-style: dashed; }

/* ------------------------------------------------------------------- talk */

.thread { margin-bottom: calc(var(--line) * 2); }
.said { margin: 0 0 var(--line); max-width: 68ch; white-space: pre-wrap; }
.said.you { color: var(--ink); font-weight: 500; }
.said.evelyn { font-family: var(--typed); font-size: 16.5px; }
.said .who { position: absolute; right: calc(100% + 22px); width: var(--gutter); text-align: right; font: 600 13px/var(--line) var(--franklin); color: var(--ink-faint); }
.said.tools { font-size: 13px; color: var(--ink-faint); font-style: italic; margin-top: calc(var(--line) / -2); }
.working { font-family: var(--typed); color: var(--ink-soft); }
.working::after { content: '▍'; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.composer {
  position: sticky;
  bottom: calc(66px + env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: 1px solid var(--rule);
  padding: 10px 0;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
@media (min-width: 900px) { .composer { bottom: 0; } }
.composer textarea { min-height: 44px; max-height: 40vh; font-size: 16px; }
.attached { font-size: 13px; color: var(--ink-soft); }

/* ------------------------------------------------------------------- desk */

.service { margin: 0 0 calc(var(--line) / 2); padding-bottom: calc(var(--line) / 2); }
.service-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.service-head strong { font-weight: 600; font-size: 17px; }
.state { font-size: 14px; }
.state.on { color: var(--ok); }
.state.off { color: var(--ink-faint); }
.state.bad { color: var(--margin); font-weight: 600; }
.service details { margin-top: 6px; }
.service summary { cursor: pointer; color: var(--ink-soft); font-size: 14px; }
.service form { margin-top: 10px; }
.copy { font-family: var(--typed); font-size: 14px; background: var(--paper-deep); padding: 2px 6px; border-radius: 2px; word-break: break-all; user-select: all; }
.check { font-size: 14px; line-height: 20px; margin: 4px 0; }

/* --------------------------------------------------------------- settings */

.setting { margin-bottom: var(--line); max-width: 520px; }
.setting .source { font-size: 13px; color: var(--ink-faint); }

/* ---------------------------------------------------------------- dialogs */

dialog {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: 20px;
  width: min(520px, calc(100vw - 24px));
  max-height: 88vh;
}
dialog::backdrop { background: rgb(18 26 22 / 0.45); }
dialog h2 { margin-top: 0; }
dialog .buttons { display: flex; gap: 8px; justify-content: space-between; flex-wrap: wrap; margin-top: 18px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 20px;
  max-width: calc(100vw - 32px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 10;
}
#toast.show { opacity: 1; }

.login { max-width: 360px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
