:root {
  --navy: #0B1F3A;
  --navy-2: #16365F;
  --background: #F3F6FA;
  --card: #FFFFFF;
  --text: #122033;
  --muted: #778399;
  --border: #DCE4EE;
  --success: #237A52;
  --danger: #B53C45;
  --gold: #D9A928;
  --radius-lg: 20px;
  --radius-md: 14px;
  --shadow: 0 14px 35px rgba(11, 31, 58, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 20px;
  background: var(--navy);
  color: white;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px 32px;
  font-size: 20px;
  font-weight: 600;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: white;
  color: var(--navy);
  font-weight: 700;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: rgba(255, 255, 255, 0.68);
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.12);
  color: white;
}

.nav-icon {
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 18px 10px 0;
  color: rgba(255, 255, 255, 0.68);
}

.sidebar-footer p {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 500;
}

.sidebar-footer small {
  font-size: 11px;
}

.main-content {
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 28px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: var(--navy);
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  color: var(--navy);
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.primary-button,
.secondary-button,
.icon-button,
.filter-button {
  border: 0;
  border-radius: 12px;
  transition: transform 150ms ease, opacity 150ms ease, background 150ms ease;
}

.primary-button:active,
.secondary-button:active,
.icon-button:active,
.filter-button:active {
  transform: scale(0.98);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 11px 17px;
  background: var(--navy);
  color: white;
  font-weight: 500;
}

.primary-button:hover {
  background: var(--navy-2);
}

.secondary-button {
  min-height: 42px;
  padding: 10px 16px;
  background: #E9EFF6;
  color: var(--navy);
  font-weight: 500;
}

.summary-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) repeat(2, minmax(160px, 0.65fr));
  gap: 16px;
  margin-bottom: 28px;
}

.rank-card,
.metric-card,
.tasks-section,
.rank-item {
  background: var(--card);
  border: 1px solid rgba(220, 228, 238, 0.8);
  box-shadow: var(--shadow);
}

.rank-card {
  padding: 22px;
  border-radius: var(--radius-lg);
}

.rank-card-top,
.rank-meta,
.section-heading,
.task-row,
.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.rank-card h2 {
  font-size: 26px;
}

.xp-total {
  color: var(--navy);
  font-size: 18px;
  font-weight: 600;
}

.progress-track {
  width: 100%;
  height: 10px;
  margin: 18px 0 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #E4EAF1;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--navy);
  transition: width 300ms ease;
}

.rank-meta {
  color: var(--muted);
  font-size: 12px;
}

.metric-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 160px;
  padding: 22px;
  border-radius: var(--radius-lg);
}

.metric-card strong {
  color: var(--navy);
  font-size: 38px;
  line-height: 1.1;
}

.metric-card span {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.tasks-section {
  padding: 22px;
  border-radius: var(--radius-lg);
}

.section-heading {
  align-items: flex-end;
  margin-bottom: 18px;
}

.filter-buttons {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  background: #EDF2F7;
}

.filter-button {
  padding: 7px 12px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.filter-button.active {
  background: white;
  color: var(--navy);
  box-shadow: 0 4px 10px rgba(11, 31, 58, 0.08);
}

.task-list {
  display: grid;
  gap: 10px;
}

.task-row {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.task-row.completed {
  background: #F7F9FC;
}

.task-main {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.task-check {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid var(--navy);
  border-radius: 50%;
  background: white;
  color: white;
}

.task-check.completed {
  background: var(--navy);
}

.task-copy {
  min-width: 0;
}

.task-title {
  margin: 0 0 4px;
  overflow: hidden;
  color: var(--navy);
  font-size: 14px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.difficulty-badge {
  padding: 4px 8px;
  border-radius: 999px;
  background: #EAF0F7;
  color: var(--navy);
  font-size: 10px;
  font-weight: 600;
}

.delete-button {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
}

.delete-button:hover {
  color: var(--danger);
}

.empty-state {
  display: grid;
  justify-items: center;
  padding: 48px 20px;
  text-align: center;
}

.empty-state.hidden,
.hidden {
  display: none !important;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin-bottom: 16px;
  border-radius: 50%;
  background: #E8EEF5;
  color: var(--navy);
  font-size: 24px;
}

.empty-state p,
.ranking-header p {
  color: var(--muted);
}

.ranking-header {
  margin-bottom: 24px;
}

.rank-list {
  display: grid;
  gap: 10px;
}

.rank-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius-md);
}

.rank-item.current {
  border-color: var(--navy);
}

.rank-status {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #E8EEF5;
  color: var(--navy);
}

.rank-name {
  color: var(--navy);
  font-weight: 500;
}

.rank-xp {
  color: var(--muted);
  font-size: 12px;
}

.task-modal {
  width: min(92vw, 500px);
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: transparent;
}

.task-modal::backdrop {
  background: rgba(3, 14, 29, 0.56);
  backdrop-filter: blur(4px);
}

.modal-card {
  padding: 24px;
  border-radius: 22px;
  background: white;
}

.icon-button {
  width: 38px;
  height: 38px;
  background: #EDF2F7;
  color: var(--navy);
  font-size: 22px;
}

form {
  display: grid;
  gap: 18px;
  margin-top: 22px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--navy);
  font-size: 13px;
  font-weight: 500;
}

input,
select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: white;
  color: var(--text);
  font-size: 14px;
}

input:focus,
select:focus {
  outline: 2px solid rgba(11, 31, 58, 0.2);
  border-color: var(--navy);
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 4px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--navy);
  color: white;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.mobile-nav {
  display: none;
}

@media (max-width: 920px) {
  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .rank-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  body {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .main-content {
    padding: 24px 16px;
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar .primary-button {
    display: none;
  }

  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .rank-card {
    grid-column: 1 / -1;
  }

  .metric-card {
    min-height: 125px;
    padding: 18px;
  }

  .metric-card strong {
    font-size: 32px;
  }

  .tasks-section {
    padding: 16px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .task-row {
    align-items: flex-start;
  }

  .rank-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .mobile-nav {
    display: grid;
    grid-template-columns: 1fr 72px 1fr;
    align-items: center;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    min-height: 68px;
    padding: 6px 14px calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
  }

  .mobile-nav-item {
    display: grid;
    justify-items: center;
    gap: 3px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 10px;
  }

  .mobile-nav-item span {
    font-size: 18px;
  }

  .mobile-nav-item.active {
    color: var(--navy);
  }

  .add-mobile {
    width: 52px;
    height: 52px;
    justify-self: center;
    border-radius: 50%;
    background: var(--navy);
    color: white;
    font-size: 26px;
  }

  .toast {
    right: 16px;
    bottom: calc(88px + env(safe-area-inset-bottom));
    left: 16px;
    text-align: center;
  }
}

@media (max-width: 430px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .rank-card {
    grid-column: auto;
  }

  .rank-card-top {
    align-items: flex-start;
  }

  .section-heading {
    gap: 14px;
  }

  .filter-buttons {
    width: 100%;
  }

  .filter-button {
    flex: 1;
  }
}
