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


:root {
  --bg-main: radial-gradient(circle at top, #020617 0, #020617 40%, #050816 100%);
  --bg-card: rgba(15, 23, 42, 0.9);
  --bg-soft: rgba(15, 23, 42, 0.95);
  --border-subtle: rgba(148, 163, 184, 0.35);
  --text-main: #e5e7eb;
  --text-muted: #9ca3af;
  --accent: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.22);
  --danger: #fb7185;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow-soft: 0 26px 80px rgba(0, 0, 0, 0.85);
  --font-main: "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

body.theme-light {
  --bg-main: radial-gradient(circle at top, #f8fafc 0, #e2e8f0 45%, #cbd5e1 100%);
  --bg-card: rgba(255, 255, 255, 0.92);
  --bg-soft: rgba(255, 255, 255, 0.96);
  --border-subtle: rgba(100, 116, 139, 0.32);
  --text-main: #0f172a;
  --text-muted: #475569;
  --shadow-soft: 0 26px 80px rgba(15, 23, 42, 0.18);
}

body.theme-dark {
  --bg-main: radial-gradient(circle at top, #020617 0, #020617 40%, #050816 100%);
  --bg-card: rgba(15, 23, 42, 0.9);
  --bg-soft: rgba(15, 23, 42, 0.95);
  --border-subtle: rgba(148, 163, 184, 0.35);
  --text-main: #e5e7eb;
  --text-muted: #9ca3af;
  --shadow-soft: 0 26px 80px rgba(0, 0, 0, 0.85);
}

body.theme-light .app-shell {
  background: rgba(241, 245, 249, 0.95);
  border-color: rgba(100, 116, 139, 0.32);
}

body.theme-light .btn.ghost,
body.theme-light #todo-input,
body.theme-light #todo-priority,
body.theme-light #todo-due,
body.theme-light #todo-effort,
body.theme-light .notes-area,
body.theme-light #habit-input,
body.theme-light #habit-frequency,
body.theme-light #habit-custom-days,
body.theme-light #goal-area,
body.theme-light #goal-name,
body.theme-light #goal-milestone,
body.theme-light #blocker-input,
body.theme-light .link-input-row input,
body.theme-light .habit-done-btn,
body.theme-light .link-pill {
  background: rgba(255, 255, 255, 0.95);
  color: #0f172a;
  border-color: rgba(100, 116, 139, 0.45);
}

body.theme-light .todo-item:hover {
  background: rgba(226, 232, 240, 0.55);
}

body.theme-light .todo-priority-tag {
  background: #dbeafe;
  color: #1e3a8a;
}

body.theme-light .todo-priority-tag.high {
  background: #fed7aa;
  color: #7c2d12;
}

body.theme-light .todo-priority-tag.low {
  background: #bae6fd;
  color: #0c4a6e;
}

body.theme-light .focus-queue-item,
body.theme-light .review-item,
body.theme-light .goal-item,
body.theme-light .blocker-item,
body.theme-light .archive-item {
  background: rgba(248, 250, 252, 0.9);
  border-color: rgba(100, 116, 139, 0.35);
}

/* BASE COLORS */

body {
  font-family: var(--font-main);
  background: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  padding: 24px;
}

.app-shell {
  max-width: 1120px;
  margin: 0 auto;
  border-radius: 28px;
  padding: 22px 22px 26px;
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.4);
}

/* HEADER */

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 22px;
}

.logo {
  font-size: 30px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 700;
}

/* XP */

.level-box {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  font-size: 13px;
}

#level-label {
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.5);
}

.xp-bar {
  width: 180px;
  height: 9px;
  border-radius: 999px;
  background: rgba(46, 45, 45, 0.5);
  overflow: hidden;
  position: relative;
}

#xp-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22c55e, #a3e635, #22c55e);
  box-shadow: 0 0 14px rgba(74, 222, 128, 0.8);
  transition: width 0.35s ease-out;
}

#xp-text {
  font-size: 12px;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  gap: 10px;
}

/* BUTTONS */

.btn {
  border-radius: 999px;
  padding: 7px 14px;
  border: none;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.1s ease;
}

.btn.primary {
  background:  #f7558e;
  color: white;
  
}

.btn.ghost {
  background: rgba(15, 23, 42, 0.85);
  color: var(--text-main);
  border: 1px solid rgba(148, 163, 184, 0.6);
}

.btn.danger {
  background: var(--danger);
  color: #fee2e2;
}

.btn.small {
  padding: 6px 10px;
  font-size: 12px;
}

.btn:hover {
  transform: translateY(-1px);
}

/* TOP ROW */

.top-row {
  display: grid;
  grid-template-columns: 2.1fr 1.5fr;
  gap: 16px;
  margin-bottom: 16px;
}

.card {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 16px 18px;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border-subtle);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: -40%;
  background: radial-gradient(circle at top left, rgba(129, 140, 248, 0.3), transparent 65%);
  opacity: 0.9;
  pointer-events: none;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h2 {
  font-size: 16px;
}

.title-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.game-icon {
  width: 22px;
  height: 22px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.9), rgba(30, 41, 59, 0.95));
  
}

.game-icon-target { color: #f59e0b; }
.game-icon-stats { color: #60a5fa; }
.game-icon-quest { color: #a78bfa; }
.game-icon-journal { color: #22d3ee; }
.game-icon-habit { color: #fb7185; }
.game-icon-portals { color: #34d399; }
.game-icon-settings { color: #94a3b8; }

.card-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.pill {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
}

.pill-soft {
  background: rgba(37, 99, 235, 0.18);
  color: #93c5fd;
}

.pill-success {
  background: rgba(16, 185, 129, 0.22);
  color: #6ee7b7;
}

/* GOAL */

.goal-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.6);
  overflow: hidden;
  margin-top: 12px;
}

#goal-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  box-shadow: 0 0 14px rgba(74, 222, 128, 0.9);
  transition: width 0.25s ease-out;
}

.goal-text {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.goal-sep {
  margin: 0 6px;
  opacity: 0.6;
}

/* STATS */

.stats-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.stat {
  flex: 1;
  border-radius: 16px;
  padding: 8px 10px;
  font-size: 12px;
  border: 1px solid rgba(148, 163, 184, 0.55);
}

.stat-label {
  color: var(--text-muted);
}

.stat-value {
  display: block;
  margin-top: 4px;
  font-weight: 600;
}

/* GRID */

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

/* WIDGETS */

.widget {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 14px 16px;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border-subtle);
  min-height: 210px;
  position: relative;
  overflow: hidden;
}

.widget::before {
  content: "";
  position: absolute;
  inset: -40%;
  background: radial-gradient(circle at top, rgba(56, 189, 248, 0.22), transparent 70%);
  opacity: 0.9;
  pointer-events: none;
}

.widget-header h3 {
  font-size: 15px;
}

/* TODOS */

.todo-input-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  margin-bottom: 8px;
}

.todo-meta-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

#todo-input {
  flex: 1;
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.5);
  padding: 7px 10px;
  font-size: 13px;
  background: rgba(15, 23, 42, 0.96);
  color: var(--text-main);
}

#todo-priority {
  width: 70px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.5);
  padding: 6px 6px;
  font-size: 12px;
  background: rgba(17, 24, 39, 0.96);
  color: var(--text-main);
}

#todo-due,
#todo-effort {
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.5);
  padding: 6px 8px;
  font-size: 12px;
  background: rgba(17, 24, 39, 0.96);
  color: var(--text-main);
}

#todo-due {
  flex: 1;
}

#todo-effort {
  width: 110px;
}

.todo-list {
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}

.todo-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 5px 4px;
  border-radius: 10px;
}

.todo-main {
  display: flex;
  flex-direction: column;
}

.todo-item:hover {
  background: rgba(15, 23, 42, 0.9);
}

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

.todo-due {
  font-size: 11px;
  margin-top: 2px;
  opacity: 0.85;
}

.due-overdue {
  color: #fb7185;
}

.due-today {
  color: #f59e0b;
}

.due-soon {
  color: #22d3ee;
}

.due-later,
.due-none {
  color: var(--text-muted);
}

.todo-priority-tag {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #334155;
}

.todo-priority-tag.high {
  background: #f97316;
  color: #1f2937;
}

.todo-priority-tag.low {
  background: #0ea5e9;
  color: #0f172a;
}

.todo-remove {
  border: none;
  background: transparent;
  cursor: pointer;
  color: #9ca3af;
  font-size: 12px;
}

.widget-subsection {
  margin-top: 10px;
}

.widget-subsection h4 {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.todo-archive {
  list-style: none;
  max-height: 90px;
  overflow-y: auto;
}

.archive-item {
  font-size: 11px;
  padding: 4px 6px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  margin-bottom: 4px;
}

.muted {
  color: var(--text-muted);
}

/* NOTES */

.notes-area {
  width: 100%;
  height: 190px;
  resize: vertical;
  margin-top: 10px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.5);
  padding: 8px 10px;
  font-size: 13px;
  background: rgba(15, 23, 42, 0.96);
  color: var(--text-main);
}

/* HABITS */

.habit-list {
  list-style: none;
  margin-top: 10px;
  max-height: 170px;
  overflow-y: auto;
}

.habit-meta-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

#habit-frequency,
#habit-custom-days {
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.5);
  padding: 6px 8px;
  font-size: 12px;
  background: rgba(17, 24, 39, 0.96);
  color: var(--text-main);
}

#habit-frequency {
  width: 130px;
}

#habit-custom-days {
  flex: 1;
}

.habit-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 13px;
}

.habit-left {
  display: flex;
  flex-direction: column;
}

.habit-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.habit-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.habit-streak {
  font-size: 12px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.habit-streak-icon {
  color: #fb7185;
}

.habit-done-btn {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  padding: 3px 9px;
  font-size: 12px;
  background: rgba(15, 23, 42, 0.96);
  cursor: pointer;
  color: var(--text-main);
}

.habit-add-row {
  margin-top: 8px;
}

#habit-input {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.5);
  padding: 7px 10px;
  font-size: 13px;
  background: rgba(15, 23, 42, 0.96);
  color: var(--text-main);
}

/* LINKS */

.link-input-row {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  margin-bottom: 8px;
}

.link-input-row input {
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.5);
  padding: 6px 8px;
  font-size: 12px;
  background: rgba(15, 23, 42, 0.96);
  color: var(--text-main);
}

#link-name {
  flex: 0.8;
}

#link-url {
  flex: 1.2;
}

.link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.link-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.link-pill {
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(15, 23, 42, 0.96);
  font-size: 12px;
  text-decoration: none;
  color: var(--text-main);
  border: 1px solid rgba(148, 163, 184, 0.6);
}

/* MODAL */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.hidden {
  display: none;
}

.modal-body {
  width: 360px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border-subtle);
  padding: 14px 16px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 17px;
  color: var(--text-main);
}

.settings-group {
  margin-top: 10px;
  font-size: 13px;
}

.settings-group h3 {
  font-size: 13px;
  margin-bottom: 5px;
}

.settings-note {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.focus-queue-list,
.goal-list,
.blocker-list {
  list-style: none;
  margin-top: 10px;
}

.focus-queue-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 12px;
  padding: 6px 8px;
  margin-bottom: 6px;
}

.queue-rank {
  font-size: 11px;
  color: #22d3ee;
}

.queue-title {
  font-size: 12px;
}

.queue-meta {
  font-size: 11px;
}

.review-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.review-item {
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 12px;
  padding: 8px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.review-reflection {
  height: 90px;
}

.goal-input-row {
  display: grid;
  grid-template-columns: 0.9fr 1.4fr 90px auto;
  gap: 8px;
  margin-top: 10px;
}

#goal-area,
#goal-name,
#goal-milestone,
#blocker-input {
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.5);
  padding: 6px 8px;
  font-size: 12px;
  background: rgba(17, 24, 39, 0.96);
  color: var(--text-main);
}

.goal-item {
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 12px;
  padding: 8px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.todo-item[draggable="true"],
.habit-item[draggable="true"],
.goal-item[draggable="true"] {
  cursor: grab;
}

.dragging {
  opacity: 0.55;
}

.drop-target {
  outline: 1px dashed rgba(56, 189, 248, 0.9);
  outline-offset: 2px;
}

.goal-main {
  font-size: 12px;
}

.goal-progress {
  color: var(--text-muted);
}

.goal-linked-wrap {
  margin-top: 6px;
}

.goal-linked-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.goal-linked-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.goal-link-chip {
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(15, 23, 42, 0.88);
  color: var(--text-main);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
}

.goal-link-controls {
  margin-top: 6px;
  display: flex;
  gap: 6px;
}

.goal-link-select {
  flex: 1;
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.5);
  padding: 5px 7px;
  font-size: 12px;
  background: rgba(17, 24, 39, 0.96);
  color: var(--text-main);
}

.goal-actions {
  display: inline-flex;
  gap: 6px;
}

.focus-timer {
  margin-top: 10px;
  font-size: 42px;
  font-weight: 700;
  text-align: center;
}

.focus-actions {
  margin-top: 8px;
  display: flex;
  justify-content: center;
  gap: 8px;
}

.focus-blockers {
  margin-top: 10px;
}

.blocker-item {
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 12px;
  padding: 6px 8px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* COMPACT */

.layout-compact .widget {
  padding: 10px 12px;
}

.layout-compact .card {
  padding: 10px 12px;
}

/* LEVEL UP OVERLAY */

.level-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top, rgba(15,23,42,0.9), #020617);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease-out;
}

.level-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.level-overlay-inner {
  text-align: center;
  color: #f9fafb;
  padding: 26px 32px;
  border-radius: 28px;
  background: rgba(15,23,42,0.97);
  border: 1px solid rgba(148,163,184,0.7);
  box-shadow: 0 30px 120px rgba(0,0,0,0.95);
  max-width: 520px;
  transform: scale(0.8);
  opacity: 0;
  animation: levelPop 0.4s ease-out forwards;
}

@keyframes levelPop {
  0% {
    transform: scale(0.7) translateY(20px);
    opacity: 0;
  }
  60% {
    transform: scale(1.05) translateY(0);
    opacity: 1;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.level-overlay-title {
  font-size: 14px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.8;
}

.level-overlay-main {
  font-size: 40px;
  font-weight: 700;
  margin-top: 8px;
}

.level-overlay-level {
  font-size: 60px;
  font-weight: 800;
  margin-top: 6px;
}

.level-overlay-sub {
  font-size: 13px;
  margin-top: 10px;
  color: #cbd5f5;
}

/* CONFETTI */

.level-particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 101;
}

.level-confetti {
  position: absolute;
  width: 8px;
  height: 14px;
  border-radius: 3px;
  opacity: 0;
  animation: dropConfetti 1.8s ease-out forwards;
}

@keyframes dropConfetti {
  0% {
    transform: translate3d(0,-80px,0) rotateZ(0deg);
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  100% {
    transform: translate3d(0,120px,0) rotateZ(240deg);
    opacity: 0;
  }
}

/* XP SHINE */

.xp-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 0 50%, rgba(255, 255, 255, 0.4), transparent 60%);
  mix-blend-mode: screen;
  transform: translateX(-120%);
  animation: xpShine 4s linear infinite;
  pointer-events: none;
}

@keyframes xpShine {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(120%);
  }
}

/* RESPONSIVE */

@media (max-width: 900px) {
  body {
    padding: 16px;
  }
  .top-row {
    grid-template-columns: 1fr;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .todo-item {
    grid-template-columns: auto 1fr;
  }
  .goal-input-row {
    grid-template-columns: 1fr;
  }
  .habit-meta-row,
  .todo-meta-row,
  .link-input-row {
    flex-direction: column;
  }
}