/* Хаб. Цвет — Radix Colors 3.0.0 (olive — холст, остальные шкалы — приложения).
   Смелость в одном месте: карточка «Сейчас». Всё вокруг тихое. */

:root {
  --bg: #fcfdfc;          /* olive-1 */
  --bg-2: #f8faf8;        /* olive-2 */
  --wash: #eff1ef;        /* olive-3 */
  --wash-2: #e7e9e7;      /* olive-4 */
  --line: #d7dad7;        /* olive-6 */
  --muted: #60655f;       /* olive-11 */
  --ink: #1d211c;         /* olive-12 */
  --new: #ffc53d;         /* amber-9 */
  --glass: color-mix(in oklab, #fcfdfc 72%, transparent);

  /* Radix step 9 — сплошные цвета, одинаковые в обеих темах; amber и sky требуют тёмного текста */
  --tomato: #e54d2e; --iris: #5b5bd6; --jade: #29a383; --amber: #ffc53d; --cyan: #00a2c7;
  --grass: #46a758; --sky: #7ce2fe; --orange: #f76b15; --violet: #6e56cf; --pink: #d6409f;
  --ink-on-light-hue: #1d211c;

  --r-xl: 28px;
  --r-lg: 18px;
  --r-md: 14px;
  --pad: 20px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.4, .64, 1);

  --font: "Onest", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111210; --bg-2: #181917; --wash: #212220; --wash-2: #282a27; --line: #383a36;
    --muted: #afb5ad; --ink: #eceeec;
    --glass: color-mix(in oklab, #181917 70%, transparent);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.45 var(--font);
  font-feature-settings: "tnum" 0, "ss01";
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
button, input, a { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { -webkit-tap-highlight-color: transparent; }
svg { width: 20px; height: 20px; flex: none; }
:focus-visible { outline: 2px solid var(--iris); outline-offset: 3px; border-radius: 8px; }
[hidden] { display: none !important; }

/* ---------- главная ---------- */

.home {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) var(--pad) calc(env(safe-area-inset-bottom) + 112px);
}

.top { display: flex; align-items: center; justify-content: space-between; min-height: 40px; }
.date { margin: 0; font-size: 15px; font-weight: 500; color: var(--muted); }
.date::first-letter { text-transform: uppercase; }
.me {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--wash); color: var(--muted);
  font-size: 14px; font-weight: 600;
  display: grid; place-items: center;
}

/* Карточка «Сейчас» — единственное громкое место экрана */
.focus { margin-top: 14px; }
.card {
  --hue: var(--iris);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: var(--r-xl);
  padding: 22px 22px 20px;
  min-height: 264px;
  display: flex; flex-direction: column;
  color: #fff;
  background:
    radial-gradient(120% 90% at 100% 0%, color-mix(in oklab, #fff 26%, transparent), transparent 60%),
    radial-gradient(90% 80% at 0% 100%, color-mix(in oklab, #000 30%, transparent), transparent 70%),
    var(--hue);
  view-transition-name: card;
}
.card::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: var(--grain); opacity: .32; mix-blend-mode: soft-light;
}
.card-why { margin: 0; font-size: 15px; font-weight: 500; opacity: .86; display: flex; align-items: center; gap: 8px; }
.card-why svg { width: 18px; height: 18px; }
.card-title {
  margin: auto 0 0;
  padding-top: 28px;
  font-size: clamp(28px, 8.4vw, 40px);
  line-height: 1.08;
  font-weight: 650;
  letter-spacing: -0.022em;
  text-wrap: balance;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-actions { display: flex; align-items: center; gap: 6px; margin-top: 20px; }
.open-btn {
  flex: 1;
  height: 52px; border-radius: 26px;
  background: #fff; color: #1d211c;
  font-size: 17px; font-weight: 600;
  transition: transform .25s var(--spring);
}
.later-btn { height: 52px; padding: 0 18px; border-radius: 26px; font-size: 16px; font-weight: 500; color: #fff; opacity: .9; }
.open-btn:active, .later-btn:active { transform: scale(.96); }

.card-note { margin: 10px 0 0; font-size: 17px; line-height: 1.35; opacity: .86; max-width: 34ch; }
.card.ink-dark, .glyph.ink-dark { color: var(--ink-on-light-hue); }
.card.ink-dark .open-btn { background: var(--ink-on-light-hue); color: #fff; }
.card.ink-dark .later-btn { color: var(--ink-on-light-hue); }
.card.calm { color: var(--ink); background: var(--wash); min-height: 200px; }
.card.calm::after { opacity: .5; mix-blend-mode: multiply; }
.card.calm .open-btn { background: var(--ink); color: var(--bg); }
.card.calm .later-btn { color: var(--muted); }

.queue { display: flex; align-items: center; gap: 10px; margin: 14px 0 0; min-height: 22px; font-size: 15px; color: var(--muted); }
.dots { display: flex; gap: 5px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); opacity: .45; transition: width .3s var(--spring); }
.dots i.now { width: 20px; border-radius: 4px; opacity: 1; }

/* Приложения: знакомая сетка иконок, как на домашнем экране */
.apps { margin-top: 34px; }
.apps h2, .group h3 { margin: 0 0 14px; font-size: 20px; font-weight: 650; letter-spacing: -0.012em; }
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px 10px; }
.app { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.glyph {
  --hue: var(--iris);
  position: relative; isolation: isolate; overflow: hidden;
  width: 64px; height: 64px; border-radius: 18px;
  display: grid; place-items: center;
  color: #fff;
  background:
    radial-gradient(110% 90% at 20% 0%, color-mix(in oklab, #fff 30%, transparent), transparent 62%),
    var(--hue);
  transition: transform .3s var(--spring);
}
.glyph::after { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--grain); opacity: .3; mix-blend-mode: soft-light; }
.glyph svg { width: 28px; height: 28px; stroke-width: 1.75; }
.app:active .glyph { transform: scale(.9); }
.app-name { font-size: 13px; line-height: 1.2; font-weight: 500; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  position: absolute; top: -3px; right: -3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--new); border: 3px solid var(--bg);
}
.app .wrap { position: relative; }

.archive {
  margin-top: 34px; width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-radius: var(--r-lg);
  background: var(--bg-2);
  font-size: 17px; font-weight: 500;
}
.archive-n { color: var(--muted); font-weight: 400; }
.archive:active { background: var(--wash); }

/* ---------- нижний поиск ---------- */

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 12px var(--pad) calc(env(safe-area-inset-bottom) + 12px);
  pointer-events: none;
}
.find {
  pointer-events: auto;
  max-width: 520px; margin: 0 auto;
  width: 100%; height: 54px; border-radius: 27px;
  display: flex; align-items: center; gap: 10px; padding: 0 20px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(1.6); backdrop-filter: blur(20px) saturate(1.6);
  box-shadow: 0 0 0 .5px color-mix(in oklab, var(--ink) 14%, transparent), 0 8px 30px color-mix(in oklab, #000 12%, transparent);
  color: var(--muted); font-size: 16px;
}
.find svg { color: var(--ink); }

/* ---------- лист поиска ---------- */

.sheet {
  position: fixed; inset: 0; z-index: 10;
  background: var(--bg);
  display: flex; flex-direction: column;
  animation: rise .38s var(--ease);
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.sheet-head {
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) var(--pad) 12px;
}
.field {
  flex: 1; display: flex; align-items: center; gap: 10px;
  height: 46px; padding: 0 14px; border-radius: 23px; background: var(--wash);
}
.field input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 17px; }
.field input::-webkit-search-cancel-button { display: none; }
.field svg { color: var(--muted); width: 18px; height: 18px; }
.text-btn { font-size: 17px; font-weight: 600; color: var(--iris); padding: 8px 2px; }
.sheet-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px var(--pad) calc(env(safe-area-inset-bottom) + 24px); }
.group { margin-top: 22px; }
.group h3 { font-size: 15px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.row {
  width: 100%; text-align: left;
  display: grid; grid-template-columns: 10px 1fr; gap: 12px; align-items: start;
  padding: 13px 0;
  border-bottom: .5px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; background: var(--c); opacity: .9; }
.row .dot.new { box-shadow: 0 0 0 3px color-mix(in oklab, var(--new) 55%, transparent); background: var(--new); }
.row-title { display: block; font-size: 17px; line-height: 1.3; font-weight: 500; }
.row-sub { display: block; margin-top: 3px; font-size: 14px; color: var(--muted); }
.row:active { opacity: .6; }
.empty { margin: 48px 8px; text-align: center; color: var(--muted); font-size: 16px; }

/* ---------- приложение внутри хаба ---------- */

.viewer { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: flex; flex-direction: column; view-transition-name: card; }
.viewer-bar {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 6px) 12px 6px 6px;
  border-bottom: .5px solid var(--line);
  background: var(--bg);
}
.back { display: flex; align-items: center; gap: 2px; height: 40px; padding: 0 10px 0 4px; font-size: 17px; font-weight: 500; color: var(--iris); }
.back svg { width: 24px; height: 24px; }
.viewer-title { margin: 0; text-align: center; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; color: var(--muted); }
.viewer iframe { flex: 1; width: 100%; border: 0; background: #fff; }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); z-index: 30;
  transform: translateX(-50%);
  padding: 12px 18px; border-radius: 22px;
  background: var(--ink); color: var(--bg); font-size: 15px; font-weight: 500;
  animation: rise .3s var(--ease);
}

/* ---------- первое появление: одна связная сцена ---------- */

.home.enter .card { animation: card-in .7s var(--ease) both; }
.home.enter .queue { animation: fade .5s .25s both; }
.home.enter .app { animation: pop .5s var(--spring) both; animation-delay: calc(.28s + var(--i) * 28ms); }
@keyframes card-in { from { transform: translateY(18px) scale(.98); opacity: 0; } }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

::view-transition-old(card), ::view-transition-new(card) { animation-duration: .42s; animation-timing-function: var(--ease); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  ::view-transition-group(*) { animation: none !important; }
}

@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(5, 1fr); }
}
