/* --- home screen — 1b iOS-минимализм ----------------------- */

.home-page {
  position: relative;
  padding-bottom: 28px;
}

.home-greeting {
  margin: 0 0 22px;
}
.home-greeting-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 30px;
  letter-spacing: -.02em;
  line-height: 1.15;
  color: var(--ink);
}
.home-greeting-sub {
  font-weight: 500;
  font-size: 15px;
  color: var(--ink-faint);
  margin-top: 2px;
}

.home-hero-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 8px;
}
.home-hero-row--solo .day-card {
  max-width: none;
}

/* --- карточка «Повторение дня» ----------------------------- */
.day-card {
  flex: 1 1 0;
  min-width: min(100%, 320px);
  background: var(--bg-raised);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.day-card-head {
  display: flex;
  align-items: center;
  gap: 14px;
}
.day-card-raven {
  width: 46px;
  height: 46px;
  flex: none;
  object-fit: contain;
}
.day-card-titles { flex: 1; min-width: 0; }
.day-card-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  line-height: 1.2;
}
.day-card-title[hidden] { display: none; }
.day-card-sub {
  font-weight: 500;
  font-size: 13px;
  color: var(--ink-faint);
}
.day-card-sub--as-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  line-height: 1.2;
  color: var(--ink);
}
.day-card-footer--no-acc {
  justify-content: flex-start;
}
.day-card-footer--no-acc .day-continue {
  flex: none;
  min-width: 160px;
}
.day-card-toggle {
  flex: none;
  width: 34px;
  height: 34px;
  border: 0;
  cursor: pointer;
  border-radius: 50%;
  background: color-mix(in srgb, var(--ink) 5%, transparent);
  color: var(--ink-soft);
  display: grid;
  place-items: center;
  font: 700 15px var(--font-body);
  transition: background .2s, color .2s;
}
.day-card-toggle:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.day-card-body-slot {
  min-height: 136px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.day-card-body-slot > .day-card-body {
  flex: 1;
}
.day-card-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 8px;
}
.day-card-ring {
  display: flex;
  align-items: center;
  gap: 22px;
  min-height: 136px;
}
.day-donut {
  position: relative;
  width: 110px;
  height: 110px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.day-donut-inner {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: var(--bg-raised);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-sizing: border-box;
  padding: 0;
}
.day-donut-num {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  line-height: 1;
  margin: 0;
}
.day-donut-of {
  font-weight: 600;
  font-size: 10px;
  line-height: 1.1;
  color: var(--ink-muted);
  margin: 3px 0 0;
}
.day-legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
}
.day-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
}
.day-legend-left { color: var(--ink-faint); }
.day-legend-val {
  margin-left: auto;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.day-legend-ok { color: var(--ok-text); }
.day-legend-fail { color: var(--danger-text); }
.day-swatch {
  width: 10px;
  height: 10px;
  border-radius: 4px;
  flex: none;
}
.day-swatch-ok { background: var(--ok); }
.day-swatch-fail { background: var(--danger); }
.day-swatch-left { background: var(--bg-sunken); }
.day-swatch-ok-sm,
.day-swatch-fail-sm {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 5px;
}
.day-swatch-ok-sm { background: var(--accent); }
.day-swatch-fail-sm { background: #E8B0A8; }

.day-card-week {
  min-height: 136px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
}
.week-bars {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 96px;
  padding-top: 4px;
}
.week-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  height: 100%;
  justify-content: flex-end;
}
.week-bar-empty {
  width: 100%;
  max-width: 34px;
  height: 6px;
  border-radius: 4px;
  background: var(--bg-sunken);
}
.week-bar-stack {
  width: 100%;
  max-width: 34px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.week-bar-fail {
  border-radius: 4px 4px 2px 2px;
  background: #E8B0A8;
  min-height: 3px;
}
.week-bar-ok {
  border-radius: 2px 2px 4px 4px;
  background: var(--accent);
  min-height: 4px;
}
.week-bar-label {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 10.5px;
  line-height: 1.2;
  color: var(--ink-muted);
}
.week-bar-label.is-today {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 0.02em;
}
.week-legend {
  display: flex;
  gap: 14px;
  font-weight: 600;
  font-size: 11.5px;
  color: var(--ink-faint);
}

.day-accuracy {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 46px;
  padding: 0 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 15px;
  color: var(--ok-text);
  background: var(--ok-soft);
}
.day-continue {
  flex: 1;
  border: 0;
  cursor: pointer;
  height: 46px;
  padding: 0 30px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  font-family: var(--font-body);
  box-shadow: 0 6px 16px rgba(196, 85, 40, .28);
  transition: transform .2s, box-shadow .2s;
}
.day-continue:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(196, 85, 40, .36);
}
.day-continue:active { transform: translateY(0); }
[data-theme="dark"] .day-continue { color: var(--btn-ink); }

/* --- серия + календарь ------------------------------------- */
.streak-cal-card {
  flex: none;
  width: 340px;
  max-width: 340px;
  background: var(--bg-raised);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.home-hero-row--solo .day-card {
  flex: 1;
  max-width: none;
}
.streak-cal-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: default;
}
.streak-cal-num {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 34px;
  line-height: 1;
  color: var(--accent);
}
.streak-cal-label {
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-faint);
}
.streak-cal-cup {
  width: 22px;
  height: 22px;
  margin-left: auto;
  object-fit: contain;
}
.streak-cal-chevron {
  display: none;
  flex: none;
  width: 8px;
  height: 8px;
  margin-left: 4px;
  border-right: 2px solid var(--ink-soft);
  border-bottom: 2px solid var(--ink-soft);
  transform: rotate(45deg);
  transition: transform var(--dur) var(--ease);
}
.streak-cal-expand { min-width: 0; }
.home-cal-weekdays,
.home-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}
.home-cal-weekdays {
  margin-top: 14px;
}
.home-cal-weekdays > div {
  text-align: center;
  font-weight: 700;
  font-size: 10.5px;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.home-cal-grid { margin-top: 5px; }
.home-cal-day {
  aspect-ratio: 1;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
  background: var(--bg-sunken);
  color: var(--ink-muted-soft);
}
.home-cal-day.is-outside {
  background: transparent;
  pointer-events: none;
}
.home-cal-day.heat-1 {
  background: #F5D9C8;
  color: var(--terra-deep);
}
.home-cal-day.heat-2 {
  background: #E8B79C;
  color: var(--terra-deep);
}
.home-cal-day.heat-3 {
  background: var(--accent);
  color: #fff;
}
.home-cal-day.is-today {
  box-shadow: inset 0 0 0 2px var(--accent);
}
.streak-cal-foot {
  font-weight: 500;
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 12px;
}

/* --- welcome / library ------------------------------------- */
.home-welcome {
  margin: 20px 0 8px;
  padding: 20px 22px;
  background: var(--bg-raised);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.home-welcome-text {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--ink-faint);
  line-height: 1.45;
}
.home-welcome-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.home-section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 14px;
}
.home-library-head { margin-top: 32px; }
.home-section-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--ink);
  text-transform: none;
}
.home-section-aside {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--accent-text);
}
.section-hint {
  margin: -6px 0 12px;
  font-size: 13px;
  color: var(--ink-faint);
  line-height: 1.45;
}

.library-grid .folder-card,
.library-grid .box-card {
  border: none;
  border-radius: var(--radius-md);
  padding: 18px;
  min-height: 118px;
  box-shadow: var(--shadow-sm);
}

/* базовые карточки коробок (также вне library) */
.box-card {
  background: var(--bg-raised);
  border: none;
  border-radius: var(--radius-md);
  padding: 18px;
  cursor: pointer;
  min-height: 118px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  animation: itemIn .4s var(--ease) backwards;
}
.box-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(44, 34, 25, .1);
}
.box-card:active { transform: scale(.97); }
.box-card .swatch {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  margin-bottom: 0;
}
.box-card h3 {
  margin: 12px 0 4px;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-display);
}
.box-card .meta { color: var(--ink-faint); font-size: 12px; margin-top: auto; line-height: 1.35; }
.box-card .due-chip {
  position: absolute;
  top: 18px;
  right: 18px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
}
.add-tile-box { min-height: 118px; }

.library-grid .folder-card:hover,
.library-grid .box-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(44, 34, 25, .1);
  border-color: transparent;
}
.library-grid .folder-card .swatch,
.library-grid .box-card .swatch {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  margin-bottom: 0;
}
.library-grid .folder-card h3,
.library-grid .box-card h3 {
  font-size: 15.5px;
  margin-top: 12px;
}
.library-grid .folder-card .meta,
.library-grid .box-card .meta {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-faint);
}
.library-grid .due-chip {
  position: absolute;
  top: 18px;
  right: 18px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
}
.library-grid .folder-card .swatch,
.library-grid .box-card .swatch {
  margin-bottom: 0;
}
.library-grid .add-tile,
.library-grid .add-tile-box {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-md);
  min-height: 118px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-muted);
  background: transparent;
}
.library-grid .add-tile:hover,
.library-grid .add-tile-box:hover {
  border-color: var(--accent);
  color: var(--accent-text);
  background: transparent;
}

/* drag-drop target на коробках */
.box-card.box-drop-target.is-drop-target {
  transform: translateY(-4px) scale(1.02);
  background: color-mix(in srgb, var(--accent-soft) 55%, var(--bg-raised));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent), var(--shadow-lg);
}
html.folder-drag-active .box-card.box-drop-target {
  transition: transform .22s var(--ease), box-shadow .22s var(--ease), background .22s var(--ease);
}

.folder-unbox-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 2px dashed color-mix(in srgb, var(--line) 85%, var(--accent) 15%);
  background: var(--bg-sunken);
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  transition: border-color .22s var(--ease), background .22s var(--ease), color .22s var(--ease), transform .22s var(--ease);
}
.folder-unbox-zone-icon { font-size: 18px; line-height: 1; opacity: .75; }
.folder-unbox-zone.is-drop-target {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--terra-deep);
  transform: scale(1.01);
}
html.folder-drag-active .folder-unbox-zone {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}
.box-folder-pick { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.box-folder-pick-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-sunken);
  cursor: pointer;
  font-size: 14px;
}
.box-folder-pick-row:has(input:checked) {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: var(--accent-soft);
}
.box-folder-pick-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.box-empty { margin-top: 8px; }
.empty-icon { width: 88px; height: 88px; margin: 0 auto 14px; object-fit: contain; opacity: .85; }

@media (max-width: 719px) {
  .home-hero-row {
    flex-direction: column;
  }
  /* календарь — сверху, свёрнут до стрика */
  .streak-cal-card {
    order: -1;
    max-width: none;
    width: 100%;
  }
  .streak-cal-collapsible:not(.is-open) {
    padding: 14px 18px;
  }
  .streak-cal-collapsible .streak-cal-head {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
    align-items: center;
  }
  .streak-cal-collapsible .streak-cal-chevron { display: block; }
  .streak-cal-collapsible.is-open .streak-cal-chevron {
    transform: rotate(-135deg);
    margin-top: 4px;
  }
  .streak-cal-collapsible .streak-cal-expand {
    display: none;
  }
  .streak-cal-collapsible.is-open .streak-cal-expand {
    display: block;
  }
  .streak-cal-collapsible.is-open .home-cal-weekdays {
    margin-top: 12px;
  }
}

@media (max-width: 560px) {
  .home-greeting-title { font-size: 26px; }
  .day-card { padding: 20px; }
  .day-card-ring { gap: 14px; }
  .day-donut { width: 96px; height: 96px; }
  .day-donut-inner { width: 72px; height: 72px; }
  .day-accuracy { padding: 0 14px; font-size: 14px; }
  .streak-cal-card { max-width: none; }
}
