/* ==========================================================================
   Cogi · Золота година з Місяцем та Зорями
   Mobile-first. Простота. Тепло. Тиша. Жодного емоджі — лише лінійні іконки.
   ========================================================================== */

:root {
  /* Небо золотої години → ніч (приглушене, щоб текст завжди читався) */
  --night-top: #160f2e;
  --night-mid: #2b1b46;
  --dusk: #543151;
  --horizon: #8a544e;
  --gold-glow: #a9774f;

  /* Золото та світло */
  --gold: #e8b964;
  --gold-soft: #f4cf8a;
  --moon: #fbe9c6;

  /* Текст */
  --ink: #f8efdd;
  --ink-soft: #dcccb3;
  --ink-faint: #b3a1ac;

  /* Скло карток */
  --card: rgba(30, 21, 49, 0.52);
  --card-edge: rgba(244, 207, 138, 0.20);
  --card-edge-strong: rgba(244, 207, 138, 0.46);

  /* Акценти розділів */
  --memory: #f4cf8a;   /* місячне золото */
  --today: #f0a868;    /* тепле сонце */
  --future: #bcaaf0;   /* зоряний бузок */

  --radius: 20px;
  --radius-sm: 14px;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;

  --nav-h: 64px; /* висота нижньої навігації на мобільному */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

/* Атрибут hidden має завжди ховати — інакше display з класів (.ghost тощо) його перекриває */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; min-height: 100%; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--night-top);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Іконки: лінійні, успадковують колір тексту */
.ico {
  width: 1.15em;
  height: 1.15em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
  display: inline-block;
  vertical-align: -0.18em;
}

button { font-family: inherit; }

/* --- Небо ----------------------------------------------------------------- */

.sky {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: linear-gradient(
    180deg,
    var(--night-top) 0%,
    var(--night-mid) 46%,
    var(--dusk) 74%,
    var(--horizon) 92%,
    var(--gold-glow) 100%
  );
}

/* Делікатне затемнення внизу екрана — щоб підвал і кнопки завжди читалися */
.sky::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 58%, rgba(22, 15, 46, 0.55) 100%);
  pointer-events: none;
}

.glow {
  position: absolute;
  left: 50%;
  bottom: -30%;
  width: 130vw;
  height: 44vh;
  transform: translateX(-50%);
  background: radial-gradient(
    ellipse at center,
    rgba(198, 138, 88, 0.26) 0%,
    rgba(198, 138, 88, 0.09) 44%,
    transparent 72%
  );
  filter: blur(12px);
  pointer-events: none;
}

.moon {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 6vh);
  right: 9vw;
  width: 64px;
  height: 64px;
  padding: 0;
  border: none;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 50%;
  z-index: 3;
  cursor: pointer;
  background: radial-gradient(circle at 38% 35%, #fff7e6 0%, var(--moon) 55%, #e7caa0 100%);
  box-shadow:
    0 0 26px 5px rgba(251, 233, 198, 0.42),
    0 0 60px 16px rgba(251, 233, 198, 0.20),
    inset -7px -5px 0 0 rgba(180, 150, 110, 0.16);
  animation: moon-breathe 9s ease-in-out infinite;
  transition: transform 0.2s var(--ease), background 0.7s ease;
}
.moon:hover { transform: scale(1.06); }
.moon:active { transform: scale(0.94); }
.moon:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 4px; }
@keyframes moon-breathe {
  0%, 100% { box-shadow: 0 0 26px 5px rgba(251,233,198,0.42), 0 0 60px 16px rgba(251,233,198,0.18), inset -7px -5px 0 0 rgba(180,150,110,0.16); }
  50%      { box-shadow: 0 0 34px 8px rgba(251,233,198,0.52), 0 0 80px 22px rgba(251,233,198,0.26), inset -7px -5px 0 0 rgba(180,150,110,0.16); }
}

.stars { position: absolute; inset: 0; pointer-events: none; }
.star {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  opacity: 0.8;
  animation: twinkle var(--dur, 4s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}
@keyframes twinkle {
  0%, 100% { opacity: 0.12; transform: scale(0.6); }
  50%      { opacity: 0.95; transform: scale(1.1); }
}

@media (prefers-reduced-motion: reduce) {
  .moon, .star, .panel, .moment { animation: none !important; }
  * { scroll-behavior: auto !important; }
}

/* --- Ніч: глибша темна тема (за натисканням на Місяць) --------------------- */
/* Золота година стихає, горизонт холоне, зорі яснішають, Місяць білішає. */
html.night {
  --night-top: #06060f;
  --night-mid: #0c0d20;
  --dusk: #10112a;
  --horizon: #161634;
  --gold-glow: #1c1c3a;
  --moon: #eaf2ff;
  --card: rgba(18, 18, 38, 0.56);
}
html.night body { background: var(--night-top); }
html.night .glow { opacity: 0.32; }
html.night .star { background: #eaf2ff; opacity: 0.9; }
html.night .moon {
  background: radial-gradient(circle at 38% 35%, #ffffff 0%, var(--moon) 55%, #cdd6f0 100%);
  animation: moon-breathe-night 9s ease-in-out infinite;
}
@keyframes moon-breathe-night {
  0%, 100% { box-shadow: 0 0 30px 7px rgba(220,230,255,0.42), 0 0 70px 20px rgba(200,215,255,0.20), inset -7px -5px 0 0 rgba(120,140,190,0.18); }
  50%      { box-shadow: 0 0 40px 10px rgba(220,230,255,0.55), 0 0 92px 26px rgba(200,215,255,0.28), inset -7px -5px 0 0 rgba(120,140,190,0.18); }
}

/* М'який перехід між золотою годиною та ніччю */
body { transition: background-color 0.7s ease; }
.glow, .star { transition: opacity 0.7s ease; }

/* --- Каркас застосунку ---------------------------------------------------- */

.app {
  max-width: 600px;
  margin: 0 auto;
  padding:
    calc(env(safe-area-inset-top, 0px) + 22px)
    18px
    calc(env(safe-area-inset-bottom, 0px) + var(--nav-h) + 28px);
}

/* --- Шапка ---------------------------------------------------------------- */

.header { text-align: center; margin-bottom: 18px; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 2.3rem;
  letter-spacing: 0.04em;
  margin: 0;
  color: var(--moon);
  text-shadow: 0 2px 22px rgba(243, 177, 95, 0.30);
}
.brand-ico {
  width: 0.92em;
  height: 0.92em;
  fill: none;
  stroke: var(--gold-soft);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 8px rgba(243, 177, 95, 0.4));
}
.brand-sub {
  margin: 5px 0 0;
  font-size: 0.74rem;
  letter-spacing: 0.18em;
  text-transform: lowercase;
  color: var(--ink-faint);
}

/* --- Питання дня ---------------------------------------------------------- */

.prompt {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.22rem;
  text-align: center;
  color: var(--gold-soft);
  margin: 6px auto 22px;
  max-width: 26ch;
  /* Питання різної довжини: резервуємо два рядки, щоб коротке («Куди ти хочеш
     прийти?») не зсувало все під ним угору при перемиканні розділів. */
  min-height: 2.9em;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.4;
  text-shadow: 0 1px 14px rgba(243, 177, 95, 0.22);
  transition: opacity 0.45s var(--ease);
}

/* --- Швидке заповнення ---------------------------------------------------- */

.capture {
  background: rgba(255, 255, 255, 0.035);
  border: none;
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  margin-bottom: 26px;
}

.capture-input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.06rem; /* ≥16px — iOS не масштабує при фокусі */
  line-height: 1.5;
  resize: none;
  outline: none;
  overflow: hidden;
  min-height: 1.5em;
}
.capture-input::placeholder { color: var(--ink-faint); }

.capture-hint {
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  margin: 14px 0 9px;
  padding-top: 13px;
  border-top: 1px solid rgba(244, 207, 138, 0.13);
}

.realm-pills { display: flex; gap: 8px; }
.pill {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 46px;
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--card-edge);
  border-radius: 13px;
  padding: 8px 6px;
  cursor: pointer;
  transition: transform 0.14s var(--ease), border-color 0.2s, background 0.2s, color 0.2s;
}
.pill .ico { opacity: 0.85; }
.pill:active { transform: scale(0.96); }
.pill-memory:hover, .pill-memory:focus-visible { color: var(--memory); border-color: var(--memory); background: rgba(244,207,138,0.10); }
.pill-today:hover,  .pill-today:focus-visible  { color: var(--today);  border-color: var(--today);  background: rgba(240,168,104,0.10); }
.pill-future:hover, .pill-future:focus-visible { color: var(--future); border-color: var(--future); background: rgba(188,170,240,0.10); }

/* --- Панелі та списки ----------------------------------------------------- */

.panel { animation: fade-in 0.4s var(--ease); }
.panel[hidden] { display: none; }
@keyframes fade-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

.panel-intro {
  font-size: 0.88rem;
  color: var(--ink-faint);
  text-align: center;
  margin: 0 0 18px;
}

/* Охайна колекція карток замість однієї довгої стрічки */
.list { display: grid; grid-template-columns: 1fr; gap: 12px; align-items: start; }

.moment {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-left: 3px solid var(--accent, var(--gold));
  border-radius: var(--radius-sm);
  padding: 14px 15px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.16);
  animation: rise 0.4s var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.moment-text { white-space: pre-wrap; word-break: break-word; font-size: 1rem; line-height: 1.55; }
.moment-text.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.moment-more {
  align-self: flex-start;
  margin-top: 6px;
  padding: 2px 0;
  font-size: 0.8rem;
  color: var(--accent, var(--gold));
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.85;
}
.moment-more:hover { opacity: 1; text-decoration: underline; }
.moment-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 8px;
  margin-top: 11px;
  gap: 12px;
}
.moment-date { font-size: 0.75rem; color: var(--ink-faint); letter-spacing: 0.02em; }
.moment-del {
  font-size: 0.76rem;
  color: var(--ink-faint);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  margin: -6px -8px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}
.moment-del:hover, .moment-del:focus-visible { color: var(--horizon); background: rgba(201,105,79,0.12); }

#list-memory .moment { --accent: var(--memory); }
#list-future .moment { --accent: var(--future); }

/* Від планшета — дві колонки, щоб картки читались як охайна колекція */
@media (min-width: 540px) {
  .list { grid-template-columns: 1fr 1fr; gap: 13px; }
}

.empty {
  grid-column: 1 / -1;   /* на всю ширину сітки, інакше тулиться в ліву колонку */
  text-align: center;
  white-space: pre-line;
  color: var(--ink-faint);
  font-family: var(--serif);
  font-style: italic;
  padding: 34px 14px;
  font-size: 1.05rem;
  line-height: 1.6;
  opacity: 0.85;
}

/* --- Сьогодення: перемоги дня --------------------------------------------- */

.victory-slots { display: flex; flex-direction: column; gap: 11px; margin-bottom: 28px; }
.slot {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px dashed var(--card-edge);
  border-radius: var(--radius-sm);
  padding: 4px 15px;
  transition: border-color 0.25s, background 0.25s;
}
.slot-main {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 50px;
}
/* Медіа перемоги дня — під текстом, з відступом під номер */
.slot .moment-media { margin: 0 0 11px 37px; max-width: 280px; }
.slot .moment-media.single .moment-thumb { aspect-ratio: 16 / 10; }
.slot:focus-within { border-color: var(--today); }
.slot.is-filled {
  border-style: solid;
  border-left: 3px solid var(--today);
  background: rgba(240, 168, 104, 0.06);
}
.slot-num {
  font-family: var(--serif);
  font-size: 1.3rem;
  color: var(--today);
  min-width: 1.1em;
  text-align: center;
  opacity: 0.8;
}
.slot.is-filled .slot-num { opacity: 1; }
.slot-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  padding: 12px 0;
  resize: none;
  outline: none;
  overflow: hidden;
}
.slot-input::placeholder { color: var(--ink-faint); font-style: italic; }

/* Перемикач «минулі дні» — прихований за замовчуванням, відкривається за бажанням */
.history-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 2px auto 6px;
  font-size: 0.83rem;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-edge);
  border-radius: 999px;
  padding: 9px 16px;
  min-height: 40px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.history-toggle:hover, .history-toggle:focus-visible {
  color: var(--ink);
  border-color: var(--card-edge-strong);
  background: rgba(255, 255, 255, 0.07);
}
.history-toggle .ico { width: 1em; height: 1em; opacity: 0.8; transition: transform 0.25s var(--ease); }
.history-toggle.is-open .ico { transform: rotate(180deg); }

.history { margin-top: 14px; animation: fade-in 0.35s var(--ease); }
.history[hidden] { display: none; }

.history-day {
  margin-bottom: 16px;
  border-top: 1px solid rgba(244, 207, 138, 0.1);
  padding-top: 15px;
}
.history-day:first-child { border-top: none; padding-top: 0; }
.history-date {
  font-size: 0.74rem;
  letter-spacing: 0.07em;
  color: var(--ink-faint);
  margin: 0 0 9px;
  text-transform: uppercase;
}
.history-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin-bottom: 7px;
}
.history-item .ico { color: var(--today); opacity: 0.7; margin-top: 0.18em; width: 0.95em; height: 0.95em; }

/* Мініатюри медіа в історії минулих днів */
.history-media { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px 19px; }
.history-thumb {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--card-edge);
  background: rgba(0, 0, 0, 0.22);
  cursor: pointer;
}
.history-thumb img, .history-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.history-thumb .chip-play .ico { width: 1.2em; height: 1.2em; }

/* --- Підвал --------------------------------------------------------------- */

.footer {
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid rgba(244, 207, 138, 0.1);
}
/* Мобільний: рівні кнопки по дві в ряд (одна зайва — по центру). Так підвал
   виглядає охайно й не тісно, а повні підписи не обрізаються. Підвал легкий —
   рідковживане сховано в «Захист». */
.footer-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
}
.footer-actions .ghost {
  flex: 0 1 calc(50% - 5px);
  justify-content: center;
  min-height: 46px;
}
.footer-actions .ghost span { white-space: nowrap; }
.ghost {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8rem;
  font-family: inherit;
  text-decoration: none;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-edge);
  border-radius: 999px;
  padding: 9px 14px;
  min-height: 40px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s, transform 0.14s var(--ease);
}
.ghost-link { color: var(--gold-soft); border-color: var(--card-edge-strong); }
.ghost-link:hover { background: rgba(232, 185, 100, 0.12); }
.ghost .ico { opacity: 0.85; }
.ghost:hover, .ghost:focus-visible { color: var(--ink); border-color: var(--card-edge-strong); background: rgba(255,255,255,0.08); }
.ghost:active { transform: scale(0.97); }
.ghost.is-on { color: var(--gold-soft); border-color: var(--card-edge-strong); }
#btn-install { color: var(--gold-soft); border-color: var(--gold); background: rgba(232,185,100,0.12); }
.footer-note {
  text-align: center;
  font-size: 0.73rem;
  color: var(--ink-faint);
  opacity: 0.72;
  margin: 16px 0 0;
}

/* --- Нижня навігація розділів --------------------------------------------- */

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  gap: 2px;
  padding: 8px 10px calc(env(safe-area-inset-bottom, 0px) + 8px);
  background: rgba(20, 14, 34, 0.78);
  border-top: 1px solid var(--card-edge);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.7rem;
  color: var(--ink-faint);
  background: transparent;
  border: none;
  border-radius: 14px;
  padding: 6px 4px;
  min-height: 48px;
  cursor: pointer;
  transition: color 0.2s, background 0.25s;
}
.tab .ico { width: 1.45em; height: 1.45em; transition: transform 0.2s var(--ease); }
.tab.is-active { color: var(--gold-soft); background: rgba(244, 207, 138, 0.10); }
.tab.is-active .ico { transform: translateY(-1px) scale(1.06); }
.tab[data-tab="memory"].is-active { color: var(--memory); }
.tab[data-tab="today"].is-active  { color: var(--today); }
.tab[data-tab="future"].is-active { color: var(--future); }
.tab:active { background: rgba(255,255,255,0.06); }

/* --- Аркуш встановлення --------------------------------------------------- */

.sheet { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(10, 7, 20, 0.6); backdrop-filter: blur(3px); animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet-card {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 12px calc(env(safe-area-inset-bottom, 0px) + 14px);
  background: linear-gradient(180deg, rgba(46, 31, 70, 0.96), rgba(30, 21, 49, 0.97));
  border: 1px solid var(--card-edge-strong);
  border-radius: 22px;
  padding: 22px 20px 18px;
  box-shadow: 0 -10px 50px rgba(0, 0, 0, 0.5);
  animation: sheet-up 0.32s var(--ease);
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-x {
  position: absolute; top: 14px; right: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  color: var(--ink-faint); background: rgba(255,255,255,0.05);
  border: none; border-radius: 50%; cursor: pointer;
}
.sheet-x:hover { color: var(--ink); }
.sheet-title { font-family: var(--serif); font-weight: 400; font-size: 1.5rem; color: var(--moon); margin: 0 0 12px; }
.sheet-body { font-size: 0.95rem; color: var(--ink-soft); line-height: 1.6; }
.sheet-body ol { margin: 12px 0 0; padding-left: 4px; list-style: none; counter-reset: step; }
.sheet-body li { counter-increment: step; display: flex; align-items: flex-start; gap: 11px; margin-bottom: 12px; }
.sheet-body li::before {
  content: counter(step);
  flex: none;
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 600;
  color: var(--night-top);
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border-radius: 50%;
}
.sheet-body .ico { color: var(--gold-soft); vertical-align: -0.22em; }
.sheet-ok {
  width: 100%; margin-top: 18px;
  font-size: 0.95rem; font-weight: 600;
  color: var(--night-top);
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border: none; border-radius: 14px; padding: 13px; cursor: pointer;
  transition: transform 0.14s var(--ease);
}
.sheet-ok:active { transform: scale(0.98); }

/* Підтвердження «відпустити»: безпечний вибір помітніший */
.confirm-actions { display: flex; gap: 10px; margin-top: 20px; }
.confirm-keep, .confirm-let-go {
  flex: 1;
  padding: 13px;
  border-radius: 14px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.14s var(--ease), color 0.2s, border-color 0.2s, background 0.2s;
}
.confirm-keep {
  font-weight: 600;
  color: var(--night-top);
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border: none;
}
.confirm-let-go {
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-edge);
}
.confirm-let-go:hover { color: var(--horizon); border-color: var(--horizon); background: rgba(201, 105, 79, 0.1); }
.confirm-keep:active, .confirm-let-go:active { transform: scale(0.98); }

/* Підтвердження має бути над усім (зокрема над кошиком і лайтбоксом) */
#confirm { z-index: 220; }

/* ==========================================================================
   Кошик: нещодавно відпущені
   ========================================================================== */

.trash { position: fixed; inset: 0; z-index: 150; display: flex; align-items: flex-end; justify-content: center; }
.trash[hidden] { display: none; }
.trash-backdrop { position: absolute; inset: 0; background: rgba(10, 7, 20, 0.62); backdrop-filter: blur(3px); animation: fade 0.25s ease; }
.trash-panel {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0 12px calc(env(safe-area-inset-bottom, 0px) + 12px);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(46, 31, 70, 0.97), rgba(30, 21, 49, 0.98));
  border: 1px solid var(--card-edge-strong);
  border-radius: 22px;
  padding: 18px 16px;
  box-shadow: 0 -10px 50px rgba(0, 0, 0, 0.5);
  animation: sheet-up 0.32s var(--ease);
}
.trash-head { display: flex; align-items: center; justify-content: space-between; }
.trash-title { font-family: var(--serif); font-weight: 400; font-size: 1.4rem; color: var(--moon); margin: 0; }
.trash-x {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-faint); background: rgba(255, 255, 255, 0.05);
  border: none; border-radius: 50%; cursor: pointer;
}
.trash-x:hover { color: var(--ink); }
.trash-note { font-size: 0.8rem; color: var(--ink-faint); margin: 5px 0 14px; }
.trash-list { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }

.trash-item {
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-left: 3px solid var(--accent, var(--gold));
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  animation: fade-in 0.3s var(--ease);
}
.trash-item[data-realm="memory"] { --accent: var(--memory); }
.trash-item[data-realm="today"]  { --accent: var(--today); }
.trash-item[data-realm="future"] { --accent: var(--future); }
.trash-thumb { width: 46px; height: 46px; border-radius: 8px; overflow: hidden; flex: none; background: rgba(0, 0, 0, 0.22); }
.trash-thumb img, .trash-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.trash-body { flex: 1; min-width: 0; }
.trash-text { font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.trash-text.faint { color: var(--ink-faint); font-style: italic; }
.trash-meta { font-size: 0.73rem; color: var(--ink-faint); margin-top: 2px; }
.trash-actions { display: flex; gap: 6px; flex: none; }
.trash-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border-radius: 10px; cursor: pointer;
  border: 1px solid var(--card-edge);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-soft);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.trash-btn .ico { width: 1.15em; height: 1.15em; }
.trash-btn.restore:hover { color: var(--gold-soft); border-color: var(--card-edge-strong); }
.trash-btn.purge:hover { color: var(--horizon); border-color: var(--horizon); background: rgba(201, 105, 79, 0.1); }

/* --- Тихе підтвердження --------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--nav-h) + 18px);
  transform: translateX(-50%) translateY(16px);
  background: rgba(36, 25, 58, 0.95);
  border: 1px solid var(--card-edge-strong);
  color: var(--ink);
  font-size: 0.88rem;
  padding: 11px 20px;
  border-radius: 999px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  z-index: 110;
  max-width: 88vw;
  text-align: center;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ==========================================================================
   Планшет / десктоп: навігація переходить угору сегментованим перемикачем
   ========================================================================== */

@media (min-width: 680px) {
  :root { --nav-h: 0px; }

  .app {
    max-width: 620px;
    padding-top: calc(env(safe-area-inset-top, 0px) + 30px);
    padding-bottom: 48px;
  }

  /* Навігація стає сегментованим перемикачем у потоці сторінки (між capture і панелями) */
  .tabs {
    position: static;
    margin: 0 0 24px;
    gap: 5px;
    padding: 5px;
    border: 1px solid var(--card-edge);
    border-radius: 999px;
    background: rgba(20, 14, 34, 0.42);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
  .tab { flex-direction: row; gap: 7px; min-height: 0; padding: 10px 8px; font-size: 0.82rem; border-radius: 999px; }
  .tab .ico { width: 1.05em; height: 1.05em; }
  .tab.is-active,
  .tab[data-tab="memory"].is-active,
  .tab[data-tab="today"].is-active,
  .tab[data-tab="future"].is-active {
    color: var(--night-top);
    background: linear-gradient(180deg, var(--gold-soft), var(--gold));
    box-shadow: 0 4px 18px rgba(232, 185, 100, 0.32);
    font-weight: 600;
  }
  .tab.is-active .ico { transform: none; }

  .brand { font-size: 2.6rem; }
  /* На десктопі питання поміщається в один рядок — знімаємо вузьке обмеження */
  .prompt { font-size: 1.3rem; max-width: none; min-height: 1.5em; white-space: nowrap; }

  .pill:hover { transform: translateY(-1px); }
  .moment:hover { border-color: var(--card-edge-strong); }

  .toast { bottom: 28px; }
  .sheet { align-items: center; }
  .sheet-card { margin: 0 16px; }

  /* На ширшому екрані — кнопки за вмістом у вільному ряду (не половинками) */
  .footer-actions .ghost { flex: 0 0 auto; min-height: 40px; }
}

/* Дрібний телефон: трохи компактніше */
@media (max-width: 360px) {
  .pill span { font-size: 0.78rem; }
  .pill { gap: 5px; padding: 8px 4px; }
  .tab-label { font-size: 0.64rem; }
}

/* Тонке налаштування фокусу для клавіатури */
:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 2px; border-radius: 6px; }

/* Текстові поля не показують золоту рамку при написанні — у них уже є курсор */
.capture-input:focus,
.capture-input:focus-visible,
.slot-input:focus,
.slot-input:focus-visible { outline: none; }

/* ==========================================================================
   Фото / відео: додавання, перегляд у картках, лайтбокс
   ========================================================================== */

/* Кнопка додавання медіа — тиха й невимушена */
.attach {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-edge);
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 40px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s, transform 0.14s var(--ease);
}
.attach .ico { opacity: 0.85; }
.attach:hover, .attach:focus-visible {
  color: var(--ink);
  border-color: var(--card-edge-strong);
  background: rgba(255, 255, 255, 0.07);
}
.attach:active { transform: scale(0.97); }

/* Прев'ю обраних медіа перед збереженням */
.capture-media { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.capture-media[hidden] { display: none; }
.media-chip {
  position: relative;
  width: 74px;
  height: 74px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--card-edge);
  background: rgba(0, 0, 0, 0.22);
  animation: fade-in 0.3s var(--ease);
}
.media-chip img, .media-chip video { width: 100%; height: 100%; object-fit: cover; display: block; }
.chip-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(10, 7, 20, 0.72);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}
.chip-remove .ico { width: 0.78em; height: 0.78em; stroke-width: 2.3; }
.chip-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.chip-play .ico {
  fill: rgba(255, 255, 255, 0.92);
  stroke: none;
  width: 1.7em;
  height: 1.7em;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.55));
}

/* Медіа всередині картки моменту */
.moment-media {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-top: 11px;
}
.moment-media.single { grid-template-columns: 1fr; }
.moment-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  padding: 0;
  border: none;
  background: rgba(0, 0, 0, 0.22);
  cursor: pointer;
}
.moment-media.single .moment-thumb { aspect-ratio: 4 / 3; }
.moment-thumb img, .moment-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.moment-thumb .chip-play .ico { width: 2.1em; height: 2.1em; }
.moment-thumb[data-more]::after {
  content: attr(data-more);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 7, 20, 0.56);
  color: #fff;
  font-size: 1.3rem;
  font-weight: 600;
}

/* Лайтбокс */
.lightbox { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.lightbox[hidden] { display: none; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(6, 4, 14, 0.92); backdrop-filter: blur(4px); animation: fade 0.25s ease; }
.lightbox-close {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: 14px;
  z-index: 2;
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.2); }
.lightbox-body {
  position: relative;
  z-index: 1;
  max-width: 94vw;
  max-height: 88vh;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: sheet-up 0.3s var(--ease);
}
.lightbox-body img, .lightbox-body video {
  max-width: 94vw;
  max-height: 88vh;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

/* ==========================================================================
   Нові розділи: цього дня раніше, місяці, редагування, тяглість,
   пошук, налаштування, замок, привітання
   ========================================================================== */

/* --- Цього дня раніше ----------------------------------------------------- */
.onthisday {
  margin: -6px 0 22px;
  background: rgba(244, 207, 138, 0.06);
  border: 1px solid var(--card-edge);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fade-in 0.4s var(--ease);
}
.onthisday[hidden] { display: none; }
.otd-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-soft);
  margin-bottom: 8px;
}
.otd-head .ico { width: 1em; height: 1em; opacity: 0.85; }
.otd-x {
  margin-left: auto;
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-faint); background: transparent; border: none; cursor: pointer;
  border-radius: 50%;
}
.otd-x:hover { color: var(--ink); background: rgba(255,255,255,0.06); }
.otd-body { display: flex; flex-direction: column; gap: 6px; }
.otd-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 5px 4px;
  border-radius: 8px;
  font-size: 0.92rem;
}
.otd-item:hover { background: rgba(255,255,255,0.05); color: var(--ink); }
.otd-when {
  flex: none;
  font-size: 0.72rem;
  color: var(--gold-soft);
  min-width: 6.5em;
  letter-spacing: 0.02em;
}
.otd-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- Заголовок місяця у списках ------------------------------------------- */
.month-head {
  grid-column: 1 / -1;
  margin: 6px 2px 0;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.month-head:first-child { margin-top: 0; }

/* --- Дії картки: редагувати / відпустити ---------------------------------- */
.moment-actions { display: flex; align-items: center; gap: 4px; }
.moment-edit {
  font-size: 0.76rem;
  color: var(--ink-faint);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  margin: -6px 0;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}
.moment-edit:hover, .moment-edit:focus-visible { color: var(--gold-soft); background: rgba(244,207,138,0.1); }

/* Інлайн-редагування */
.edit-area {
  width: 100%;
  min-height: 4em;
  border: 1px solid var(--card-edge-strong);
  background: rgba(0, 0, 0, 0.18);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  border-radius: 10px;
  padding: 10px 12px;
  resize: none;
  outline: none;
}
.edit-bar { display: flex; gap: 9px; margin-top: 10px; }
.edit-save, .edit-cancel {
  flex: 1;
  padding: 10px;
  border-radius: 11px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.14s var(--ease);
}
.edit-save {
  font-weight: 600;
  color: var(--night-top);
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border: none;
}
.edit-cancel {
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-edge);
}
.edit-save:active, .edit-cancel:active { transform: scale(0.98); }

/* --- Тиха тяглість -------------------------------------------------------- */
.continuity { margin: 0 0 22px; text-align: center; }
.continuity[hidden] { display: none; }
.cont-row { display: flex; justify-content: center; gap: 6px; margin-bottom: 8px; }
.cont-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.cont-dot.on { background: var(--today); border-color: var(--today); box-shadow: 0 0 7px rgba(240,168,104,0.4); }
.cont-dot.today { outline: 2px solid rgba(240,168,104,0.5); outline-offset: 2px; }
.cont-note { font-size: 0.78rem; color: var(--ink-faint); margin: 0; }

/* --- Пошук ---------------------------------------------------------------- */
.search { position: fixed; inset: 0; z-index: 150; display: flex; align-items: flex-start; justify-content: center; }
.search[hidden] { display: none; }
.search-backdrop { position: absolute; inset: 0; background: rgba(10, 7, 20, 0.62); backdrop-filter: blur(3px); animation: fade 0.25s ease; }
.search-panel {
  position: relative;
  width: 100%;
  max-width: 540px;
  margin: calc(env(safe-area-inset-top, 0px) + 14px) 12px 12px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(46, 31, 70, 0.97), rgba(30, 21, 49, 0.98));
  border: 1px solid var(--card-edge-strong);
  border-radius: 20px;
  padding: 12px 12px 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  animation: sheet-up 0.3s var(--ease);
}
.search-head { display: flex; align-items: center; gap: 9px; padding: 4px 4px 10px; }
.search-head .ico { color: var(--gold-soft); opacity: 0.85; }
.search-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.06rem;
  outline: none;
}
.search-input::placeholder { color: var(--ink-faint); }
.search-x {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-faint); background: rgba(255,255,255,0.05);
  border: none; border-radius: 50%; cursor: pointer;
}
.search-x:hover { color: var(--ink); }
.search-tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px 10px; border-bottom: 1px solid rgba(244,207,138,0.1); }
.search-tags[hidden] { display: none; }
.tag-chip {
  font-size: 0.78rem;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-edge);
  border-radius: 999px;
  padding: 5px 11px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.tag-chip:hover { color: var(--ink); border-color: var(--card-edge-strong); }
.tag-chip.on { color: var(--night-top); background: linear-gradient(180deg, var(--gold-soft), var(--gold)); border-color: transparent; font-weight: 600; }
.search-results { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 12px 2px 0; -webkit-overflow-scrolling: touch; }
.search-hint { text-align: center; color: var(--ink-faint); font-family: var(--serif); font-style: italic; padding: 24px 12px; }
.search-item {
  text-align: left;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-left: 3px solid var(--accent, var(--gold));
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.search-item[data-realm="memory"] { --accent: var(--memory); }
.search-item[data-realm="today"]  { --accent: var(--today); }
.search-item[data-realm="future"] { --accent: var(--future); }
.search-item:hover { border-color: var(--card-edge-strong); background: rgba(255,255,255,0.05); }
.search-item-text {
  color: var(--ink);
  font-size: 0.96rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.search-item-meta { font-size: 0.73rem; color: var(--ink-faint); margin-top: 4px; }

/* --- Налаштування (всередині .sheet) -------------------------------------- */
.set-block { margin-top: 18px; }
.set-block:first-child { margin-top: 4px; }
.set-h {
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-soft);
  margin: 0 0 8px;
}
.set-line { font-size: 0.92rem; margin: 0 0 8px; }
.set-line.ok { color: var(--ink); }
.set-line.ok::before { content: '✓ '; color: var(--memory); }
.set-line.warn { color: var(--gold-soft); }
.set-sub { font-size: 0.84rem; color: var(--ink-faint); margin: 0 0 10px; line-height: 1.5; }
.set-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 11px;
  font-size: 0.9rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-edge);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.set-btn:hover { border-color: var(--card-edge-strong); background: rgba(255,255,255,0.08); }
.set-btn.ghost-danger { color: var(--horizon); border-color: rgba(201,105,79,0.4); }
.set-btn.ghost-danger:hover { background: rgba(201,105,79,0.12); }
.set-link { display: block; text-align: center; text-decoration: none; color: var(--gold-soft); }
.set-link:hover { background: rgba(232,185,100,0.12); border-color: var(--card-edge-strong); }
.set-input {
  width: 100%;
  margin-top: 8px;
  padding: 11px 13px;
  font-size: 1rem;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--card-edge);
  border-radius: 12px;
  outline: none;
}
.set-input:focus { border-color: var(--card-edge-strong); }
.set-themes { display: flex; gap: 8px; }
.set-chip {
  flex: 1;
  padding: 10px 6px;
  font-size: 0.82rem;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-edge);
  border-radius: 12px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.set-chip.on { color: var(--night-top); background: linear-gradient(180deg, var(--gold-soft), var(--gold)); border-color: transparent; font-weight: 600; }

/* --- Привітання ----------------------------------------------------------- */
.welcome-list { margin: 12px 0; padding-left: 4px; list-style: none; }
.welcome-list li { margin-bottom: 8px; color: var(--ink-soft); }
.welcome-list strong { color: var(--gold-soft); font-weight: 600; }

/* --- Екран замка ---------------------------------------------------------- */
.lockscreen {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, var(--night-top), var(--night-mid));
}
.lockscreen[hidden] { display: none; }
.lock-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
  animation: sheet-up 0.4s var(--ease);
}
.lock-ico {
  width: 46px; height: 46px;
  fill: none; stroke: var(--gold-soft); stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 0 12px rgba(243, 177, 95, 0.4));
  margin-bottom: 14px;
}
.lock-title { font-family: var(--serif); font-weight: 400; font-size: 1.6rem; color: var(--moon); margin: 0 0 6px; }
.lock-sub { font-size: 0.9rem; color: var(--ink-faint); margin: 0 0 20px; }
.lock-input {
  width: 100%;
  padding: 13px 15px;
  font-size: 1.06rem;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--card-edge-strong);
  border-radius: 14px;
  outline: none;
  text-align: center;
}
.lock-input:focus { border-color: var(--gold); }
.lock-ok {
  width: 100%;
  margin-top: 12px;
  padding: 13px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--night-top);
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border: none; border-radius: 14px; cursor: pointer;
  transition: transform 0.14s var(--ease);
}
.lock-ok:active { transform: scale(0.98); }
.lock-error { color: var(--horizon); font-size: 0.85rem; margin: 12px 0 0; }
.lock-error[hidden] { display: none; }
