/* Все цвета и размеры — в переменных ниже: чтобы перекрасить приложение, меняй только их. */
:root {
  --bg: #f6f2ee;
  --surface: #ffffff;
  --surface-2: #efe9e3;
  --text: #1f1a17;
  --hint: #857a72;
  --accent: #e8743b;
  --accent-soft: #fbe5d8;
  --accent-text: #ffffff;
  --danger: #c8412f;
  --ok: #2f8f5b;
  --line: rgba(31, 26, 23, .08);
  --shadow: 0 6px 24px rgba(60, 35, 20, .08);
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171412; --surface: #221e1b; --surface-2: #2d2824; --text: #f3ece6; --hint: #a39a92;
    --accent: #f08a52; --accent-soft: #3d2a1f; --line: rgba(255, 255, 255, .08);
    --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--font); }
body { min-height: 100vh; }
[hidden] { display: none !important; }
main { padding: calc(12px + env(safe-area-inset-top)) 16px 104px; max-width: 560px; margin: 0 auto; min-height: 100vh; }
h1 { font-size: 26px; line-height: 1.2; margin: 6px 0 12px; letter-spacing: -.01em; }
h2 { font-size: 19px; margin: 22px 0 10px; }
h3 { font-size: 17px; margin: 0 0 4px; }
p { margin: 0 0 12px; }
a { color: var(--accent); }
.hint { color: var(--hint); font-size: 14px; }
.small { font-size: 13px; }
.center { text-align: center; }
.loading { padding: 38vh 0; text-align: center; color: var(--hint); }

/* шапка экрана */
.topbar { display: flex; align-items: center; gap: 8px; min-height: 44px; margin-bottom: 6px; }
.topbar .title { flex: 1; font-weight: 700; font-size: 18px; }
.iconbtn { width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; background: var(--surface);
  display: grid; place-items: center; font-size: 18px; position: relative; box-shadow: var(--shadow); }
.dot { position: absolute; top: 6px; right: 6px; width: 11px; height: 11px; border-radius: 50%; background: var(--danger); border: 2px solid var(--surface); }
.badge { position: absolute; top: -2px; right: -2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.back { background: none; padding: 8px 0; min-height: 40px; color: var(--accent); font-weight: 600; }

/* кнопки */
button { font: inherit; border: 0; cursor: pointer; border-radius: 14px; padding: 13px 18px; min-height: 48px;
  background: var(--surface); color: var(--text); }
button:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-text); font-weight: 600; width: 100%; }
.btn-soft { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.btn-ghost { background: transparent; color: var(--accent); padding-left: 0; padding-right: 0; }
.btn-danger { background: transparent; color: var(--danger); }
.btn-line { background: var(--surface); border: 1.5px solid var(--line); width: 100%; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.chipbtn { padding: 8px 12px; min-height: 36px; font-size: 14px; border-radius: 10px; background: var(--surface-2); }

.box { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.segmented { display: flex; background: var(--surface); border-radius: 14px; padding: 4px; margin-bottom: 14px; box-shadow: var(--shadow); }
.segmented button { flex: 1; min-height: 40px; padding: 8px; background: transparent; border-radius: 10px; font-size: 15px; }
.segmented button.on { background: var(--accent); color: var(--accent-text); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--surface); border: 1.5px solid var(--line); border-radius: 999px; padding: 8px 14px;
  min-height: 40px; font-size: 15px; }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tag { display: inline-block; background: var(--surface-2); border-radius: 999px; padding: 4px 11px; font-size: 13px; color: var(--hint); }
.tag.ok { background: #e3f3ea; color: var(--ok); }
.tag.warn { background: var(--accent-soft); color: var(--accent); }
.tag.bad { background: #f8e1dd; color: var(--danger); }

/* лента */
.marks { display: flex; justify-content: space-between; align-items: center; margin: -4px 2px 10px; font-size: 14px; color: var(--hint); }
.deck { position: relative; height: clamp(300px, calc(100vh - 360px), 520px); height: clamp(300px, calc(100dvh - 360px), 520px); margin-bottom: 14px; }
.card { position: absolute; inset: 0; background: var(--surface); border-radius: 24px; padding: 22px;
  display: flex; flex-direction: column; box-shadow: var(--shadow); touch-action: pan-y; user-select: none;
  transition: transform .25s ease, opacity .25s ease; overflow: hidden; }
.card.static { position: relative; inset: auto; min-height: 320px; }
.card.dragging { transition: none; }
.card > * { flex-shrink: 0; }  /* текст не сжимаем — при нехватке места сжимается обложка и описание */
.card .tag { align-self: flex-start; margin-bottom: 14px; }
.card h1 { margin-top: 0; }
.card .meta { color: var(--hint); margin-bottom: 4px; }
.card .desc { margin-top: 12px; min-height: 0; flex: 0 1 auto; overflow-y: auto; overscroll-behavior: contain; }
.card .foot { flex-shrink: 0; padding-top: 10px; margin-top: auto; color: var(--hint); font-size: 14px; }
.stamp { position: absolute; top: 22px; font-weight: 800; font-size: 20px; padding: 4px 12px; border-radius: 10px;
  border: 3px solid; opacity: 0; transform: rotate(-12deg); pointer-events: none; }
.stamp.yes { right: 22px; color: var(--accent); }
.stamp.no { left: 22px; color: var(--hint); transform: rotate(12deg); }
.actions { display: flex; justify-content: center; gap: 40px; }
.act { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; color: var(--hint); }
.round { width: 66px; height: 66px; border-radius: 50%; font-size: 24px; padding: 0; box-shadow: var(--shadow); }
.round.yes { background: var(--accent); color: var(--accent-text); }

/* люди */
.plate { display: flex; gap: 10px; align-items: center; background: var(--accent-soft); color: var(--text);
  border-radius: 14px; padding: 10px 14px; margin-bottom: 12px; font-size: 14px; }
.plate b { color: var(--accent); }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 26px; font-weight: 700; flex: none; }
.avatar.sm { width: 36px; height: 36px; font-size: 17px; }
.avatar.xs { width: 28px; height: 28px; font-size: 14px; margin-left: -6px; border: 2px solid var(--surface); }
.avatars { display: flex; padding-left: 6px; }
.quote { font-style: italic; margin-top: 10px; }
.menu-dots { position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; min-height: 40px; padding: 0;
  border-radius: 50%; background: var(--surface-2); font-size: 18px; }
.plist .item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.plist .item:last-child { border-bottom: 0; }
.plist .grow { flex: 1; min-width: 0; }
.plist .name { font-weight: 600; }

/* встречи */
.meeting .members { display: flex; align-items: center; gap: 10px; margin: 10px 0; font-size: 14px; }
.note { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin: 10px 0; }
.note.accent { background: var(--accent-soft); }
.meeting .row button { padding: 10px; min-height: 44px; font-size: 15px; background: var(--surface-2); }
.meeting .row button.btn-primary { background: var(--accent); }
.unread { display: inline-block; background: var(--danger); color: #fff; border-radius: 9px; font-size: 11px;
  padding: 1px 6px; margin-left: 6px; vertical-align: middle; }

/* чат */
.chat { display: flex; flex-direction: column; gap: 8px; padding-bottom: 80px; }
.msg { max-width: 82%; padding: 9px 13px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.msg.me { align-self: flex-end; background: var(--accent); color: var(--accent-text); }
.msg .who { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.msg .t { font-size: 11px; opacity: .6; text-align: right; margin-top: 2px; }
.composer { position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg); padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); }
.composer .inner { max-width: 528px; margin: 0 auto; display: flex; gap: 8px; }
.composer textarea { min-height: 44px; height: 44px; max-height: 120px; resize: none; padding: 11px 14px; line-height: 20px; overflow-y: hidden; white-space: pre-wrap; scrollbar-width: none; }
.composer textarea::-webkit-scrollbar { display: none; }
.composer textarea::placeholder { white-space: nowrap; overflow: visible; }
.composer button { min-height: 44px; padding: 0 16px; }

/* формы */
label { display: block; font-size: 14px; color: var(--hint); margin: 14px 0 6px; }
input, textarea, select { width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 14px; min-height: 48px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }
.counter { text-align: right; font-size: 12px; color: var(--hint); margin-top: 4px; }
.toggle { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.toggle input { -webkit-appearance: none; appearance: none; flex: none; width: 28px; height: 28px; min-height: 0;
  padding: 0; margin: 0; border-radius: 50%; border: 2px solid rgba(133, 122, 114, .45); background: var(--surface);
  cursor: pointer; transition: background-color .15s, border-color .15s; }
.toggle input:checked { border-color: var(--accent); background: var(--accent)
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12.5l4 4 8-9' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
  center / 18px no-repeat; }
.toggle input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rules { padding-left: 38px !important; }
.rules li { margin-bottom: 8px; padding-left: 4px; }
.avpick { display: flex; flex-wrap: wrap; gap: 8px; }
.avpick button { width: 48px; height: 48px; min-height: 48px; padding: 0; font-size: 24px; border-radius: 50%;
  background: var(--surface); border: 2px solid transparent; }
.avpick button.on { border-color: var(--accent); background: var(--accent-soft); }

/* вход */
.logo { font-size: 40px; font-weight: 800; letter-spacing: -.03em; color: var(--accent); margin: 14vh 0 4px; }
.btn-ya { background: #fc3f1d; color: #fff; font-weight: 600; width: 100%; }
.btn-vk { background: #0077ff; color: #fff; font-weight: 600; width: 100%; }
.code-input { letter-spacing: .4em; font-size: 22px; text-align: center; }

.empty { text-align: center; padding: 34px 10px; }
.empty .big { font-size: 44px; margin-bottom: 8px; }

nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--surface);
  border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); z-index: 5; }
nav .inner { display: flex; width: 100%; max-width: 560px; margin: 0 auto; }
nav button { flex: 1; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 12px; color: var(--hint); padding: 6px; min-height: 52px; border-radius: 12px; }
nav button .ico { font-size: 20px; line-height: 1.1; }
nav button.on { color: var(--accent); font-weight: 600; }

#toast { position: fixed; left: 16px; right: 16px; bottom: calc(88px + env(safe-area-inset-bottom)); background: var(--text);
  color: var(--bg); padding: 12px 16px; border-radius: 14px; z-index: 30; max-width: 528px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow); }
#toast .msg-t { flex: 1; }
#toast button { background: transparent; color: var(--accent); font-weight: 700; min-height: 32px; padding: 4px 6px; }
#sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 20; display: flex; align-items: flex-end; }
#sheet .panel { background: var(--bg); width: 100%; max-width: 560px; margin: 0 auto; border-radius: 22px 22px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 88vh; overflow: auto; }
.notif { padding: 12px 0; border-bottom: 1px solid var(--line); }
.notif.unread-n .ntext { font-weight: 600; }
.stat { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat div { background: var(--surface); border-radius: 14px; padding: 10px; text-align: center; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 20px; }
.clip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 2px 0 6px; }
.card .desc.more { -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }

/* версия 0.2 */
/* журнал PWA, №7, версия 0.3: как в Яндекс Про — выбранный чип залит, с крестиком «убрать» */
.chips.multi .chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chips.multi .chip.on::after { content: "✕"; margin-left: 8px; font-size: .85em; opacity: .9; }
.segmented.tabs3 button { font-size: 14px; padding: 8px 4px; }
.segmented .n { opacity: .7; font-weight: 400; margin-left: 3px; }
.meeting { position: relative; }
.meeting .menu-dots { top: 10px; right: 10px; }
.meeting h3 { padding-right: 44px; }
.members .avatars .avatar { cursor: pointer; }
.chat .who { cursor: pointer; }
.msg { -webkit-touch-callout: none; }
.msg.pressed { opacity: .6; }
.reasons { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.source { margin-top: 10px; font-size: 12px; color: var(--hint); opacity: .8; }
.source a { color: inherit; }
.pick-day { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }

/* 0.3: фото человека и картинки события (журнал PWA, №22–23) */
.avatar.photo { overflow: hidden; padding: 0; background: var(--surface-2); }
.avatar.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-actions { margin-top: 12px; gap: 8px; }
.photo-actions button { flex: none; }
.card .cover { flex: 0 1 168px; min-height: 0; position: relative; margin: -22px -22px 14px; border-radius: 24px 24px 0 0; overflow: hidden; background: var(--surface-2); }
.card.static .cover { flex-basis: 200px; height: 200px; }
.cover.ph { display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--surface-2), var(--accent-soft)); }
.cover.ph span { font-size: 56px; opacity: .55; filter: grayscale(.35); }
.cover.gallery img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .25s; }
.cover.gallery img.on { opacity: 1; }
.cover .dots { position: absolute; left: 0; right: 0; bottom: 10px; display: flex; justify-content: center; gap: 6px; }
.cover .dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .55); box-shadow: 0 0 2px rgba(0, 0, 0, .3); }
.cover .dots i.on { background: #fff; width: 16px; border-radius: 3px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb { position: relative; width: 72px; height: 72px; border-radius: 14px; overflow: hidden; background: var(--surface-2); flex: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; min-height: 0; padding: 0; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, .55); color: #fff; font-size: 12px; line-height: 24px; }
button.thumb.add { min-height: 0; padding: 0; border: 2px dashed rgba(133, 122, 114, .45); background: transparent; color: var(--hint); font-size: 28px; }

/* пустая лента: второстепенные действия — спокойный сгруппированный список, как в настройках iOS (журнал PWA, №32) */
.cells { margin-top: 28px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; text-align: left; }
.row-cell { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 10px 14px; margin: 0;
  background: transparent; border: 0; border-radius: 0; box-shadow: none; color: var(--text); text-align: left; font: inherit; font-weight: 400; cursor: pointer; }
.row-cell + .row-cell { border-top: 1px solid var(--line); }
.row-cell:active { background: var(--surface-2); }
.rc-ico { flex: none; width: 28px; text-align: center; color: var(--hint); font-size: 17px; }
.rc-text { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.rc-text b { font-weight: 500; font-size: 15px; }
.rc-text span { color: var(--hint); font-size: 13px; line-height: 1.3; }
.rc-chev { flex: none; color: var(--hint); opacity: .6; font-size: 20px; line-height: 1; }
nav button .ico.me { width: 26px; height: 26px; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 1.5px var(--line); }
nav button .ico.me img { width: 100%; height: 100%; object-fit: cover; display: block; }
nav button.on .ico.me { box-shadow: 0 0 0 2px var(--accent); }
/* невысокие экраны (iPhone SE): карточка компактнее, чтобы всё помещалось без обрезки */
@media (max-height: 700px) {
  .card { padding: 18px; }
  .card .cover { margin: -18px -18px 12px; }
  .card h1 { font-size: 22px; margin-bottom: 8px; }
  .card .tag { margin-bottom: 10px; }
}
