/* Avui — mini journal. Dark only, Apple system type. */

:root {
  color-scheme: dark;

  --bg: #08080a;
  --surface: #131316;
  --surface-2: #1c1c20;
  --line: #26262b;
  --text: #f5f5f7;
  --muted: #9a9aa2;
  --faint: #5a5a63;
  --accent: #ff9f0a;
  --accent-soft: rgb(255 159 10 / .14);

  --ease: cubic-bezier(.32,.72,0,1);
  --pad: 24px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
               "Helvetica Neue", Inter, system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  letter-spacing: -0.015em;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
}

.screen {
  width: 100%;
  max-width: 460px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(18px + env(safe-area-inset-top)) var(--pad)
           calc(22px + env(safe-area-inset-bottom));
}
@supports not (view-transition-name: none) {
  .screen { animation: in .3s var(--ease) both; }
}
@keyframes in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- top bar ---------- */
.top {
  view-transition-name: topbar;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 34px;
  margin-bottom: 34px;
}
.back {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  margin-left: -8px;
  border-radius: 50%;
  color: var(--muted);
  text-decoration: none;
  transition: background .15s, color .15s;
}
.back:hover { background: var(--surface); color: var(--text); }
.back svg { width: 19px; height: 19px; fill: currentColor; }

.dots { display: flex; gap: 6px; margin-left: auto; }
.dots i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--line);
  transition: background .3s var(--ease), width .3s var(--ease);
}
.dots i.on { background: var(--accent); width: 18px; border-radius: 3px; }
.dots i.done { background: var(--faint); }

/* ---------- content ---------- */
main { flex: 1; }

.eyebrow {
  font-size: 13px;
  font-weight: 590;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 10px;
}
h1 {
  font-size: 30px;
  line-height: 1.15;
  font-weight: 680;
  letter-spacing: -0.035em;
  margin-bottom: 8px;
}
.sub {
  font-size: 15.5px;
  color: var(--muted);
  letter-spacing: -0.01em;
  margin-bottom: 32px;
}

/* ---------- moods ---------- */
.moods {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.mood {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font-size: 27px;
  line-height: 1;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 16px;
  cursor: pointer;
  transition: transform .16s var(--ease), background .18s, border-color .18s, opacity .18s;
}
.mood:hover { background: var(--surface-2); }
.mood:active { transform: scale(.93); }
.mood[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  transform: scale(1.06);
}
.moods:has([aria-pressed="true"]) .mood:not([aria-pressed="true"]) { opacity: .38; }
.mood-label {
  margin-top: 20px;
  text-align: center;
  font-size: 17px;
  font-weight: 560;
  color: var(--accent);
  min-height: 24px;
  transition: opacity .2s;
}

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 15px;
  font: inherit;
  font-size: 15.5px;
  letter-spacing: -0.01em;
  color: var(--text);
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: transform .14s var(--ease), background .18s, border-color .18s;
}
.chip:hover { background: var(--surface-2); }
.chip:active { transform: scale(.96); }
.chip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.chip .em { font-size: 15px; }

/* ---------- fields ---------- */
.field {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  font: inherit;
  letter-spacing: -0.015em;
  padding: 14px 16px;
  transition: border-color .18s, background .18s;
}
.field::placeholder { color: var(--faint); }
.field:focus { outline: none; border-color: var(--accent); background: var(--surface-2); }
textarea.field { resize: none; min-height: 170px; line-height: 1.5; }

.count {
  margin-top: 10px;
  font-size: 13px;
  color: var(--faint);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.stack { display: flex; flex-direction: column; gap: 14px; }
.label {
  font-size: 13px;
  font-weight: 590;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 26px 0 10px;
}

/* ---------- buttons ---------- */
.cta { margin-top: 30px; display: flex; flex-direction: column; gap: 12px; }
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: 15px;
  background: var(--text);
  color: #0a0a0b;
  font: inherit;
  font-size: 17px;
  font-weight: 590;
  letter-spacing: -0.015em;
  text-decoration: none;
  cursor: pointer;
  transition: transform .14s var(--ease), opacity .18s;
}
.btn:active { transform: scale(.975); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .28; pointer-events: none; }
.btn.secondary { background: var(--surface); color: var(--text); }
.btn.quiet {
  background: none;
  color: var(--muted);
  min-height: 44px;
  font-weight: 400;
  font-size: 15.5px;
}
.btn.quiet:hover { color: var(--text); }

a, button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 12px; }

/* ---------- summary / diary ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
}
.card + .card { margin-top: 10px; }
.card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}
.card-top .em { font-size: 24px; line-height: 1; }
.card-date {
  font-size: 15px;
  font-weight: 560;
  letter-spacing: -0.01em;
}
.card-mood { font-size: 13.5px; color: var(--muted); }
.card-places {
  margin-top: 12px;
  font-size: 14px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.card-places span {
  background: var(--surface-2);
  border-radius: 7px;
  padding: 3px 8px;
}
.card-note {
  margin-top: 12px;
  font-size: 15.5px;
  color: #d9d9de;
  line-height: 1.5;
  white-space: pre-wrap;
}

.streak {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 22px;
  font-size: 14px;
  color: var(--muted);
}
.streak b { font-size: 15px; color: var(--text); font-weight: 590; }

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 15.5px;
  padding: 70px 0;
}
.empty .big { font-size: 34px; display: block; margin-bottom: 14px; opacity: .5; }

.day-group + .day-group { margin-top: 26px; }
.day-title {
  font-size: 13px;
  font-weight: 590;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 10px;
}

.big-date { font-size: 15.5px; color: var(--muted); }

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

/* ---------- share (export / import) ---------- */
.qr {
  background: #fff;
  border-radius: 20px;
  padding: 16px;
  width: 100%;
  max-width: 280px;
  margin: 4px auto 0;
  animation: in .4s var(--ease) both;
}
.qr svg { display: block; width: 100%; height: auto; }
.qr-note {
  margin: 14px auto 0;
  max-width: 300px;
  text-align: center;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--muted);
}

textarea.code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 0;
  min-height: 0;
  word-break: break-all;
  color: var(--muted);
}

.err {
  margin-top: 12px;
  font-size: 14px;
  color: #ff6b6b;
}

#cam {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 18px;
  background: #000;
  margin-bottom: 16px;
}


/* ---------- page transitions ----------
   Cross-document view transitions: the browser holds the old frame until the
   new one is ready, so navigating never flashes. Forward pushes left, back
   pushes right — the direction is decided in app.js before leaving the page. */
@view-transition { navigation: auto; }

@keyframes vt-out-left  { to { opacity: 0; transform: translateX(-22px); } }
@keyframes vt-in-right  { from { opacity: 0; transform: translateX(22px); } }
@keyframes vt-out-right { to { opacity: 0; transform: translateX(22px); } }
@keyframes vt-in-left   { from { opacity: 0; transform: translateX(-22px); } }

::view-transition-old(root) {
  animation: 220ms cubic-bezier(.4, 0, 1, 1) both vt-out-left;
}
::view-transition-new(root) {
  animation: 300ms cubic-bezier(.215, .61, .355, 1) 40ms both vt-in-right;
}
:root[data-dir="back"]::view-transition-old(root) {
  animation: 220ms cubic-bezier(.4, 0, 1, 1) both vt-out-right;
}
:root[data-dir="back"]::view-transition-new(root) {
  animation: 300ms cubic-bezier(.215, .61, .355, 1) 40ms both vt-in-left;
}

/* The bar itself only cross-fades while the step dots morph in place. */
::view-transition-group(topbar) {
  animation-duration: 300ms;
  animation-timing-function: cubic-bezier(.215, .61, .355, 1);
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root),
  :root[data-dir="back"]::view-transition-old(root),
  :root[data-dir="back"]::view-transition-new(root) {
    animation: none;
  }
  ::view-transition-group(topbar) { animation-duration: 1ms; }
}
