:root {
  --bg:       #f7f7f6;
  --surface:  #ffffff;
  --surface2: #f2f2f0;
  --border:   #e8e8e5;
  --border2:  #efefed;
  --text:     #0d0d0d;
  --text2:    #5c5c5a;
  --text3:    #9b9b98;
  --text4:    #c8c8c4;
  --green:    #16a34a;
  --green-bg: #f0fdf4;
  --red:      #dc2626;
  --red-bg:   #fef2f2;
  --blue:     #2563eb;
  --blue-bg:  #eff6ff;
  --amber:    #d97706;
  --amber-bg: #fffbeb;
  --purple:   #7c3aed;
  --purple-bg:#f5f3ff;
  --font:     'Geist', system-ui, sans-serif;
  --mono:     'Geist Mono', monospace;
  --ease:     cubic-bezier(0.4,0,0.2,1);
  --radius:   8px;
}

.dark {
  --bg:       #111110;
  --surface:  #1c1c1a;
  --surface2: #242422;
  --border:   #2e2e2b;
  --border2:  #272724;
  --text:     #f0efe9;
  --text2:    #8c8c87;
  --text3:    #555550;
  --text4:    #333330;
  --green-bg: rgba(22,163,74,.1);
  --red-bg:   rgba(220,38,38,.1);
  --blue-bg:  rgba(37,99,235,.1);
  --amber-bg: rgba(217,119,6,.1);
  --purple-bg:rgba(124,58,237,.1);
}

*,*::before,*::after { margin:0; padding:0; box-sizing:border-box; }

html {
  background: var(--bg);
  height: 100%;
  overscroll-behavior: none;
}

body {
  height: 100%;
  min-height: 100dvh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font-family: var(--font); cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: var(--font); }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.hidden { display: none !important; }

/* ── AUTH ── */

#auth-screen {
  min-height: 100dvh;
  width: 100%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-wrap {
  width: 100%;
  max-width: 340px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
  color: var(--text);
}

.auth-logo h1 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -.02em;
}

.auth-logo p {
  font-size: .75rem;
  color: var(--text3);
  margin-top: 3px;
}

/* ── FORM ── */

.field { margin-bottom: 10px; }

.field-label {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 5px;
  display: block;
}

.field-optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text4);
}

.field-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--text);
  font-size: .82rem;
  outline: none;
  transition: border-color .12s;
}

.field-input:focus { border-color: var(--text); }
.field-input::placeholder { color: var(--text4); }

select.field-input { cursor: pointer; }

.field-textarea {
  resize: none;
  line-height: 1.6;
  overflow-y: auto;
}

/* ── BUTTONS ── */

.btn-cta {
  width: 100%;
  padding: 9px;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .12s;
  margin-top: 4px;
}
.btn-cta:hover { opacity: .88; }
.btn-cta:disabled { opacity: .4; cursor: not-allowed; }

.btn-ghost {
  width: 100%;
  padding: 8px;
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  margin-top: 6px;
  transition: background .12s;
}
.btn-ghost:hover { background: var(--surface2); }

.btn-sm {
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: .75rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  transition: all .12s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-sm:hover { background: var(--surface2); color: var(--text); }

.btn-danger {
  padding: 8px 16px;
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .12s;
}
.btn-danger:hover { opacity: .8; }

.btn-muted {
  padding: 6px 10px;
  background: transparent;
  color: var(--text3);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .12s;
}
.btn-muted:hover { background: var(--surface2); color: var(--text2); }

/* ── AUTH MESSAGE ── */

#auth-message {
  margin-top: 10px;
  font-size: .75rem;
  min-height: 1rem;
  text-align: center;
}
#auth-message.error { padding: 6px 10px; background: var(--red-bg); color: var(--red); border-radius: 6px; }
#auth-message.success { padding: 6px 10px; background: var(--green-bg); color: var(--green); border-radius: 6px; }
#auth-message.info { color: var(--text3); }

/* ── APP LAYOUT ── */

#app-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ── TOP BAR ── */

#topbar {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  gap: 8px;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.topbar-logo-text {
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--text);
}

.demo-badge {
  font-size: .65rem;
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text3);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  line-height: 1.6;
}

/* ── About panel ── */

.about-panel {
  position: relative;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 20px 24px 20px;
  flex-shrink: 0;
}

.about-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  font-size: .85rem;
  color: var(--text3);
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
}
.about-close:hover { color: var(--text); }

.about-content { max-width: 560px; }

.about-title {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 10px;
}

.about-content p {
  font-size: .78rem;
  line-height: 1.7;
  color: var(--text2);
  margin: 0 0 8px;
}

.about-links {
  display: flex;
  gap: 12px;
  margin: 12px 0 10px;
}

.about-link {
  font-size: .75rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
}
.about-link:hover { border-color: var(--text); }

.about-note {
  font-size: .70rem !important;
  color: var(--text4) !important;
  margin: 0 !important;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: .75rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  transition: all .12s;
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-family: var(--font);
}
.btn-sm:hover { background: var(--surface2); color: var(--text); }
.btn-sm.active { color: var(--text); background: var(--surface2); }

.nav-badge {
  height: 18px;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--text);
  color: var(--bg);
  font-size: .65rem;
  font-weight: 600;
  font-family: var(--mono);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── MAIN CONTENT ── */

#main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* ── VIEW HEADER ── */

.view-header {
  padding: 20px 24px 0;
  flex-shrink: 0;
}

.view-title {
  font-size: .95rem;
  font-weight: 600;
  letter-spacing: -.02em;
}

.view-desc {
  font-size: .75rem;
  color: var(--text3);
  margin-top: 2px;
}

/* ── DASHBOARD ── */

.dashboard-body {
  flex: 1;
  overflow: hidden;
  padding: 4px 20px 20px;
  display: flex;
  flex-direction: column;
}

.dashboard-columns {
  display: flex;
  gap: 14px;
  height: 100%;
  min-height: 0;
}

.dashboard-col-today {
  flex: 3;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.dashboard-col-pool {
  flex: 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.dashboard-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.dashboard-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.dashboard-section-title {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text2);
}

.dashboard-section-date {
  font-size: .68rem;
  color: var(--text3);
  font-family: var(--mono);
  margin-left: auto;
}

.finish-modal { max-width: 360px; width: 100%; }

.finish-summary {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.finish-summary-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .85rem;
}

.finish-summary-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.finish-summary-label { color: var(--text2); }
.finish-summary-count { font-weight: 600; color: var(--text); }

.finish-incomplete-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  background: var(--amber-bg);
  border: 1px solid var(--amber);
  border-radius: 6px;
  margin-top: 4px;
}

.finish-incomplete-item {
  font-size: .75rem;
  color: var(--text2);
  display: flex;
  gap: 6px;
  align-items: flex-start;
}

.finish-incomplete-item::before {
  content: '→';
  color: var(--amber);
  flex-shrink: 0;
}

.btn-finish-today {
  height: 22px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: .65rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text3);
  transition: all .1s;
  white-space: nowrap;
}
.btn-finish-today:hover { color: var(--green); border-color: var(--green); background: var(--green-bg); }

.dashboard-section-count {
  font-size: .68rem;
  font-weight: 600;
  font-family: var(--mono);
  background: var(--green-bg);
  color: var(--green);
  border-radius: 10px;
  padding: 1px 7px;
}

.dashboard-section-count.hidden { display: none; }

/* ── TODAY ── */

.today-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.today-card {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: background .1s;
}

.today-card:last-child { border-bottom: none; }
.today-card:hover { background: var(--hover, rgba(0,0,0,.03)); }
.today-card.is-completed { opacity: .5; }

.today-card-top {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.today-check {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .12s;
  background: transparent;
}

.today-check:hover { border-color: var(--green); }
.today-card.is-completed .today-check {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-size: .6rem;
}

.today-card-content {
  font-size: .82rem;
  line-height: 1.55;
  color: var(--text);
  word-break: break-word;
  flex: 1;
}

.today-card.is-completed .today-card-content {
  text-decoration: line-through;
  color: var(--text3);
}

.today-card-actions {
  display: flex;
  gap: 5px;
  padding-left: 25px;
}

.btn-today-action {
  height: 22px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: .65rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text3);
  transition: all .1s;
}

.btn-today-action:hover { color: var(--text); border-color: var(--text4); }
.btn-today-action.danger:hover { color: var(--red); border-color: var(--red); }

.today-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 32px 16px;
  text-align: center;
  color: var(--text3);
  font-size: .8rem;
  gap: 6px;
}

.today-empty-icon { font-size: 1.4rem; opacity: .4; }

/* ── POOL GROUPS ── */

.pool-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px 6px;
  flex-shrink: 0;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.pool-group-title {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text3);
}

.pool-group-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
  flex-shrink: 0;
}

#recurring-list {
  flex: 0 0 auto;
  overflow-y: visible;
}

/* ── POOL ADD ROW ── */

.pool-add-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.pool-task-input {
  flex: 1;
  height: 26px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0 8px;
  font-size: .75rem;
  font-family: var(--font);
  color: var(--text);
  outline: none;
  transition: border-color .12s;
}

.pool-task-input:focus { border-color: var(--text3); }
.pool-task-input::placeholder { color: var(--text4); }

.pool-recurring-toggle {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  font-size: .9rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .12s;
  flex-shrink: 0;
}
.pool-recurring-toggle:hover { color: var(--text2); border-color: var(--text3); }
.pool-recurring-toggle.active {
  background: var(--amber-bg);
  border-color: var(--amber);
  color: var(--amber);
}

.pool-task-add-btn {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  font-size: 1rem;
  font-weight: 400;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .12s;
  flex-shrink: 0;
}
.pool-task-add-btn:hover { background: var(--blue-bg); color: var(--blue); border-color: var(--blue); }

/* ── PIPELINE ── */

.pipeline-grid {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
}

.pipeline-card {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 7px 11px;
  transition: background .1s;
}

.pipeline-card:last-child { border-bottom: none; }
.pipeline-card:hover { background: var(--hover, rgba(0,0,0,.03)); }
.pipeline-card.is-in-progress { opacity: .45; }
.pipeline-card.is-in-progress:hover { opacity: .7; }
.is-recurring-done { text-decoration: line-through; }

.pool-status-badge {
  font-size: .62rem;
  font-weight: 500;
  color: var(--amber);
  background: var(--amber-bg);
  border-radius: 10px;
  padding: 1px 6px;
  white-space: nowrap;
}

.pool-in-today-indicator {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--text4);
  line-height: 1;
}

.pipeline-card-content {
  font-size: .75rem;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 2px;
}

.pipeline-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pipeline-card-info {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pipeline-card-time {
  font-size: .68rem;
  color: var(--text3);
  font-family: var(--mono);
}

.pipeline-label {
  display: inline-flex;
  align-items: center;
  padding: 0px 5px;
  border-radius: 8px;
  font-size: .58rem;
  font-weight: 600;
  color: var(--lc, var(--text3));
  border: 1px solid var(--lc, var(--border));
  white-space: nowrap;
  opacity: .85;
}

.pipeline-card-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.btn-start-build {
  height: 26px;
  padding: 0 10px;
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .12s;
  white-space: nowrap;
}
.btn-start-build:hover { opacity: .8; }

.btn-add-today {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  font-size: 1rem;
  line-height: 1;
  color: var(--text3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .12s;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
}
.btn-add-today:hover { background: var(--blue-bg); color: var(--blue); border-color: var(--blue); }

.btn-dismiss {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  font-size: .72rem;
  color: var(--text4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .12s;
}
.btn-dismiss:hover { background: var(--red-bg); color: var(--red); }

/* ── HABIT TRACKER ── */

.habit-tracker {
  flex-shrink: 0;
  padding: 0 20px 20px;
}

.habit-grid {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  flex-wrap: wrap;
  width: fit-content;
  margin: 0 auto;
}

.habit-day {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: var(--surface2);
  border: 1px solid var(--border);
  cursor: default;
  transition: transform .1s;
  position: relative;
  flex-shrink: 0;
}

.habit-day:hover { transform: scale(1.2); z-index: 1; }
.habit-day[data-count="0"] { background: var(--surface2); }
.habit-day[data-count="1"] { background: #bbf7d0; border-color: #86efac; }
.habit-day[data-count="2"] { background: #86efac; border-color: #4ade80; }
.habit-day[data-count="3"] { background: #4ade80; border-color: #22c55e; }
.habit-day[data-count="4"] { background: #22c55e; border-color: #16a34a; }
.habit-day[data-count="5+"] { background: #16a34a; border-color: #15803d; }

.dark .habit-day[data-count="1"] { background: rgba(22,163,74,.2); border-color: rgba(22,163,74,.3); }
.dark .habit-day[data-count="2"] { background: rgba(22,163,74,.35); border-color: rgba(22,163,74,.5); }
.dark .habit-day[data-count="3"] { background: rgba(22,163,74,.5); border-color: rgba(22,163,74,.65); }
.dark .habit-day[data-count="4"] { background: rgba(22,163,74,.7); border-color: rgba(22,163,74,.85); }
.dark .habit-day[data-count="5+"] { background: #16a34a; border-color: #15803d; }

.habit-tooltip {
  position: absolute;
  top: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-size: .62rem;
  font-family: var(--mono);
  padding: 3px 6px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .1s;
  z-index: 10;
}

.habit-day:hover .habit-tooltip { opacity: 1; }

/* ── LOG VIEW ── */

.log-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.log-day {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.log-day-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.log-day-date {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text);
}

.log-day-count {
  font-size: .62rem;
  color: var(--text3);
  font-family: var(--mono);
}

.log-task-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 0;
}

.log-task-check {
  font-size: .64rem;
  color: var(--green);
  margin-top: 1px;
  flex-shrink: 0;
}

.log-task-title {
  font-size: .72rem;
  color: var(--text2);
  line-height: 1.4;
}

.log-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--text3);
  font-size: .8rem;
  gap: 6px;
  padding: 40px;
}

/* ── BUILDS VIEW ── */

.builds-layout {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.builds-left {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.builds-left-header {
  padding: 20px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

#builds-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.build-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .1s;
  border: 1px solid transparent;
}

.build-row:hover { background: var(--surface2); }

.build-row.selected {
  background: var(--surface2);
  border-color: var(--border);
}

.build-row-body { flex: 1; min-width: 0; }

.build-row-title {
  font-size: .82rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.build-row-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.build-row-progress {
  font-size: .68rem;
  color: var(--text3);
  font-family: var(--mono);
}

/* ── STATUS BADGE ── */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: .65rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.status-planning  { color: var(--amber);  background: var(--amber-bg); }
.status-active    { color: var(--green);  background: var(--green-bg); }
.status-paused    { color: var(--text3);  background: var(--surface2); }
.status-done      { color: var(--blue);   background: var(--blue-bg); }
.status-dropped   { color: var(--red);    background: var(--red-bg); }

/* ── BUILD DETAIL ── */

.build-detail {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.detail-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text4);
}

.detail-placeholder-icon {
  font-size: 2rem;
  opacity: .3;
}

.detail-placeholder p {
  font-size: .78rem;
}

.detail-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}

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

.detail-title-block { flex: 1; min-width: 0; }

.detail-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.4;
  word-break: break-word;
}

.detail-from-squiggles {
  font-size: .68rem;
  color: var(--text3);
  margin-top: 3px;
  font-family: var(--mono);
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.detail-desc {
  font-size: .82rem;
  color: var(--text2);
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.detail-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-status-label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .04em;
  flex-shrink: 0;
}

.detail-status-select {
  height: 26px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text2);
  font-size: .75rem;
  cursor: pointer;
  outline: none;
  transition: border-color .12s;
}
.detail-status-select:focus { border-color: var(--text); }

/* ── TASKS ── */

.tasks-section { display: flex; flex-direction: column; gap: 0; }

.tasks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.tasks-title {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.tasks-count {
  font-size: .68rem;
  font-family: var(--mono);
  color: var(--text4);
}

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

.task-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border2);
  transition: background .1s;
}
.task-row:last-child { border-bottom: none; }
.task-row:hover { background: var(--surface2); }

.task-checkbox {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .12s;
  background: transparent;
  font-size: .65rem;
  color: transparent;
}
.task-checkbox:hover { border-color: var(--text3); }
.task-checkbox.checked {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.task-title {
  flex: 1;
  font-size: .82rem;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
}
.task-title.done {
  color: var(--text3);
  text-decoration: line-through;
}

.task-del {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  font-size: .65rem;
  color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .1s;
}
.task-row:hover .task-del { color: var(--text4); }
.task-del:hover { background: var(--red-bg); color: var(--red) !important; }

.task-add-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
}

.task-add-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: .82rem;
  outline: none;
  padding: 0;
}
.task-add-input::placeholder { color: var(--text4); }

.task-add-btn {
  height: 22px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 600;
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all .12s;
  flex-shrink: 0;
}
.task-add-btn:hover { background: var(--text); color: var(--bg); border-color: var(--text); }

.tasks-empty {
  padding: 20px;
  text-align: center;
  font-size: .78rem;
  color: var(--text3);
}

/* ── DETAIL DANGER ZONE ── */

.detail-danger {
  display: flex;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* ── ARCHIVE ── */

.archive-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.archive-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .12s;
}

.archive-row-body { flex: 1; min-width: 0; }

.archive-row-title {
  font-size: .82rem;
  font-weight: 500;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.archive-row-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

.archive-row-date {
  font-size: .68rem;
  color: var(--text3);
  font-family: var(--mono);
}

/* ── MODAL ── */

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
  overflow: hidden;
}

.confirm-modal { max-width: 300px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
  font-weight: 600;
}

.modal-close {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  font-size: .75rem;
  color: var(--text3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .1s;
}
.modal-close:hover { background: var(--surface2); color: var(--text); }

.modal-body { padding: 16px; }

.confirm-actions {
  display: flex;
  gap: 8px;
  margin-top: 0;
}
.confirm-actions .btn-ghost { margin-top: 0; }
.confirm-actions .btn-danger { flex: 1; }
.confirm-actions .btn-ghost { flex: 1; }

/* ── TOAST ── */

#toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--text);
  color: var(--bg);
  padding: 7px 14px;
  border-radius: 6px;
  font-size: .75rem;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transition: all .22s var(--ease);
  pointer-events: none;
  white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── EMPTY STATE ── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 60px 24px;
  color: var(--text3);
  text-align: center;
}

.empty-icon { font-size: 1.8rem; opacity: .25; margin-bottom: 4px; }

.empty-state p {
  font-size: .78rem;
  line-height: 1.7;
}

.empty-state .empty-hint {
  font-size: .72rem;
  color: var(--text4);
}

/* ── MOBILE TOP BAR ── */

.mobile-topbar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.mobile-topbar-name {
  font-size: .88rem;
  font-weight: 600;
  letter-spacing: -.02em;
  flex: 1;
}

.mobile-topbar-signout {
  font-size: .72rem;
  font-weight: 500;
  color: var(--text2);
  padding: 0 10px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  transition: background .1s, color .1s;
}
.mobile-topbar-signout:active { background: var(--border); }

/* ── MOBILE TAB BAR ── */

.mobile-tabs { display: none; }

/* ── MORE MENU ── */

.more-menu {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.more-menu-item {
  padding: 12px 16px;
  text-align: left;
  font-size: .88rem;
  color: var(--text);
  border-radius: 8px;
  transition: background .1s;
}
.more-menu-item:hover { background: var(--surface2); }

.more-menu-cancel {
  padding: 12px 16px;
  text-align: center;
  font-size: .82rem;
  color: var(--text3);
  border-radius: 8px;
  margin-top: 4px;
  transition: background .1s;
}
.more-menu-cancel:hover { background: var(--surface2); }

/* ── MOBILE ── */

@media (max-width: 640px) {
  input, select, textarea { font-size: 16px !important; }
  .pool-task-input { font-size: 12px !important; }

  #auth-screen { align-items: flex-start; padding-top: 15dvh; }

  /* Lock the body — inner container scrolls so iOS toolbar never triggers */
  body { overflow: hidden; position: fixed; width: 100%; height: 100%; }

  /* Full-height flex column: topbar, scrolling content, tab bar */
  #app-screen {
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
    width: 100%;
  }

  #topbar { display: none; }

  /* Top bar: normal flex child, never moves */
  .mobile-topbar {
    display: flex;
    position: static;
    flex-shrink: 0;
    transform: none;
  }

  /* Scrolling content fills remaining space */
  #main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-top: 0;
    padding-bottom: 0;
    scrollbar-width: none;
  }
  #main-content::-webkit-scrollbar { width: 0; height: 0; }

  /* Bottom tab bar: normal flex child, never moves */
  .mobile-tabs {
    display: flex;
    position: static;
    flex-shrink: 0;
    transform: none;
    border-top: 1px solid var(--border);
    background: var(--surface);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .tab-btn {
    flex: 1;
    height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: .6rem;
    font-weight: 500;
    color: var(--text3);
    transition: color .12s;
  }
  .tab-btn.active { color: var(--text); }
  .tab-icon { font-size: .95rem; }

  /* Views scroll with the page — no overflow clipping */
  .view { overflow: visible; min-height: unset; }

  /* hide the view title — topbar already shows app name */
  .view-header { display: none; }

  .dashboard-body {
    padding: 8px 12px 24px;
    overflow: visible;
    flex: unset;
  }

  .habit-tracker { padding: 12px 12px 8px; }

  .dashboard-columns {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  .dashboard-col-today,
  .dashboard-col-pool { flex: 0 0 auto; }

  .dashboard-section { overflow: visible; min-height: unset; }
  .today-list { max-height: none; overflow-y: visible; }
  .pipeline-grid { max-height: none; overflow-y: visible; }

  .builds-layout { flex-direction: column; }
  .builds-left { width: 100%; border-right: none; border-bottom: 1px solid var(--border); max-height: 240px; }
  .build-detail { min-height: 200px; }
  .detail-body { padding: 16px; }

  .archive-body { padding: 12px 16px 16px; }

  #toast { bottom: calc(52px + env(safe-area-inset-bottom, 0px) + 12px); }
}

@media (min-width: 641px) {
  .mobile-tabs { display: none; }
  .mobile-topbar { display: none; }
}
