:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-2: #eef7f4;
  --text: #17211f;
  --muted: #66736f;
  --line: #d8e3df;
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --accent: #f59e0b;
  --danger: #b42318;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

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

.app {
  min-height: 100vh;
  padding: 14px 14px 88px;
  max-width: 720px;
  margin: 0 auto;
}

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

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 18px;
}

.icon-btn,
.text-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--primary);
  min-height: 38px;
  padding: 8px 12px;
  border-radius: var(--radius);
}

.primary {
  width: 100%;
  border: 0;
  background: var(--primary);
  color: white;
  min-height: 46px;
  border-radius: var(--radius);
  font-weight: 700;
}

.primary:active,
.tab:active,
.text-btn:active {
  transform: translateY(1px);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.date-card,
.form-card,
.record-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.date-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.score {
  min-width: 86px;
  min-height: 64px;
  border-radius: var(--radius);
  background: var(--surface-2);
  display: grid;
  place-items: center;
  color: var(--primary-dark);
}

.score span {
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
}

.score small {
  color: var(--muted);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 18px 0 10px;
}

.inline-actions {
  display: flex;
  gap: 6px;
}

.stack {
  display: grid;
  gap: 10px;
}

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

.project-tile,
.module-tile {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px;
  text-align: left;
  display: grid;
  gap: 4px;
  color: var(--text);
}

.project-tile span,
.module-tile span {
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
}

.project-tile strong,
.module-tile strong {
  font-size: 14px;
  line-height: 1.3;
}

.project-tile small,
.module-tile small {
  color: var(--muted);
  font-size: 12px;
}

.project-tile em,
.module-tile em {
  color: var(--accent);
  font-size: 11px;
  font-style: normal;
}

.project-tile.done {
  border-color: var(--primary);
  background: var(--surface-2);
}

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

.module-tile:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.record-card {
  display: grid;
  gap: 8px;
}

.compact-card {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.compact-card .record-top {
  grid-column: 1 / -1;
}

.compact-card .hint {
  grid-column: 1;
}

.compact-card .text-btn {
  grid-column: 2;
  grid-row: 2 / 4;
}

.task-list {
  margin: 0;
  padding-left: 20px;
}

.task-list li {
  margin: 6px 0;
}

.record-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 700;
}

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

.delete-btn {
  border: 0;
  background: transparent;
  color: var(--danger);
  padding: 4px 0;
  text-align: left;
}

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

.field-title {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
}

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

.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  min-height: 42px;
  border-radius: var(--radius);
  padding: 7px 5px;
  font-size: 13px;
}

.chip.active {
  border-color: var(--primary);
  background: var(--surface-2);
  color: var(--primary-dark);
  font-weight: 800;
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 11px;
  min-height: 42px;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  padding: 8px max(8px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
}

@media (min-width: 620px) {
  .dashboard-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

  .module-tile:last-child:nth-child(odd) {
    grid-column: auto;
  }
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  min-height: 44px;
  border-radius: var(--radius);
  font-weight: 700;
}

.tab.active {
  background: var(--surface-2);
  color: var(--primary-dark);
}

.report {
  min-height: 420px;
  background: var(--surface);
}

.actions {
  margin-top: 12px;
}

.empty {
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 78px;
  z-index: 20;
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  background: var(--primary-dark);
  color: white;
  border-radius: var(--radius);
  padding: 10px 14px;
  max-width: min(90vw, 420px);
  transition: opacity 160ms ease, transform 160ms ease;
  font-weight: 700;
}

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