:root {
  color-scheme: dark;
  --bg: #050505;
  --surface: #101113;
  --surface-strong: #17191d;
  --line: #292c32;
  --text: #f4f4f5;
  --muted: #9da3af;
  --soft: #cfd4dc;
  --green: #45d483;
  --orange: #f3a43b;
  --red: #f05d5e;
  --blue: #6aa7ff;
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.auth-panel {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 440px);
  gap: 48px;
  align-items: center;
  min-height: 100vh;
  padding: 48px clamp(20px, 5vw, 80px);
  background:
    linear-gradient(120deg, rgba(69, 212, 131, 0.16), transparent 36%),
    radial-gradient(circle at 85% 15%, rgba(106, 167, 255, 0.18), transparent 28%),
    #050505;
}

.brand-lockup {
  display: flex;
  gap: 18px;
  align-items: center;
}

.brand-lockup h1 {
  max-width: 720px;
  margin: 4px 0 0;
  font-size: clamp(48px, 8vw, 96px);
  line-height: 0.92;
  letter-spacing: 0;
}

.brand-lockup.compact {
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(69, 212, 131, 0.55);
  border-radius: 14px;
  background: #0d1a12;
  color: var(--green);
  font-weight: 800;
}

.eyebrow {
  margin: 0;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.auth-card,
.panel,
.profile-card,
.metric-grid article,
.score-pill,
.streak-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 17, 19, 0.88);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22);
}

.auth-card {
  display: grid;
  gap: 18px;
  padding: 28px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #08090b;
}

.auth-tab {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.auth-tab.is-active {
  background: #17191d;
  color: var(--text);
}

.auth-card h2,
.topbar h2,
.panel h3,
.hero-band h3 {
  margin: 0;
  letter-spacing: 0;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid #2d3037;
  border-radius: 6px;
  background: #08090b;
  color: var(--text);
  outline: none;
  padding: 12px 13px;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

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

.large-textarea {
  min-height: 280px;
}

.primary-action,
.google-action,
.nav-button,
.icon-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  font-weight: 800;
}

.primary-action {
  background: var(--green);
  color: #021006;
}

.google-action {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  background: #15171b;
  border-color: var(--line);
}

.google-action span {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: #111;
}

.muted {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

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

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100vh;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: #08090b;
}

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

.nav-button {
  width: 100%;
  padding: 0 14px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-button.is-active,
.nav-button:hover {
  background: #16191d;
  color: var(--text);
}

.profile-card {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: auto;
  padding: 14px;
}

.profile-card p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.avatar {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  background: #1a2a20;
  color: var(--green);
  font-weight: 800;
}

.content {
  padding: 28px;
}

.topbar,
.panel-heading {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
}

.topbar {
  margin-bottom: 24px;
}

.score-pill {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 10px 14px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.topbar-actions input {
  width: auto;
  min-height: 38px;
  padding: 8px 10px;
}

.score-pill span,
.streak-box span,
.metric-grid span,
.panel-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.score-pill strong {
  color: var(--green);
  font-size: 28px;
}

.view {
  display: none;
}

.view.is-visible {
  display: grid;
  gap: 20px;
}

.hero-band {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  min-height: 180px;
  padding: 28px;
  border: 1px solid #263229;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(69, 212, 131, 0.2), transparent 46%),
    linear-gradient(90deg, #111315, #08090b);
}

.hero-band h3 {
  max-width: 720px;
  margin-top: 10px;
  font-size: clamp(28px, 4vw, 54px);
  line-height: 1;
}

.habit-hero {
  border-color: rgba(69, 212, 131, 0.45);
  background:
    linear-gradient(135deg, rgba(69, 212, 131, 0.24), transparent 42%),
    linear-gradient(90deg, #111315, #08090b);
}

.streak-box {
  display: grid;
  min-width: 138px;
  gap: 8px;
  padding: 18px;
}

.streak-box strong {
  color: var(--green);
  font-size: 24px;
}

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

.metric-grid article {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.metric-grid strong {
  font-size: 30px;
}

.metric-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

progress {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: #25282e;
}

progress::-webkit-progress-bar {
  background: #25282e;
}

progress::-webkit-progress-value {
  background: var(--green);
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 20px;
}

.panel {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.onboarding-panel {
  display: grid;
  gap: 18px;
  margin-bottom: 20px;
  padding: 22px;
  border: 1px solid rgba(69, 212, 131, 0.45);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(69, 212, 131, 0.14), transparent 48%), #0b0c0f;
}

.onboarding-panel h2 {
  margin: 4px 0 0;
}

.task-list,
.meal-list,
.exercise-list,
.run-list,
.history-list,
.habit-list,
.photo-grid {
  display: grid;
  gap: 10px;
}

.task-row,
.meal-row,
.exercise-row,
.run-row,
.history-row,
.empty-state {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid #24272d;
  border-radius: 8px;
  background: #0b0c0f;
}

.task-row strong,
.meal-row strong,
.exercise-row strong,
.run-row strong,
.history-row strong,
.empty-state strong {
  display: block;
  margin-bottom: 4px;
}

.task-row p,
.meal-row p,
.exercise-row p,
.run-row p,
.history-row p,
.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  grid-template-columns: 1fr;
  border-style: dashed;
}

.photo-card {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid #24272d;
  border-radius: 8px;
  background: #0b0c0f;
}

.photo-card img {
  width: 96px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
}

.photo-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.row-controls {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.status-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-button {
  min-height: 34px;
  border: 1px solid #30343b;
  border-radius: 999px;
  background: #111318;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 0 12px;
}

.status-button.is-active[data-status="done"] {
  border-color: rgba(69, 212, 131, 0.7);
  background: rgba(69, 212, 131, 0.16);
  color: var(--green);
}

.status-button.is-active[data-status="partial"] {
  border-color: rgba(243, 164, 59, 0.7);
  background: rgba(243, 164, 59, 0.14);
  color: var(--orange);
}

.status-button.is-active[data-status="missed"] {
  border-color: rgba(240, 93, 94, 0.65);
  background: rgba(240, 93, 94, 0.12);
  color: var(--red);
}

.item-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.mini-button {
  min-height: 30px;
  border: 1px solid #30343b;
  border-radius: 6px;
  background: #15171b;
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
  padding: 0 10px;
}

.mini-button.danger {
  color: #ff9b9b;
}

.motivation-panel blockquote {
  margin: 0;
  padding-left: 18px;
  border-left: 3px solid var(--green);
  color: var(--soft);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.28;
}

.icon-button {
  width: 42px;
  background: #15171b;
  border-color: var(--line);
}

.checkin-card,
.ai-preview,
.recovery-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid #24272d;
  border-radius: 8px;
  background: #0b0c0f;
}

.recovery-card {
  color: var(--green);
  font-weight: 800;
  line-height: 1.35;
}

.checkin-card h4 {
  margin: 0;
}

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

.quick-form {
  display: grid;
  grid-template-columns: minmax(160px, 0.7fr) minmax(220px, 1fr) auto;
  gap: 10px;
}

#weeklyItemForm {
  grid-template-columns: minmax(140px, 0.55fr) minmax(160px, 0.7fr) minmax(220px, 1fr) auto;
}

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

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

.week-day {
  display: grid;
  gap: 8px;
  min-height: 112px;
  padding: 14px;
  border: 1px solid #24272d;
  border-radius: 8px;
  background: #0b0c0f;
  color: var(--text);
  text-align: left;
}

.week-day span,
.week-day small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.week-day strong {
  font-size: 22px;
}

.week-day.is-active {
  border-color: rgba(69, 212, 131, 0.7);
  background: rgba(69, 212, 131, 0.12);
}

.month-day,
.month-spacer {
  min-height: 42px;
  border: 1px solid #24272d;
  border-radius: 6px;
  background: #0b0c0f;
  color: var(--soft);
  font-weight: 800;
}

.month-spacer {
  background: transparent;
  border-color: transparent;
}

.month-day.is-active {
  border-color: rgba(69, 212, 131, 0.72);
  background: rgba(69, 212, 131, 0.16);
  color: var(--green);
}

.planner-tools {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto minmax(160px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
}

.inline-check {
  display: flex;
  min-height: 42px;
  flex-direction: row;
  gap: 8px;
  align-items: center;
  color: var(--muted);
}

.inline-check input {
  width: auto;
}

.habit-form {
  display: grid;
  gap: 14px;
}

.habit-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid #284234;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(69, 212, 131, 0.12), transparent 38%), #0b0c0f;
}

.habit-main {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
}

.habit-main strong {
  display: block;
  margin-bottom: 4px;
  font-size: 18px;
}

.habit-main p,
.habit-main small {
  display: block;
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.habit-ring {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 4px solid var(--green);
  border-radius: 50%;
  background: #08090b;
  color: var(--text);
  font-size: 20px;
  font-weight: 900;
}

.habit-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.habit-week span {
  height: 10px;
  border-radius: 999px;
  background: #25282e;
}

.habit-week .done {
  background: var(--green);
}

.habit-week .resisted {
  background: var(--blue);
}

.habit-week .missed {
  background: var(--red);
}

.habit-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, auto));
  gap: 8px;
  justify-content: start;
}

.habit-button {
  min-height: 40px;
  border: 1px solid #30343b;
  border-radius: 999px;
  background: #111318;
  color: var(--soft);
  font-size: 12px;
  font-weight: 900;
  padding: 0 14px;
}

.habit-button.is-active[data-status="done"] {
  border-color: rgba(69, 212, 131, 0.75);
  background: rgba(69, 212, 131, 0.18);
  color: var(--green);
}

.habit-button.is-active[data-status="resisted"] {
  border-color: rgba(106, 167, 255, 0.75);
  background: rgba(106, 167, 255, 0.16);
  color: var(--blue);
}

.habit-button.is-active[data-status="missed"] {
  border-color: rgba(240, 93, 94, 0.75);
  background: rgba(240, 93, 94, 0.14);
  color: var(--red);
}

.habit-guide {
  padding: 16px;
  border: 1px solid rgba(69, 212, 131, 0.35);
  border-radius: 8px;
  background: rgba(69, 212, 131, 0.1);
  color: var(--green);
  font-weight: 800;
  line-height: 1.35;
}

.form-span {
  grid-column: 1 / -1;
}

.chart-bars {
  display: grid;
  grid-template-columns: repeat(14, minmax(18px, 1fr));
  gap: 8px;
  min-height: 220px;
  align-items: end;
}

.chart-day {
  display: grid;
  min-height: 190px;
  grid-template-rows: 1fr auto;
  gap: 8px;
  align-items: end;
}

.chart-day span {
  display: block;
  width: 100%;
  min-height: 8px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--green), #1f6d43);
}

.chart-day small {
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.ai-preview {
  color: var(--soft);
  line-height: 1.5;
  white-space: pre-wrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.72);
}

.modal-card {
  display: grid;
  width: min(560px, 100%);
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101113;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
}

@media (max-width: 960px) {
  .auth-panel,
  .workspace,
  .two-column {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .week-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .month-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .planner-tools {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .auth-panel,
  .content,
  .sidebar {
    padding: 18px;
  }

  .brand-lockup h1 {
    font-size: 46px;
  }

  .hero-band,
  .topbar,
  .topbar-actions,
  .panel-heading,
  .task-row,
  .meal-row,
  .exercise-row,
  .run-row,
  .history-row,
  .empty-state,
  .photo-card {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .nav-list,
  .metric-grid,
  .form-grid,
  .quick-form,
  #weeklyItemForm,
  .week-grid,
  .planner-tools,
  .register-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .topbar-actions input {
    width: 100%;
  }

  .status-group,
  .item-actions,
  .row-controls,
  .habit-actions {
    justify-content: flex-start;
    justify-items: stretch;
  }

  .status-button,
  .mini-button,
  .habit-button,
  .primary-action,
  .google-action {
    min-height: 46px;
  }

  .habit-actions {
    grid-template-columns: 1fr;
  }

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 4;
    gap: 14px;
    background: rgba(8, 9, 11, 0.96);
    backdrop-filter: blur(14px);
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .nav-button {
    flex: 0 0 auto;
    width: auto;
    padding: 0 14px;
    white-space: nowrap;
  }

  .profile-card {
    display: none;
  }

  .chart-bars {
    gap: 5px;
    min-height: 170px;
  }

  .chart-day {
    min-height: 145px;
  }

  .chart-day small {
    writing-mode: vertical-rl;
  }
}
