/* Минимализм in the manner of Apple and Linear: black, white and greys, hairlines instead of
   fills and shadows, tight confident type, numbers that line up, quick quiet motion. */

:root {
  --bg: #ffffff;
  --surface: #fafafa;
  --raised: #ffffff;
  --text: #0a0a0a;
  --muted: #737373;
  --faint: #a3a3a3;
  --line: #e5e5e5;
  --line-strong: #d4d4d4;
  --ink: #0a0a0a;
  --on-ink: #ffffff;
  --accent: #4f5bd5;
  --danger: #dc2626;
  --press: rgba(0, 0, 0, 0.04);
  --chrome: #ffffff;
  --radius: 10px;
  --font: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --safe-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
}
[data-scheme="dark"] {
  --bg: #0a0a0a;
  --surface: #111111;
  --raised: #161616;
  --text: #ededed;
  --muted: #a1a1a1;
  --faint: #6b6b6b;
  --line: #222222;
  --line-strong: #333333;
  --ink: #ededed;
  --on-ink: #0a0a0a;
  --accent: #8b93f8;
  --danger: #f87171;
  --press: rgba(255, 255, 255, 0.05);
  --chrome: #0a0a0a;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15px/1.45 var(--font); letter-spacing: -0.006em; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
  font-feature-settings: "cv11", "ss01";
}
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; }
h1, h2, h3, p { margin: 0; }
.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round; }

.app { min-height: var(--tg-viewport-stable-height, 100vh); display: flex; flex-direction: column; }
.page { flex: 1; display: flex; flex-direction: column; gap: 14px;
  padding: 8px 20px calc(84px + var(--safe-bottom)); }
.app:not(:has(.tabbar)) .page { padding-bottom: calc(24px + var(--safe-bottom)); }

/* Header */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(var(--safe-top) + 14px) 20px 12px; background: var(--bg); }
.topbar__text { flex: 1; min-width: 0; }
.topbar__title { font-size: 24px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.15; }
.topbar__sub { font-size: 13px; color: var(--muted); }
.icon-btn { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; flex: none;
  color: var(--muted); border: 1px solid var(--line); transition: background .12s, color .12s; }
.icon-btn:active { background: var(--press); color: var(--text); }
.icon-btn--filled { width: 30px; height: 30px; border-radius: 7px; border-color: var(--line-strong); color: var(--text); }
.icon-btn--filled .i { width: 16px; height: 16px; stroke-width: 2; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--surface); border: 1px solid var(--line); font-size: 13px; font-weight: 600; }

/* Cards: a hairline, no shadow; the main card is inverted */
.card { background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card--accent { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.hero__label { font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .08em; opacity: .6; }
.hero__value { font-size: 44px; font-weight: 600; letter-spacing: -0.045em; line-height: 1.1; margin: 6px 0 16px;
  font-variant-numeric: tabular-nums; }
.hero__value small { font-size: 22px; font-weight: 500; opacity: .5; }
.hero__hint { font-size: 13px; opacity: .6; margin-top: 10px; }
.progress { height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.card--accent .progress { background: color-mix(in srgb, var(--on-ink) 18%, transparent); }
.progress > span { display: block; height: 100%; background: currentColor; }

.section-title { font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); padding-top: 14px; margin-bottom: -4px; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--raised); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; transition: background .12s; }
.row + .row { border-top: 1px solid var(--line); }
.row:active { background: var(--press); }
.row__icon { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; flex: none;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.row__icon .i { width: 18px; height: 18px; }
.row__body { flex: 1; min-width: 0; }
.row__title { font-weight: 500; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; }
.row__sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__end { display: flex; align-items: center; gap: 10px; color: var(--faint); }
.price { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.chev { width: 16px; height: 16px; }
.badge { font-size: 11px; font-weight: 500; padding: 0 6px; line-height: 18px; border-radius: 5px;
  color: var(--accent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent); }

/* Segmented control, chips */
.segmented { display: flex; padding: 3px; gap: 3px; border-radius: 9px; background: var(--surface); border: 1px solid var(--line); }
.segmented > * { flex: 1; height: 30px; border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--muted);
  transition: background .12s, color .12s; }
.segmented > .is-active { background: var(--raised); color: var(--text); box-shadow: 0 0 0 1px var(--line-strong), 0 1px 2px rgba(0, 0, 0, .06); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chip { height: 30px; padding: 0 12px; border-radius: 8px; white-space: nowrap; font-size: 13px; font-weight: 500;
  color: var(--muted); border: 1px solid var(--line); transition: background .12s, color .12s, border-color .12s; }
.chip.is-active { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }

/* Fields */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 13px; font-weight: 500; }
.input { width: 100%; min-height: 40px; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--bg); font-size: 16px; outline: none; resize: none; transition: border-color .12s, box-shadow .12s; }
.input::placeholder { color: var(--faint); }
.input:focus { border-color: var(--text); box-shadow: 0 0 0 3px var(--press); }
.search { display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--faint); }
.search .i { width: 16px; height: 16px; }
.search .input { border: 0; background: none; padding: 0; min-height: 40px; box-shadow: none; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 28px; font-weight: 500; }
.switch { appearance: none; -webkit-appearance: none; margin: 0; flex: none; position: relative; cursor: pointer;
  width: 38px; height: 22px; border-radius: 11px; background: var(--line-strong); transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .15s ease-out; }
.switch:checked { background: var(--ink); }
.switch:checked::after { transform: translateX(16px); background: var(--on-ink); }

/* Buttons */
.actions { display: flex; flex-direction: column; gap: 8px; }
.actions__row { display: flex; gap: 8px; }
.actions__row > .btn { flex: 1; }
.btn { height: 44px; padding: 0 16px; border-radius: 8px; font-size: 15px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
  transition: opacity .12s, background .12s; }
.btn:active { opacity: .8; }
.btn:disabled { opacity: .4; }
.btn--primary { background: var(--ink); color: var(--on-ink); }
.btn--secondary { border: 1px solid var(--line-strong); background: var(--raised); }
.btn--secondary:active, .btn--ghost:active { background: var(--press); opacity: 1; }
.btn--ghost { color: var(--muted); }
.btn--danger { color: var(--danger); }
.btn--block { width: 100%; }

/* Empty state: a dashed outline where the content will be */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 32px 24px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty__icon { color: var(--faint); margin-bottom: 6px; }
.empty__icon .i { width: 28px; height: 28px; stroke-width: 1.3; }
.empty__title { font-size: 15px; font-weight: 600; }
.empty__text { color: var(--muted); font-size: 13px; max-width: 260px; margin-bottom: 10px; }

/* Bottom navigation */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex;
  padding: 8px 12px calc(8px + var(--safe-bottom)); border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 500;
  color: var(--faint); padding: 4px 0; transition: color .12s; }
.tab.is-active { color: var(--text); }
.tab .i { width: 22px; height: 22px; }

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

/* app */
.topbar__title { display: flex; align-items: center; gap: 8px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.dot--on { background: var(--accent); }
#back-btn { display: none; }
.app.is-detail #back-btn { display: grid; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mt { margin-top: 2px; }
.hero__value--sm { font-size: 38px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 14px;
  border-top: 1px solid color-mix(in srgb, var(--on-ink) 18%, transparent); padding-top: 12px; }
.stat__n { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat__l { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .55; }
.row__sub--clamp { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; }
.row__end .badge { white-space: nowrap; }
.loading { padding: 28px 4px; text-align: center; color: var(--muted); font-size: 14px; }
.error { padding: 16px; border: 1px solid var(--danger); border-radius: var(--radius);
  color: var(--danger); font-size: 14px; }
.media-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.media-card { display: flex; flex-direction: column; gap: 6px; padding: 12px; text-align: left;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--raised); min-height: 92px; }
.media-card:active { background: var(--press); }
.media-card__top { display: flex; align-items: center; justify-content: space-between; gap: 6px;
  color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.media-card__name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.media-card__meta { font-size: 12px; color: var(--muted); }
.player { display: flex; flex-direction: column; gap: 10px; }
.player img, .player video { width: 100%; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); display: block; }
.player video { max-height: 62vh; }
.player audio { width: 100%; }
.player__caption { font-size: 13px; color: var(--muted); }
.media-badge { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.diff { display: flex; flex-direction: column; gap: 6px; }
.diff__label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.diff__text { white-space: pre-wrap; word-break: break-word; font-size: 14px; line-height: 1.5;
  border-left: 2px solid var(--line-strong); padding: 2px 0 2px 10px; }
.diff__text--add { border-color: var(--accent); }
.diff__text--del { border-color: var(--danger); }
.ins { color: var(--accent); }
.del { color: var(--danger); text-decoration: line-through; }
.message-text { white-space: pre-wrap; word-break: break-word; font-size: 15px; line-height: 1.5; }
.meta-list { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.meta-list b { color: var(--text); font-weight: 500; }
.divider { height: 1px; background: var(--line); margin: 2px 0; }
.settings-hint { font-size: 13px; color: var(--muted); line-height: 1.45; }
.settings-hint b { color: var(--text); font-weight: 500; }
.chat-row .row__icon { font-size: 11px; font-weight: 600; color: var(--text); }
.chat-row .switch { margin-left: auto; }
.toast { position: fixed; left: 50%; bottom: calc(94px + var(--safe-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--on-ink); border-radius: 8px; padding: 10px 14px; font-size: 13px;
  z-index: 20; opacity: 0; pointer-events: none; transition: opacity .15s; max-width: calc(100% - 40px);
  text-align: center; }
.toast.is-on { opacity: 1; }
.privacy { border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 14px;
  font-size: 13px; color: var(--muted); line-height: 1.5; }
.privacy b { color: var(--text); font-weight: 500; }
.section-note { font-size: 12px; color: var(--faint); margin-top: -8px; }
.skeleton-row { height: 58px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); margin-bottom: 8px; opacity: .55; }
.pager { margin-top: 2px; }
.player img { max-height: 70vh; object-fit: contain; }
.player video.note { aspect-ratio: 1; width: 68%; border-radius: 50%; margin: 0 auto; object-fit: cover; }
