:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --paper: #ffffff;
  --ink: #172033;
  --muted: #747b8a;
  --line: #e7e9ef;
  --soft: #f1f3f7;
  --blue: #2563eb;
  --green: #15803d;
  --amber: #b45309;
  --red: #dc2626;
  --shadow: 0 14px 36px rgba(22, 29, 48, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  padding: 12px 13px;
  outline: 0;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea {
  resize: vertical;
  min-height: 86px;
  line-height: 1.55;
}

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

#app {
  min-height: 100vh;
}

.auth-shell {
  width: min(100%, 480px);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  align-content: center;
  padding: 28px 16px;
}

.auth-card {
  display: grid;
  gap: 18px;
  padding: 22px 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.auth-head p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.auth-head h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

.auth-head span {
  display: block;
  margin-top: 10px;
  color: #4b5563;
  font-size: 14px;
  line-height: 1.45;
}

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

.auth-form .primary-btn {
  width: 100%;
}

.auth-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff1f2;
  color: var(--red);
  font-size: 13px;
  line-height: 1.4;
}

.auth-switch {
  min-height: 38px;
  border-radius: 12px;
  background: var(--soft);
  color: var(--blue);
  font-size: 14px;
  font-weight: 800;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 16px 104px;
}

.topbar,
.page-head,
.detail-head,
.section-head,
.capture-actions,
.sheet-head,
.sheet-actions,
.project-title-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  align-items: flex-start;
  padding-top: 8px;
}

.topbar p,
.page-head p,
.sheet-head p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topbar h1 {
  max-width: 290px;
  margin: 0;
  font-size: 34px;
  line-height: 1.05;
  font-weight: 850;
  letter-spacing: 0;
}

.subtitle {
  display: block;
  margin-top: 8px;
  color: #4b5563;
  font-size: 14px;
  line-height: 1.4;
}

.page-head {
  padding: 10px 0 18px;
}

.page-head h1,
.project-summary h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: 0;
}

.icon-btn,
.back-btn {
  width: 42px;
  height: 42px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 22px;
  font-weight: 650;
}

.icon-btn.dark {
  border-color: #111827;
  background: #111827;
  color: #fff;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 18px;
}

.metric-strip article {
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
}

.metric-strip strong {
  display: block;
  font-size: 24px;
  line-height: 1;
}

.metric-strip span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.capture-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #dfe4ee;
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.capture-controls {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 13px;
  background: var(--soft);
}

.segmented button {
  min-height: 36px;
  border-radius: 10px;
  color: #4b5563;
  font-size: 14px;
  font-weight: 700;
}

.segmented button.active {
  background: #fff;
  color: var(--blue);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.capture-actions {
  margin-top: 12px;
}

.switch-line {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.switch-line input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.primary-btn,
.ghost-btn,
.danger-btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  padding: 0 16px;
  font-weight: 800;
}

.primary-btn {
  background: var(--blue);
  color: #fff;
}

.ghost-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.danger-btn {
  border: 1px solid rgba(220, 38, 38, 0.18);
  background: #fff1f1;
  color: var(--red);
}

.section-block {
  margin-top: 24px;
}

.section-head {
  margin-bottom: 10px;
}

.section-head h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
}

.section-head button {
  min-height: 32px;
  border-radius: 10px;
  padding: 0 10px;
  color: var(--blue);
  background: #eaf1ff;
  font-size: 13px;
  font-weight: 750;
}

.list-surface {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
}

.list-surface.standalone {
  margin-top: 12px;
}

.todo-row {
  min-height: 72px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 12px 13px;
  border-bottom: 1px solid var(--line);
}

.todo-row:last-child,
.thinking-row:last-child {
  border-bottom: 0;
}

.todo-row.done .row-main {
  opacity: 0.52;
  text-decoration: line-through;
}

.check-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 2px solid #c7ccd6;
  border-radius: 999px;
  background: #fff;
  color: var(--blue);
  font-weight: 900;
}

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

.row-main strong,
.thinking-row strong,
.project-chip strong {
  display: block;
  overflow-wrap: anywhere;
}

.row-main strong {
  font-size: 16px;
  line-height: 1.3;
}

.row-main small {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.todo-stars {
  color: #f59e0b;
  letter-spacing: 0;
  white-space: nowrap;
}

.due-pill {
  min-width: 52px;
  min-height: 30px;
  border-radius: 9px;
  padding: 0 8px;
  background: var(--soft);
  color: #4b5563;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.due-pill.today,
.due-pill.overdue {
  background: #fff1f2;
  color: var(--red);
}

.due-pill.tomorrow,
.due-pill.future {
  background: #eff6ff;
  color: var(--blue);
}

.thinking-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.thinking-row p {
  display: -webkit-box;
  overflow: hidden;
  margin: 6px 0 0;
  color: #4b5563;
  font-size: 13px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.thinking-row small {
  align-self: start;
  max-width: 92px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.empty {
  margin: 0;
  padding: 18px 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.project-rail,
.filter-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 3px;
  scrollbar-width: none;
}

.project-rail::-webkit-scrollbar,
.filter-row::-webkit-scrollbar {
  display: none;
}

.project-chip {
  min-width: 168px;
  min-height: 78px;
  flex: 0 0 auto;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  text-align: left;
}

.project-chip span {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

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

.project-card {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
}

.project-card h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
}

.project-card p {
  display: -webkit-box;
  overflow: hidden;
  margin: 7px 0 0;
  color: #525b6b;
  font-size: 12px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.project-summary > span {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 8px;
  background: var(--soft);
  color: #4b5563;
  font-size: 12px;
  font-weight: 800;
}

.project-title-line {
  align-items: flex-start;
  gap: 8px;
}

.project-name-line {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.project-name-line span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.star-rating {
  flex: 0 0 auto;
  color: #f59e0b;
  font-size: 12px;
  letter-spacing: 0;
  white-space: nowrap;
}

.project-chip.importance-high {
  background: #fff1f2;
}

.project-chip.importance-medium {
  background: #fff7ed;
}

.project-chip.importance-low {
  background: #f0fdf4;
}

.filter-row {
  margin-bottom: 12px;
}

.filter-row button {
  min-height: 36px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 13px;
  background: #fff;
  color: #4b5563;
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}

.filter-row button.active {
  border-color: rgba(37, 99, 235, 0.28);
  background: #eff6ff;
  color: var(--blue);
}

.detail-head {
  padding: 8px 0 12px;
}

.project-summary {
  padding: 18px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--line);
}

.project-summary h1 {
  margin-top: 12px;
}

.project-summary p {
  margin: 10px 0 16px;
  color: #4b5563;
  font-size: 14px;
  line-height: 1.5;
}

.project-summary div {
  color: var(--muted);
  font-size: 13px;
}

.project-summary b {
  color: var(--ink);
}

.quick-add {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.quick-add button {
  min-height: 46px;
  border-radius: 13px;
  background: #111827;
  color: #fff;
  font-weight: 800;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  align-items: end;
  background: rgba(17, 24, 39, 0.4);
}

.sheet {
  width: min(100%, 760px);
  max-height: 92vh;
  overflow: auto;
  margin: 0 auto;
  display: grid;
  gap: 14px;
  padding: 18px 16px max(18px, env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  background: #fff;
}

.sheet-head h2 {
  margin: 0;
  font-size: 20px;
}

.sheet-head button {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

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

.sheet-actions {
  align-items: stretch;
}

.confirm-list {
  display: grid;
  gap: 12px;
}

.confirm-row {
  display: grid;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fafbfc;
}

.compact-confirm {
  gap: 14px;
  background: #fff;
}

.confirm-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.confirm-meta span {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--soft);
  color: #4b5563;
  font-size: 12px;
  font-weight: 800;
}

.raw-block {
  padding: 12px;
  border-radius: 12px;
  background: #f6f7f9;
}

.raw-block small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.raw-block p {
  margin: 7px 0 0;
  color: #293244;
  font-size: 14px;
  line-height: 1.55;
}

.todo-confirm-fields {
  display: grid;
  gap: 12px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  width: min(100%, 760px);
  min-height: 74px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 -12px 28px rgba(15, 23, 42, 0.08);
}

.bottom-nav button {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  color: #6b7280;
  font-size: 12px;
  font-weight: 700;
}

.bottom-nav span {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  font-size: 16px;
}

.bottom-nav button.active {
  color: var(--blue);
}

@media (min-width: 720px) {
  .app-shell {
    padding-top: 28px;
  }

  .capture-controls,
  .field-grid,
  .todo-confirm-fields {
    grid-template-columns: 1fr 1fr;
  }

  .topbar h1 {
    max-width: 520px;
    font-size: 40px;
  }

  .sheet-actions {
    flex-direction: row;
    justify-content: flex-end;
  }

  .sheet-actions button {
    min-width: 140px;
  }
}
