:root {
  --bg: #e8eef4;
  --ink: #1a2332;
  --muted: #5a6a7a;
  --a: #c8e6c9;
  --a-border: #2e7d32;
  --b: #bbdefb;
  --b-border: #1565c0;
  --card: #fff;
  --line: #c5d0db;
  --danger: #c62828;
  --radius: 12px;
  --font: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, #d7e8f7 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #d9f0dc 0%, transparent 50%),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
  padding: 12px 12px calc(24px + env(safe-area-inset-bottom, 0px));
}

body.page-workouts {
  padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
}

.sub-link {
  color: inherit;
  text-underline-offset: 2px;
}

.hdr-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  min-width: 40px;
  min-height: 40px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.top-bare {
  justify-content: flex-end;
  margin-bottom: 8px;
}

.brand {
  flex: 1 1 auto;
  min-width: 0;
}

h1 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

.sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.timer-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(transparent, color-mix(in srgb, var(--bg) 92%, #000) 35%, var(--bg));
  pointer-events: none;
}

.timer {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 420px;
  margin: 0 auto;
  padding: 8px 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 8px 28px rgba(26, 35, 50, 0.18);
}

.timer.running {
  border-color: var(--a-border);
  background: color-mix(in srgb, var(--a) 55%, #fff);
}

.timer.finished {
  border-color: var(--danger);
  animation: timer-flash 0.35s ease 3;
}

@keyframes timer-flash {
  50% { background: #ffcdd2; }
}

.timer-preset,
.timer-action {
  flex: 0 0 auto;
  min-width: 72px;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 999px;
}

.timer-action {
  min-width: 52px;
  font-size: 1.1rem;
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.timer-action.is-reset {
  background: #fff;
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
}

.timer-display {
  flex: 1 1 auto;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.55rem;
  letter-spacing: 0.04em;
  min-width: 4.5ch;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 8px 0;
  background: linear-gradient(var(--bg), color-mix(in srgb, var(--bg) 85%, transparent));
}

button, .ghost, .primary, .danger, .btn-a, .btn-b {
  font: inherit;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 10px 14px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}

button:active { transform: scale(0.98); }

.btn-a { background: var(--a); border-color: var(--a-border); font-weight: 600; }
.btn-b { background: var(--b); border-color: var(--b-border); font-weight: 600; }
.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.ghost { background: transparent; }

.status {
  background: #fff3cd;
  border: 1px solid #ffe69c;
  padding: 8px 12px;
  border-radius: 8px;
  margin: 0 0 12px;
}

.feed {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.workout {
  flex: 0 0 min(92vw, 420px);
  scroll-snap-align: start;
  background: var(--card);
  border-radius: var(--radius);
  border: 2px solid var(--line);
  box-shadow: 0 8px 24px rgba(26, 35, 50, 0.08);
  overflow: hidden;
}

.workout.type-A { border-color: var(--a-border); }
.workout.type-B { border-color: var(--b-border); }

.workout-head {
  padding: 12px 14px;
  cursor: pointer;
  display: grid;
  gap: 4px;
}

.workout.type-A .workout-head { background: var(--a); }
.workout.type-B .workout-head { background: var(--b); }

.workout-head .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 0.92rem;
}

.badge {
  font-weight: 700;
  font-size: 1.1rem;
}

.warmup {
  font-size: 0.85rem;
  color: var(--muted);
}

.exercise {
  border-top: 1px solid var(--line);
  padding: 10px 12px;
}

.exercise h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
  line-height: 1.25;
}

.super-tag {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--b-border);
  vertical-align: middle;
}

.super-hint {
  margin: -2px 0 8px;
  font-size: 0.75rem;
  color: var(--muted);
}

.sets {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  table-layout: fixed;
}

.sets th, .sets td {
  text-align: left;
  padding: 2px 3px;
  vertical-align: middle;
}

.sets th { color: var(--muted); font-weight: 600; font-size: 0.7rem; }

/* # */
.sets th:nth-child(1),
.sets td:nth-child(1) {
  width: 18px;
  padding-left: 0;
  padding-right: 2px;
}

/* обычная: вес | раз — узкие, прим. — остальное */
.sets:not(.sets-super) th:nth-child(2),
.sets:not(.sets-super) td:nth-child(2),
.sets:not(.sets-super) th:nth-child(3),
.sets:not(.sets-super) td:nth-child(3) {
  width: 42px;
}

.sets:not(.sets-super) th:nth-child(4),
.sets:not(.sets-super) td:nth-child(4) {
  width: auto;
}

/* суперсет: вес1 раз1 вес2 раз2 — узкие */
.sets-super th:nth-child(2),
.sets-super td:nth-child(2),
.sets-super th:nth-child(3),
.sets-super td:nth-child(3),
.sets-super th:nth-child(4),
.sets-super td:nth-child(4),
.sets-super th:nth-child(5),
.sets-super td:nth-child(5) {
  width: 38px;
}

.sets-super th:nth-child(6),
.sets-super td:nth-child(6) {
  width: auto;
}

.set-num {
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  font-size: 0.8rem;
}

.cell-input {
  width: 100%;
  min-width: 0;
  padding: 8px 2px !important;
  font-size: 0.85rem !important;
  border-radius: 8px;
  text-align: center;
  -moz-appearance: textfield;
}

.cell-input::-webkit-outer-spin-button,
.cell-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.cell-note {
  text-align: left !important;
  padding-left: 6px !important;
  padding-right: 6px !important;
}

.ex-foot {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.save-state {
  font-weight: 700;
  color: var(--a-border);
}
dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0;
  width: min(96vw, 440px);
  max-width: calc(100vw - 12px);
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
  box-sizing: border-box;
}

dialog::backdrop { background: rgba(20, 30, 40, 0.45); }

dialog form {
  display: grid;
  gap: 10px;
  padding: 16px;
  max-width: 100%;
  overflow: hidden;
}

#dlg-sets form {
  padding: 5px;
  gap: 8px;
}

#dlg-sets h2 {
  font-size: 1rem;
  padding: 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

dialog h2 { margin: 0; font-size: 1.15rem; }

label {
  display: grid;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--muted);
}

input, select, textarea {
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  max-width: 100%;
  box-sizing: border-box;
}

.dlg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

#sets-rows {
  max-width: 100%;
  overflow: hidden;
}

.set-row {
  display: grid;
  grid-template-columns: 22px 52px 52px minmax(0, 1fr);
  gap: 5px;
  align-items: center;
  margin-bottom: 5px;
  max-width: 100%;
}

.set-row.superset {
  grid-template-columns: 22px 44px 44px 44px minmax(0, 1fr);
}

.set-row span { font-weight: 700; font-size: 0.9rem; text-align: center; }

.set-row input {
  padding: 8px 4px;
  font-size: 0.9rem;
  min-width: 0;
  width: 100%;
}

.set-row input[data-f="weight"],
.set-row input[data-f="weight_secondary"],
.set-row input[data-f="reps"] {
  text-align: center;
}

.set-row input[data-f="note"] {
  padding-left: 6px;
  padding-right: 6px;
}
.hint { font-size: 0.85rem; color: var(--muted); margin: 0; }

.empty {
  padding: 40px 16px;
  color: var(--muted);
  text-align: center;
}

/* --- День / чеклист --- */
.home-grid {
  display: grid;
  gap: 14px;
  align-items: start;
}

.day-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 10px 12px;
  margin-bottom: 0;
  box-shadow: 0 4px 18px rgba(26, 35, 50, 0.06);
}

.day-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
}

.day-arrow {
  flex: 0 0 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f7fa;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
}

.day-arrow:active { background: #e4ebf2; }

.day-heading {
  flex: 1;
  text-align: center;
  min-width: 0;
}

.day-weekday {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.day-date-label {
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.78rem;
}

.day-meta {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 6px;
}

.day-steps { flex: 0 1 auto; max-width: none; }

.day-steps-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

.day-steps-wrap input {
  width: 88px;
  margin-top: 0;
}

.day-steps-unit {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}

.day-field {
  display: block;
  margin-bottom: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
}

.day-field textarea,
.day-field input[type="number"] {
  display: block;
  width: 100%;
  margin-top: 3px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink);
  background: #fafcfe;
  resize: vertical;
}

.day-field textarea { min-height: 42px; }

.day-field textarea:focus,
.day-field input:focus {
  outline: 2px solid color-mix(in srgb, var(--a-border) 45%, transparent);
  border-color: var(--a-border);
}

.day-save-state {
  font-size: 0.75rem;
  color: var(--muted);
  padding-bottom: 6px;
  white-space: nowrap;
}

.day-checklist {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 8px 0 10px;
}

.habit-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: stretch;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafcfe;
}

.habit-row.highlight {
  background: #eceff1;
  border-color: #90a4ae;
}

.habit-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  flex: 1 1 auto;
  min-width: min(100%, 100px);
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--ink);
}

.habit-main {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  min-width: 0;
}

.habit-mark {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  padding: 0;
  border: 1.5px solid #b0bec5;
  border-radius: 5px;
  background: #fff;
  color: transparent;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.habit-item.status-done .habit-mark {
  border-color: #2e7d32;
  background: #e8f5e9;
  color: #2e7d32;
}

.habit-item.status-almost .habit-mark {
  border-color: #78909c;
  background: #eceff1;
  color: #607d8b;
}

.habit-item.status-fail .habit-mark {
  border-color: #c62828;
  background: #ffebee;
  color: #c62828;
}

.habit-label {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.25;
  padding-top: 2px;
  user-select: none;
}

.habit-item.status-done .habit-label {
  text-decoration: line-through;
  color: var(--muted);
  font-weight: 500;
}

.habit-item.status-fail .habit-label {
  color: #b71c1c;
}

.habit-note {
  width: 100%;
  box-sizing: border-box;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--ink);
  background: #fff;
}

.habit-note:focus {
  outline: 2px solid color-mix(in srgb, var(--a-border) 45%, transparent);
  border-color: var(--a-border);
}

.habit-note::placeholder {
  color: #9aa8b5;
}

.habit-row.highlight .habit-label {
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* --- Задачи --- */
.tasks-panel { min-width: 0; }

.tasks-panel-standalone .task-boards {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.tasks-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 10px;
  padding: 8px 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 2px 10px rgba(26, 35, 50, 0.04);
}

.tasks-toolbar-left,
.tasks-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tasks-who-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.tasks-who-badge.assignee-yura {
  background: #e3f2fd;
  color: #0d47a1;
  border: 1px solid #90caf9;
}

.tasks-who-badge.assignee-anara {
  background: #fce4ec;
  color: #ad1457;
  border: 1px solid #f48fb1;
}

.tasks-mine-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}

.tasks-mine-switch input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  accent-color: var(--ink);
  cursor: pointer;
}

.tasks-page-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--b-border);
  text-decoration: none;
}

.tasks-page-link:hover {
  text-decoration: underline;
}

.tasks-grp-toggle {
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 8px;
}

.tasks-grp-toggle.is-active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.tasks-group-add {
  flex: 1 1 100%;
  display: flex;
  gap: 6px;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

.tasks-group-add input {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  font-size: 0.85rem;
}

.tasks-group-add button {
  padding: 7px 12px;
  font-size: 0.82rem;
  border-radius: 8px;
}

.task-boards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.task-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: 0 4px 18px rgba(26, 35, 50, 0.06);
  min-width: 0;
}

.task-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.task-card-head h2 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.task-card-head-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.group-move-ops,
.group-ops {
  display: flex;
  align-items: center;
  gap: 2px;
}

.group-move-ops .task-op {
  width: 22px;
  height: 22px;
  font-size: 0.78rem;
  opacity: 0.65;
}

.group-move-ops .task-op:hover {
  opacity: 1;
}

.task-count {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 700;
}

.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.task-item {
  display: grid;
  grid-template-columns: 14px 22px minmax(0, 1fr) auto;
  gap: 6px;
  align-items: start;
  padding: 6px 4px;
  border-radius: 8px;
}

.task-item:hover { background: #f4f7fa; }

.task-prio {
  width: 12px;
  height: 12px;
  margin-top: 5px;
  padding: 0;
  border: 1.5px solid #c5d0db;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.task-item.prio-black .task-prio {
  background: #1a2332;
  border-color: #1a2332;
}

.task-item.prio-red .task-prio {
  background: #c62828;
  border-color: #c62828;
}

.task-assignee {
  width: 20px;
  height: 20px;
  margin-top: 1px;
  padding: 0;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}

.task-assignee.assignee-yura {
  background: #e3f2fd;
  color: #0d47a1;
  border: 1px solid #90caf9;
}

.task-assignee.assignee-anara {
  background: #fce4ec;
  color: #ad1457;
  border: 1px solid #f48fb1;
}

.task-title {
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  line-height: 1.35;
}

.task-item.is-done .task-title {
  text-decoration: line-through;
  color: var(--muted);
  font-weight: 400;
}

.task-ops {
  display: flex;
  gap: 2px;
  flex: 0 0 auto;
}

.task-op {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
}

.task-op:hover { background: #e4ebf2; color: var(--ink); }

.task-del:hover { background: #ffebee; color: var(--danger); }

.task-add {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.task-add input {
  flex: 1;
  min-width: 0;
  padding: 7px 8px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 0.85rem;
  background: #fafcfe;
}

.task-add input:focus {
  outline: 2px solid color-mix(in srgb, var(--a-border) 45%, transparent);
  border-style: solid;
  border-color: var(--a-border);
}

.task-add-btn {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f7fa;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
}

.workouts-block { margin-top: 4px; }

.section-title {
  margin: 0 0 10px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
}

@media (min-width: 720px) {
  .task-boards {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 980px) {
  .home-grid {
    grid-template-columns: minmax(280px, 0.55fr) minmax(0, 1fr);
    gap: 18px;
  }
  .day-panel {
    padding: 10px 10px 12px;
  }
  .habit-row {
    flex-wrap: nowrap;
    gap: 6px 8px;
    padding: 4px 6px;
  }
  .habit-item {
    min-width: 0;
    flex: 1 1 0;
    font-size: 0.74rem;
  }
  .task-boards {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1280px) {
  .home-grid {
    grid-template-columns: minmax(320px, 0.55fr) minmax(0, 1fr);
  }
  .task-boards {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 900px) {
  body { padding: 20px 24px 48px; }
  body.page-workouts { padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
  .feed { gap: 18px; }
  .workout { flex-basis: 380px; }
}

/* --- Чеклист недели --- */
.week-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 10px 14px;
  box-shadow: 0 4px 18px rgba(26, 35, 50, 0.06);
}

.week-nav { margin-bottom: 10px; }

.week-matrix-wrap { min-width: 0; }

.week-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -2px;
  padding-bottom: 4px;
}

.week-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 520px;
  font-size: 0.78rem;
}

.week-table th,
.week-table td {
  border-bottom: 1px solid var(--line);
  padding: 5px 4px;
  text-align: center;
  vertical-align: middle;
}

.week-table thead th {
  position: sticky;
  top: 0;
  background: #f4f7fa;
  z-index: 1;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 1px solid #b0bec5;
}

.week-corner {
  width: 28%;
  min-width: 120px;
  text-align: left !important;
  background: #f4f7fa;
}

.week-day-h {
  min-width: 36px;
  line-height: 1.15;
}

.week-day-h.is-today {
  color: var(--a-border);
  background: #e8f5e9;
}

.week-dow { display: block; font-size: 0.72rem; }
.week-dom { display: block; font-size: 0.85rem; font-weight: 800; color: var(--ink); }
.week-day-h.is-today .week-dom { color: var(--a-border); }

.week-table tbody th {
  text-align: left;
  font-weight: 600;
  color: var(--ink);
  padding-left: 6px;
  padding-right: 8px;
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: #fafcfe;
  position: sticky;
  left: 0;
  z-index: 1;
}

.week-habit-hl th,
.week-habit-hl td {
  background: #eceff1;
}

.week-habit-hl th {
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.week-steps-row th,
.week-steps-row td {
  background: #f0f4f8;
  font-weight: 700;
  color: var(--muted);
  border-bottom-width: 2px;
}

.week-cell {
  font-weight: 800;
  font-size: 0.9rem;
}

.week-cell.status-done { color: #2e7d32; background: #e8f5e9; }
.week-cell.status-almost { color: #607d8b; background: #eceff1; }
.week-cell.status-fail { color: #c62828; background: #ffebee; }
.week-cell.status-na { color: #c5d0db; font-weight: 500; }
.week-cell.status-none { color: transparent; }
.week-cell.steps { color: var(--ink); font-size: 0.78rem; font-weight: 700; }

@media (min-width: 900px) {
  .week-panel { padding: 14px 16px 18px; }
  .week-table { font-size: 0.85rem; min-width: 0; }
  .week-table tbody th { max-width: 220px; }
  .week-day-h { min-width: 48px; }
}

/* =========================================================
   БЛИЖАЙШИЕ СОБЫТИЯ КАЛЕНДАРЯ ВНИЗУ ЭКРАНА ЗАДАЧ
   ========================================================= */
.upcoming-events-box {
  margin-top: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: 0 4px 18px rgba(26, 35, 50, 0.06);
}

.upcoming-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.upcoming-head h3 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--ink);
}

.upcoming-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.upcoming-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.15s, background 0.15s;
}

.upcoming-item:hover {
  border-color: #94a3b8;
  background: #f1f5f9;
}

.cal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
  display: inline-block;
}

.upcoming-title {
  font-weight: 700;
  font-size: 0.88rem;
  line-height: 1.25;
}

.upcoming-meta {
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 2px;
}

.upcoming-quick-form {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.upcoming-quick-form input[type="text"] {
  flex: 1 1 200px;
  min-width: 160px;
}

.upcoming-quick-form input[type="datetime-local"] {
  flex: 0 1 180px;
}

/* =========================================================
   КАЛЕНДАРЬ (GOOGLE CALENDAR STYLE)
   ========================================================= */
.cal-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 14px;
  align-items: start;
}

@media (max-width: 820px) {
  .cal-layout {
    grid-template-columns: 1fr;
  }
}

.cal-sidebar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cal-create-btn {
  width: 100%;
  padding: 10px;
  font-weight: 800;
  font-size: 0.92rem;
}

.cal-groups-box h3,
.cal-upcoming-side h3 {
  margin: 0 0 8px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.cal-filters {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cal-filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  cursor: pointer;
}

.cal-side-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
}

.cal-side-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: #f8fafc;
  border: 1px solid var(--line);
  cursor: pointer;
}

.cal-side-title {
  font-weight: 700;
  font-size: 0.84rem;
}

.cal-side-meta {
  font-size: 0.74rem;
  color: var(--muted);
}

.cal-main {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.cal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 10px;
}

.cal-nav-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cal-month-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--muted);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-left: 1px solid var(--line);
  border-top: 1px solid var(--line);
}

.cal-cell {
  min-height: 92px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 4px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cal-cell.is-other-month {
  background: #f8fafc;
  color: #94a3b8;
}

.cal-cell.is-today {
  background: #eff6ff;
}

.cal-cell-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cal-day-num {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 99px;
}

.cal-cell.is-today .cal-day-num {
  background: #2563eb;
  color: #fff;
}

.cal-cell-add {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 4px;
  opacity: 0.35;
}

.cal-cell:hover .cal-cell-add {
  opacity: 1;
}

.cal-cell-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cal-ev-chip {
  font-size: 0.73rem;
  padding: 2px 5px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
  font-weight: 600;
}

.cal-ev-time {
  font-weight: 800;
  opacity: 0.85;
}

.cal-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

@media (max-width: 560px) {
  .cal-cell { min-height: 68px; padding: 2px; }
  .cal-ev-chip { font-size: 0.66rem; padding: 1px 3px; }
  .cal-form-row { grid-template-columns: 1fr; }
}

/* =========================================================
   ЗАМЕТКИ (GOOGLE KEEP) И ДОКУМЕНТЫ / СЧЕТА
   ========================================================= */
.notes-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.notes-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.notes-tab {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 99px;
  font-weight: 700;
  cursor: pointer;
}

.notes-tab.is-active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.notes-search-inline {
  margin-left: auto;
  min-width: 240px;
  flex: 1 1 240px;
  max-width: 380px;
}

.keep-composer {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 4px 16px rgba(26, 35, 50, 0.06);
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.keep-composer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.keep-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.keep-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.keep-select {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 0.82rem;
}

.composer-files-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pending-file-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #e2e8f0;
  padding: 4px 8px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 600;
}

.pending-file-pill button {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  align-items: start;
}

.keep-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 2px 10px rgba(26, 35, 50, 0.05);
}

.keep-card.is-pinned {
  border-width: 2px;
  border-color: #2563eb;
}

.keep-color-blue { background: #eff6ff; border-color: #bfdbfe; }
.keep-color-green { background: #f0fdf4; border-color: #bbf7d0; }
.keep-color-amber { background: #fffbeb; border-color: #fde68a; }
.keep-color-red { background: #fef2f2; border-color: #fecaca; }
.keep-color-purple { background: #faf5ff; border-color: #e9d5ff; }

.keep-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}

.keep-card-title {
  font-weight: 800;
  font-size: 0.96rem;
}

.keep-card-ops {
  display: flex;
  gap: 2px;
}

.keep-card-body {
  font-size: 0.88rem;
  line-height: 1.4;
  word-break: break-word;
}

.keep-card-files {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px dashed rgba(0, 0, 0, 0.12);
  padding-top: 6px;
}

.note-att-img {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.note-att-link {
  font-size: 0.8rem;
  font-weight: 700;
  color: #1d4ed8;
  text-decoration: none;
}

.note-ocr-badge {
  font-size: 0.72rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
  padding: 3px 6px;
  border-radius: 4px;
  margin-top: 2px;
}

.keep-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 4px;
}

.keep-tag {
  background: rgba(15, 23, 42, 0.07);
  padding: 2px 7px;
  border-radius: 99px;
  font-weight: 700;
}

.docs-upload-bar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.docs-upload-bar h3 { margin: 0 0 4px; }

.docs-upload-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.files-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.doc-row {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.doc-preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.doc-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: #f1f5f9;
  border-radius: 8px;
  font-size: 1.6rem;
  text-decoration: none;
}

.doc-info {
  flex: 1;
  min-width: 0;
}

.doc-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.doc-name {
  font-weight: 800;
  color: #1d4ed8;
  text-decoration: none;
}

.doc-size {
  font-size: 0.76rem;
  color: var(--muted);
}

.doc-ocr-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 0.76rem;
}

/* =========================================================
   ГЛОБАЛЬНЫЙ ПОИСК (🔍) И ИИ-ПОМОЩНИК (🤖)
   ========================================================= */
.dlg-wide {
  width: min(640px, 94vw);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

.gsearch-head {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.gsearch-head input {
  flex: 1;
  font-size: 1rem;
  padding: 10px 12px;
}

.gsearch-results {
  max-height: 68vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gsearch-results h3 {
  margin: 10px 0 4px;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--muted);
}

.gsearch-item {
  display: block;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  text-decoration: none;
  color: var(--ink);
}

.gsearch-item:hover {
  border-color: #94a3b8;
  background: #f1f5f9;
}

.gsearch-title {
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.gsearch-meta {
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: 600;
  margin-left: auto;
}

.gsearch-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 3px;
}

.ai-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #1a2332;
  color: #fff;
  border: 2px solid #3b82f6;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.35);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-panel {
  position: fixed;
  right: 18px;
  bottom: 80px;
  width: min(410px, calc(100vw - 24px));
  max-height: min(600px, calc(100vh - 110px));
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.28);
  z-index: 95;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ai-panel[hidden] {
  display: none !important;
}

.ai-head {
  background: #1a2332;
  color: #fff;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-sub {
  display: block;
  font-size: 0.7rem;
  color: #94a3b8;
}

.ai-head-actions {
  display: flex;
  gap: 4px;
}

.ai-btn-sm {
  color: #fff !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
  padding: 4px 7px !important;
  font-size: 0.82rem !important;
}

.ai-btn-sm.is-active {
  background: #2563eb !important;
}

.ai-cfg-box {
  padding: 10px 12px;
  background: #f1f5f9;
  border-bottom: 1px solid var(--line);
  overflow-y: auto;
  max-height: 360px;
  font-size: 0.82rem;
}

.ai-cfg-box h4 {
  margin: 0 0 4px;
}

.ai-cfg-box label {
  display: block;
  margin-top: 6px;
  font-weight: 600;
}

.ai-messages {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f8fafc;
  min-height: 220px;
  max-height: 360px;
}

.ai-msg {
  padding: 8px 11px;
  border-radius: 10px;
  font-size: 0.86rem;
  line-height: 1.4;
  max-width: 88%;
}

.ai-msg-bot {
  background: #fff;
  border: 1px solid var(--line);
  align-self: flex-start;
}

.ai-msg-user {
  background: #1a2332;
  color: #fff;
  align-self: flex-end;
}

.ai-actions-done {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.ai-act-pill {
  background: #dcfce7;
  color: #166534;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 99px;
}

.ai-form {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.ai-form input {
  flex: 1;
}

.ai-mic.is-listening {
  background: #ef4444 !important;
  color: #fff !important;
  border-color: #ef4444 !important;
}

.ai-head-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-engine-switch {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 99px;
  padding: 2px;
  gap: 2px;
}

.ai-eng-btn {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 99px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ai-eng-btn:hover {
  color: #fff;
}

.ai-eng-btn.is-active {
  background: #3b82f6;
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.ai-speak-btn {
  font-size: 0.72rem !important;
  padding: 2px 8px !important;
  border-radius: 99px !important;
}


