:root {
  color-scheme: light;
  --bg: #f6f7f1;
  --panel: #ffffff;
  --panel-soft: #f0f6ec;
  --ink: #171918;
  --muted: #6f756f;
  --line: #e3e6df;
  --green: #4f7f35;
  --green-dark: #2f612f;
  --green-soft: #eef6e9;
  --amber: #a36b16;
  --amber-soft: #fff6df;
  --violet: #7b6a8b;
  --blue: #46788f;
  --danger: #a4423e;
  --shadow: 0 10px 28px rgba(44, 54, 40, 0.08);
  --radius: 8px;
  --topbar: 64px;
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(246, 247, 241, 0.94)),
    radial-gradient(circle at 10% 0%, rgba(79, 127, 53, 0.08), transparent 30%),
    var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  overflow-x: hidden;
}

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

button {
  -webkit-tap-highlight-color: transparent;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: calc(var(--topbar) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 18px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.topbar-left {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

.menu-button,
.icon-button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.menu-button:hover,
.icon-button:hover {
  background: #f0f2ec;
}

.screen-title {
  min-width: 0;
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.date-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 17px;
  white-space: nowrap;
}

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  max-width: 1180px;
  margin: 0 auto;
}

.drawer {
  position: sticky;
  top: var(--topbar);
  height: calc(100vh - var(--topbar));
  padding: 28px 18px 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.drawer-profile {
  padding: 8px 10px 24px;
  border-bottom: 1px solid var(--line);
}

.profile-name {
  margin: 0;
  color: var(--green);
  font-size: 24px;
  font-weight: 900;
}

.profile-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
}

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

.nav-item {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 750;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover {
  background: #f1f3ec;
}

.nav-item.is-active {
  background: var(--green);
  color: #fff;
  box-shadow: 0 8px 18px rgba(79, 127, 53, 0.2);
}

.nav-icon {
  text-align: center;
  font-size: 22px;
}

.nav-count {
  min-width: 28px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(23, 25, 24, 0.08);
  color: inherit;
  font-size: 13px;
  text-align: center;
}

.drawer-footer {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  padding: 16px 10px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.drawer-footer strong {
  color: var(--green);
}

.drawer-overlay {
  display: none;
}

.content {
  min-width: 0;
  padding: 28px 28px 96px;
}

.view-stack {
  display: grid;
  gap: 22px;
}

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

.stat-card,
.panel,
.task-card,
.note-card,
.image-card,
.trend-card,
.drill-card,
.stage-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.stat-card {
  min-height: 112px;
  padding: 18px;
}

.stat-value {
  margin: 0;
  color: var(--green);
  font-size: 34px;
  font-weight: 900;
  line-height: 1.1;
}

.stat-label {
  margin: 10px 0 0;
  color: var(--muted);
}

.panel {
  padding: 22px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-title {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
}

.panel-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1 1 220px;
  min-width: 0;
}

.search-box input,
.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  outline: none;
}

.search-box input {
  min-height: 42px;
  padding: 0 14px;
}

.field input,
.field select {
  min-height: 44px;
  padding: 0 12px;
}

.field textarea {
  resize: vertical;
  padding: 11px 12px;
}

.search-box input:focus,
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(79, 127, 53, 0.12);
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.segmented button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
  cursor: pointer;
}

.segmented button.is-active {
  background: var(--green);
  color: #fff;
}

.task-list,
.note-list,
.image-grid,
.trend-list,
.drill-list {
  display: grid;
  gap: 12px;
}

.task-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  padding: 16px;
  box-shadow: none;
}

.task-card.is-done {
  border-color: rgba(79, 127, 53, 0.65);
  background: var(--green-soft);
}

.check-button {
  width: 34px;
  height: 34px;
  border: 2px solid var(--green);
  border-radius: var(--radius);
  background: #fff;
  color: transparent;
  font-size: 22px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.task-card.is-done .check-button {
  background: var(--green);
  color: #fff;
}

.check-button.is-checked {
  background: var(--green);
  color: #fff;
}

.task-title {
  margin: 0;
  font-size: 18px;
  font-weight: 850;
  word-break: break-word;
}

.task-card.is-done .task-title {
  color: #677067;
  text-decoration: line-through;
}

.task-desc {
  margin: 3px 0 0;
  color: var(--muted);
  word-break: break-word;
}

.meta-row,
.chip-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 800;
}

.tag.amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.tag.blue {
  background: #eaf4f7;
  color: var(--blue);
}

.task-actions {
  display: flex;
  align-items: flex-start;
  gap: 2px;
}

.task-actions .icon-button {
  width: 34px;
  height: 34px;
  color: #9da39d;
  font-size: 20px;
}

.thumb-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.thumb-row img {
  width: 74px;
  height: 74px;
  flex: 0 0 auto;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.empty-state {
  min-height: 128px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.55);
  padding: 24px;
}

.primary-button,
.ghost-button,
.danger-button {
  min-height: 42px;
  border-radius: var(--radius);
  padding: 0 16px;
  border: 1px solid transparent;
  font-weight: 850;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

.primary-button {
  background: var(--green);
  color: #fff;
  box-shadow: 0 8px 16px rgba(79, 127, 53, 0.18);
}

.ghost-button {
  background: #fff;
  border-color: rgba(79, 127, 53, 0.55);
  color: var(--green-dark);
}

.danger-button {
  background: #fff;
  border-color: rgba(164, 66, 62, 0.35);
  color: var(--danger);
}

.fab {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 15;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 34px;
  line-height: 1;
  box-shadow: 0 14px 28px rgba(47, 97, 47, 0.28);
  cursor: pointer;
}

.quick-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.quick-add input {
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 14px;
}

.note-card,
.trend-card,
.drill-card,
.stage-card {
  padding: 18px;
  box-shadow: none;
}

.note-card h3,
.trend-card h3,
.drill-card h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
  word-break: break-word;
}

.note-card p,
.trend-card p,
.drill-card p,
.stage-card p {
  color: var(--muted);
  margin: 8px 0 0;
  word-break: break-word;
}

.trend-card {
  border-left: 5px solid var(--green);
}

.trend-card .reason {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--green-soft);
  color: #465044;
}

.stage-card {
  border-color: rgba(123, 106, 139, 0.72);
  background: linear-gradient(120deg, #fff, #faf8ff);
}

.progress-bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #eceaf0;
  margin: 18px 0 12px;
}

.progress-bar span {
  display: block;
  height: 100%;
  width: var(--progress, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--violet));
}

.stage-label {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 2px 10px;
  border-radius: 999px;
  background: #f3eafa;
  color: #624d73;
  font-weight: 850;
  font-size: 14px;
}

.drill-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
}

.image-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.image-card {
  overflow: hidden;
  box-shadow: none;
}

.image-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: #f1f2ed;
}

.image-card-body {
  padding: 12px;
}

.image-card h3 {
  margin: 0;
  font-size: 15px;
  word-break: break-word;
}

.image-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.upload-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
}

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

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 750;
}

.checkbox-field {
  align-content: end;
  grid-template-columns: 22px 1fr;
  align-items: center;
  min-height: 72px;
  padding-top: 25px;
}

.checkbox-field input {
  width: 20px;
  height: 20px;
}

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

.modal {
  width: min(560px, calc(100vw - 28px));
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(23, 25, 24, 0.48);
  backdrop-filter: blur(4px);
}

.modal-card {
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 24px 70px rgba(23, 25, 24, 0.28);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h2 {
  margin: 0;
  font-size: 22px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--green);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 900;
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 40;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  max-width: min(420px, calc(100vw - 36px));
  padding: 10px 14px;
  border-radius: var(--radius);
  background: rgba(23, 25, 24, 0.9);
  color: #fff;
  font-size: 14px;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.hint-box {
  padding: 14px;
  border-radius: var(--radius);
  background: #f7f8f4;
  color: var(--muted);
  border: 1px solid var(--line);
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 18px;
}

@media (max-width: 880px) {
  .layout {
    display: block;
  }

  .drawer {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 35;
    width: min(78vw, 330px);
    height: 100vh;
    padding-top: calc(48px + env(safe-area-inset-top));
    transform: translateX(-104%);
    transition: transform 0.2s ease;
    background: #fff;
    box-shadow: 22px 0 42px rgba(23, 25, 24, 0.18);
  }

  .drawer.is-open {
    transform: translateX(0);
  }

  .drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: none;
    background: rgba(23, 25, 24, 0.42);
  }

  .drawer-overlay.is-visible {
    display: block;
  }

  .content {
    padding: 20px 14px 92px;
  }

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

  .two-column {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  :root {
    --topbar: 58px;
  }

  body {
    font-size: 16px;
  }

  .topbar {
    padding-left: 12px;
    padding-right: 12px;
  }

  .screen-title {
    font-size: 20px;
  }

  .date-label {
    font-size: 15px;
  }

  .panel {
    padding: 18px;
  }

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

  .stats-grid,
  .form-grid,
  .settings-grid,
  .upload-panel {
    grid-template-columns: 1fr;
  }

  .task-card {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .task-actions {
    grid-column: 2;
    justify-content: flex-end;
  }

  .quick-add {
    grid-template-columns: 1fr;
  }

  .segmented {
    width: 100%;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-flow: initial;
  }

  .segmented button {
    padding: 0 6px;
  }

  .modal {
    width: 100vw;
    max-width: 100vw;
    margin: auto 0 0;
  }

  .modal-card {
    border-radius: var(--radius) var(--radius) 0 0;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

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

  .primary-button,
  .ghost-button,
  .danger-button {
    width: 100%;
  }
}
