:root {
  color-scheme: dark;
  --bg: #1a0d2e;
  --surface: rgba(45, 25, 75, 0.95);
  --surface-strong: #3d2a5c;
  --text: #f0e6ff;
  --muted: #c4b5d5;
  --accent: #d4b8ff;
  --accent-strong: #b794ff;
  --danger: #ff8fd4;
  --danger-strong: #ff6fc8;
  --success: #78f0c8;
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(187, 144, 255, 0.18), transparent 28%),
    linear-gradient(180deg, #13082d 0%, #0a0420 100%);
  color: var(--text);
}

body {
  padding: 24px;
}

.app-shell {
  max-width: 1000px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  padding: 24px;
  border-radius: 24px;
  background: rgba(16, 27, 47, 0.9);
  box-shadow: var(--shadow);
}

.topbar h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 3vw, 2.6rem);
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.status-chip {
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(100, 210, 255, 0.12);
  color: var(--accent);
  font-size: 0.95rem;
  white-space: nowrap;
  border: 1px solid rgba(212, 184, 255, 0.18);
}

.status-chip.is-online {
  color: var(--success);
  background: rgba(120, 240, 200, 0.12);
  border-color: rgba(120, 240, 200, 0.24);
}

.status-chip.is-offline {
  color: var(--accent);
}

main {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid rgba(146, 186, 245, 0.08);
  border-radius: 28px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

#today-completed {
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 500;
}

.section-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.section-header span {
  color: var(--muted);
  font-size: 0.95rem;
}

#streak-count,
#today-rate {
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 500;
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.progress-bar {
  flex: 1;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  border: 1px solid rgba(212, 184, 255, 0.12);
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  transition: width 0.25s ease;
}

.progress-text {
  color: var(--muted);
  font-size: 0.9rem;
  min-width: 52px;
  text-align: right;
}

#category-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

#category-form input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  outline: none;
}

#category-form input:focus {
  border-color: rgba(212, 184, 255, 0.45);
}

#category-form button {
  border: none;
  border-radius: 16px;
  padding: 14px 20px;
  color: #090010;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  font-weight: 700;
  cursor: pointer;
}

.habit-list {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.habit-section {
  display: grid;
  gap: 10px;
}

.habit-section-header {
  margin: 0;
  font-size: 1rem;
  color: var(--accent);
  font-weight: 600;
  border-bottom: 1px solid rgba(187, 144, 255, 0.2);
  padding-bottom: 8px;
}

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

.category-actions {
  display: flex;
  gap: 8px;
}

.category-edit-btn,
.category-add-btn,
.category-delete-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.05rem;
  cursor: pointer;
  padding: 6px 9px;
  border-radius: 8px;
  transition: background-color 0.2s, color 0.2s;
}

.category-edit-btn:hover,
.category-add-btn:hover,
.category-delete-btn:hover {
  background: rgba(212, 184, 255, 0.1);
}

.category-add-btn {
  color: var(--accent);
  font-weight: bold;
}

.category-delete-btn:hover,
.habit-delete-btn:hover {
  background: rgba(255, 143, 212, 0.2);
  color: var(--danger);
}

.habit-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(61, 42, 92, 0.9);
  border: 1px solid rgba(212, 184, 255, 0.2);
  transition: all 0.2s;
}

.habit-item:hover {
  background: rgba(71, 52, 102, 0.92);
  border-color: rgba(212, 184, 255, 0.3);
}

.habit-item.empty {
  color: var(--muted);
  font-style: italic;
  padding: 12px 18px;
  background: rgba(61, 42, 92, 0.5);
  border-style: dashed;
}

.habit-label {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  cursor: pointer;
}

.habit-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-strong);
  cursor: pointer;
}

.habit-actions {
  display: flex;
  gap: 8px;
}

.habit-edit-btn,
.habit-delete-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  font-size: 0.95rem;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.habit-edit-btn:hover {
  background: rgba(212, 184, 255, 0.2);
  color: var(--accent);
}

.reset-section {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

#reset-data-button {
  border: none;
  border-radius: 16px;
  padding: 12px 20px;
  color: var(--danger);
  background: rgba(255, 143, 212, 0.1);
  border: 1px solid rgba(255, 143, 212, 0.3);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

#reset-data-button:hover {
  background: rgba(255, 143, 212, 0.2);
  border-color: var(--danger-strong);
}

.note {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.history-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.history-day {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 18px;
  background: rgba(28, 8, 58, 0.88);
  border: 1px solid rgba(187, 144, 255, 0.12);
}

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

@media (max-width: 860px) {
  body {
    padding: 16px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  main {
    grid-template-columns: 1fr;
  }

  .habit-item {
    align-items: flex-start;
  }

  .habit-label {
    align-items: flex-start;
  }
}