/* Fastpad — white paper cards on a quiet Scandinavian desk. */
:root {
  --desk: #efede8;          /* page */
  --card: #ffffff;          /* paper */
  --ink: #1d1d1f;
  --ink-2: #6e6e73;
  --ink-3: #a1a1a6;
  --hair: rgba(60, 60, 67, .12);
  --ghost: #e4e2dc;
  --accent: #1d1d1f;
  --accent-ink: #ffffff;
  --activity: #4f7a5f;
  --measure: #4d6e8f;
  --day: #9c9384;
  --danger: #c0392b;
  --chip: #f1f0ec;
  --shadow: 0 1px 2px rgba(30, 25, 15, .06), 0 6px 24px rgba(30, 25, 15, .07);
  --shadow-lift: 0 2px 4px rgba(30, 25, 15, .06), 0 14px 40px rgba(30, 25, 15, .12);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, "Segoe UI", Roboto, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", system-ui, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --radius: 16px;
  --col: min(100vw - 32px, 560px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --desk: #0b0b0c;
    --card: #1c1c1e;
    --ink: #f5f5f7;
    --ink-2: #98989d;
    --ink-3: #636366;
    --hair: rgba(255, 255, 255, .1);
    --ghost: #232325;
    --accent: #f5f5f7;
    --accent-ink: #0d0d0e;
    --activity: #7fb08f;
    --measure: #86a8cc;
    --day: #8a8378;
    --danger: #ff6b5e;
    --chip: #2a2a2c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 24px rgba(0, 0, 0, .35);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, .5), 0 14px 40px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font: 17px/1.47 var(--font);
  letter-spacing: -0.022em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- type */
.large-title { font: 700 34px/1.2 var(--font-display); letter-spacing: -0.03em; margin: 0 0 8px; }
.title { font: 600 22px/1.27 var(--font-display); letter-spacing: -0.026em; margin: 0 0 6px; }
.lede { color: var(--ink-2); margin: 0 0 22px; }
.hint, .footnote { color: var(--ink-2); font-size: 13px; line-height: 1.38; letter-spacing: -0.008em; }
.error { color: var(--danger); font-size: 15px; }

/* ---------- controls */
.btn {
  appearance: none; border: 0; border-radius: 12px;
  background: var(--chip); color: var(--ink);
  padding: 12px 18px; font-weight: 590; font-size: 17px;
  transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .25; cursor: default; transform: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.small { padding: 8px 16px; font-size: 15px; border-radius: 999px; }
.btn.link { background: none; padding: 8px 4px; color: var(--ink-2); font-weight: 500; font-size: 15px; }
.btn.danger, .btn.link.danger { color: var(--danger); }
.icon-btn {
  border: 0; background: none; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; color: var(--ink-2); font-size: 20px;
}
.icon-btn:hover { background: var(--ghost); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); }
.field.inline { flex-direction: row; align-items: center; justify-content: space-between; font-size: 17px; color: var(--ink); }
input[type=text], input[type=password], select, dialog textarea {
  border: 1px solid var(--hair); background: var(--card); color: var(--ink);
  border-radius: 10px; padding: 11px 13px; font-size: 17px; outline: none; width: 100%;
}
select { width: auto; }
input:focus, select:focus, dialog textarea:focus { border-color: var(--ink-3); }
.check { display: flex; gap: 10px; align-items: center; margin: 18px 0; color: var(--ink-2); font-size: 15px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.spacer { flex: 1; }

/* ---------- onboarding */
.screen { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.panel { width: 100%; max-width: 420px; }
.code {
  font: 500 19px/1.6 var(--mono); letter-spacing: .04em;
  background: var(--card); border: 1px solid var(--hair); border-radius: var(--radius);
  padding: 16px; text-align: center; user-select: all; word-spacing: .3em;
}

/* ---------- shell */
#app { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  width: var(--col); margin: 0 auto; padding: 12px 0 8px;
  background: var(--desk);
}
.topbar::after { /* soft fade so cards slide under the bar */
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 14px;
  background: linear-gradient(var(--desk), transparent); pointer-events: none;
}
.today { font: 600 15px/1 var(--font-display); color: var(--ink-2); letter-spacing: -0.01em; }
.topbar-actions { display: flex; align-items: center; gap: 2px; margin-right: -8px; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: transparent; margin-right: 8px; }
.sync-dot.pending { background: #d49a3a; }
.sync-dot.offline { background: var(--ink-3); }
.column { width: var(--col); margin: 0 auto; padding: 4px 0 calc(48px + env(safe-area-inset-bottom)); }

/* ---------- the card */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* composer: credit-card proportions (85.6 × 54 mm), grows with the text */
.composer {
  display: flex; flex-direction: column;
  min-height: calc(var(--col) / 1.586);
  padding: 18px 22px 16px;
  box-shadow: var(--shadow-lift);
  transition: box-shadow .2s;
}
.card-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; color: var(--ink-3); letter-spacing: -0.005em; }
.card-meta time { font-variant-numeric: tabular-nums; }
.enc-note { display: inline-flex; gap: 5px; align-items: center; }
#note {
  flex: 0 0 auto; width: 100%; resize: none; border: 0; outline: none; background: transparent;
  font: 400 30px/1.28 var(--font-display); letter-spacing: -0.028em;
  padding: 10px 0 6px; margin: 0; overflow: hidden;
}
#note::placeholder { color: var(--ink-3); }
.card-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.detected { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.metric-chip {
  border: 0; display: inline-flex; gap: 5px; align-items: baseline;
  background: var(--chip); border-radius: 999px; padding: 5px 11px; font-size: 13.5px;
}
.metric-chip b { font-weight: 600; font-variant-numeric: tabular-nums; }
.metric-chip .x { color: var(--ink-3); margin-left: 2px; }
.metric-chip.off { opacity: .4; text-decoration: line-through; }

/* ---------- locked: ghost cards with one way in */
.locked { position: relative; margin-top: 18px; }
.ghost { padding: 22px; margin-top: 12px; box-shadow: none; background: var(--ghost); }
.ghost i { display: block; height: 11px; border-radius: 6px; background: var(--desk); opacity: .9; margin: 9px 0; }
.ghost i.short { width: 55%; }
.ghost.g2 { opacity: .7; }
.ghost.g3 { opacity: .4; }
.unlock {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-align: center;
}
.unlock-pill {
  display: inline-flex; align-items: center; gap: 9px;
  border: 0; border-radius: 999px; padding: 13px 22px;
  background: var(--card); color: var(--ink); font-weight: 600; font-size: 16px;
  box-shadow: var(--shadow-lift);
}
.unlock-pill svg { font-size: 18px; }
.unlock-pill:active { transform: scale(.98); }
.unlock .error { max-width: 340px; margin: 6px 0 0; }

/* ---------- timeline of cards */
#timeline-wrap { margin-top: 10px; }
.day { margin-top: 26px; }
.day-head { display: flex; align-items: baseline; gap: 10px; padding: 0 4px 10px; }
.day-title { font: 700 20px/1.2 var(--font-display); letter-spacing: -0.024em; }
.day-sub { color: var(--ink-2); font-size: 14px; }
.entries { display: flex; flex-direction: column; gap: 10px; }
.entry { padding: 16px 22px 18px; transition: box-shadow .15s, transform .15s; }
.entry.clickable { cursor: pointer; }
.entry.clickable:hover { box-shadow: var(--shadow-lift); }
.entry.pending { opacity: .6; }
.e-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-3); margin-bottom: 6px; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.e-head .kind { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.entry.activity .kind { background: var(--activity); }
.entry.measure .kind { background: var(--measure); }
.entry.day-sum .kind { background: var(--day); }
.e-head .src::before { content: "·"; margin-right: 8px; }

/* notes: short is big, long is calm */
.e-text { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font-display); }
.sz-l .e-text { font-size: 24px; line-height: 1.3; letter-spacing: -0.026em; }
.sz-m .e-text { font-size: 20px; line-height: 1.38; letter-spacing: -0.022em; }
.sz-s .e-text { font-size: 17px; line-height: 1.47; letter-spacing: -0.02em; }
.e-text .tag { color: var(--ink-2); }
.e-title { font-weight: 600; font-size: 18px; }
.e-title .sub { font-weight: 400; color: var(--ink-3); font-size: 14px; margin-left: 6px; }
.e-line { color: var(--ink-2); font-size: 15px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; margin-top: 2px; }
.e-big { font-size: 20px; font-variant-numeric: tabular-nums; }
.e-big b { font-weight: 600; }
.e-metrics { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.e-metrics b { color: var(--ink); font-weight: 600; }
.entry.day-sum { padding: 12px 22px 14px; }
.entry.day-sum .e-metrics { margin-top: 0; }
.tl-sentinel { height: 40px; }
.empty { color: var(--ink-2); text-align: center; padding: 40px 0; }

/* ---------- sheets */
dialog {
  border: 0; padding: 0; background: var(--desk); color: var(--ink);
  border-radius: 18px; width: min(560px, calc(100vw - 24px)); max-height: min(86dvh, 820px);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(0,0,0,.32); backdrop-filter: blur(2px); }
.sheet-head {
  position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px 8px; background: var(--desk); z-index: 1;
}
.sheet-head .title { margin: 0; }
.sheet-body { padding: 0 20px 24px; }
.group { margin-top: 18px; }
.group h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); font-weight: 500; margin: 0 0 8px 4px; }
.list { list-style: none; margin: 0 0 10px; padding: 0; background: var(--card); border-radius: 12px; overflow: hidden; }
.list:empty { display: none; }
.list li { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: .5px solid var(--hair); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .sub { color: var(--ink-2); font-size: 13px; }
.list button { border: 0; background: none; color: var(--danger); font-size: 15px; }
.secret-box { margin-top: 10px; }
.secret-box code {
  display: block; font: 12px/1.5 var(--mono); background: var(--card); border: 1px solid var(--hair);
  padding: 10px; border-radius: 10px; word-break: break-all; margin-bottom: 8px; letter-spacing: 0;
}
.sheet.small form { padding: 18px; }
.edit { display: flex; flex-direction: column; gap: 8px; }
.edit textarea { min-height: 180px; resize: vertical; line-height: 1.47; font-family: var(--font-display); font-size: 19px; }

/* ---------- toast */
.toast {
  position: fixed; left: 50%; top: calc(56px + env(safe-area-inset-top)); z-index: 10;
  transform: translate(-50%, -8px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--desk); padding: 9px 16px; border-radius: 999px; font-size: 15px;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media print {
  body * { visibility: hidden; }
  #recovery-code, #recovery-code * { visibility: visible; }
  #recovery-code { position: absolute; top: 40px; left: 40px; right: 40px; }
}

/* ---------- sign in */
.panel.center { text-align: center; }
.panel.center .lede { margin-bottom: 28px; }
.google-web { display: flex; justify-content: center; min-height: 44px; margin-bottom: 8px; }
.btn.google {
  display: inline-flex; align-items: center; gap: 10px; background: var(--card); color: var(--ink);
  box-shadow: var(--shadow); border-radius: 999px; padding: 13px 24px; font-weight: 600;
}
.btn.google .g { font-size: 20px; }
.dev { max-width: 280px; margin: 18px auto 0; }
.panel .hint { margin-top: 26px; }

/* ---------- "Salaa aikajanasi" prompt card */
.prompt {
  display: flex; gap: 14px; padding: 18px 20px; margin: 4px 0;
  background: linear-gradient(135deg, var(--card), var(--chip));
  border: 1px dashed var(--hair);
}
.prompt-glyph {
  flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-size: 20px;
}
.prompt h3 { margin: 0 0 2px; font: 600 17px/1.3 var(--font-display); }
.prompt p { margin: 0 0 10px; color: var(--ink-2); font-size: 15px; line-height: 1.4; }
.prompt-actions { display: flex; gap: 6px; align-items: center; }

/* ---------- encryption flow */
.enc-flow { padding: 26px 22px 22px; }
.enc-glyph { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-size: 26px; margin-bottom: 14px; }
.enc-points { padding-left: 18px; margin: 0 0 8px; color: var(--ink-2); font-size: 15px; line-height: 1.45; }
.enc-points li { margin-bottom: 8px; }
.enc-points b { color: var(--ink); font-weight: 600; }
.progress { height: 6px; border-radius: 3px; background: var(--chip); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
