/* Mini App бота поздравлений. Система как на личном лендинге xna1d.com:
   эспрессо-фон, субтитровый текст, жёлтый панч только на главном действии,
   заголовки Bitcrusher, текст Golos. Единственная анимация - титр собирается по словам. */

@font-face {
  font-family: "Bitcrusher";
  src: url("fonts/bitcrusher-cd-bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Golos Text";
  src: url("fonts/golos-text-cyrillic-wght.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Golos Text";
  src: url("fonts/golos-text-latin-wght.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --espresso: #170e08;
  --roast: #2b1c12;
  --glow: #6a3d22;
  --paper: #f7f5f0;
  --signal: #f0b427;
  --lens: #e8ab92;
  --muted: #c2b1a2;
  --line: rgba(247, 245, 240, .08);
  --display: "Bitcrusher", "Oswald", "Arial Narrow", sans-serif;
  --text: "Golos Text", -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 14px;
  --tap: 44px;
}

* { box-sizing: border-box; }
html { background: var(--espresso); color-scheme: dark; }
body {
  margin: 0 auto;
  max-width: 640px;
  min-height: 100vh;
  padding: 16px 16px calc(88px + env(safe-area-inset-bottom));
  background: var(--espresso);
  color: var(--paper);
  font: 400 1rem/1.5 var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

/* ---------- титр ---------- */
.title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.6rem, 13vw, 3.6rem);
  line-height: .9;
  letter-spacing: .01em;
  margin: 6px 0 14px;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .35);
  overflow-wrap: anywhere;
}
.title-sm { font-size: clamp(2rem, 10vw, 2.8rem); }
.title .w { display: inline-block; margin-right: .22em; animation: word-in .5s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(var(--i) * 90ms); }
.title .punch { color: var(--signal); }
@keyframes word-in { from { opacity: 0; transform: translateY(.35em); } to { opacity: 1; transform: none; } }

.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .9rem; margin: .5rem 0 0; }
.meta { color: var(--muted); font-size: .9rem; }
.name { font-weight: 600; }
.error { color: var(--lens); }

/* ---------- календарь ---------- */
.banner {
  display: block; width: 100%; min-height: var(--tap); margin: 0 0 16px; padding: 12px 14px;
  text-align: left; color: var(--lens); background: var(--roast);
  border: 1px solid var(--glow); border-radius: var(--radius);
}
.day { margin: 0 0 22px; }
.card {
  display: block; width: 100%; min-height: var(--tap); margin: 0 0 10px; padding: 14px;
  text-align: left; background: var(--roast); border: 1px solid transparent; border-radius: var(--radius);
  transition: transform .12s ease, border-color .12s ease;
}
.card:hover { border-color: var(--glow); }
.card:active, .row:active, .btn:active { transform: scale(.98); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.preview { margin: 8px 0 0; opacity: .92; white-space: pre-wrap; overflow-wrap: anywhere; }

.toolbar {
  position: sticky; top: 0; z-index: 2;
  display: flex; gap: 8px; margin: 8px -16px 12px; padding: 8px 16px;
  background: var(--espresso);
}
.month-title { font-family: var(--display); font-weight: 700; font-size: 1.6rem; color: var(--lens); margin: 18px 0 6px; }
.row {
  display: grid; grid-template-columns: 5.6rem minmax(0, 1fr) auto; align-items: center; gap: 10px;
  width: 100%; min-height: 56px; padding: 10px 0;
  text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line);
}
.row-date { color: var(--muted); font-size: .9rem; }
.row-main { display: flex; flex-direction: column; min-width: 0; }
.row-main > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.is-never { opacity: .55; }

.pill { flex: none; padding: 3px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; color: var(--muted); background: rgba(247, 245, 240, .08); }
.pill-draft { color: var(--signal); background: rgba(240, 180, 39, .14); }
.pill-approved { color: var(--lens); background: rgba(232, 171, 146, .16); }
.pill-sent { color: var(--paper); background: rgba(247, 245, 240, .12); }
.pill-failed { color: var(--lens); background: rgba(232, 171, 146, .24); }

/* ---------- поля и кнопки ---------- */
.input {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  background: var(--roast); border: 1px solid rgba(247, 245, 240, .12); border-radius: 12px;
}
.input:focus { border-color: var(--signal); outline: none; }
.select { width: auto; min-width: 6.5rem; }
.btn {
  min-height: var(--tap); padding: 0 16px; white-space: nowrap;
  background: var(--roast); border: 1px solid rgba(247, 245, 240, .16); border-radius: 12px;
  transition: transform .12s ease;
}
.btn:disabled { opacity: .5; }
.btn-primary { width: 100%; margin-top: 8px; font-weight: 700; color: var(--espresso); background: var(--signal); border-color: var(--signal); }
.btn-ghost { background: transparent; }
.icon-btn { flex: none; min-width: var(--tap); min-height: var(--tap); color: var(--muted); background: none; border: 1px solid rgba(247, 245, 240, .12); border-radius: 12px; }

/* ---------- редактор ---------- */
.editor-head { margin: 0 0 12px; }
.editor-info { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; color: var(--muted); }
.bio { margin: 10px 0 0; }
.chat { margin: 12px 0; padding: 4px 12px 10px; background: var(--roast); border-radius: var(--radius); }
.chat summary { display: flex; align-items: center; min-height: var(--tap); color: var(--lens); cursor: pointer; }
.bubble { max-width: 85%; margin: 6px 0; padding: 8px 10px; background: rgba(247, 245, 240, .07); border-radius: 12px 12px 12px 4px; }
.bubble.me { margin-left: auto; background: rgba(240, 180, 39, .12); border-radius: 12px 12px 4px 12px; }
.bubble-text { display: block; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble-time { display: block; margin-top: 2px; font-size: .72rem; color: var(--muted); }
.messages { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.message-row { display: flex; align-items: flex-start; gap: 6px; }
.message { min-height: 76px; line-height: 1.45; resize: vertical; }
.screen > .btn-ghost:first-child { margin-bottom: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

/* ---------- история и настройки ---------- */
.segmented { display: flex; gap: 3px; margin: 8px 0; padding: 3px; background: var(--roast); border-radius: 12px; }
.seg {
  flex: 1; min-height: var(--tap); padding: 0 6px; white-space: nowrap; font-size: .9rem; font-weight: 600;
  color: var(--muted); background: none; border: 0; border-radius: 10px;
}
.seg[aria-pressed="true"] { color: var(--paper); background: var(--espresso); }
.history-item { border-bottom: 1px solid var(--line); }
.history-item summary {
  display: grid; grid-template-columns: 5.6rem minmax(0, 1fr) auto; align-items: center; gap: 10px;
  min-height: 52px; list-style: none; cursor: pointer;
}
.history-item summary::-webkit-details-marker { display: none; }
.row-year { display: block; }
.history-item .preview:last-child { margin-bottom: 12px; }
.group { margin: 0 0 26px; }
.group-title { margin: 0 0 6px; font-size: .8rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-inline { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--line); }
.switch { width: 48px; height: 28px; accent-color: var(--signal); }

/* ---------- импорт .vcf ---------- */
.import-summary { margin: 0 0 8px; }
.import-group { margin: 0 0 8px; }
.import-row {
  display: grid; grid-template-columns: var(--tap) minmax(0, 1fr) auto; align-items: center; gap: 8px;
  min-height: 56px; padding: 6px 0; border-bottom: 1px solid var(--line); cursor: pointer;
}
.import-row:active { background: var(--roast); }
.check { width: 22px; height: 22px; margin: 0 auto; accent-color: var(--signal); }
.import-date { color: var(--muted); font-size: .9rem; text-align: right; }
.row-main > .import-change, .row-main > .import-note { white-space: normal; }
.import-change { font-size: .9rem; color: var(--lens); }
.import-note { font-size: .85rem; color: var(--muted); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- навигация, шторки, тост ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; padding-bottom: env(safe-area-inset-bottom);
  background: rgba(23, 14, 8, .94); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
}
.tab { flex: 1; min-height: 56px; font-weight: 600; color: var(--muted); background: none; border: 0; }
.tab[aria-current="page"] { color: var(--signal); }
.sheet-backdrop { position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; background: rgba(0, 0, 0, .55); animation: fade .18s ease both; }
.sheet {
  display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 640px; margin: 0 auto;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  background: var(--roast); border-radius: 20px 20px 0 0; animation: up .22s cubic-bezier(.2, .7, .2, 1) both;
}
.sheet .input { background: var(--espresso); }
.sheet-title { margin: 0; font-family: var(--display); font-size: 2rem; line-height: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { opacity: 0; transform: translateY(24px); } }
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 20;
  padding: 12px 14px; font-weight: 600; color: var(--espresso); background: var(--paper);
  border-radius: 12px; box-shadow: 0 8px 30px rgba(0, 0, 0, .4);
}
.empty { padding-top: 18vh; }

@media (prefers-reduced-motion: reduce) {
  .title .w, .sheet, .sheet-backdrop { animation: none; }
  .card, .btn { transition: none; }
}
