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

html {
  scrollbar-gutter: stable;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #0e1116;
  color: #e6e9ef;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

.muted {
  color: #8b93a7;
  font-size: 13px;
}

.gold {
  color: #fbbf24;
}

.empty {
  color: #8b93a7;
  padding: 12px 2px;
}

.field-label {
  display: block;
  font-size: 12px;
  color: #8b93a7;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}

/* ---------- auth ---------- */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 20% -10%, rgba(99, 102, 241, 0.25), transparent),
    radial-gradient(700px 400px at 90% 110%, rgba(192, 132, 252, 0.18), transparent),
    #0e1116;
}

.auth-box {
  background: #161b26;
  border: 1px solid #232a3a;
  border-radius: 16px;
  padding: 32px;
  width: 360px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.brand {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 1px;
  background: linear-gradient(90deg, #818cf8, #c084fc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand.small {
  font-size: 20px;
}

.tagline {
  color: #8b93a7;
  margin: 6px 0 20px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.tab {
  flex: 1;
  padding: 8px;
  background: #1f2636;
  color: #9aa3b8;
  border: 1px solid #2a3348;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.tab.active {
  background: #6366f1;
  color: #fff;
  border-color: #6366f1;
}

.error {
  color: #f87171;
  font-size: 13px;
  margin-bottom: 10px;
}

/* ---------- forms ---------- */

input,
select,
textarea,
button {
  font: inherit;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  background: #0e1116;
  border: 1px solid #2a3348;
  border-radius: 8px;
  color: #e6e9ef;
  margin-bottom: 10px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #6366f1;
}

input[type="checkbox"] {
  accent-color: #6366f1;
  width: auto;
  margin: 0 6px 0 0;
}

input[type="color"] {
  padding: 3px;
  height: 40px;
  width: 56px;
  background: #0e1116;
  border: 1px solid #2a3348;
  border-radius: 8px;
}

.btn {
  padding: 9px 14px;
  border: none;
  border-radius: 8px;
  background: #6366f1;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}

.btn:hover {
  background: #7579f7;
}

.btn.full {
  width: 100%;
}

.btn.ghost {
  background: #1f2636;
  color: #9aa3b8;
  border: 1px solid #2a3348;
}

.btn.ghost:hover {
  background: #263046;
  color: #e6e9ef;
}

.btn.danger {
  color: #f87171;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.check {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #9aa3b8;
  font-size: 14px;
  margin: 0;
  cursor: pointer;
}

.checks {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin: 14px 0 4px;
}

.reverse-check {
  color: #fca5a5;
}

.reverse-check:has(input:checked) {
  color: #f87171;
}

/* ---------- range sliders ---------- */

input[type="range"].slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 6px;
  background: linear-gradient(90deg, #22c55e, #fbbf24, #ef4444);
  outline: none;
  margin: 6px 0 2px;
  cursor: pointer;
}

input[type="range"].slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e6e9ef;
  border: 3px solid #6366f1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  cursor: grab;
}

input[type="range"].slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #e6e9ef;
  border: 3px solid #6366f1;
  cursor: grab;
}

.sliders {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px 24px;
  margin-top: 14px;
}

.slider-block {
  background: #12161f;
  border: 1px solid #232a3a;
  border-radius: 10px;
  padding: 12px 14px;
}

.slider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.slider-head .field-label {
  margin-bottom: 0;
}

.slider-out {
  font-size: 13px;
  font-weight: 700;
  color: #6366f1;
  background: #1f2636;
  border: 1px solid #2a3348;
  border-radius: 999px;
  padding: 2px 10px;
}

.slider-scale {
  display: flex;
  justify-content: space-between;
  color: #5b647a;
  font-size: 11px;
  padding: 0 4px;
}

.xp-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  background: linear-gradient(90deg, #101a2c, #161b26);
  border: 1px solid #2a3348;
  border-radius: 10px;
  padding: 10px 14px;
  color: #8b93a7;
  font-size: 13px;
}

.xp-preview-val {
  font-size: 20px;
  font-weight: 800;
  color: #34d399;
}

/* ---------- skill picker ---------- */

.skill-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.skill-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #1f2636;
  border: 1px solid #2a3348;
  border-radius: 999px;
  padding: 5px 12px;
  color: #9aa3b8;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.skill-chip:has(input[type="checkbox"]) input {
  accent-color: #6366f1;
}

.skill-chip:hover {
  border-color: #3b4566;
}

.skill-chip.on {
  background: rgba(99, 102, 241, 0.18);
  border-color: #6366f1;
  color: #e6e9ef;
}

/* ---------- layout ---------- */

.main-wrap {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 245px;
  background: #12161f;
  border-right: 1px solid #232a3a;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: fixed;
  top: 0;
  bottom: 0;
  overflow-y: auto;
}

.main {
  margin-left: 245px;
  padding: 28px 36px 60px;
  flex: 1;
  max-width: 980px;
}

.page-title {
  font-size: 24px;
  margin-bottom: 20px;
}

.section-title {
  font-size: 17px;
  margin: 24px 0 12px;
  color: #c7cdd9;
}

.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filters .btn.active {
  background: #6366f1;
  color: #fff;
  border-color: #6366f1;
}

/* ---------- profile ---------- */

#profile-card {
  background: #161b26;
  border: 1px solid #232a3a;
  border-radius: 12px;
  padding: 14px;
}

.profile-name {
  font-weight: 700;
}

.profile-rank {
  font-size: 12px;
  font-weight: 700;
  margin-top: 2px;
}

.profile-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 12px;
  color: #8b93a7;
  flex-wrap: wrap;
}

.dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #8b93a7;
}

.nav-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  background: none;
  border: none;
  border-radius: 10px;
  color: #9aa3b8;
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 4px;
}

.nav-btn:hover {
  background: #1a2030;
  color: #e6e9ef;
}

.nav-btn.active {
  background: #6366f1;
  color: #fff;
}

.logout {
  margin-top: auto;
}

/* ---------- cards ---------- */

.card {
  background: #161b26;
  border: 1px solid #232a3a;
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
}

.task-form .form-grid:not(.coins-row) {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.xp-card {
  background: #161b26;
  border: 1px solid #232a3a;
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 20px;
}

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

.rank-badge {
  background: #64748b;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bar {
  height: 10px;
  background: #1f2636;
  border-radius: 6px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.4s ease;
}

.bar-fill.xp {
  background: linear-gradient(90deg, #22c55e, #10b981);
}

.bar-fill.skill {
  background: linear-gradient(90deg, #818cf8, #c084fc);
}

.bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #8b93a7;
  margin-top: 6px;
  gap: 10px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

.stat-card {
  background: #161b26;
  border: 1px solid #232a3a;
  border-radius: 12px;
  padding: 16px;
}

.stat-label {
  display: block;
  font-size: 12px;
  color: #8b93a7;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.stat-value {
  font-size: 22px;
  font-weight: 800;
}

/* ---------- tasks ---------- */

.task {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #161b26;
  border: 1px solid #232a3a;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
}

.task.done {
  opacity: 0.55;
}

.task.done .task-title {
  text-decoration: line-through;
}

.task.reverse {
  border-color: #5b1f24;
  background: linear-gradient(180deg, #1c1214, #161b26);
}

.task-cat {
  width: 8px;
  align-self: stretch;
  border-radius: 4px;
  flex-shrink: 0;
}

.task-body {
  flex: 1;
  min-width: 0;
}

.task-title {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.task-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.chip {
  background: #1f2636;
  border: 1px solid #2a3348;
  color: #9aa3b8;
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 999px;
}

.chip.skill {
  color: #a78bfa;
  border-color: #4c3783;
}

.chip.bad {
  color: #f87171;
  border-color: #7f2b33;
  background: #2c1214;
}

.chip.due {
  color: #7dd3fc;
  border-color: #155e75;
}

.chip.streak {
  color: #fbbf24;
  border-color: #4f4218;
}

.task-desc {
  color: #8b93a7;
  font-size: 13px;
  margin-top: 4px;
}

.task-reward {
  text-align: right;
  font-size: 13px;
  color: #34d399;
  line-height: 1.4;
  flex-shrink: 0;
}

.task-reward.neg {
  color: #f87171;
}

.task-reward .neg {
  color: #f87171;
}

.task-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ---------- categories / skills / rewards ---------- */

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #161b26;
  border: 1px solid #232a3a;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
}

.row .grow {
  flex: 1;
  min-width: 0;
}

.swatch {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  display: inline-block;
  flex-shrink: 0;
}

.skill-name {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.skill-title {
  font-weight: 700;
}

.xp-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}

.xp-form input[type="number"] {
  width: 110px;
  margin-bottom: 0;
}

.reward-cost {
  font-weight: 800;
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0 12px;
}

.form-grid .check {
  align-self: center;
}

/* ---------- achievements ---------- */

.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.ach {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #161b26;
  border: 1px solid #232a3a;
  border-radius: 12px;
  padding: 14px;
}

.ach.unlocked {
  border-color: #f59e0b;
  background: linear-gradient(180deg, #1c1a10, #161b26);
}

.ach-icon {
  font-size: 26px;
  flex-shrink: 0;
  filter: grayscale(1);
  opacity: 0.5;
}

.ach.unlocked .ach-icon {
  filter: none;
  opacity: 1;
}

.ach-body {
  flex: 1;
  min-width: 0;
}

.ach-title {
  font-weight: 700;
}

.ach.unlocked .ach-title {
  color: #fbbf24;
}

.ach-reward {
  margin-top: 6px;
  font-size: 12px;
  color: #fbbf24;
}

.bar-fill.ach-bar {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.ach-check {
  color: #fbbf24;
  font-size: 18px;
  flex-shrink: 0;
  align-self: center;
}

.ach .btn.danger {
  flex-shrink: 0;
}

/* ---------- table ---------- */

.tx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.tx-table th,
.tx-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid #232a3a;
}

.tx-table th {
  color: #8b93a7;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.pos {
  color: #34d399;
}

.neg {
  color: #f87171;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: #232a3c;
  color: #e6e9ef;
  border: 1px solid #333c54;
  border-radius: 10px;
  padding: 11px 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 100;
  max-width: 80vw;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.success {
  border-color: #166534;
  background: #0f2c1c;
}

.toast.error {
  border-color: #7f2b2b;
  background: #2c1212;
}

@media (max-width: 720px) {
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
  }
  .main-wrap {
    flex-direction: column;
  }
  .main {
    margin-left: 0;
    padding: 20px;
  }
  .task {
    flex-wrap: wrap;
  }
  .task-reward {
    text-align: left;
  }
  .task-actions {
    width: 100%;
    flex-wrap: wrap;
  }
  .sliders {
    grid-template-columns: 1fr;
  }
}