/* PM Organizer styles.
   Built phone-first: big tap targets for gloves and job sites, bottom tab
   bar on phones, top menu on bigger screens. Follows the phone's
   light/dark mode automatically. */

:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #1f2a37;
  --accent: #f59e0b;      /* safety orange: Top 3 star */
  --primary: #2563eb;
  --green: #16a34a;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --win-bg: #f0fdf4;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141a;
    --card: #1a222c;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --line: #2a3441;
    --brand: #0b1016;
    --primary: #3b82f6;
    --red-bg: #2a1517;
    --win-bg: #11241a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: var(--primary); }
h1 { font-size: 1.5rem; margin: 0.4rem 0 0.4rem; }
h2 { font-size: 1.08rem; margin: 0 0 0.6rem; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 0.9rem; margin: 0.4rem 0; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  background: var(--brand);
  color: #fff;
  padding-top: env(safe-area-inset-top);
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
  max-width: 900px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 16px;
}
.brand { color: #fff; font-weight: 700; text-decoration: none; }
.topnav { display: none; gap: 4px; flex: 1; }
.topnav a, .small-link { color: #cbd5e1; text-decoration: none; padding: 6px 10px; border-radius: 8px; }
.topnav a.on { color: #fff; background: rgba(255,255,255,0.12); }
.small-link { margin-left: auto; font-size: 0.9rem; }

/* ---------- bottom tab bar (phones) ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; text-align: center; padding: 8px 0 10px; font-size: 0.75rem;
  color: var(--muted); text-decoration: none; position: relative;
}
.tabbar a.on { color: var(--primary); font-weight: 600; }
.tabbar .ico { display: block; font-size: 1.35rem; line-height: 1.3; }

@media (min-width: 760px) {
  .topnav { display: flex; }
  .small-link { margin-left: 0; }
  .tabbar { display: none; }
  body { padding-bottom: 24px; }
}

.badge {
  display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--red); color: #fff; font-size: 0.75rem; font-weight: 700;
  line-height: 20px; text-align: center;
}
.badge.tab-badge { position: absolute; top: 4px; left: 55%; }

/* ---------- page layout ---------- */
.page { max-width: 900px; margin: 0 auto; padding: 12px 14px; }
.date-line { color: var(--muted); margin: 4px 2px 10px; font-weight: 600; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 14px;
}
.card-alert { border-color: var(--red); background: var(--red-bg); }
.card-win { background: var(--win-bg); }
.empty { color: var(--muted); margin: 0; }

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-weight: 500; }
.flash-success { background: var(--win-bg); color: var(--green); border: 1px solid var(--green); }
.flash-error { background: var(--red-bg); color: var(--red); border: 1px solid var(--red); }

/* ---------- forms ---------- */
input[type=text], input[type=password], input[type=date], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
textarea { resize: vertical; }
label { display: block; font-size: 0.9rem; color: var(--muted); }
label input, label select, label textarea { margin-top: 4px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.big-input { font-size: 1.1rem; padding: 14px; margin: 10px 0; }
.capture-extras { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.capture-extras > select { align-self: end; }
.kind-toggle { display: flex; gap: 8px; }
.kind-toggle label {
  flex: 1; text-align: center; padding: 10px; border: 1px solid var(--line);
  border-radius: 10px; color: var(--text); cursor: pointer; font-size: 1rem;
}
.kind-toggle input { margin-right: 6px; }
.kind-toggle label:has(input:checked) { border-color: var(--primary); background: rgba(37,99,235,0.08); font-weight: 600; }

.btn {
  display: inline-block; font: inherit; font-weight: 600; padding: 10px 16px; min-height: 44px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text);
  cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-ghost { background: transparent; }
.btn-wide { width: 100%; }
.btn-small { padding: 6px 10px; min-height: 36px; font-size: 0.85rem; }
.link-btn { background: none; border: none; color: var(--primary); font: inherit; font-size: 0.85rem; cursor: pointer; }
.inline { display: inline; margin: 0; }

/* ---------- task / waiting rows ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: none; }
.row-top3 .row-title { font-weight: 600; }
.row-main { flex: 1; min-width: 0; }
.row-title { word-wrap: break-word; }
.row-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.row-actions { display: flex; gap: 2px; }
.row-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.check {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--muted);
  background: transparent; cursor: pointer; margin-top: 1px; flex-shrink: 0;
}
.check:hover, .check:active { border-color: var(--green); background: var(--win-bg); }
.icon-btn {
  width: 40px; height: 40px; border: none; background: none; color: var(--muted);
  font-size: 1.2rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; border-radius: 8px;
}
.icon-btn:disabled { opacity: 0.25; cursor: not-allowed; }
.star-on { color: var(--accent); }

.chip {
  display: inline-block; font-size: 0.78rem; padding: 2px 8px; border-radius: 999px;
  background: var(--bg); color: var(--muted); border: 1px solid var(--line);
}
.chip-red { color: var(--red); border-color: var(--red); background: var(--red-bg); }

.done-list { list-style: none; margin: 0; padding: 0; }
.done-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 6px 0; border-top: 1px solid var(--line);
}
.done-list li:first-child { border-top: none; }

/* ---------- jobs ---------- */
.job-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .job-grid { grid-template-columns: 1fr 1fr; } }
.job-card {
  display: block; background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--primary);
  border-radius: var(--radius); padding: 14px; color: var(--text); text-decoration: none;
}
.job-warn { border-left-color: var(--accent); }
.job-inactive { opacity: 0.55; border-left-color: var(--muted); }
.job-name { font-weight: 700; font-size: 1.05rem; }
.job-stage { color: var(--primary); font-size: 0.85rem; font-weight: 600; margin: 2px 0 6px; }
.job-next { font-size: 0.95rem; margin-bottom: 8px; }
.job-counts { display: flex; flex-wrap: wrap; gap: 10px; font-size: 0.8rem; color: var(--muted); align-items: center; }

/* ---------- login / setup ---------- */
.auth { max-width: 380px; margin: 10vh auto 0; }
.auth h1 { text-align: center; }

.big-done { font-weight: 700; color: var(--green); font-size: 1.1rem; margin: 20px 0; }

/* ---------- calendar ---------- */
:root { --work: #2563eb; --personal: #9333ea; --family: #16a34a; --task: #f59e0b; --wait: #dc2626; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-head h1 { margin: 0; text-align: center; flex: 1; font-size: 1.25rem; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 0.78rem; color: var(--muted); margin: 8px 0; justify-content: center; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.cat-work { background: var(--work); } .dot.cat-personal { background: var(--personal); } .dot.cat-family { background: var(--family); }
.dot-task { background: var(--task); } .dot-waiting { background: var(--wait); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-dow { text-align: center; font-size: 0.75rem; color: var(--muted); font-weight: 600; padding: 4px 0; }
.cal-cell {
  min-height: 58px; background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 4px; color: var(--text); text-decoration: none; display: flex; flex-direction: column; gap: 3px; overflow: hidden;
}
.cal-other { opacity: 0.45; }
.cal-today { border: 2px solid var(--primary); }
.cal-today .cal-num { color: var(--primary); font-weight: 700; }
.cal-num { font-size: 0.85rem; }
.cal-dots { display: flex; flex-wrap: wrap; gap: 2px; }
.cal-labels { display: none; flex-direction: column; gap: 2px; }
.cal-label { font-size: 0.72rem; padding: 1px 4px; border-radius: 4px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-label.cat-work { background: var(--work); } .cal-label.cat-personal { background: var(--personal); } .cal-label.cat-family { background: var(--family); }
.lbl-task { background: var(--task); color: #111 !important; } .lbl-waiting { background: var(--wait); }
.cal-more { font-size: 0.7rem; color: var(--muted); }
@media (min-width: 760px) {
  .cal-cell { min-height: 100px; }
  .cal-dots { display: none; }
  .cal-labels { display: flex; }
}
.cat-bar { width: 4px; align-self: stretch; border-radius: 2px; background: var(--work); flex-shrink: 0; }
.cat-bar.cat-personal { background: var(--personal); } .cat-bar.cat-family { background: var(--family); }
input[type=time] {
  width: 100%; font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; margin-top: 4px;
}
.kind-toggle label { padding: 10px 4px; font-size: 0.95rem; }

/* ---------- Claude assistant ---------- */
.mode-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px; }
.mode-tabs a {
  text-align: center; padding: 10px 4px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); text-decoration: none; font-size: 0.85rem; font-weight: 600;
}
.mode-tabs a.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.answer { white-space: pre-wrap; line-height: 1.5; }
details summary { cursor: pointer; color: var(--primary); font-size: 0.9rem; margin-bottom: 6px; }
.check-label { display: flex; align-items: center; gap: 8px; color: var(--text); }
.check-label input { width: 22px; height: 22px; margin: 0; }
.keep-box { width: 24px; height: 24px; margin-top: 10px; flex-shrink: 0; }
.sort-item .stack { gap: 6px; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }
.tweak { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }

/* ---------- study / cheat sheets ---------- */
.mode-tabs { grid-template-columns: repeat(3, 1fr); }
@media (min-width: 760px) { .mode-tabs { grid-template-columns: repeat(5, 1fr); } }
.study-top { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
@media (min-width: 640px) { .study-top { flex-direction: row; align-items: center; } .study-search { flex: 1; } }
.sheet-list { list-style: none; margin: 0; padding: 0; }
.sheet-list li { border-top: 1px solid var(--line); }
.sheet-list li:first-child { border-top: none; }
.sheet-list a { display: flex; flex-direction: column; gap: 3px; padding: 10px 0; color: var(--text); text-decoration: none; align-items: flex-start; }
.sheet-title { font-weight: 600; }
.sheet-sub { font-size: 0.88rem; color: var(--muted); }
.sheet-cat { margin: 0; font-weight: 600; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.04em; }
.sheet-summary { margin: 0; font-size: 1.05rem; }
.bullets { margin: 0; padding-left: 20px; }
.bullets li { margin: 4px 0; }
.flash-list { margin: 0; padding-left: 22px; }
.flash-list li { margin: 8px 0; }
.ask-answer { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.quiz { text-align: center; }
.quiz-count { color: var(--muted); font-size: 0.9rem; margin-bottom: 8px; }
.quiz-card {
  width: 100%; min-height: 180px; border: 2px solid var(--primary); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font: inherit; cursor: pointer;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px; padding: 18px;
}
.quiz-label { font-size: 0.8rem; font-weight: 700; color: var(--primary); text-transform: uppercase; }
.quiz-text { font-size: 1.2rem; font-weight: 600; }
.quiz .row-buttons { justify-content: center; margin-top: 12px; }
@media print {
  .topbar, .tabbar, .no-print, .flash { display: none !important; }
  body { background: #fff; padding: 0; }
  .card { border: none; padding: 4px 0; break-inside: avoid; }
}
#quiz { scroll-margin-top: 80px; }

/* ---------- talk-to-type mic button ---------- */
.mic-wrap { position: relative; display: block; }
.mic-wrap > input, .mic-wrap > textarea { padding-right: 52px; }
.mic-wrap > .big-input { margin: 10px 0; }
.mic-btn {
  position: absolute; right: 6px; bottom: 6px; width: 40px; height: 40px;
  border-radius: 50%; border: 1px solid var(--line); background: var(--card);
  font-size: 1.15rem; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.mic-wrap > .big-input + .mic-btn { bottom: 18px; }
.mic-btn.listening { background: var(--red); border-color: var(--red); animation: mic-pulse 1.2s infinite; }
@keyframes mic-pulse { 0% { box-shadow: 0 0 0 0 rgba(220,38,38,0.5); } 70% { box-shadow: 0 0 0 10px rgba(220,38,38,0); } 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); } }
.mic-note { font-size: 0.82rem; color: var(--red); margin-top: 4px; }

/* ---------- life areas ---------- */
:root { --home: #0d9488; }
.area-filter { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.area-filter a {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card);
  color: var(--text); text-decoration: none; font-size: 0.9rem; font-weight: 600;
}
.area-filter a.on { background: var(--text); color: var(--card); border-color: var(--text); }
.area-tag { font-size: 0.72rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; color: #fff; vertical-align: middle; background: var(--work); }
.area-tag.area-home { background: var(--home); } .area-tag.area-family { background: var(--family); } .area-tag.area-personal { background: var(--personal); }
.area-border-work { border-left-color: var(--work); } .area-border-home { border-left-color: var(--home); }
.area-border-family { border-left-color: var(--family); } .area-border-personal { border-left-color: var(--personal); }
.job-card.job-warn { border-left-color: var(--accent); }
.dot.cat-home, .cat-bar.cat-home { background: var(--home); }
.cal-label.cat-home { background: var(--home); }
.steps { margin: 8px 0; padding-left: 22px; }
.steps li { margin: 6px 0; }
.steps input { margin: 6px 0; font-size: 0.85rem; }
.push-test { margin: 10px 0; }

/* ---------- area + project picker ---------- */
.picker { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.area-pills { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pill { position: relative; }
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill span {
  display: block; text-align: center; padding: 9px 2px; border-radius: 10px; border: 1px solid var(--line);
  font-size: 0.88rem; font-weight: 600; color: var(--text); cursor: pointer; background: var(--card);
}
.pill-work input:checked + span { background: var(--work); border-color: var(--work); color: #fff; }
.pill-home input:checked + span { background: var(--home); border-color: var(--home); color: #fff; }
.pill-family input:checked + span { background: var(--family); border-color: var(--family); color: #fff; }
.pill-personal input:checked + span { background: var(--personal); border-color: var(--personal); color: #fff; }
.chip-area-work { border-color: var(--work); color: var(--work); }
.chip-area-home { border-color: var(--home); color: var(--home); }
.chip-area-family { border-color: var(--family); color: var(--family); }
.chip-area-personal { border-color: var(--personal); color: var(--personal); }
.area-filter.small { margin: 0 0 6px; }
.area-filter.small a { padding: 4px 10px; font-size: 0.8rem; }
