:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #999999);
  --link: var(--tg-theme-link-color, #007aff);
  --btn: var(--tg-theme-button-color, #007aff);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --card: var(--tg-theme-secondary-bg-color, #f4f4f7);
  --danger: #e94b3c;
  --border: rgba(120, 120, 130, 0.2);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 72px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
[x-cloak] { display: none !important; }

.screen { padding: 0 12px 12px; }

.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 0 8px;
  position: sticky; top: 0; background: var(--bg); z-index: 2;
}
.topbar h1 { flex: 1; margin: 0; font-size: 20px; }
.topbar .ghost { background: transparent; border: none; color: var(--link); font-size: 20px; padding: 6px 10px; cursor: pointer; }

.card {
  background: var(--card);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: transform 0.1s;
}
.card:active { transform: scale(0.98); }
.card-title { font-weight: 600; font-size: 16px; margin-bottom: 6px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 13px; color: var(--hint); align-items: center; }

.chip { padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.chip-danger { background: rgba(233, 75, 60, 0.15); color: var(--danger); }
.chip-info { background: rgba(0, 122, 255, 0.12); color: var(--link); }

.phase-block { margin-bottom: 18px; }
.phase-header {
  font-size: 15px; margin: 12px 0 6px; display: flex; justify-content: space-between; align-items: baseline;
}
.phase-header.danger { color: var(--danger); }
.phase-date { font-size: 12px; color: var(--hint); font-weight: normal; }
.progress {
  font-family: ui-monospace, monospace;
  font-size: 13px;
  color: var(--hint);
  margin-bottom: 8px;
  padding-left: 4px;
}
.progress code { color: var(--link); }

.task-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 8px; border-radius: 10px;
  border-bottom: 1px solid var(--border);
}
.task-row:last-child { border-bottom: none; }
.task-row.done { opacity: 0.5; }
.task-row.done .task-title { text-decoration: line-through; }
.task-row.blocker { border-left: 3px solid var(--danger); padding-left: 9px; }

.task-check { display: inline-flex; align-items: center; padding-top: 2px; }
.task-check input { width: 20px; height: 20px; accent-color: var(--btn); cursor: pointer; }
.task-check input:disabled { opacity: 0.6; }

.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 14px; line-height: 1.35; word-break: break-word; }
.task-meta { font-size: 12px; color: var(--hint); margin-top: 3px; }

.ghost.tiny { background: transparent; border: none; font-size: 18px; cursor: pointer; padding: 4px 8px; color: var(--hint); }

.empty { padding: 40px 20px; text-align: center; color: var(--hint); }

.fab {
  position: fixed; right: 16px; bottom: 88px;
  width: 56px; height: 56px; border-radius: 28px;
  background: var(--btn); color: var(--btn-text);
  border: none; font-size: 28px; line-height: 56px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  cursor: pointer; z-index: 5;
}
.fab:active { transform: scale(0.95); }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 10;
}
.modal {
  background: var(--bg);
  border-radius: 18px 18px 0 0;
  width: 100%; max-width: 600px;
  padding: 20px 16px 24px;
  animation: slide-up 0.2s;
}
@keyframes slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal h2 { margin: 0 0 14px; font-size: 18px; }
.modal label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--hint); }
.modal input, .modal select {
  display: block; width: 100%; margin-top: 6px;
  padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  font-size: 15px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.modal-actions button {
  padding: 10px 20px; border-radius: 10px; font-size: 15px; cursor: pointer; border: none;
}
.modal-actions .ghost { background: transparent; color: var(--link); }
.modal-actions .primary { background: var(--btn); color: var(--btn-text); }
.modal-actions .primary:disabled { opacity: 0.5; cursor: not-allowed; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; background: var(--bg);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 3;
}
.bottom-nav button {
  flex: 1; padding: 14px 8px;
  background: transparent; border: none; color: var(--hint);
  font-size: 14px; cursor: pointer;
}
.bottom-nav button.active { color: var(--link); font-weight: 600; }

.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8); color: white; padding: 10px 16px;
  border-radius: 20px; font-size: 14px; z-index: 20;
}
