/* ===== Theme tokens (CSS variables) ===== */
:root{
  --bg: #f6f7fb;
  --text: #111;
  --card: #fff;
  --border: #eee;
  --border2: #e6e6e6;

  --muted: #777;
  --muted2: #888;

  --chip: #f3f3f3;

  --accent: #0088cc;
  --accentSoft: #e3f2fd;
  --accentSoftText: #1976d2;

  --success: #4CAF50;
  --dangerBg: #ffebee;
  --dangerText: #c62828;
  /* ✅ completed card */
  --completedBg: #f8fff9;
  --completedBorder: #d0f0d4;
  --barBg: #eceef3;

  --overlay: rgba(0,0,0,0.55);

  --shadowSm: 0 1px 3px rgba(0,0,0,0.06);
  --shadowMd: 0 2px 6px rgba(0,0,0,0.05);
  --shadowLg: 0 6px 16px rgba(0,0,0,0.22);
    /* закрытый день (обводка в календаре) */
  --dayClosedRing: #d83a3a; /* красная, как сейчас */

}

/* Тёмная (приятно-серая) */
body[data-theme="dark"]{
  --bg: #141518;
  --text: #f1f1f1;
  --card: #1d1f24;
  --border: #2a2d34;
  --border2: #2a2d34;

  --muted: #a7a7a7;
  --muted2: #b0b0b0;

  --chip: #2a2d34;

  --accent: #4da3ff;
  --accentSoft: rgba(77,163,255,0.14);
  --accentSoftText: #9fd0ff;

  --success: #45c07a;
  --dangerBg: rgba(255, 91, 91, 0.16);
  --dangerText: #ff8080;
  /* ✅ completed card (тёмная, приятная) */
  --completedBg: rgba(69, 192, 122, 0.12);
  --completedBorder: rgba(69, 192, 122, 0.25);
  --barBg: #2a2d34;

  --overlay: rgba(0,0,0,0.65);

  --shadowSm: 0 1px 3px rgba(0,0,0,0.35);
  --shadowMd: 0 2px 6px rgba(0,0,0,0.35);
  --shadowLg: 0 6px 16px rgba(0,0,0,0.50);
  --dayClosedRing: #ff6b6b; /* мягкий красный, читаемый на тёмном */

}

/* Розовая (бледная) */
body[data-theme="pink"]{
  --bg: #fff5f8;
  --text: #1a1214;
  --card: #ffffff;
  --border: #f2d6df;
  --border2: #f2d6df;

  --muted: #85656f;
  --muted2: #7c5d67;

  --chip: #fde7ee;

  --accent: #d84a7a;
  --accentSoft: #ffe0ea;
  --accentSoftText: #a72d57;

  --success: #2f9e62;
  --dangerBg: #ffe3ea;
  --dangerText: #b42345;

  --barBg: #f3dbe3;
  /* ✅ completed card = цвет фона темы */
  --completedBg: #fff5f8;
  --completedBorder: #f2d6df;
  --dayClosedRing: #d84a7a; /* акцентный розовый */

}

/* Голубая (нюдовая) */
body[data-theme="blue"]{
  --bg: #f3f7ff;
  --text: #111827;
  --card: #ffffff;
  --border: #dbe6ff;
  --border2: #dbe6ff;

  --muted: #5b6b85;
  --muted2: #60708a;

  --chip: #e9f0ff;

  --accent: #3b7ddd;
  --accentSoft: #e1ecff;
  --accentSoftText: #245aa8;

  --success: #2f9e62;
  --dangerBg: #ffe9ee;
  --dangerText: #b42345;

  --barBg: #dfe9ff;
    /* ✅ completed card = цвет фона темы */
  --completedBg: #f3f7ff;
  --completedBorder: #dbe6ff;
  --dayClosedRing: #3b7ddd; /* акцентный голубой */

}

/* Зелёная (приятная) */
body[data-theme="green"]{
  --bg: #f3fbf6;
  --text: #0f1a13;
  --card: #ffffff;
  --border: #d3efe0;
  --border2: #d3efe0;

  --muted: #486457;
  --muted2: #4f6b5e;

  --chip: #e7f6ee;

  --accent: #2f9e62;
  --accentSoft: #ddf3e7;
  --accentSoftText: #1f6d43;

  --success: #2f9e62;
  --dangerBg: #ffe9ee;
  --dangerText: #b42345;

  --barBg: #d9f1e5;
  --dayClosedRing: #2f9e62; /* зелёный акцент */
}

/* ===== Base ===== */
* { box-sizing: border-box; }

html, body {
  height: 100%;
}
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.container {
  padding: 16px;
  padding-bottom: 110px; /* место под нижнее меню */
}

.user-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0 16px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

#user-name {
  font-weight: 600;
  font-size: 16px;
  white-space: pre-line; /* ✅ показываем перенос строки \n */
  line-height: 1.25;
}

.settings-btn {
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  box-shadow: var(--shadowSm);
  color: var(--text);
}

/* ===== Tabs ===== */
.tab { display: none; }
.tab.active { display: block; }

/* ===== Floating add button ===== */
.fab {
  position: fixed;
  bottom: 80px;
  right: 18px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 22px;
  box-shadow: var(--shadowLg);
  cursor: pointer;
  z-index: 10;
}

/* ===== Bottom navigation ===== */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border2);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.12);
  z-index: 100;
}

#bottom-nav button {
  flex: 1;
  padding: 10px 6px;
  font-size: 13px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted2);
}

#bottom-nav button.active {
  color: var(--accent);
  font-weight: 700;
}

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #666;
}
.empty-state p {
  margin: 0;
  line-height: 1.4;
}

/* ===== Habit cards ===== */
.habit-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadowMd);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  cursor: pointer;
}

/* ===== Habit menu (⋮) ===== */
.habit-menu-btn {
  border: none;
  background: transparent;
  color: var(--muted2);
  font-size: 22px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  margin-left: auto;
}

.habit-menu-btn:hover {
  background: var(--chip);
}


.habit-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.habit-card.completed {
  background: var(--completedBg);
  border-color: var(--completedBorder);
}

.habit-card-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.habit-checkbox {
  font-size: 20px;
  min-width: 24px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  margin-top: 1px;
}

.habit-info { flex: 1; }

.habit-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 4px 0;
  line-height: 1.3;
  word-break: break-word;
}

.habit-schedule {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

/* ===== Habit detail modal ===== */
#habit-detail-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--overlay);
  display: flex;
  align-items: flex-end;
  z-index: 2000;
}

.habit-detail-modal {
  /* ✅ по умолчанию — фон как у темы */
  background: var(--bg);
  color: var(--text);

  border-radius: 16px;
  padding: 18px;
  width: 100%;
  max-width: 420px;
}

/* ✅ в тёмной теме оставляем карточный фон */
body[data-theme="dark"] .habit-detail-modal {
  background: var(--card);
}

.habit-detail-modal h3 {
  margin: 0 0 14px 0;
  font-size: 20px;
}

.modal-actions {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-btn {
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  cursor: pointer;
}

.modal-btn.edit {
  background: var(--accentSoft);
  color: var(--accentSoftText);
  border: 1px solid var(--border2);
}

.modal-btn.archive {
  background: var(--dangerBg);
  color: var(--dangerText);
  border: 1px solid var(--border2);
}

.modal-btn.cancel {
  background: var(--chip);
  color: var(--text);
  border: 1px solid var(--border2);
}


/* ===== Habit editor modal ===== */
#habit-editor-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--overlay);
  display: flex;
  align-items: flex-end;
  z-index: 2000;
}

.habit-editor-modal {
  background: var(--card);
  color: var(--text);
  padding: 22px;
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}

.habit-editor-modal h3 {
  text-align: center;
  margin: 0 0 18px 0;
  font-weight: 700;
}

.habits-list { margin-bottom: 16px; }

.habit-editor-item {
  background: var(--bg);
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}

.habit-field { margin-bottom: 12px; }

.habit-field label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 14px;
  color: var(--text);
}

.habit-title-input,
.schedule-type-select,
.remind-select,
.custom-time-input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border2);
  border-radius: 10px;
  font-size: 16px;
  background: var(--card);
  color: var(--text);
}
.habit-title-input::placeholder{
  color: var(--muted);
}


.days-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.day-btn {
  padding: 7px 12px;
  border: 1px solid var(--border2);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}

.day-btn.selected {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.delete-habit-btn {
  background: #ffebee;
  color: #c62828;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  margin-top: 10px;
  cursor: pointer;
  font-weight: 700;
  width: 100%;
}

.add-habit-btn {
  background: var(--accentSoft);
  color: var(--accentSoftText);
  border: 1px solid var(--border2);
  padding: 12px;
  border-radius: 10px;
  width: 100%;
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 14px;
  cursor: pointer;
}

.editor-actions {
  display: flex;
  gap: 12px;
}

.btn-primary,
.btn-secondary {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}

.btn-primary { background: var(--success); color: #fff; }
.btn-secondary { background: var(--chip); color: var(--text); border: 1px solid var(--border2); }
/* ===== Modal helpers ===== */
.hidden { display: none !important; }

.modal-overlay{
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;

  width: 100%;
  height: 100%;

  background: var(--overlay);
  display: flex;
  align-items: flex-end;
  z-index: 2500;
}


.settings-modal{
  /* ✅ по умолчанию фон = как на главной */
  background: var(--bg);
  color: var(--text);

  width: 100%;
  border-radius: 16px 16px 0 0;
  padding: 18px;
  max-height: 85vh;
  overflow-y: auto;
}

/* ✅ в тёмной теме оставляем “карточный” фон (как было красиво) */
body[data-theme="dark"] .settings-modal{
  background: var(--card);
}

.setting-row{
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.setting-text{ flex: 1; }
.setting-title{ font-weight: 800; }
.setting-sub{ color: var(--muted); font-size: 13px; margin-top: 2px; }

.setting-block{ padding: 12px 0; }
.setting-label{ display:block; font-weight: 800; margin-bottom: 8px; }

.setting-input{
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border2);
  border-radius: 10px;
  font-size: 16px;
  background: var(--card);
  color: var(--text);
}

.setting-range{
  width: 100%;
}

.settings-actions{
  display:flex;
  gap: 12px;
  margin-top: 14px;
}

/* ===== iOS-like switch ===== */
.switch{
  position: relative;
  display: inline-block;
  width: 46px;
  height: 28px;
  flex: 0 0 auto;
}

.switch input{ display:none; }

.slider{
  position:absolute;
  cursor:pointer;
  inset:0;
  background: var(--chip);
  border: 1px solid var(--border2);
  border-radius: 999px;
  transition: .2s;
}

.slider:before{
  content:"";
  position:absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  top: 3px;
  background:white;
  border-radius: 50%;
  transition: .2s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
}

.switch input:checked + .slider{
  background: var(--success);
  border-color: var(--success);
}

.switch input:checked + .slider:before{
  transform: translateX(18px);
}

/* ===== Date header card ===== */
.date-card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius:14px;
  padding:12px 10px;
  display:flex;
  align-items:center;
  gap:10px;
  box-shadow: var(--shadowMd);
  margin-bottom: 10px;
}

.date-card-center{
  flex:1;
  text-align:center;
  cursor: pointer;
}

.date-title{
  font-weight: 800;
  font-size: 16px;
  text-transform: capitalize;
}

.date-subtitle{
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
  text-transform: capitalize;
}

.icon-btn{
  border: 1px solid var(--border);
  background: var(--chip);
  color: var(--text);
  border-radius:12px;
  padding:10px 12px;
  cursor:pointer;
  font-size:16px;
}

.today-btn{
  width: 100%;
  border: 1px solid var(--border2);
  background: var(--card);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 800;
  cursor:pointer;
  margin-bottom: 10px;
  box-shadow: var(--shadowSm);
}
/* ✅ чуть больше воздуха между заметкой и кнопкой "Редактор привычек" */
#open-habit-editor-btn{
  margin-top: 12px; /* как между карточками привычек */
}

/* ===== Progress card ===== */
.progress-card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius:14px;
  padding:12px;
  box-shadow: var(--shadowMd);
  margin-bottom: 12px;
}

.progress-top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom: 10px;
}

.progress-left{ font-weight: 700; }
.progress-right{ font-weight: 900; }

.progress-bar{
  height: 12px;
  background: var(--barBg);
  border-radius: 999px;
  overflow:hidden;
}

.progress-fill{
  height:100%;
  background: var(--accent);
  width:0%;
  transition: width 0.25s ease;
}

.streak-line{
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

/* ===== Bottom nav layout adjustments ===== */
.container{
  padding-bottom: 110px; /* место под нижнее меню */
}

/* чтобы кнопки смотрелись аккуратнее внутри меню */
#bottom-nav button{
  padding: 12px 6px;
}

/* FAB — выше нижнего меню */
.fab{
  bottom: 80px;
}

.editor-row-actions{
  display:flex;
  gap:10px;
}

.editor-row-actions button{
  flex:1;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 800;
}

.archive-habit-btn, .restore-btn{
  background:#e3f2fd;
  color:#1976d2;
}

.hard-delete-habit-btn, .hard-delete-btn{
  background:#ffebee;
  color:#c62828;
}

.archive-habit-btn-full{
  width: 100%;
  background: #ffebee;
  color: #c62828;
  border: none;
  padding: 12px 16px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 800;
  font-size: 16px;
  margin-top: 10px;
}

/* ===== Day note card ===== */
.note-card{
  /* ✅ фон как у темы (как на главной) */
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius:14px;
  padding:14px;
  margin-top: 12px;
  box-shadow: var(--shadowMd);
}

/* ✅ в тёмной теме оставим карточку как card, чтобы не сливалась */
body[data-theme="dark"] .note-card{
  background: var(--card);
}

.note-title{
  font-weight: 800;
  margin-bottom: 10px;
  color: var(--text);
}
/* ✅ читаемый заголовок в тёмной теме */
body[data-theme="dark"] .note-title{
  color: var(--text);
  font-weight: 900;
}

.note-textarea{
  width: 100%;
  min-height: 120px;
  resize: vertical;
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 12px;
  font-size: 15px;
  background: var(--card);   /* ✅ поле ввода остаётся “белым/карточным” */
  color: var(--text);
  outline: none;
}

.note-textarea::placeholder{
  color: var(--muted);
}

.note-bottom{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.note-counter{
  color: var(--muted);
  font-size: 13px;
}

.note-save-btn{
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;

  /* ✅ под тему */
  background: var(--accent);
  color: #fff;

  opacity: 1;
}

.note-save-btn:disabled{
  opacity: 0.5;
  cursor: default;
}

.note-status{
  margin-top: 8px;
  font-size: 13px;
  color: var(--success);
  min-height: 16px;
}

/* ===== Calendar modal ===== */
.calendar-modal{
  background: var(--card);
  color: var(--text);
  /* ширина и отступы */
  width: calc(100% - 24px);   /* по 12px слева/справа */
  max-width: 420px;
  margin: 0 auto 12px;        /* отступ снизу */

  border-radius: 18px;
  padding: 18px;

  max-height: 85vh;
  overflow-y: auto;
}


.calendar-header{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.calendar-title{
  font-weight: 900;
  text-align:center;
  flex: 1;
}

.calendar-weekdays{
  display:grid;
  grid-template-columns: repeat(7, 1fr);
  text-align:center;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.calendar-grid{
  display:grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;

  /* ✅ фиксируем под 6 строк, чтобы модалка не "прыгала" */
  height: 270px; /* 6*40px + 5*6px */
}


.calendar-day{
  position: relative;
  height: 40px;
  border-radius: 12px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
  user-select: none;
}

.calendar-day:hover{
  filter: brightness(0.97);
}
body[data-theme="dark"] .calendar-day:hover{
  filter: brightness(1.08);
}

.calendar-day.is-today{
  border-color: var(--accent);
}

.calendar-day.is-selected{
  outline: 2px solid rgba(0,136,204,0.25);
  outline-offset: 0px;
}
body[data-theme="dark"] .calendar-day.is-selected{
  outline: 2px solid rgba(77,163,255,0.35);
}

.calendar-day.is-empty{
  background: transparent;
  border: none;
  cursor: default;
}

.calendar-header-center{
  display:flex;
  flex-direction: column;
  align-items:center;
  gap: 6px;
  flex: 1;
}

.cal-current-btn{
  border: 1px solid var(--border2);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  width: 34px;
  height: 28px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight: 900;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
}
/* ===== Closed day hand-drawn oval ===== */
.calendar-day.closed-day::after{
  content:"";
  position:absolute;
  inset:4px;
  border:3px solid var(--dayClosedRing);
  border-radius:50%;
  pointer-events:none;
  opacity:0.95;
}
/* ===== Theme picker (dots) ===== */
.theme-picker{
  display:flex;
  gap: 10px;
  align-items:center;
  padding: 6px 0 2px;
}

.theme-dot{
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 2px solid var(--border2);
  background: var(--card);
  cursor: pointer;
  padding: 0;
  box-shadow: var(--shadowSm);
}

.theme-dot[data-theme="default"]{ background: #ffffff; }
.theme-dot[data-theme="dark"]{ background: #2a2d34; border-color: #3a3f49; }
.theme-dot[data-theme="pink"]{ background: #ffe0ea; }
.theme-dot[data-theme="blue"]{ background: #e1ecff; }
.theme-dot[data-theme="green"]{ background: #ddf3e7; }

.theme-dot.is-selected{
  outline: 3px solid rgba(0,0,0,0.12);
  outline-offset: 2px;
  border-color: var(--accent);
}

/* чтобы в dark outline не был “грязным” */
body[data-theme="dark"] .theme-dot.is-selected{
  outline: 3px solid rgba(255,255,255,0.18);
}

/* ===== Quick add overlay uses same modal style ===== */
#quick-add-overlay{
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--overlay);
  display: flex;
  align-items: flex-end;
  z-index: 2600;
}

/* ===== Habit editor accordion ===== */
.habit-editor-header{
  display: flex;
  align-items: center;
  gap: 10px;
}

.habit-expand-btn{
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid var(--border2);
  background: var(--chip);
  color: var(--text);
  cursor: pointer;
  font-weight: 900;
  line-height: 1;
}

.habit-title-input--header{
  margin: 0;
}

.habit-editor-details{
  margin-top: 10px;
}
/* ✅ Support button under settings actions */
.settings-support{
  margin-top: 12px;
}

.settings-support-btn{
  width: 100%;
}


