:root {
  --bg: #f0f4ff;
  --surface: #ffffff;
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #e0e7ff;
  --accent: #f59e0b;
  --accent-light: #fef3c7;
  --success: #10b981;
  --success-light: #d1fae5;
  --text: #1e1b4b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 4px 20px rgba(99, 102, 241, 0.12);
  --shadow-lg: 0 8px 32px rgba(99, 102, 241, 0.18);
  --radius: 16px;
  --radius-sm: 10px;
  --font: 'Nunito', system-ui, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  background: var(--bg);
  background-image:
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 90% 80%, rgba(245, 158, 11, 0.08) 0%, transparent 50%);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
}

.app {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 11.5rem;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  padding: 0.65rem 0.55rem;
  padding-bottom: calc(0.65rem + var(--safe-bottom));
  overflow-y: auto;
  z-index: 100;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
}

.site-home {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: var(--primary);
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: -0.02em;
  text-decoration: none;
  line-height: 1;
}

.site-home:hover,
.site-home:focus-visible {
  background: var(--primary);
  color: #fff;
  outline: none;
}

.sidebar__logo {
  font-size: 1.2rem;
  line-height: 1;
}

.sidebar__title {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
}

.sidebar__motivation {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary-dark);
  line-height: 1.35;
  margin-bottom: 0.35rem;
}

.sidebar__date {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1.3;
  margin-bottom: 0.45rem;
}

.sidebar__badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.app__content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.header-level {
  font-size: 0.62rem;
  font-weight: 800;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-dark);
  white-space: nowrap;
}

.stars-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  background: var(--accent-light);
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-weight: 800;
  font-size: 0.82rem;
  color: #b45309;
  transition: transform 0.2s;
}

.stars-badge--pulse {
  animation: starPulse 0.5s ease;
}

@keyframes starPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.stars-badge__icon { font-size: 0.85rem; }

.sync-status {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.sync-status[data-status="ok"] { color: var(--success); }
.sync-status[data-status="sync"] { color: var(--primary); }
.sync-status[data-status="error"] { color: #ef4444; }

/* Nav — vertical in sidebar */
.nav {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: auto;
  padding-top: 0.5rem;
}

.nav__btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.55rem 0.6rem;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 42px;
  text-align: left;
}

.nav__icon {
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}

.nav__label { line-height: 1.2; }

.nav__btn:hover { background: var(--primary-light); color: var(--primary); }

.nav__btn--active {
  background: var(--primary);
  color: white;
  border-color: var(--primary-dark);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

/* Main */
.main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.35rem 0.6rem 0.45rem;
  overflow: hidden;
}

.tab[hidden] { display: none !important; }

.tab:not([hidden]) {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

#tab-day:not([hidden]) {
  overflow: hidden;
  gap: 0.3rem;
}

#tab-week:not([hidden]) {
  overflow: hidden;
  gap: 0.25rem;
}

#yesterdayCard:not([hidden]) {
  flex-shrink: 0;
}

#dayContent {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow: hidden;
}

.day-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.day-list__section {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.25rem 0.1rem 0.1rem;
}

#tab-day .task-compact {
  min-height: 38px;
  padding: 0.4rem 0.5rem;
  font-size: 0.78rem;
  margin-bottom: 0;
  gap: 0.45rem;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
}

#tab-day .task-compact__check {
  width: 22px;
  height: 22px;
  border-width: 2px;
  font-size: 0.65rem;
}

#tab-day .task-compact__icon { font-size: 1rem; }

#tab-day .task-compact__name {
  font-size: 0.78rem;
  line-height: 1.25;
}

.day-list__bonus-done {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--success);
  background: var(--success-light);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  text-align: center;
  margin-top: 0.15rem;
}

.day-progress--slim {
  padding: 0;
  margin: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.day-progress--slim .day-progress__bar {
  flex: 1;
  height: 6px;
  margin: 0;
}

.day-progress--slim .day-progress__hint {
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.yesterday-mini {
  display: block;
  width: 100%;
  border: 1px solid var(--success);
  background: var(--success-light);
  border-radius: 8px;
  padding: 0.28rem 0.5rem;
  font-family: var(--font);
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--success);
  text-align: center;
  cursor: pointer;
  flex-shrink: 0;
}

.yesterday-mini:hover { filter: brightness(0.97); }

.section-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

/* Week view */
.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.25rem;
  gap: 0.5rem;
  flex-shrink: 0;
}

.week-nav__btn {
  width: 44px;
  height: 44px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--primary);
  font-weight: 700;
  flex-shrink: 0;
}

.week-nav__btn:hover:not(:disabled) {
  background: var(--primary-light);
  border-color: var(--primary);
}

.week-nav__btn:disabled { opacity: 0.35; cursor: not-allowed; }

.week-nav__label {
  text-align: center;
  font-weight: 800;
  font-size: 1rem;
  flex: 1;
}

.week-nav__today {
  display: block;
  margin: 0 auto 0.45rem;
  padding: 0.35rem 0.85rem;
  border: 2px solid var(--primary);
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-family: var(--font);
  font-weight: 800;
  font-size: 0.75rem;
  cursor: pointer;
  flex-shrink: 0;
}

.week-nav__today:hover { background: var(--primary); color: white; }

.week-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.35rem;
  align-items: start;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 0.25rem;
}

.day-tab__date {
  text-align: center;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--primary-dark);
  margin-bottom: 1rem;
}

.week-day {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.week-day--today {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
}

.week-day--past { opacity: 0.92; }

.week-day__head {
  padding: 0.35rem 0.25rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  flex-shrink: 0;
}

.week-day--today .week-day__head {
  background: var(--primary-light);
}

.week-day__dow {
  font-weight: 800;
  font-size: 0.68rem;
  color: var(--primary-dark);
}

.week-day__date {
  font-size: 0.58rem;
  color: var(--text-muted);
  font-weight: 700;
}

.week-day__badge {
  display: inline-block;
  margin-top: 0.15rem;
  font-size: 0.55rem;
  font-weight: 800;
  background: var(--primary);
  color: white;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
}

.week-day__stats {
  display: flex;
  justify-content: space-between;
  padding: 0.2rem 0.3rem;
  font-size: 0.58rem;
  font-weight: 800;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.week-day__stars { color: var(--accent); }

.week-day__bar {
  height: 3px;
  background: var(--border);
  margin: 0 0.3rem 0.25rem;
  border-radius: 999px;
  overflow: hidden;
  flex-shrink: 0;
}

.week-day__bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 999px;
}

.week-day__section {
  padding: 0.2rem 0.25rem 0.05rem;
  font-size: 0.52rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.week-day__tasks {
  padding: 0 0.2rem 0.25rem;
}

.week-day .task-compact {
  padding: 0.18rem 0.15rem;
  min-height: 24px;
  font-size: 0.58rem;
  gap: 0.15rem;
  margin-bottom: 0.12rem;
  border-radius: 6px;
}

.week-day .task-compact__check {
  width: 14px;
  height: 14px;
  border-width: 1.5px;
  font-size: 0.5rem;
  flex-shrink: 0;
}

.week-day .task-compact__icon {
  font-size: 0.68rem;
  flex-shrink: 0;
}

.week-day .task-compact__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.15;
}

.week-day .task-compact__tag {
  font-size: 0.48rem;
  padding: 0.02rem 0.2rem;
  flex-shrink: 0;
}

.task-compact {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.35rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
  user-select: none;
  min-height: 36px;
}

.task-compact:hover { background: var(--bg); }

.task-compact--done {
  background: var(--success-light);
  opacity: 0.85;
}

.task-compact__check {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  flex-shrink: 0;
  background: var(--surface);
}

.task-compact--done .task-compact__check {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.task-compact__icon { font-size: 0.85rem; flex-shrink: 0; }

.task-compact__name {
  flex: 1;
  line-height: 1.2;
  min-width: 0;
}

.task-compact--done .task-compact__name {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-compact__tag {
  font-size: 0.55rem;
  font-weight: 800;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 0.05rem 0.3rem;
  border-radius: 999px;
  flex-shrink: 0;
}

.week-day--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.5rem;
  text-align: center;
}

/* Day nav (calendar detail) */
.day-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 0.5rem;
}

.day-nav__btn {
  width: 44px;
  height: 44px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  color: var(--primary);
  font-weight: 700;
  transition: all 0.2s;
  flex-shrink: 0;
}

.day-nav__btn:hover:not(:disabled) {
  background: var(--primary-light);
  border-color: var(--primary);
}

.day-nav__btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.day-nav__label {
  text-align: center;
  font-weight: 800;
  font-size: 1rem;
  color: var(--text);
  flex: 1;
}

.day-nav__label small {
  display: block;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  overflow: hidden;
}

.card__header {
  padding: 0.85rem 1.1rem;
  font-weight: 800;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card__header--lessons {
  background: linear-gradient(135deg, var(--primary-light), #ede9fe);
  color: var(--primary-dark);
}

.card__header--bonus {
  background: linear-gradient(135deg, var(--accent-light), #fde68a);
  color: #92400e;
}

.card__body { padding: 0.5rem; }

/* Task items */
.task {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
  cursor: pointer;
  user-select: none;
  min-height: 56px;
}

.task:hover { background: var(--bg); }

.task--done {
  background: var(--success-light);
}

.task--done .task__name {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task__check {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
  transition: all 0.25s;
  background: var(--surface);
}

.task--done .task__check {
  background: var(--success);
  border-color: var(--success);
  color: white;
  animation: checkPop 0.3s ease;
}

@keyframes checkPop {
  0% { transform: scale(0.5); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.task__icon { font-size: 1.5rem; flex-shrink: 0; }

.task__info { flex: 1; min-width: 0; }

.task__name {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.3;
}

.task__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 0.15rem;
}

.task__badge {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  margin-left: 0.35rem;
  vertical-align: middle;
}

.task__stars {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--accent);
  flex-shrink: 0;
  white-space: nowrap;
}

/* Progress bar */
.day-progress {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.day-progress__label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}

.day-progress__bar {
  height: 12px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.day-progress__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* Calendar */
.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.4rem;
}

.cal-header {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-muted);
  padding: 0.25rem;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.2s;
  padding: 0.2rem;
  min-height: 48px;
}

.cal-day:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.cal-day--today {
  border-color: var(--primary);
  background: var(--primary-light);
  font-weight: 800;
}

.cal-day--selected {
  background: var(--primary);
  border-color: var(--primary-dark);
  color: white;
}

.cal-day--done {
  background: var(--success-light);
  border-color: var(--success);
}

.cal-day__num {
  font-size: 0.85rem;
  font-weight: 800;
  line-height: 1;
}

.cal-day__dots {
  display: flex;
  gap: 2px;
  margin-top: 3px;
}

.cal-day__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.cal-day--selected .cal-day__dot { background: white; }

.cal-month-label {
  grid-column: 1 / -1;
  text-align: center;
  font-weight: 800;
  font-size: 1rem;
  color: var(--primary);
  padding: 0.75rem 0 0.25rem;
}

/* Shop */
.shop-header { margin-bottom: 1.25rem; }

.shop-balance {
  text-align: center;
  background: var(--accent-light);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.75rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: #92400e;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
}

.shop-item {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 0.75rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  min-height: 140px;
}

.shop-item:hover:not(.shop-item--locked) {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.shop-item--locked {
  opacity: 0.55;
  cursor: not-allowed;
}

.shop-item__icon { font-size: 2.5rem; line-height: 1; }

.shop-item__name {
  font-weight: 800;
  font-size: 0.85rem;
  line-height: 1.25;
}

.shop-item__price {
  font-weight: 800;
  color: var(--accent);
  font-size: 0.9rem;
  margin-top: auto;
}

/* Orders */
.orders-section { margin-top: 2rem; }

.orders-title {
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
  color: var(--primary);
}

.orders-list { list-style: none; }

.order-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
}

.order-item__icon { font-size: 1.5rem; }

.order-item__info { flex: 1; }

.order-item__name { font-weight: 700; }

.order-item__status {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.order-item__status--pending { color: var(--accent); }
.order-item__status--approved { color: var(--success); }

/* Modal */
.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: 360px;
  width: calc(100% - 2rem);
  box-shadow: var(--shadow-lg);
  background: transparent;
}

.modal::backdrop {
  background: rgba(30, 27, 75, 0.5);
  backdrop-filter: blur(4px);
}

.modal__content {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem 1.5rem 1.5rem;
  text-align: center;
  position: relative;
}

.modal__close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg);
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 700;
}

.modal__icon { font-size: 4rem; margin-bottom: 0.5rem; }

.modal__title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.modal__price {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.modal__desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  font-weight: 600;
}

/* Buttons */
.btn {
  font-family: var(--font);
  font-weight: 800;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.btn--primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn--primary:hover { background: var(--primary-dark); }

.btn--secondary {
  background: var(--surface);
  color: var(--primary);
  border: 2px solid var(--primary);
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  min-height: 44px;
}

.btn--secondary:hover { background: var(--primary-light); }

.btn--large {
  width: 100%;
  padding: 0.9rem;
  font-size: 1rem;
  min-height: 52px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(1.5rem + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--text);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  z-index: 200;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
  max-width: calc(100% - 2rem);
  text-align: center;
}

.toast--show { transform: translateX(-50%) translateY(0); }

/* Confetti */
.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 300;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}

.empty-state__icon { font-size: 3rem; margin-bottom: 0.5rem; }

.empty-state__text { font-weight: 700; }

/* Header meta */
.header-streak {
  color: #92400e;
}

.pin-input {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.5rem;
}

.pin-input:focus {
  outline: none;
  border-color: var(--primary);
}

.pin-error {
  color: #ef4444;
  font-size: 0.85rem;
  font-weight: 700;
  min-height: 1.25rem;
  margin-bottom: 0.75rem;
}

.modal--pin .modal__content { padding-top: 1.5rem; }

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-weight: 700;
  border: none;
  margin-top: 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  width: 100%;
  padding: 0.5rem;
}

.btn--ghost:hover { color: var(--primary); }

/* Yesterday card */
.yesterday-card {
  background: var(--surface);
  border: 2px solid var(--success);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.yesterday-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--success);
  margin-bottom: 0.35rem;
}

.yesterday-card__stars { color: var(--accent); }

.yesterday-card__stats {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.yesterday-card__list {
  font-size: 0.8rem;
  color: var(--text);
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.yesterday-card__link {
  background: none;
  border: none;
  color: var(--primary);
  font-family: var(--font);
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
}

.yesterday-card__link:hover { text-decoration: underline; }

/* Day summary (calendar detail) */
.day-summary {
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}

.day-summary--past {
  background: var(--success-light);
}

.day-summary__title {
  font-weight: 800;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}

.day-summary__scheduled {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.day-summary__progress {
  display: flex;
  justify-content: space-between;
  font-weight: 800;
  font-size: 0.9rem;
}

.day-summary__stars { color: var(--accent); }

.day-summary__note {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.task--readonly { opacity: 0.85; }

/* Calendar detail */
.calendar-detail {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 2px dashed var(--border);
}

.calendar-detail__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.calendar-detail__header h3 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary);
}

.calendar-detail__tag {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

.calendar-detail__tag--past {
  background: var(--success-light);
  color: var(--success);
}

.calendar-detail__tag--today {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.cal-day--partial {
  background: #fef9c3;
  border-color: var(--accent);
}

.cal-day__stars {
  font-size: 0.55rem;
  font-weight: 800;
  margin-top: 2px;
  line-height: 1;
}

.cal-day--selected .cal-day__stars { color: rgba(255,255,255,0.9); }

/* Progress tab */
.level-card {
  display: flex;
  gap: 1rem;
  align-items: center;
  background: linear-gradient(135deg, var(--primary-light), #ede9fe);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.level-card__icon { font-size: 3rem; line-height: 1; }

.level-card__title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary-dark);
}

.level-card__stars {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  margin: 0.2rem 0 0.5rem;
}

.level-card__next {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.level-card__bar {
  height: 8px;
  background: rgba(99, 102, 241, 0.2);
  border-radius: 999px;
  overflow: hidden;
}

.level-card__fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.4s;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 0.85rem 0.5rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-card__val {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
}

.stat-card__label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.chart-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.35rem;
  min-height: 140px;
  padding: 0.5rem 0.25rem 0 !important;
}

.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 130px;
  justify-content: flex-end;
}

.chart-col__bar {
  width: 100%;
  max-width: 36px;
  background: linear-gradient(180deg, var(--accent), var(--primary));
  border-radius: 6px 6px 2px 2px;
  min-height: 8px;
  transition: height 0.4s;
}

.chart-col__label {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.chart-col__val {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--accent);
}

.history-list { padding: 0.25rem !important; }

.history-row {
  display: grid;
  grid-template-columns: 2.5rem 1fr 2.5rem 3rem;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}

.history-row:last-child { border-bottom: none; }

.history-row__date {
  font-weight: 800;
  color: var(--text-muted);
}

.history-row__bar-wrap {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.history-row__bar {
  height: 100%;
  background: var(--success);
  border-radius: 999px;
  min-width: 4px;
}

.history-row__stats {
  font-weight: 700;
  text-align: center;
  color: var(--text-muted);
}

.history-row__stars {
  font-weight: 800;
  color: var(--accent);
  text-align: right;
}

.achievements-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.25rem !important;
}

.achievement {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  opacity: 0.55;
}

.achievement--unlocked {
  opacity: 1;
  background: var(--accent-light);
  border: 1px solid var(--accent);
}

.achievement__icon { font-size: 1.5rem; }

.achievement__title {
  font-weight: 800;
  font-size: 0.9rem;
}

.achievement__desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.backup-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.backup-btns {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.backup-import {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Responsive */
@media (max-width: 520px) {
  .sidebar {
    width: 4.5rem;
    padding: 0.5rem 0.35rem;
  }

  .sidebar__title,
  .sidebar__motivation,
  .sidebar__date,
  .nav__label,
  .sync-status {
    display: none;
  }

  .sidebar__brand {
    justify-content: center;
    margin-bottom: 0.5rem;
  }

  .sidebar__badges {
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.35rem;
  }

  .header-level {
    font-size: 0.55rem;
    padding: 0.1rem 0.3rem;
  }

  .stars-badge {
    font-size: 0.72rem;
    padding: 0.12rem 0.35rem;
  }

  .nav__btn {
    justify-content: center;
    padding: 0.5rem;
    min-height: 40px;
  }

  .nav__icon { font-size: 1.15rem; }
}

@media (min-width: 480px) {
  .nav__btn { font-size: 0.85rem; }
  .shop-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-height: 680px) {
  #tab-day .task-compact {
    padding: 0.28rem 0.4rem;
    min-height: 34px;
    font-size: 0.72rem;
  }

  #tab-day .task-compact__check {
    width: 18px;
    height: 18px;
  }

  .nav__btn {
    min-height: 38px;
    padding: 0.45rem 0.5rem;
    font-size: 0.78rem;
  }

  .sidebar { padding: 0.45rem 0.45rem; }
}

@media (min-width: 720px) {
  .main { padding: 0.5rem 1rem; }
  .shop-grid { grid-template-columns: repeat(3, 1fr); gap: 1rem; }
}

@media (max-width: 360px) {
  .sidebar { width: 3.75rem; }
  .stats-grid { grid-template-columns: 1fr; }
}
