/* Щанкин — классический Instagram 2012 (Android): синий топ-бар, стальные карточки, нижняя навигация */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #d3dce2;            /* стально-голубой фон страницы */
  --card: #ffffff;
  --line: #c2ccd3;          /* внешние границы карточек */
  --hairline: #e9edef;      /* внутренние линии */
  --text: #29333a;
  --muted: #66717a;         /* контраст ≥4.5:1 на белом */
  --muted2: #5b6670;
  --blue: #3f729b;          /* фирменный синий ссылок/имён */
  --bar: #517fa4;           /* топ-бар */
  --bar-dark: #4a7396;
  --bar-edge: #3d6280;
  --nav: #2b3136;           /* нижняя панель */
  --nav-ico: #9aa4ab;
  --nav-active: #5b93bd;
  --accent: #e1306c;
  --radius: 2px;
}

/* hidden атрибут всегда сильнее авторских display-правил */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

.page { max-width: 500px; margin: 0 auto; }

/* видимая клавиатурная фокусировка */
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--nav-active);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---------- верхняя панель как в старой инсте (уезжает при скролле) ---------- */
.ig-topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 48px; padding: 0 6px 0 14px;
  background: linear-gradient(180deg, #5f8dad, var(--bar-dark));
  border-bottom: 1px solid var(--bar-edge);
  box-shadow: 0 1px 3px rgba(40, 60, 76, .25);
}
.ig-brand {
  display: flex; align-items: center; gap: 8px; min-width: 0;
}
.ig-logo-ico {
  width: 30px; height: 30px; flex: 0 0 auto;
  filter: drop-shadow(0 1px 1px rgba(30, 50, 66, .35));
  user-select: none;
}
.ig-logo {
  font-family: Pacifico, "Segoe Script", "Snell Roundhand", cursive;
  font-size: 23px; line-height: 1;
  color: #fff; text-shadow: 0 1px 1px rgba(30, 50, 66, .45);
  transform: translateY(-1px);
  user-select: none;
}
.ig-refresh {
  width: 42px; height: 42px; border: 0; background: none; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #eaf1f6; cursor: pointer; transition: background-color .16s ease;
}
.ig-refresh:hover { background: rgba(255, 255, 255, .14); }
.ig-refresh:active { background: rgba(255, 255, 255, .24); }
.ig-refresh svg { width: 21px; height: 21px; }

.header-sub {
  text-align: center; padding: 8px 12px 2px;
  font-size: 13px; color: var(--muted2);
}
.today-badge { color: var(--blue); font-weight: 700; }
.countdown { color: var(--muted2); }

/* ---------- live slot ---------- */
.live-slot { padding: 6px 0 2px; }
.live-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--blue); font-weight: 700; padding: 0 2px 5px;
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--nav-active);
  animation: pulse 1.6s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
.live-card { box-shadow: 0 0 0 2px var(--nav-active) inset; }
.live-card.fresh { animation: slidein .45s ease-out; }
@keyframes slidein {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.live-placeholder { color: var(--muted); text-align: center; padding: 18px; }

/* ---------- лента ---------- */
.feed { margin-top: 6px; }
.feed-sentinel { height: 8px; }
.end-note { text-align: center; padding: 20px; color: var(--muted2); }

.post-card {
  background: var(--card);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 0 0 10px;
}
.special-card { background: #fbfcfd; border: 1px dashed #a9b9c4; }

/* шапка карточки: квадратный аватар, синее имя, время справа */
.post-head {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
}
.avatar {
  width: 40px; height: 40px; border-radius: 3px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 19px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
  text-shadow: 0 0 2px rgba(0,0,0,.25);
}
.avatar-sys { background: linear-gradient(135deg, var(--bar), var(--blue)); }
.post-head-names { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.post-head-names b { font-size: 14px; }
.post-head-names .muted { font-size: 12px; }
.post-user { color: var(--blue); font-size: 15px; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-time {
  margin-left: auto; flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--muted); font-size: 12px;
}
.i-clock { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* медиа на всю ширину, квадратный характер старой ленты */
.post-media { background: #dfe5e9; border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline); }
.post-media img, .post-media video {
  display: block; width: 100%; height: auto; max-height: 620px; object-fit: contain;
}
.media-processing {
  position: relative; color: #8fa4b5; text-align: center;
  padding: 12px; font-size: 14px; background: #22303a;
  aspect-ratio: 1 / 1;
  display: flex; align-items: center; justify-content: center;
}
.media-processing + img { display: none; }

.post-body { padding: 10px 12px; }
.post-body.text-post { font-size: 15px; white-space: pre-wrap; }

/* подпись: иконка-коммент + синее имя + текст */
.post-caption { display: flex; gap: 8px; padding: 10px 12px 4px; font-size: 14px; }
.i-bubble { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 2px; fill: none; stroke: #8fa4b5; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.post-caption b { color: var(--blue); margin-right: 2px; }

/* нижняя строка карточки — плоские кнопки-действия */
.post-foot {
  display: flex; gap: 2px; padding: 4px 8px 6px;
  border-top: 1px solid var(--hairline); margin-top: 8px;
}
.react {
  border: 0; background: none; font-size: 17px; cursor: pointer;
  min-width: 52px; min-height: 44px;
  padding: 6px 10px; border-radius: 3px;
  transition: background-color .16s ease, transform .16s ease;
}
.react:hover { background: #f2f5f7; }
.react:active { transform: scale(.92); }
.react.active { background: #e8f0f6; }
.react-n { font-size: 13px; color: var(--muted); align-self: center; }

.wordcloud-q { font-size: 14px; color: var(--blue); margin-bottom: 8px; font-weight: 600; }
.wordcloud { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; margin-bottom: 10px; min-height: 22px; }
.wordcloud .w { cursor: pointer; border: 0; background: none; font: inherit; color: var(--blue); padding: 2px 4px; min-height: 32px; transition: color .16s ease; }
.wordcloud .w:hover { text-decoration: underline; color: var(--accent); }

.progress-line { background: #dfe5e9; border-radius: 3px; height: 10px; overflow: hidden; margin-bottom: 6px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--bar), var(--nav-active)); transition: width .6s; }

.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.site-footer { text-align: center; padding: 22px 0 12px; color: var(--muted2); }

/* ---------- формы / кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px;
  border: 1px solid #b9c4cc; background: #fff; color: var(--text);
  border-radius: var(--radius); padding: 9px 16px; font-size: 14px; cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, transform .1s ease;
}
.btn:hover { background: #f2f5f7; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--bar); border-color: var(--bar-dark); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--bar-dark); }
.btn-small { padding: 6px 12px; min-height: 38px; font-size: 13px; }

.input-name, .input-word, input[type="text"], input[type="password"], textarea {
  border: 1px solid #b9c4cc; border-radius: var(--radius);
  padding: 9px 10px; font-size: 15px; background: #fff; color: var(--text);
  min-height: 44px;
}
textarea { min-height: 0; }
.input-name:focus, .input-word:focus, textarea:focus, input[type="text"]:focus { outline: 2px solid #9dc0da; border-color: var(--bar); }

.word-form { display: flex; gap: 6px; }
.word-form .input-name { flex: 0 0 38%; min-width: 0; }
.word-form .input-word { flex: 1; min-width: 0; }

/* ---------- нижняя навигация как в старой инсте ---------- */
.ig-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  display: flex; align-items: stretch;
  height: calc(52px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--nav);
  border-top: 1px solid #1a1f23;
  box-shadow: 0 -1px 4px rgba(20, 28, 34, .3);
}
.nav-btn {
  flex: 1; border: 0; background: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--nav-ico);
  transition: color .16s ease, background-color .16s ease;
}
.nav-btn:hover { color: #c6cfd5; }
.nav-btn:active { background: rgba(255, 255, 255, .06); }
.nav-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.nav-btn.active { color: var(--nav-active); box-shadow: inset 0 3px 0 var(--nav-active); }
.nav-cam { transform: translateY(-6px); }
.nav-cam svg {
  width: 46px; height: 46px; padding: 5px;
  color: #fff;
  background: linear-gradient(180deg, #66a0c9, #4a7fa8);
  border: 1px solid #3a688c; border-radius: 9px;
  box-shadow: 0 2px 5px rgba(15, 25, 33, .5);
  stroke-width: 1.7;
}
.nav-cam:hover svg { color: #fff; }

/* ---------- bottom sheet / modal ---------- */
.sheet-backdrop, .modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 28, 34, .55);
  z-index: 100; display: flex; align-items: flex-end; justify-content: center;
}
.modal-backdrop { align-items: center; padding: 14px; }
.sheet, .modal {
  background: #fff; width: 100%; max-width: 420px;
  border-radius: 10px 10px 0 0; padding: 10px 14px calc(14px + env(safe-area-inset-bottom));
  animation: up .22s ease-out;
}
.modal { border-radius: 10px; max-height: 82vh; overflow-y: auto; }
@keyframes up { from { transform: translateY(30px); opacity: .4; } }
.sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: #ccd4da; margin: 4px auto 10px; }
.sheet-title { text-align: center; font-size: 16px; margin-bottom: 10px; color: var(--text); }
.sheet-item {
  display: flex; align-items: center; gap: 13px;
  width: 100%; min-height: 56px;
  border: 0; border-bottom: 1px solid var(--hairline); background: none;
  padding: 10px 6px; font-size: 16px; text-align: left; cursor: pointer;
  transition: background-color .16s ease;
}
.sheet-item svg { width: 22px; height: 22px; flex: 0 0 auto; color: var(--bar); }
.sheet-item .sheet-item-text { display: flex; flex-direction: column; }
.sheet-item span { font-size: 16px; }
.sheet-item small { color: var(--muted); font-size: 12px; margin-top: 2px; }
.sheet-item:hover { background: #f5f8fa; }
.sheet-item:active { background: #ecf1f4; }
.sheet-cancel { width: 100%; min-height: 48px; border: 0; background: none; padding: 14px; font-size: 15px; color: var(--muted); cursor: pointer; transition: color .16s ease; }
.sheet-cancel:hover { color: var(--text); }

.modal { position: relative; }
.modal-close {
  position: absolute; right: 8px; top: 8px;
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: none; border-radius: 50%;
  color: var(--muted); cursor: pointer;
  transition: background-color .16s ease, color .16s ease;
}
.modal-close svg { width: 22px; height: 22px; }
.modal-close:hover { background: #eef2f4; color: var(--text); }
.modal h3 { font-size: 16px; margin-bottom: 10px; text-align: center; padding: 0 40px; color: var(--blue); }
.modal form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }

/* ---------- recorder ---------- */
.rec-video, .rec-preview {
  width: 100%; max-height: 58vh; background: #10181d; border-radius: 4px; display: block;
}
.rec-timer {
  position: absolute; top: 10px; left: 10px; background: rgba(16, 24, 29, .65);
  color: #fff; font-size: 13px; padding: 3px 9px; border-radius: 10px; font-weight: 600;
}
.rec-stage { position: relative; }
.rec-controls { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.rec-btn {
  border: 0; border-radius: 20px; padding: 11px 20px; min-height: 44px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: filter .16s ease, transform .1s ease;
}
.rec-btn:hover { filter: brightness(1.08); }
.rec-btn:active { transform: scale(.97); }
.rec-btn.rec { background: var(--accent); color: #fff; }
.rec-btn.stop { background: #29333a; color: #fff; }
.rec-btn.ok { background: #2e9e5b; color: #fff; }
.rec-btn:disabled { opacity: .4; cursor: default; }
.rec-phrase {
  text-align: center; font-size: 25px; font-weight: 700; padding: 14px 8px;
  color: #3f729b; background: #eef4f8; border: 1px solid #d4e2ec; border-radius: 5px; margin-bottom: 12px;
}
.rec-phrase small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 6px; }

.perm-error { color: #b03a2e; font-size: 14px; padding: 12px; text-align: center; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(35, 45, 52, .94); color: #fff; font-size: 14px;
  padding: 10px 18px; border-radius: 18px; z-index: 200;
  animation: up .2s ease-out; max-width: 86vw; text-align: center;
}

.new-pill {
  display: block; width: 100%; min-height: 40px; margin: 2px 0 8px;
  border: 1px solid #bcd3e4; background: #eef5fa; color: var(--blue);
  font-size: 13px; font-weight: 600; padding: 8px; border-radius: 14px; cursor: pointer;
  transition: background-color .16s ease;
}
.new-pill:hover { background: #e2eef7; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media (min-width: 560px) {
  body { background: #c9d4db; }
  .post-card { box-shadow: 0 1px 2px rgba(60, 84, 100, .12); }
  .sheet, .modal { border-radius: 10px; }
  .sheet-backdrop { align-items: center; padding: 14px; }
  .ig-nav { left: 50%; right: auto; transform: translateX(-50%); width: 500px; border-radius: 8px 8px 0 0; }
}
