/* Дневник — "настроение как свет": вечер, лампа, год из огоньков. */

@font-face { font-family: "Literata"; font-weight: 400; font-style: normal; font-display: swap; src: url(fonts/literata-cyrillic-400-normal.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Literata"; font-weight: 400; font-style: normal; font-display: swap; src: url(fonts/literata-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: "Literata"; font-weight: 400; font-style: italic; font-display: swap; src: url(fonts/literata-cyrillic-400-italic.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Literata"; font-weight: 400; font-style: italic; font-display: swap; src: url(fonts/literata-latin-400-italic.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: "Literata"; font-weight: 500; font-style: normal; font-display: swap; src: url(fonts/literata-cyrillic-500-normal.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Literata"; font-weight: 500; font-style: normal; font-display: swap; src: url(fonts/literata-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: "Literata"; font-weight: 500; font-style: italic; font-display: swap; src: url(fonts/literata-cyrillic-500-italic.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Literata"; font-weight: 500; font-style: italic; font-display: swap; src: url(fonts/literata-latin-500-italic.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: "Literata"; font-weight: 600; font-style: normal; font-display: swap; src: url(fonts/literata-cyrillic-600-normal.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Literata"; font-weight: 600; font-style: normal; font-display: swap; src: url(fonts/literata-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: "Onest"; font-weight: 400; font-display: swap; src: url(fonts/onest-cyrillic-400-normal.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Onest"; font-weight: 400; font-display: swap; src: url(fonts/onest-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: "Onest"; font-weight: 500; font-display: swap; src: url(fonts/onest-cyrillic-500-normal.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Onest"; font-weight: 500; font-display: swap; src: url(fonts/onest-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: "Onest"; font-weight: 600; font-display: swap; src: url(fonts/onest-cyrillic-600-normal.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Onest"; font-weight: 600; font-display: swap; src: url(fonts/onest-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }

/* ---------- tokens ---------- */
:root {
  --night: #1E1B2E;        /* фон: вечернее небо */
  --dusk: #29253D;         /* поверхности */
  --dusk-2: #332E4B;
  --ink: #EDE7F6;          /* основной текст */
  --muted: #A49CBE;
  --faint: #6E6690;
  --line: rgba(237, 231, 246, .09);
  --lamp: #F2C46D;         /* единственный акцент: свет лампы */
  --lamp-ink: #2A2132;
  --glow: rgba(242, 196, 109, .22);

  /* настроение = количество света */
  --m1: #5E4F94; --m2: #8A80C4; --m3: #B7B0D2; --m4: #EBC97E; --m5: #F7A25E;
  --m0: rgba(237, 231, 246, .07);

  /* Mood Meter */
  --q-red: #E07A6B; --q-yellow: #F2C46D; --q-green: #84B59A; --q-blue: #7D9BD1;

  --serif: "Literata", Georgia, serif;
  --sans: "Onest", -apple-system, "Segoe UI", Roboto, sans-serif;
  --r-lg: 22px; --r-md: 14px; --r-sm: 10px;
  --pad: 20px;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --night: #F1EFF7;
  --dusk: #FFFFFF;
  --dusk-2: #F6F4FB;
  --ink: #26213A;
  --muted: #6D6688;
  --faint: #A39DBA;
  --line: rgba(38, 33, 58, .09);
  --lamp: #E3A93F;
  --lamp-ink: #2A2132;
  --glow: rgba(227, 169, 63, .18);
  --m1: #6A5AA6; --m2: #9A91D0; --m3: #CAC4E0; --m4: #EDC56D; --m5: #F2954A;
  --m0: rgba(38, 33, 58, .06);
  color-scheme: light;
}

/* ---------- base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--night); color: var(--ink); }
body {
  font-family: var(--sans); font-size: 15px; line-height: 1.45;
  min-height: 100vh; overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--lamp); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.view { padding: 18px var(--pad) calc(var(--tab-h) + var(--safe-b) + 28px); max-width: 560px; margin: 0 auto; }
.view.no-tabs { padding-bottom: calc(var(--safe-b) + 40px); }

h1, h2, h3 { margin: 0; font-weight: 500; }
.serif { font-family: var(--serif); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 36px; margin-bottom: 6px; }
.topbar .weekday { color: var(--muted); font-size: 15px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  color: var(--muted); background: var(--dusk);
}
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- today hero ---------- */
.hero-date { font-family: var(--serif); font-size: 44px; line-height: 1.05; letter-spacing: -0.01em; margin: 2px 0 10px; }
.streak { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.streak b { color: var(--ink); font-weight: 600; }
.streak .flame { width: 8px; height: 8px; border-radius: 50%; background: var(--lamp); box-shadow: 0 0 0 4px var(--glow), 0 0 14px 4px var(--glow); }

.lamp-card {
  position: relative; margin: 22px 0 28px; padding: 22px 20px 20px;
  border-radius: var(--r-lg); background: var(--dusk); overflow: hidden;
}
.lamp-card::before { /* свет лампы сверху: главный акцент экрана */
  content: ""; position: absolute; inset: -60% -20% auto; height: 220px;
  background: radial-gradient(closest-side, var(--glow), transparent 70%);
  pointer-events: none;
}
.lamp-card > * { position: relative; }
.lamp-card .title { font-family: var(--serif); font-size: 22px; line-height: 1.25; margin-bottom: 8px; }
.lamp-card .preview { font-family: var(--serif); font-size: 16px; line-height: 1.6; color: var(--ink); opacity: .86; margin: 0 0 16px; }
.lamp-card .empty-title { font-family: var(--serif); font-size: 24px; line-height: 1.25; margin-bottom: 8px; }
.lamp-card .empty-text { color: var(--muted); margin: 0 0 18px; max-width: 30ch; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: 999px; font-weight: 500;
  background: var(--lamp); color: var(--lamp-ink);
}
.btn.ghost { background: var(--dusk-2); color: var(--ink); }
.btn.small { height: 34px; padding: 0 14px; font-size: 14px; }
.btn:active { transform: scale(.98); }

/* ---------- sections ---------- */
.section { margin-top: 30px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.section-head h2 { font-family: var(--serif); font-size: 19px; }
.section-head a, .section-head button { color: var(--muted); font-size: 14px; }

/* week strip */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; }
.week .d { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.week .d .dot { width: 34px; height: 34px; border-radius: 50%; background: var(--m0); display: grid; place-items: center; color: var(--lamp-ink); font-weight: 600; font-size: 13px; }
.week .d.today { color: var(--ink); }
.week .d.today .dot { outline: 2px solid var(--lamp); outline-offset: 2px; }
.week .d.future .dot { background: transparent; border: 1px dashed var(--line); }

/* light swatches */
.m1 { background: var(--m1) !important; color: #fff; }
.m2 { background: var(--m2) !important; }
.m3 { background: var(--m3) !important; }
.m4 { background: var(--m4) !important; }
.m5 { background: var(--m5) !important; }
.q-red { --q: var(--q-red); } .q-yellow { --q: var(--q-yellow); } .q-green { --q: var(--q-green); } .q-blue { --q: var(--q-blue); }

/* memory list */
.memory { display: block; padding: 16px 0; border-top: 1px solid var(--line); }
.memory:first-child { border-top: 0; padding-top: 4px; }
.memory .when { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.memory .when i { width: 10px; height: 10px; border-radius: 50%; background: var(--m0); }
.memory .t { font-family: var(--serif); font-size: 17px; line-height: 1.3; }
.memory .p { color: var(--muted); font-size: 14px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.report-teaser { display: block; padding: 18px; border-radius: var(--r-md); background: var(--dusk); }
.report-teaser .t { font-family: var(--serif); font-size: 18px; margin-bottom: 4px; }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px;
  border-radius: 999px; background: var(--dusk-2); font-size: 14px; color: var(--ink);
}
.chip .q { width: 8px; height: 8px; border-radius: 50%; background: var(--q, var(--faint)); }
.chip.suggested { background: transparent; border: 1px dashed var(--faint); color: var(--muted); }
.chip.add { color: var(--muted); }
.chip.tag { color: var(--muted); }

/* ---------- calendar ---------- */
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--dusk); }
.seg button { height: 32px; padding: 0 16px; border-radius: 999px; color: var(--muted); font-size: 14px; }
.seg button.on { background: var(--dusk-2); color: var(--ink); }

.month-nav { display: flex; align-items: center; justify-content: space-between; margin: 22px 0 14px; }
.month-nav h1 { font-family: var(--serif); font-size: 30px; }
.month-nav .arrows { display: flex; gap: 8px; }

.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.month .wd { text-align: center; font-size: 12px; color: var(--faint); padding-bottom: 4px; }
.month .cell {
  aspect-ratio: 1; border-radius: 12px; background: var(--m0);
  display: flex; align-items: flex-start; justify-content: flex-start; padding: 6px 7px;
  font-size: 13px; color: var(--muted); position: relative;
}
.month .cell.has { color: var(--lamp-ink); font-weight: 600; }
.month .cell.m1.has { color: #fff; }
.month .cell.today { outline: 2px solid var(--lamp); outline-offset: 1px; }
.month .cell.future { background: transparent; color: var(--faint); }
.month .cell .qd { position: absolute; right: 6px; bottom: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--q); box-shadow: 0 0 0 1.5px rgba(255,255,255,.55); }

.legend { display: flex; align-items: center; gap: 6px; margin-top: 18px; color: var(--muted); font-size: 12px; }
.legend i { width: 14px; height: 14px; border-radius: 4px; }

.month-sum { margin-top: 26px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { padding: 14px; border-radius: var(--r-md); background: var(--dusk); }
.stat b { display: block; font-family: var(--serif); font-size: 24px; font-weight: 500; line-height: 1.1; }
.stat span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.3; }

/* year in pixels */
.year-title { font-family: var(--serif); font-size: 30px; margin: 22px 0 6px; }
.pixels { display: grid; grid-template-columns: 14px repeat(31, minmax(0, 1fr)); gap: 2px; margin-top: 14px; }
.pixels .ml { font-size: 10px; color: var(--faint); line-height: 1; align-self: center; }
.pixels .px { aspect-ratio: 1; border-radius: 2.5px; background: var(--m0); }
.pixels .px.none { background: transparent; }
.pixels .px.today { outline: 1.5px solid var(--lamp); }

/* ---------- day ---------- */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); height: 36px; }
.back svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.day-date { color: var(--muted); margin: 10px 0 4px; }
.day-title { font-family: var(--serif); font-size: 30px; line-height: 1.15; margin-bottom: 18px; }
.day-title[contenteditable="true"] { outline: none; border-bottom: 1px dashed var(--faint); }

.mood-row { display: flex; gap: 10px; align-items: center; }
.mood-btn { width: 40px; height: 40px; border-radius: 50%; position: relative; opacity: .35; transition: opacity .15s, transform .15s; }
.mood-btn.on { opacity: 1; transform: scale(1.08); box-shadow: 0 0 18px 2px var(--glow); }
.mood-btn.sugg { opacity: .7; outline: 1.5px dashed var(--faint); outline-offset: 3px; }
.mood-label { margin-left: 4px; color: var(--muted); font-size: 14px; }

.block { margin-top: 26px; }
.block h3 { font-size: 14px; color: var(--muted); font-weight: 500; margin-bottom: 10px; }
.confirm-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; padding: 10px 10px 10px 14px; border-radius: var(--r-md); background: var(--dusk); font-size: 14px; color: var(--muted); }

.rbt { display: grid; gap: 14px; }
.rbt .row { display: grid; grid-template-columns: 26px 1fr; gap: 10px; }
.rbt .row .ic { font-size: 17px; line-height: 1.5; }
.rbt .row .lbl { font-size: 13px; color: var(--muted); }
.rbt .row ul { margin: 2px 0 0; padding: 0; list-style: none; font-family: var(--serif); font-size: 16px; line-height: 1.5; }

.note { padding: 22px 0; border-top: 1px solid var(--line); }
.note-head { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.note-head .kind { display: inline-flex; align-items: center; gap: 8px; }
.note-q { font-family: var(--serif); font-style: italic; color: var(--muted); margin: 0 0 10px; padding-left: 12px; border-left: 2px solid var(--lamp); }
.note-text { font-family: var(--serif); font-size: 17px; line-height: 1.68; white-space: pre-wrap; }
.note-text[contenteditable="true"] { outline: none; background: var(--dusk); border-radius: var(--r-sm); padding: 10px 12px; }
.note-actions { display: flex; gap: 16px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.note-actions button { color: var(--muted); }
.original { margin-top: 12px; padding: 12px 14px; border-radius: var(--r-sm); background: var(--dusk); color: var(--muted); font-size: 14px; line-height: 1.55; white-space: pre-wrap; }

.composer { margin-top: 26px; padding: 14px; border-radius: var(--r-lg); background: var(--dusk); }
.composer textarea { width: 100%; min-height: 96px; resize: vertical; border: 0; background: transparent; font-family: var(--serif); font-size: 16px; line-height: 1.6; outline: none; }
.composer textarea::placeholder { color: var(--faint); }
.composer .row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }

/* ---------- insights ---------- */
.page-title { font-family: var(--serif); font-size: 34px; line-height: 1.1; margin: 8px 0 4px; }
.quad-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--m0); margin: 10px 0 10px; }
.quad-bar i { display: block; height: 100%; background: var(--q); }
.quad-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.quad-legend span { display: inline-flex; align-items: center; gap: 6px; }
.quad-legend span i { width: 8px; height: 8px; border-radius: 50%; background: var(--q); }

.bars { display: grid; gap: 10px; }
.bars .b { display: grid; grid-template-columns: 112px 1fr 24px; align-items: center; gap: 10px; font-size: 14px; }
.bars .b .track { height: 8px; border-radius: 999px; background: var(--m0); overflow: hidden; }
.bars .b .fill { height: 100%; border-radius: 999px; background: var(--q, var(--muted)); }
.bars .b .n { color: var(--muted); text-align: right; font-size: 13px; }

.report-list a { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 16px 0; border-top: 1px solid var(--line); }
.report-list a:first-child { border-top: 0; }
.report-list .t { font-family: var(--serif); font-size: 17px; }
.report-list .s { color: var(--muted); font-size: 13px; margin-top: 2px; }
.report-list .mood-pill { width: 28px; height: 28px; border-radius: 50%; background: var(--m0); }

.prose { font-family: var(--serif); font-size: 16.5px; line-height: 1.68; }
.prose h2 { font-family: var(--sans); font-size: 14px; font-weight: 600; color: var(--muted); margin: 28px 0 8px; }
.prose p { margin: 0 0 12px; }
.prose ul { margin: 0 0 12px; padding-left: 18px; }
.prose li { margin-bottom: 6px; }
.prose li::marker { color: var(--lamp); }

/* search */
.search-input { width: 100%; height: 48px; border-radius: 999px; border: 0; padding: 0 20px; background: var(--dusk); font-size: 16px; outline: none; margin: 10px 0 8px; }
.hit { display: block; padding: 16px 0; border-top: 1px solid var(--line); }
.hit .t { font-family: var(--serif); font-size: 17px; }
.hit .s { color: var(--muted); font-size: 14px; margin-top: 4px; }
.hit mark { background: var(--glow); color: var(--ink); border-radius: 3px; padding: 0 2px; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--night) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; color: var(--faint); }
.tabbar svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: var(--ink); }
.tabbar a.on svg { stroke: var(--lamp); }
.tabbar.hidden { display: none; }

/* ---------- sheet (Mood Meter) ---------- */
.sheet { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; background: rgba(10, 8, 20, .55); }
.sheet[hidden] { display: none; }
.sheet .panel {
  width: 100%; max-width: 560px; margin: 0 auto; max-height: 88vh; overflow: auto;
  padding: 10px var(--pad) calc(var(--safe-b) + 20px); border-radius: 26px 26px 0 0; background: var(--night);
  animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet .grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--faint); opacity: .5; margin: 0 auto 14px; }
.sheet h2 { font-family: var(--serif); font-size: 24px; margin-bottom: 4px; }

.meter { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 18px 0 8px; position: relative; }
.meter .quad { height: 112px; border-radius: 18px; padding: 14px; display: flex; flex-direction: column; justify-content: space-between; text-align: left; background: color-mix(in srgb, var(--q) 22%, var(--dusk)); color: var(--ink); }
.meter .quad b { font-family: var(--serif); font-weight: 500; font-size: 19px; }
.meter .quad span { font-size: 12px; color: var(--muted); }
.meter .quad .count { align-self: flex-end; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 12px; background: var(--q); color: var(--lamp-ink); font-size: 13px; font-weight: 600; display: grid; place-items: center; }
.axis { display: flex; justify-content: space-between; color: var(--faint); font-size: 12px; margin-top: 4px; }

.words { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 20px; }
.word { height: 38px; padding: 0 14px; border-radius: 999px; background: var(--dusk); font-size: 15px; }
.word.on { background: var(--q); color: var(--lamp-ink); font-weight: 500; }
.sheet-actions { display: flex; gap: 10px; }
.sheet-actions .btn { flex: 1; }

/* ---------- misc ---------- */
.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 16px); transform: translateX(-50%); z-index: 40; padding: 11px 18px; border-radius: 999px; background: var(--ink); color: var(--night); font-size: 14px; }
.skeleton { height: 120px; border-radius: var(--r-lg); background: var(--dusk); opacity: .6; margin-top: 20px; }
.empty { color: var(--muted); padding: 12px 0; }
.error { padding: 40px 0; text-align: center; color: var(--muted); }
