:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --bg-softer: #334155;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --accent: #6366f1;
  --accent-soft: #4f46e5;
  --danger: #ef4444;
  --ok: #22c55e;
  --border: #334155;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

.container {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Topbar */
.topbar {
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.brand { font-size: 1.2rem; }
.brand strong { color: var(--accent); }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  margin-top: 24px;
  align-items: start;
}
@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
}

/* Sidebar */
.sidebar {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.sidebar__head h2 { font-size: 1rem; margin: 0; }
.habit-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.habit-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-softer);
  border: 1px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.habit-item:hover { transform: translateX(2px); }
.habit-item.is-active { border-color: var(--accent); }
.habit-item__dot {
  width: 12px; height: 12px; border-radius: 50%;
  flex: 0 0 auto;
}
.habit-item__emoji { font-size: 1.1rem; }
.habit-item__name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.habit-item__badge {
  font-size: 0.75rem;
  color: var(--text-dim);
  background: rgba(0,0,0,0.25);
  padding: 2px 6px;
  border-radius: 6px;
}
.empty { color: var(--text-dim); text-align: center; padding: 16px 0; font-size: 0.9rem; }

/* Panel */
.panel {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.panel--placeholder { display: flex; align-items: center; justify-content: center; min-height: 220px; color: var(--text-dim); }
.panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.panel__title { margin: 0; font-size: 1.3rem; display: flex; align-items: center; gap: 8px; }
.panel__stats { margin: 4px 0 0; color: var(--text-dim); font-size: 0.9rem; }
.panel__actions { display: flex; gap: 8px; }
.panel__hint { color: var(--text-dim); font-size: 0.85rem; text-align: center; margin: 14px 0 0; }

/* Calendar */
.cal__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
}
.cal__month { font-weight: 600; min-width: 160px; text-align: center; text-transform: capitalize; }
.cal__weekdays, .cal__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.cal__weekdays { margin-bottom: 6px; }
.cal__weekday { text-align: center; font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; }
.cal__day {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--bg-softer);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.95rem;
  position: relative;
  transition: transform 0.08s, background 0.15s;
  user-select: none;
}
.cal__day:hover { transform: scale(1.06); }
.cal__day.is-empty { background: transparent; cursor: default; }
.cal__day.is-empty:hover { transform: none; }
.cal__day.is-future { opacity: 0.4; cursor: not-allowed; }
.cal__day.is-future:hover { transform: none; }
.cal__day.is-today { border-color: var(--text-dim); font-weight: 700; }
.cal__day.is-done { color: #fff; font-weight: 700; }
.cal__day.is-done::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: var(--habit-color, var(--accent));
  z-index: -1;
}
.cal__day span { position: relative; z-index: 1; }

/* Buttons */
.btn {
  font: inherit;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--text);
  background: var(--bg-softer);
  transition: background 0.15s, opacity 0.15s;
}
.btn:hover { opacity: 0.9; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-soft); }
.btn--ghost { background: transparent; border-color: var(--border); }
.btn--danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn--danger:hover { background: var(--danger); color: #fff; }
.btn--sm { padding: 6px 10px; font-size: 0.85rem; }
.btn--icon { padding: 4px 12px; font-size: 1.3rem; line-height: 1; }

/* Banner */
.banner {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
}
.banner--warn { background: rgba(234, 179, 8, 0.12); border-color: #ca8a04; }
.banner--ok { background: rgba(34, 197, 94, 0.12); border-color: var(--ok); }
.banner--err { background: rgba(239, 68, 68, 0.12); border-color: var(--danger); }

/* Dialog */
.dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--text);
  padding: 0;
  max-width: 380px;
  width: 90%;
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(0,0,0,0.6); }
.dialog__form { padding: 20px; display: grid; gap: 14px; }
.dialog__form h3 { margin: 0; }
.field { display: grid; gap: 6px; font-size: 0.9rem; }
.field span { color: var(--text-dim); }
.field input {
  font: inherit;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.field input[type="color"] { padding: 4px; height: 42px; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* Footer */
.footer { margin: 32px auto; text-align: center; color: var(--text-dim); }
