/* app.css — мобильный интерфейс, тёмная и светлая темы */

:root {
  --bg: #0b0d12;
  --bg-soft: #10131b;
  --panel: #151a24;
  --panel-2: #1b2130;
  --text: #e9edf6;
  --muted: #8d97ab;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --accent: #7c6cff;
  --accent-soft: rgba(124, 108, 255, 0.16);
  --teal: #35d0ba;
  --warn: #ffb020;
  --danger: #ff5d6c;
  --ok: #36d399;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.42);
  --radius: 18px;
  --tab-h: 64px;
}

:root[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-soft: #eaeef7;
  --panel: #ffffff;
  --panel-2: #f2f5fb;
  --text: #131722;
  --muted: #667085;
  --border: rgba(16, 24, 40, 0.09);
  --border-strong: rgba(16, 24, 40, 0.16);
  --accent: #5b4bff;
  --accent-soft: rgba(91, 75, 255, 0.12);
  --shadow: 0 10px 28px rgba(16, 24, 40, 0.12);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f6fb;
    --bg-soft: #eaeef7;
    --panel: #ffffff;
    --panel-2: #f2f5fb;
    --text: #131722;
    --muted: #667085;
    --border: rgba(16, 24, 40, 0.09);
    --border-strong: rgba(16, 24, 40, 0.16);
    --accent: #5b4bff;
    --accent-soft: rgba(91, 75, 255, 0.12);
    --shadow: 0 10px 28px rgba(16, 24, 40, 0.12);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 620px at 82% -12%, rgba(124, 108, 255, 0.20), transparent 62%),
    radial-gradient(800px 480px at -12% 8%, rgba(53, 208, 186, 0.13), transparent 58%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  position: relative;
}

/* ---------- шапка ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: linear-gradient(to bottom, var(--bg) 62%, transparent);
  backdrop-filter: blur(8px);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.logo {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(140deg, #7c6cff, #35d0ba);
  box-shadow: 0 6px 18px rgba(124, 108, 255, 0.35);
  flex: none;
}
.logo svg { width: 20px; height: 20px; }

.brand-title { font-weight: 650; font-size: 15px; letter-spacing: 0.1px; }
.brand-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- контент ---------- */
.view {
  flex: 1;
  padding: 4px 16px calc(var(--tab-h) + 30px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: fade 0.22s ease;
}

@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-title { font-size: 12px; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted); }

.section-title {
  font-size: 13px; font-weight: 650; color: var(--muted);
  margin: 6px 2px 0; letter-spacing: 0.3px;
}

/* ---------- кнопки ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 11px 16px;
  border-radius: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
  min-height: 44px;
}
.btn:active { transform: scale(0.975); }
.btn.primary {
  background: linear-gradient(140deg, #7c6cff, #6a5bff);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 22px rgba(124, 108, 255, 0.32);
}
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: rgba(255, 93, 108, 0.35); background: rgba(255, 93, 108, 0.08); }
.btn.small { min-height: 36px; padding: 7px 12px; font-size: 13px; border-radius: 11px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; pointer-events: none; }

.icon-btn {
  appearance: none; border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; cursor: pointer; flex: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- запись ---------- */
.hero {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; padding: 18px 8px 8px;
}

.rec-btn {
  appearance: none; border: 0; cursor: pointer;
  width: 108px; height: 108px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(145deg, #7c6cff, #4d3fe0);
  box-shadow: 0 16px 40px rgba(124, 108, 255, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform 0.16s ease, box-shadow 0.25s ease, background 0.25s ease;
  touch-action: manipulation;
}
.rec-btn:active { transform: scale(0.96); }
.rec-btn svg { width: 44px; height: 44px; }

.hero.is-rec .rec-btn {
  background: linear-gradient(145deg, #ff5d6c, #d92f45);
  box-shadow: 0 0 0 10px rgba(255, 93, 108, 0.12), 0 16px 40px rgba(255, 93, 108, 0.4);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 8px rgba(255, 93, 108, 0.10), 0 16px 40px rgba(255, 93, 108, 0.34); }
  50% { box-shadow: 0 0 0 18px rgba(255, 93, 108, 0.02), 0 16px 40px rgba(255, 93, 108, 0.46); }
}

.rec-timer {
  font-variant-numeric: tabular-nums;
  font-size: 30px; font-weight: 650; letter-spacing: 1px; margin-top: 10px;
}
.rec-hint { color: var(--muted); font-size: 13px; }

.wave {
  display: flex; align-items: center; justify-content: center; gap: 3px;
  height: 44px; width: 100%; max-width: 320px; margin-top: 10px;
  opacity: 0.9;
}
.wave i {
  display: block; width: 3px; border-radius: 3px;
  background: linear-gradient(to top, var(--accent), var(--teal));
  height: 4px; transition: height 0.08s linear;
}

.live-text {
  margin-top: 12px;
  width: 100%;
  font-size: 13.5px;
  color: var(--muted);
  text-align: center;
  max-height: 84px;
  overflow: hidden;
  line-height: 1.5;
}

/* ---------- поля ---------- */
textarea, input[type="text"], input[type="password"], input[type="url"],
input[type="number"], input[type="datetime-local"], input[type="date"], select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
  min-height: 44px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  color-scheme: dark light;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
input:focus, textarea:focus, select:focus {
  border-color: rgba(124, 108, 255, 0.65);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
label.field > small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 5px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 0; min-width: 0; }
.row.tight { gap: 8px; }
.row.end { justify-content: flex-end; }
.row.end > * { flex: 0 0 auto; }

.chk { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.chk input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- списки ---------- */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.task {
  display: flex; align-items: flex-start; gap: 11px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 12px 12px 12px 10px;
  transition: opacity 0.2s ease, border-color 0.2s ease;
}
.task.done { opacity: 0.52; }
.task.done .task-title { text-decoration: line-through; }

.check {
  appearance: none; border: 1.5px solid var(--border-strong);
  width: 26px; height: 26px; border-radius: 9px;
  background: transparent; color: transparent;
  display: grid; place-items: center; cursor: pointer; flex: none;
  margin-top: 1px; transition: background 0.15s ease, border-color 0.15s ease;
}
.check svg { width: 15px; height: 15px; }
.task.done .check { background: var(--ok); border-color: var(--ok); color: #0b0d12; }

.task-main { flex: 1; min-width: 0; cursor: pointer; }
.task-title { font-weight: 550; font-size: 14.5px; overflow-wrap: anywhere; }

.task-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px;
  margin-top: 5px; font-size: 12px; color: var(--muted);
}
.task-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: 0.5; }
.task-meta svg { width: 13px; height: 13px; }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--panel-2); border: 1px solid var(--border);
}
.pill.warn { color: var(--warn); border-color: rgba(255, 176, 32, 0.32); background: rgba(255, 176, 32, 0.10); }
.pill.danger { color: var(--danger); border-color: rgba(255, 93, 108, 0.32); background: rgba(255, 93, 108, 0.10); }
.pill.accent { color: var(--accent); border-color: rgba(124, 108, 255, 0.32); background: var(--accent-soft); }
.pill.teal { color: var(--teal); border-color: rgba(53, 208, 186, 0.32); background: rgba(53, 208, 186, 0.10); }

.task .icon-btn { width: 34px; height: 34px; border-radius: 10px; border-color: transparent; background: transparent; }
.task .icon-btn svg { width: 17px; height: 17px; }

/* ---------- записи ---------- */
.rec-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 15px;
}
.rec-icon {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center; color: var(--accent); background: var(--accent-soft);
}
.rec-icon svg { width: 18px; height: 18px; }
.rec-body { flex: 1; min-width: 0; }
.rec-name { font-size: 13.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ---------- календарь ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-month { font-size: 16px; font-weight: 650; text-transform: capitalize; }
.cal-nav { display: flex; gap: 6px; }

.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  font-size: 11px; color: var(--muted); text-align: center; margin: 12px 0 6px;
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }

.cal-cell {
  appearance: none; border: 1px solid transparent; background: transparent;
  color: var(--text); font: inherit; font-size: 13px;
  aspect-ratio: 1 / 1.06; border-radius: 12px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 2px; position: relative;
}
.cal-cell:hover { background: var(--panel-2); }
.cal-cell.out { color: var(--muted); opacity: 0.45; }
.cal-cell.today { border-color: rgba(124, 108, 255, 0.45); }
.cal-cell.sel { background: var(--accent); color: #fff; }
.cal-cell.sel .cal-dot { background: rgba(255, 255, 255, 0.9); }

.cal-dots { display: flex; gap: 2px; height: 4px; }
.cal-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.cal-dot.event { background: var(--teal); }
.cal-dot.task { background: var(--warn); }
.cal-dot.reminder { background: var(--accent); }
.cal-dot.note { background: var(--muted); }

.day-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 2px; }
.day-title { font-weight: 650; font-size: 14px; text-transform: capitalize; }

/* ---------- пустое состояние ---------- */
.empty {
  text-align: center; color: var(--muted); padding: 26px 16px; font-size: 13.5px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
.empty strong { color: var(--text); display: block; margin-bottom: 4px; font-size: 14px; }

/* ---------- нижнее меню ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(16px) saturate(140%);
  border-top: 1px solid var(--border);
  max-width: 720px; margin: 0 auto;
}
.tab {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 11px; font-weight: 550;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 4px; border-radius: 12px; cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.tab svg { width: 21px; height: 21px; }
.tab.active { color: var(--text); background: var(--accent-soft); }
.tab.active svg { color: var(--accent); }

/* ---------- диалог ---------- */
.sheet {
  position: fixed; inset: auto 0 0 0;
  width: 100%; max-width: 720px; margin: 0 auto;
  max-height: 92dvh;
  padding: 0;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  background: var(--bg-soft);
  color: var(--text);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  transform: translateY(12px);
  opacity: 0;
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.18s ease;
}
.sheet[open] { transform: none; opacity: 1; }
.sheet::backdrop { background: rgba(4, 6, 12, 0.62); backdrop-filter: blur(3px); }

.sheet-wrap { display: flex; flex-direction: column; max-height: 92dvh; }

.sheet-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.sheet-head .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: -8px auto 10px; }
.sheet-title { font-size: 16px; font-weight: 650; }
.sheet-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.sheet-body { padding: 14px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.sheet-foot {
  display: flex; gap: 10px; padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); background: var(--panel);
}
.sheet-foot .btn { flex: 1; }

/* карточка разбора */
.rev-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.rev-top { display: flex; gap: 8px; align-items: center; }
.rev-top select { min-height: 38px; padding: 8px 10px; font-size: 13px; flex: 1; }
.rev-top .icon-btn { width: 36px; height: 36px; }
.rev-row { display: flex; gap: 8px; align-items: center; }
.rev-row > input[type="datetime-local"] { flex: 1; min-height: 40px; padding: 8px 10px; font-size: 13px; }
.rev-title { font-weight: 600; }
.rev-note { font-size: 11.5px; color: var(--muted); }

/* ---------- тост ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 26px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  max-width: min(520px, calc(100vw - 32px));
  padding: 11px 16px; border-radius: 13px;
  background: #22283a; color: #fff; font-size: 13.5px; font-weight: 550;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
  opacity: 0; pointer-events: none; z-index: 60;
  transition: opacity 0.22s ease, transform 0.22s ease;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #4a1d27; color: #ffc9cf; }
.toast.ok { background: #12332a; color: #b6f0dc; }

/* ---------- прочее ---------- */
.hint { font-size: 12px; color: var(--muted); line-height: 1.5; }
.hint strong { color: var(--text); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--border); margin: 4px 0; }
.hidden { display: none !important; }

@media (min-width: 640px) {
  .view { padding-left: 20px; padding-right: 20px; }
  .rec-btn { width: 120px; height: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- индикатор занятости ---------- */
.busy {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center;
  background: rgba(6, 8, 14, 0.62);
  backdrop-filter: blur(3px);
  animation: fade 0.15s ease;
}
.busy-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px; border-radius: 16px;
  background: var(--panel); border: 1px solid var(--border);
  box-shadow: var(--shadow); max-width: 84vw;
}
.busy-text { font-size: 13.5px; line-height: 1.4; }
.spinner {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }