/* SemSam — базовые стили (Этап 2). Полная полировка — Этап 5. */
:root {
  --primary: #4f8ef7;
  --primary-dark: #3a78e0;
  --accent: #8a6de9;
  --bg: #f0f3fa;
  --card: #ffffff;
  --text: #1c2536;
  --muted: #8a94a6;
  --line: #e5e9f2;
  --danger: #e0506b;
  --ok: #22b07d;
  --radius: 16px;
  --shadow: 0 3px 14px rgba(28,37,54,.08);
  /* семантические мягкие фоны (для тёмной темы переопределяются) */
  --soft: #edf1fa;       /* фон табов/кнопок */
  --soft-active: #eef4ff; /* фон активного пункта */
  --chip-bg: #fbfcfe;    /* поле ввода */
  --kid-log-bg: #f4f7fc;
  --danger-soft: #fdeef1;
  --ok-soft: #e6f6ef;
  --star: #f5b942;
  --water: #4aa8e8;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
}
input, button, textarea, select { font-family: inherit; font-size: 15px; }

/* ===== ЭКРАНЫ ===== */
.screen { display: none; }
.screen.active { display: block; }

/* ===== АВТОРИЗАЦИЯ ===== */
#screen-auth { min-height: 100vh; display: none; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg,#dfe9ff,#f4f6fb); }
#screen-auth.active { display: flex; }
.auth-card {
  width: 100%; max-width: 400px; background: var(--card); border-radius: 20px;
  box-shadow: var(--shadow); padding: 26px 22px;
}
.logo { text-align: center; margin-bottom: 16px; }
.logo-mark {
  width: 56px; height: 56px; margin: 0 auto 8px; border-radius: 16px;
  background: linear-gradient(135deg,var(--primary),var(--accent));
  color: #fff; font-weight: 800; font-size: 26px; display: flex; align-items: center; justify-content: center;
}
.logo h1 { margin: 0; font-size: 24px; }
.tagline { margin-top: 2px; color: var(--muted); font-size: 13px; }

.tabs { display: flex; gap: 4px; background: var(--soft); padding: 4px; border-radius: 12px; margin-bottom: 16px; }
.tab { flex: 1; border: 0; background: transparent; padding: 9px 6px; border-radius: 9px; color: var(--muted); font-weight: 600; cursor: pointer; }
.tab.active { background: var(--card); color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.tabs.small .tab { font-size: 13px; }

.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form input, .f input, .modal-card input, .modal-card select, .modal-card textarea {
  width: 100%; padding: 12px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--chip-bg); outline: none;
}
.auth-form input:focus, .f input:focus, .modal-card input:focus, .modal-card textarea:focus { border-color: var(--primary); background: var(--card); }

.btn {
  border: 0; border-radius: 10px; padding: 12px 16px; font-weight: 700; cursor: pointer;
  transition: filter .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: var(--soft); color: var(--text); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn.accent { background: var(--accent); color: #fff; }
.btn.loading { opacity: .6; pointer-events: none; }

.msg { text-align: center; color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 10px; }
.msg.ok { color: var(--ok); }

/* ===== ШАПКА ПРИЛОЖЕНИЯ ===== */
#screen-app .view { display: none; }
#screen-app .view.active { display: block; }
#app-header {
  position: sticky; top: 0; z-index: 20; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 12px; box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
#app-header #header-title { font-size: 17px; font-weight: 800; }
.icon-btn {
  background: transparent; border: 0; color: inherit; font-size: 22px; cursor: pointer;
  width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.15);
}
.icon-btn.accent { background: rgba(0,0,0,.15); font-size: 26px; line-height: 1; padding-bottom: 3px; }

/* ===== МЕНЮ-ЯЩИК ===== */
.drawer {
  position: fixed; top: 0; left: 0; height: 100%; width: 280px; max-width: 82%;
  background: var(--card); z-index: 40; transform: translateX(-105%);
  transition: transform .22s ease; display: flex; flex-direction: column; box-shadow: 2px 0 14px rgba(0,0,0,.15);
}
.drawer.open { transform: translateX(0); }
.drawer-head { padding: 18px 16px 12px; border-bottom: 1px solid var(--line); }
.logo-small {
  width: 40px; height: 40px; border-radius: 11px; background: linear-gradient(135deg,var(--primary),var(--accent));
  color: #fff; font-weight: 800; font-size: 20px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px;
}
.code-badge { display: inline-block; margin-top: 6px; background: var(--soft); border-radius: 8px; padding: 3px 9px; font-size: 12px; color: var(--muted); letter-spacing: 1px; }
#drawer-fam { font-size: 16px; }
.drawer-item {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 14px 16px; font-size: 15px; color: var(--text); cursor: pointer; border-bottom: 1px solid var(--line);
}
.drawer-item.active { color: var(--primary); font-weight: 700; background: var(--soft-active); }
.drawer-foot { margin-top: auto; padding: 12px 16px; border-top: 1px solid var(--line); }
#drawer-user { font-weight: 600; margin-bottom: 8px; }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }

/* ===== КАЛЕНДАРЬ ===== */
.view-nav, .day-header, .view-head {
  display: flex; align-items: center; gap: 8px; padding: 12px 12px 4px; flex-wrap: wrap;
}
.view-nav .icon-btn, .day-header .icon-btn { color: var(--primary); background: var(--soft); }
.cal-title { font-size: 17px; font-weight: 800; flex: 1; min-width: 120px; }
.mode-toggle { display: flex; background: var(--soft); border-radius: 9px; padding: 2px; }
.mode { border: 0; background: none; padding: 7px 12px; border-radius: 7px; font-weight: 600; color: var(--muted); cursor: pointer; font-size: 13px; }
.mode.active { background: var(--card); color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

#calendar { padding: 8px 10px 16px; }
.cal-head, .cal-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head-cell { text-align: center; font-size: 11px; color: var(--muted); font-weight: 700; padding: 4px 0; }
.cal-dnum { font-size: 15px; color: var(--text); }
.cal-dnum.today, .cal-cell.today .cal-num { color: var(--primary); font-weight: 800; }
.cal-cell {
  background: var(--card); border-radius: 10px; min-height: 76px; padding: 3px;
  border: 1px solid transparent; cursor: pointer; position: relative; overflow: hidden;
}
.cal-cell:hover, .cal-cell.today { border-color: var(--primary); }
.cal-cell.other .cal-num { color: #c6cdda; }
.cal-cell.wide { min-height: 90px; }
.cal-num { font-size: 13px; font-weight: 700; color: #5b6577; margin-bottom: 1px; }
.cal-mini { display: flex; flex-direction: column; gap: 2px; }
.cal-pill {
  background: var(--chip-bg); border-left: 3px solid var(--primary); border-radius: 4px;
  padding: 1px 4px; font-size: 10px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  line-height: 1.5;
}
.cal-more { font-size: 10px; color: var(--muted); padding-left: 4px; }

.legend { display: flex; flex-wrap: wrap; gap: 10px; padding: 2px 12px 10px; }
.lg-item { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.lg-dot { width: 10px; height: 10px; border-radius: 50%; }

/* ===== ПЛАН ДНЯ ===== */
.view-head { align-items: center; }
.day-header { align-items: center; }
.timeline { padding: 4px 12px 20px; }
.tl-row { display: flex; gap: 8px; margin-bottom: 2px; }
.tl-hour { width: 46px; text-align: right; color: var(--muted); font-size: 12px; padding-top: 12px; }
.tl-slot { flex: 1; min-height: 40px; border-bottom: 1px solid #eef1f7; border-radius: 6px; display: flex; flex-direction: column; gap: 4px; padding: 2px 0; cursor: pointer; }
.tl-row.now .tl-hour { color: var(--primary); font-weight: 800; }
.tl-empty { text-align: center; color: #ccd3e0; font-size: 18px; padding: 6px 0; }
.ev-card {
  background: #fff; border-radius: 8px; padding: 5px 8px; box-shadow: 0 1px 4px rgba(0,0,0,.08);
  position: relative; border-left: 3px solid var(--primary);
}
.ev-main { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.ev-cat { width: 8px; height: 8px; border-radius: 3px; flex: 0 0 auto; }
.ev-who { color: var(--muted); font-size: 11px; font-style: normal; margin-left: auto; }
.ev-desc { color: var(--muted); font-size: 11px; }
.ev-del {
  position: absolute; top: 2px; right: 4px; border: 0; background: none; color: var(--danger);
  font-size: 10px; cursor: pointer; opacity: 0;
}
.ev-card:hover .ev-del { opacity: 1; }

/* ===== МОДАЛКА ===== */
.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 60; align-items: center; justify-content: center; padding: 16px; }
.modal.show { display: flex; }
.modal-card { background: #fff; border-radius: 16px; padding: 18px 18px; width: 100%; max-width: 420px; max-height: 88vh; overflow-y: auto; }
.modal-card h3 { margin-top: 0; }
.f { margin-bottom: 12px; }
.f label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); padding: 7px 10px; border-radius: 9px; cursor: pointer; font-size: 13px; color: var(--text); background: #fbfcfe; }
.chips input { accent-color: var(--primary); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

/* ===== ТОСТ ===== */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px);
  background: #1c2536; color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 100; max-width: 86%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* пустые разделы-заглушки */
.ph { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ===== ТРЕКЕР / ПАНЕЛИ ===== */
.panel {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 16px; margin: 12px;
}
.panel-t { font-size: 16px; font-weight: 800; margin-bottom: 10px; }
.stars { display: flex; gap: 2px; font-size: 30px; color: #d6dbe7; cursor: pointer; user-select: none; }
.stars .star { transition: transform .1s, color .1s; }
.stars .star.on { color: var(--star); }
.stars .star:active { transform: scale(1.25); }
.water-total { font-size: 34px; font-weight: 800; text-align: center; margin: 8px 0 12px; }
.water-row { display: flex; gap: 8px; justify-content: center; margin-bottom: 12px; }
.glasses { font-size: 22px; line-height: 1.6; text-align: center; }
.quick { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.quick input[type=date] { flex: 1; min-width: 140px; }
.c-next { margin-top: 8px; font-weight: 700; color: #d2567a; }
.c-note { margin-top: 4px; color: var(--muted); font-size: 11px; }
.c-hist { margin-top: 10px; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.kid-block { margin-bottom: 14px; }
.kid-log { background: var(--kid-log-bg); border-radius: 10px; padding: 8px 10px; }
.kid-item { display: inline-block; margin: 2px 6px 2px 0; background: var(--card); border-radius: 8px; padding: 3px 8px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }

/* ===== НАПОМИНАНИЯ ===== */
#reminder-list { padding: 4px 12px 20px; }
.rem {
  display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--shadow); border-left: 4px solid var(--primary);
}
.rem-time { font-size: 18px; font-weight: 800; color: var(--primary); min-width: 52px; }
.rem-main { flex: 1; }
.rem-main b { display: block; }
.rem-days { color: var(--muted); font-size: 12px; }
.rem-del { background: none; border: 0; color: var(--danger); font-size: 18px; cursor: pointer; }

/* ===== ЗАМЕТКИ ===== */
#note-list { padding: 4px 12px 20px; }
.notes { }
.note-card { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 10px; border-left: 4px solid #f5a623; }
.note-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 16px; }
.note-body { white-space: pre-wrap; color: #333; font-size: 14px; }
.note-date { margin-top: 8px; color: var(--muted); font-size: 11px; text-align: right; }
.note-del { background: none; border: 0; color: var(--danger); font-size: 18px; cursor: pointer; }

/* ===== УЧАСТНИКИ ===== */
#member-list { padding: 4px 12px 20px; }
.member-row { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--shadow); }
.member-ava { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; color: #fff; flex: 0 0 auto; }
.member-info { display: flex; flex-direction: column; }
.member-type { color: var(--muted); font-size: 12px; }
.member-invite { margin-top: 16px; border-top: 1px solid #e6ebf4; padding-top: 14px; text-align: center; }
.chips label { display: inline-flex; align-items: center; gap: 5px; }
.sw { display: inline-block; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 2px #ddd; }

/* мобилки */
@media (max-width: 600px) {
  .cal-cell { min-height: 62px; }
  .cal-cell.wide { min-height: 74px; }
  .cal-pill { font-size: 9px; }
}

/* =====================================================================
   Этап 5: полировка под телефон
   ===================================================================== */
/* безопасная зона под вырез/жесты современных телефонов */
body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
#app-header {
  padding-top: calc(12px + env(safe-area-inset-top));
}
.modal { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.toast { bottom: calc(30px + env(safe-area-inset-bottom)); }

/* приятное скругление и анимация тоста */
.modal-card { animation: pop .16s ease; }
@keyframes pop { from { transform: translateY(8px); opacity: .6; } to { transform: none; opacity: 1; } }

/* аккуратные чекбоксы дней в напоминании — поколоночнее на узком */
#rm-days { display: flex; flex-wrap: wrap; gap: 6px; }
.copy-list { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 12px; }
.copy-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px; background: var(--soft); cursor: pointer;
  font-weight: 600; border: 1px solid transparent;
}
.copy-row:hover { border-color: var(--primary); background: var(--soft-active); }
.copy-row i { font-style: normal; font-weight: 500; color: var(--faint, #8a93a3); font-size: 12px; }
.hint { color: #6b7485; font-size: 13px; line-height: 1.45; margin: 0 0 10px; }
#rm-days label { flex: 1 0 82px; }

/* водо/цикл яркости */
.water-row .btn { min-width: 64px; }

/* тёмная тема (подхватывается системной темой телефона) */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151d;
    --card: #1c2029;
    --text: #e8ecf4;
    --muted: #8b93a5;
    --line: #2b3140;
    --soft: #262c38;
    --soft-active: #26334a;
    --chip-bg: #232936;
    --kid-log-bg: #1a1f29;
    --shadow: 0 3px 16px rgba(0,0,0,.4);
    color-scheme: dark;
  }
  /* точечные хардкод-фоны/цвета, которые нельзя выразить переменной */
  #screen-auth { background: linear-gradient(160deg,#18202e,#12151d); }
  .modal-card { background: var(--card); }
  .cal-cell.other .cal-num { color: #4a5162; }
  .cal-num { color: #aeb6c6; }
  .note-body { color: #c8cfdc; }
  .kid-item { box-shadow: 0 1px 3px rgba(0,0,0,.25); }
  .glasses { filter: none; }
  .tl-slot { border-bottom-color: var(--line); }
  .tl-empty { color: #4a5162; }
  .ev-card { background: var(--card); box-shadow: 0 1px 4px rgba(0,0,0,.25); }
  .water-total { color: var(--text); }
  .auth-card { box-shadow: 0 4px 24px rgba(0,0,0,.5); }
  .stars { color: #3a4150; }
}

/* узкие экраны: медиа-мобилки */
@media (max-width: 600px) {
  .view-nav, .day-header { padding: 10px 8px 2px; }
  .view-head { padding: 10px 10px 2px; }
  .cal-title { font-size: 16px; }
  #calendar { padding: 6px 6px 12px; }
  .cal-head-cell { font-size: 10px; }
  .cal-cell { border-radius: 8px; }
  .member-ava { width: 36px; height: 36px; font-size: 18px; }
  .icon-btn { width: 36px; height: 36px; }
  .rem-time { min-width: 46px; font-size: 16px; }
}
