:root {
  color-scheme: dark;
  --bg: #191919;
  --bg-deep: #101010;
  --panel: #111111;
  --panel-soft: #1f1f1f;
  --field: #302b2f;
  --text: #f6f3f5;
  --muted: #b7b0b7;
  --dim: #777177;
  --pink: #ff3f91;
  --pink-deep: #c43672;
  --berry: #942a55;
  --blue: #35aaff;
  --violet: #7f63ff;
  --amber: #ffc257;
  --danger: #f25b5b;
  --line: rgba(255, 255, 255, 0.07);
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.45);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --font-display: "Trebuchet MS", "Manrope", Verdana, sans-serif;
  --font-body: "Trebuchet MS", "Manrope", Verdana, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
  scroll-padding-top: 16px;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 50% -10%, rgba(255, 63, 145, 0.18), transparent 320px),
    radial-gradient(circle at 100% 24%, rgba(53, 170, 255, 0.08), transparent 280px),
    linear-gradient(180deg, #1d1d1d 0%, var(--bg) 100%);
}

button,
input,
select {
  font: inherit;
}

button,
a,
label.file-button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--pink);
  outline-offset: 3px;
}

a {
  color: inherit;
  text-decoration: none;
}

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

h1,
h2,
h3 {
  line-height: 1.04;
}

.is-hidden {
  display: none !important;
}

.auth-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
}

.phone-frame {
  width: min(100%, 430px);
}

.auth-card,
.app-header,
.panel,
.stat-card,
.task-card,
.habit-card,
.mobile-dock {
  background: rgba(17, 17, 17, 0.94);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.auth-card {
  padding: 24px;
  border-radius: var(--radius-xl);
}

.auth-card h1 {
  margin-bottom: 12px;
  font-size: clamp(2.3rem, 11vw, 4.1rem);
  letter-spacing: -0.08em;
}

.auth-copy {
  color: var(--muted);
  line-height: 1.55;
}

.auth-form,
.stack-form {
  display: grid;
  gap: 13px;
}

.auth-form {
  margin-top: 20px;
}

.text-button {
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  color: var(--pink);
  cursor: pointer;
  background: transparent;
  border: 0;
  font-weight: 900;
}

.app-shell {
  width: min(100% - 14px, 520px);
  margin: 0 auto;
  padding: 7px 0 calc(96px + env(safe-area-inset-bottom));
}

.app-header {
  position: relative;
  min-height: 100svh;
  padding: 18px 14px 20px;
  border-radius: 42px 42px 28px 28px;
}

.phone-notch {
  width: 132px;
  height: 36px;
  margin: 0 auto 28px;
  background: #000;
  border-radius: 999px;
}

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

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(145deg, var(--pink), var(--berry));
  border-radius: 15px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1.32rem;
  letter-spacing: -0.04em;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--muted);
  cursor: pointer;
  background: #0d0d0d;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.progress-panel {
  margin-bottom: 20px;
  padding: 14px 10px;
  background: #111;
  border-radius: 18px;
}

.progress-strip {
  display: grid;
  grid-auto-columns: minmax(74px, 1fr);
  grid-auto-flow: column;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.progress-strip::-webkit-scrollbar {
  display: none;
}

.ring-item {
  display: grid;
  min-width: 74px;
  gap: 9px;
  place-items: center;
  color: var(--text);
  cursor: pointer;
  background: transparent;
  border: 0;
  font-size: 0.82rem;
  font-weight: 900;
}

.ring-item.is-active {
  color: var(--pink);
}

.progress-ring {
  --value: 0deg;
  --ring: var(--pink);
  position: relative;
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  background: conic-gradient(var(--ring) var(--value), #1b1b1b 0);
  border-radius: 50%;
}

.progress-ring::before {
  position: absolute;
  width: 48px;
  height: 48px;
  content: "";
  background: #111;
  border-radius: 50%;
}

.progress-ring strong {
  position: relative;
  z-index: 1;
  font-size: 0.9rem;
}

.progress-ring.amber {
  --ring: var(--amber);
}

.progress-ring.blue {
  --ring: var(--blue);
}

.progress-ring.violet {
  --ring: var(--violet);
}

.progress-ring.cyan {
  --ring: var(--blue);
}

.add-orb {
  display: grid;
  width: 70px;
  height: 70px;
  place-items: center;
  color: #fff;
  font-size: 2.2rem;
  background: var(--pink);
  border-radius: 50%;
  box-shadow: 0 18px 36px rgba(255, 63, 145, 0.28);
}

.focus-card {
  position: absolute;
  right: 14px;
  bottom: 110px;
  left: 14px;
  min-height: 168px;
  padding: 24px;
  text-align: center;
  background: #111;
  border-radius: var(--radius-lg);
}

.focus-card::before {
  display: block;
  width: 86px;
  height: 86px;
  margin: -76px auto 12px;
  content: "";
  background:
    radial-gradient(circle, #fff 0 18%, transparent 19%),
    repeating-radial-gradient(circle, #d94737 0 12%, #fff 13% 22%, #d94737 23% 32%);
  border-radius: 50%;
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.28);
}

.focus-card h2 {
  margin-bottom: 8px;
  font-size: 1.8rem;
  letter-spacing: -0.05em;
}

.focus-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.focus-percent {
  display: inline-flex;
  min-width: 64px;
  justify-content: center;
  margin-bottom: 12px;
  padding: 8px 12px;
  color: #fff;
  background: rgba(255, 63, 145, 0.22);
  border-radius: 999px;
  font-weight: 900;
}

main {
  display: grid;
  gap: 12px;
  padding-top: 12px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.stat-card {
  min-height: 112px;
  padding: 14px;
  border-radius: 22px;
}

.stat-card span,
.stat-card small {
  display: block;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.stat-card strong {
  display: block;
  margin: 7px 0 2px;
  font-size: 2.2rem;
  letter-spacing: -0.08em;
}

.stat-card small {
  color: var(--dim);
  font-size: 0.72rem;
}

.panel {
  padding: 16px;
  border-radius: var(--radius-lg);
}

.section-heading {
  margin-bottom: 16px;
}

.section-heading.with-actions {
  display: grid;
  gap: 14px;
}

.app-kicker {
  margin: 0 0 6px;
  color: var(--pink);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: 1.75rem;
  letter-spacing: -0.06em;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

input,
select {
  width: 100%;
  min-height: 54px;
  padding: 14px 16px;
  color: var(--text);
  background: var(--field);
  border: 1px solid transparent;
  border-radius: 18px;
  outline: none;
}

input::placeholder {
  color: rgba(246, 243, 245, 0.38);
}

input:focus,
select:focus {
  border-color: rgba(255, 63, 145, 0.58);
  box-shadow: 0 0 0 4px rgba(255, 63, 145, 0.12);
}

.form-row {
  display: grid;
  gap: 12px;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.filter-button,
.tiny-button {
  min-height: 50px;
  padding: 12px 16px;
  color: #fff;
  cursor: pointer;
  border: 0;
  border-radius: 999px;
  font-weight: 900;
}

.primary-button {
  width: 100%;
  background: var(--pink);
}

.secondary-button {
  width: 100%;
  color: #161616;
  background: var(--amber);
}

.ghost-button {
  background: #202020;
  border: 1px solid var(--line);
}

.danger-button,
.tiny-button.danger {
  color: #ff8b8b;
  background: transparent;
  border: 1px solid rgba(242, 91, 91, 0.45);
}

.file-button input {
  display: none;
}

.compact-form {
  margin-bottom: 14px;
}

.filters {
  display: flex;
  gap: 8px;
  margin: 0 -16px;
  padding: 0 16px 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filters::-webkit-scrollbar {
  display: none;
}

.filter-button {
  min-height: 38px;
  padding: 9px 14px;
  color: var(--muted);
  white-space: nowrap;
  background: #202020;
}

.filter-button.is-active {
  color: #fff;
  background: var(--pink-deep);
}

.toolbar {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px;
  background: #202020;
  border-radius: 18px;
}

.toggle-row input {
  width: auto;
  min-height: auto;
  accent-color: var(--pink);
}

.task-list,
.habit-list,
.achievement-grid,
.chart-stack {
  display: grid;
  gap: 10px;
}

.task-card,
.habit-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 24px;
}

.task-card {
  background: var(--pink-deep);
}

.task-card.is-done {
  opacity: 0.62;
}

.task-card.is-done h3 {
  text-decoration: line-through;
}

.complete-toggle {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #fff;
  cursor: pointer;
  background: #171717;
  border: 0;
  border-radius: 50%;
}

.complete-toggle.is-done {
  background: #fff;
}

.complete-toggle.is-done::after {
  color: var(--pink-deep);
  font-weight: 900;
  content: "✓";
}

.task-content h3,
.habit-content h3 {
  margin-bottom: 7px;
  font-size: 1.04rem;
}

.task-note,
.habit-content p {
  margin-bottom: 6px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.88rem;
  line-height: 1.35;
}

.task-meta,
.habit-content small {
  color: rgba(255, 255, 255, 0.56);
  font-size: 0.76rem;
}

.task-topline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 7px;
}

.scope-pill,
.priority-pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 5px 8px;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 900;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 999px;
}

.priority-pill.high {
  background: rgba(0, 0, 0, 0.42);
}

.task-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.habit-card .task-actions {
  grid-template-columns: repeat(2, 1fr);
}

.tiny-button {
  min-height: 38px;
  padding: 9px 10px;
  color: #fff;
  background: #171717;
  font-size: 0.78rem;
}

.habit-card {
  background: #202020;
}

.habit-orb {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  background: conic-gradient(var(--blue) 270deg, #111 0);
  border-radius: 50%;
}

.habit-orb strong {
  align-self: end;
  font-size: 1.5rem;
}

.habit-orb span {
  align-self: start;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 900;
}

.habit-meter,
.chart-track {
  overflow: hidden;
  height: 12px;
  background: #121212;
  border-radius: 999px;
}

.habit-meter {
  margin: 10px 0 7px;
}

.habit-meter span,
.chart-track span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--pink);
  border-radius: inherit;
}

.chart-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.chart-row span {
  color: var(--muted);
  font-weight: 900;
}

.achievement {
  padding: 14px;
  background: #202020;
  border-radius: 18px;
}

.achievement strong {
  display: block;
  margin-bottom: 6px;
}

.achievement span {
  color: var(--muted);
  line-height: 1.4;
}

.data-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.empty-state {
  padding: 28px 18px;
  color: var(--muted);
  text-align: center;
  background: #202020;
  border-radius: 22px;
}

.toast {
  position: fixed;
  right: 14px;
  bottom: calc(92px + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: min(360px, calc(100% - 28px));
  padding: 13px 15px;
  color: #fff;
  background: #111;
  border: 1px solid rgba(255, 63, 145, 0.34);
  border-radius: 18px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.mobile-dock {
  position: fixed;
  right: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  left: 10px;
  z-index: 15;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  width: min(520px, calc(100% - 20px));
  margin: 0 auto;
  padding: 8px;
  background: rgba(17, 17, 17, 0.96);
  border-radius: 28px;
}

.mobile-dock a {
  display: grid;
  min-height: 58px;
  place-items: center;
  gap: 3px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 900;
  border-radius: 20px;
}

.mobile-dock a:first-child {
  color: var(--pink);
  background: rgba(255, 63, 145, 0.34);
}

.mobile-dock span {
  font-size: 1.2rem;
  line-height: 1;
}

@media (max-width: 370px) {
  .app-shell {
    width: min(100% - 8px, 520px);
  }

  .app-header {
    border-radius: 34px 34px 24px 24px;
  }

  .progress-ring {
    width: 58px;
    height: 58px;
  }

  .progress-ring::before {
    width: 43px;
    height: 43px;
  }
}

@media (min-width: 641px) {
  .app-shell {
    width: min(100% - 42px, 1100px);
  }

  .app-header {
    min-height: 720px;
  }

  main {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .stats-row,
  .planner-section,
  #stats {
    grid-column: 1 / -1;
  }

  .form-row {
    grid-template-columns: 1fr 1fr;
  }

  .mobile-dock {
    width: 420px;
  }
}
