:root {
  --bg: #0b0e11;
  --surface: #181a20;
  --surface-soft: #1e2329;
  --surface-deep: #11151c;
  --ink: #f5f5f5;
  --muted: #848e9c;
  --muted-strong: #b7bdc6;
  --line: rgba(255, 255, 255, 0.08);
  --gold: #f0b90b;
  --gold-strong: #fcd535;
  --gold-soft: rgba(240, 185, 11, 0.12);
  --green: #0ecb81;
  --green-soft: rgba(14, 203, 129, 0.12);
  --blue: #5b9cff;
  --blue-soft: rgba(91, 156, 255, 0.12);
  --amber: #f0b90b;
  --amber-soft: rgba(240, 185, 11, 0.12);
  --red: #f6465d;
  --red-soft: rgba(246, 70, 93, 0.12);
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
  color-scheme: dark;
  font-family: "IBM Plex Sans", "Noto Sans SC", "Microsoft YaHei UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
}

body {
  color: var(--ink);
  background: linear-gradient(180deg, #0b0e11 0%, #0e1218 52%, #090c10 100%);
}

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

button {
  border: 0;
  cursor: pointer;
}

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

h1,
h2,
p {
  margin: 0;
}

.planner-app {
  width: min(1380px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 16px 0 36px;
}

.topbar,
.summary-strip,
.panel,
.task-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 26, 32, 0.96);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 64px;
  padding: 10px 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: max-content;
}

.brand span {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: #0b0e11;
  background: var(--gold);
  font-weight: 900;
}

.brand strong {
  font-size: 16px;
  letter-spacing: 0;
  white-space: nowrap;
}

.topbar.with-subnav {
  flex-wrap: wrap;
}

.ba-subnav--green {
  --subnav-bg: rgba(255, 255, 255, 0.035);
  --subnav-border: rgba(240, 185, 11, 0.2);
  --subnav-text: #d8dee6;
  --subnav-active-bg: linear-gradient(135deg, #f0b90b, #fcd535);
  --subnav-active-text: #0b0e11;
}

.date-control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.body-fat-link,
.text-button,
.quiet-button,
.focus-form button,
.task-form button,
.habit-form button,
.segmented button,
.icon-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted-strong);
  background: var(--surface-deep);
}

.icon-button {
  width: 38px;
  padding: 0;
  color: var(--gold-strong);
  font-size: 24px;
  line-height: 1;
}

.text-button,
.quiet-button,
.body-fat-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  font-weight: 900;
  white-space: nowrap;
}

.text-button,
.body-fat-link,
.focus-form button,
.task-form button,
.habit-form button {
  color: #0b0e11;
  border-color: transparent;
  background: linear-gradient(135deg, var(--gold), var(--gold-strong));
}

.quiet-button {
  color: var(--red);
  border-color: rgba(246, 70, 93, 0.2);
  background: var(--red-soft);
}

.body-fat-link:hover,
.text-button:hover,
.quiet-button:hover,
.focus-form button:hover,
.task-form button:hover,
.habit-form button:hover,
.segmented button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  outline: none;
  color: var(--ink);
  background: #0f141b;
}

select {
  color-scheme: dark;
}

option {
  color: var(--ink);
  background: #0f141b;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(240, 185, 11, 0.62);
  box-shadow: 0 0 0 3px rgba(240, 185, 11, 0.12);
}

textarea {
  min-height: 96px;
  padding: 10px 12px;
  line-height: 1.6;
  resize: vertical;
}

.summary-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 0.9fr);
  gap: 18px;
  margin-top: 14px;
  padding: 20px;
  background:
    linear-gradient(135deg, rgba(240, 185, 11, 0.11), transparent 42%),
    rgba(24, 26, 32, 0.96);
}

.summary-title {
  display: grid;
  align-content: center;
  gap: 10px;
  min-width: 0;
}

.summary-title span,
.panel-counter,
.metrics span,
.task-meta,
.routine-grid label span,
.review-panel label span {
  color: var(--muted);
  font-size: 13px;
}

.summary-title > span {
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.summary-title h1 {
  color: var(--ink);
  font-size: clamp(28px, 3.4vw, 44px);
  line-height: 1.12;
  letter-spacing: 0;
}

.progress-track {
  width: min(540px, 100%);
  height: 9px;
  overflow: hidden;
  border-radius: 8px;
  background: #2b3139;
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--gold), var(--gold-strong));
  transition: width 180ms ease;
}

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

.metrics article {
  min-height: 82px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.metrics strong {
  display: block;
  margin-top: 10px;
  color: var(--gold-strong);
  font-size: 25px;
  line-height: 1;
}

.planner-grid {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 360px;
  grid-template-areas:
    "focus tasks routine"
    "habits tasks routine"
    "habits tasks review";
  gap: 14px;
  margin-top: 14px;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.focus-panel {
  grid-area: focus;
}

.habits-panel {
  grid-area: habits;
}

.tasks-panel {
  grid-area: tasks;
}

.routine-panel {
  grid-area: routine;
}

.review-panel {
  grid-area: review;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  margin-bottom: 14px;
}

.panel-head h2 {
  font-size: 18px;
  line-height: 1.2;
}

.focus-form,
.habit-form,
.task-form {
  display: grid;
  gap: 10px;
}

.focus-form {
  grid-template-columns: minmax(0, 1fr) 72px;
}

.focus-form button,
.task-form button,
.habit-form button {
  padding: 0 12px;
  font-weight: 900;
}

.focus-display {
  min-height: 76px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(240, 185, 11, 0.16);
  border-radius: 8px;
  color: var(--gold-strong);
  background: var(--gold-soft);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.45;
  word-break: break-word;
}

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

.habit-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.habit-item input,
.task-item input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  accent-color: var(--gold);
}

.habit-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.habit-item button,
.task-delete {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  color: var(--red);
  background: transparent;
}

.habit-item button:hover,
.task-delete:hover {
  background: var(--red-soft);
}

.habit-form {
  grid-template-columns: minmax(0, 1fr) 42px;
  margin-top: 12px;
}

.task-head {
  align-items: start;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.segmented button {
  min-height: 34px;
  padding: 0 10px;
  color: var(--muted-strong);
}

.segmented button.active {
  color: #0b0e11;
  border-color: transparent;
  background: linear-gradient(135deg, var(--gold), var(--gold-strong));
  font-weight: 900;
}

.task-form {
  grid-template-columns: minmax(0, 1fr) 112px 104px 104px 42px;
  align-items: center;
}

.task-form > * {
  min-width: 0;
}

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

.task-item {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  min-height: 72px;
  padding: 12px;
  background: var(--surface-soft);
  box-shadow: none;
}

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

.task-title {
  display: block;
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.35;
  word-break: break-word;
}

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

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

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 8px;
  color: var(--muted-strong);
  background: #2b3139;
}

.chip.priority-high {
  color: var(--red);
  background: var(--red-soft);
}

.chip.priority-medium {
  color: var(--gold-strong);
  background: var(--gold-soft);
}

.chip.priority-low {
  color: var(--green);
  background: var(--green-soft);
}

.empty-state {
  min-height: 120px;
  display: grid;
  place-items: center;
  padding: 18px;
  border: 1px dashed rgba(240, 185, 11, 0.24);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(17, 21, 28, 0.75);
  text-align: center;
}

.routine-grid {
  display: grid;
  gap: 12px;
}

.routine-grid label,
.review-panel label {
  display: grid;
  gap: 8px;
}

.routine-grid textarea {
  background: #0f141b;
}

.review-panel {
  display: grid;
  gap: 12px;
}

.review-panel .panel-head {
  margin-bottom: 0;
}

.review-panel select {
  max-width: 120px;
}

@media (max-width: 1260px) {
  .summary-strip,
  .planner-grid {
    grid-template-columns: 1fr;
  }

  .planner-grid {
    grid-template-areas:
      "focus"
      "tasks"
      "routine"
      "habits"
      "review";
  }

  .summary-strip {
    gap: 14px;
  }

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

@media (max-width: 760px) {
  .planner-app {
    width: min(100vw - 16px, 760px);
    padding-top: 8px;
  }

  .topbar,
  .task-head {
    align-items: stretch;
    flex-direction: column;
  }

  .brand {
    justify-content: center;
  }

  .date-control {
    width: 100%;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 38px 64px;
  }

  .body-fat-link {
    grid-column: 1 / -1;
  }

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

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

  .segmented {
    justify-content: flex-start;
  }

  .summary-title h1 {
    font-size: 24px;
  }
}
