:root {
  --bg: #0d0d12;
  --bg2: #12121a;
  --bg3: #1a1a26;
  --border: #252535;
  --border2: #2e2e45;
  --text: #e8e8f0;
  --text2: #8888a8;
  --text3: #555570;
  --accent: #7c6ff7;
  --accent2: #9d94ff;
  --accent-glow: rgba(124, 111, 247, 0.18);
  --low: #10b981;
  --medium: #f59e0b;
  --high: #ef4444;
  --needs-input: #f97316;
  --radius: 10px;
  --font-display: 'Syne', sans-serif;
  --font-mono: 'DM Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── LOGIN ── */
.login-bg {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100vh;
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(124,111,247,0.15) 0%, transparent 70%),
    var(--bg);
}

.login-card {
  width: 360px;
  padding: 48px 40px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 16px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.5);
  animation: fadeUp 0.35s ease both;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.logo-mark {
  width: 36px; height: 36px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  flex-shrink: 0;
}
.logo-mark.sm { width: 28px; height: 28px; font-size: 14px; border-radius: 6px; }

.logo-text { font-weight: 700; font-size: 20px; letter-spacing: -0.5px; }
.logo-text.sm { font-size: 16px; }

.login-sub {
  color: var(--text2);
  font-size: 13px;
  margin-bottom: 28px;
  font-family: var(--font-mono);
}

/* ── TOPBAR ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.topbar-project-name {
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.back-btn {
  font-size: 13px;
  border-color: transparent;
  flex-shrink: 0;
}

/* ── PAGE CONTENT ── */
.page-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 36px 32px 80px;
}

.page-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 24px;
}

.project-desc {
  color: var(--text2);
  font-family: var(--font-mono);
  font-size: 13px;
  margin-bottom: 32px;
  min-height: 4px;
}

/* ── PROJECT LIST ── */
.project-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.project-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  animation: fadeUp 0.2s ease both;
}
.project-card:hover {
  border-color: var(--border2);
  transform: translateY(-1px);
}
.project-card-name {
  font-weight: 600;
  font-size: 15px;
  flex: 1;
}
.project-card-desc {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.project-card-counts {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text3);
  flex-shrink: 0;
}

/* ── TABS ── */
.tabs {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text2);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 18px 10px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
  letter-spacing: 0.01em;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }

.tab-spacer { flex: 1; }

/* ── DONE TOGGLE ── */
.done-toggle {
  background: none;
  border: none;
  color: var(--text3);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  padding: 10px 4px;
  transition: color 0.15s;
}
.done-toggle:hover { color: var(--text2); }

.empty-hint {
  color: var(--text3);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 8px 0;
}

/* ── GOALS ── */
.goals-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.goal-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  animation: fadeUp 0.2s ease both;
}

.goal-diamond {
  color: var(--accent);
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
}

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

.goal-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}

.goal-desc {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text2);
  white-space: pre-wrap;
}

.goal-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 6px;
  font-family: var(--font-mono);
  transition: color 0.12s, background 0.12s;
}
.icon-btn:hover { color: var(--text); background: var(--bg3); }
.icon-btn.danger:hover { color: var(--high); }

/* ── TASKS ── */
.task-group { margin-bottom: 6px; }

.task-group-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  padding: 6px 0 6px 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.task-group-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: border-color 0.15s;
  animation: fadeUp 0.18s ease both;
}
.task-item:hover { border-color: var(--border2); }

.task-item-title {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}
.task-item-title.done-text {
  color: var(--text3);
}

/* ── FIELDS ── */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.field.row { display: flex; gap: 12px; }
.field-half { flex: 1; }

input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
textarea { resize: vertical; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238888a8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
select option { background: var(--bg3); }

.error-msg { color: var(--high); font-size: 13px; margin-top: 10px; font-family: var(--font-mono); }

/* ── BUTTONS ── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 10px 20px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--accent2); }
.btn-primary:active { transform: scale(0.97); }
.btn-full { width: 100%; }

.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-family: var(--font-display);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}
.btn-ghost:hover { border-color: var(--border2); color: var(--text); background: var(--bg3); }
.btn-ghost.sm { padding: 5px 10px; font-size: 12px; }
.btn-ghost.danger { color: #ef4444; border-color: transparent; }
.btn-ghost.danger:hover { border-color: #ef4444; background: rgba(239,68,68,0.08); }

/* ── BADGES ── */
.priority-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 4px;
  flex-shrink: 0;
}
.priority-badge.low    { background: rgba(16,185,129,0.15);  color: var(--low); }
.priority-badge.medium { background: rgba(245,158,11,0.15);  color: var(--medium); }
.priority-badge.high   { background: rgba(239,68,68,0.15);   color: var(--high); }

.color-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.color-dot.lg { width: 14px; height: 14px; }

.status-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 10px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  color: var(--text2);
  flex-shrink: 0;
}
.status-badge.active   { border-color: #10b981; color: #10b981; background: rgba(16,185,129,0.08); }

/* ── NEEDS-USER-INPUT STATUS ── */
.task-group[data-status="needs-user-input"] .task-group-label {
  color: var(--needs-input);
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeBg 0.2s ease both;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 14px;
  width: 460px;
  max-width: calc(100vw - 32px);
  padding: 28px 32px;
  animation: fadeUp 0.22s ease both;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
.modal.modal-large {
  width: 560px;
  padding: 0;
  display: flex;
  flex-direction: column;
  max-height: 88vh;
}
.modal-large .modal-header {
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-scroll {
  overflow-y: auto;
  padding: 20px 28px 28px;
  flex: 1;
}
.modal-sep {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}
.modal-section { margin-bottom: 4px; }
.modal-section-title {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  margin-bottom: 12px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.modal-header h2 { font-size: 18px; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text3);
  font-size: 16px; cursor: pointer; padding: 4px; line-height: 1;
  transition: color 0.12s;
}
.modal-close:hover { color: var(--text); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.modal-actions-split { justify-content: space-between; }
.modal-actions-right { display: flex; gap: 10px; }

/* ── COMMENTS ── */
.comments-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.comment-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.comment-body {
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 6px;
}
.comment-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.comment-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text3);
}

/* ── ATTACHMENTS ── */
.attachments-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.attachment-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}
.attachment-name {
  flex: 1;
  font-size: 13px;
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attachment-size {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text3);
  flex-shrink: 0;
}

/* ── ADD ROWS ── */
.add-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.add-row textarea {
  flex: 1;
  min-height: 60px;
}
.add-row-file { align-items: center; }
.file-pick {
  display: inline-flex;
  align-items: center;
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 10px;
  font-family: var(--font-display);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.file-pick:hover { border-color: var(--border2); color: var(--text); background: var(--bg3); }
.file-pick-name {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border-width: 0;
}
.empty-hint-sm {
  color: var(--text3);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 0 8px;
}

/* ── COLOR SWATCHES ── */
.color-swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.12s, border-color 0.12s;
}
.swatch:hover { transform: scale(1.15); }
.swatch.selected { border-color: var(--text); transform: scale(1.15); }

/* ── EMPTY STATE ── */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 80px 0;
  gap: 14px; color: var(--text3);
}
.empty-icon { font-size: 40px; opacity: 0.4; }

/* ── ANIMATIONS ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeBg {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes itemFlash {
  0%   { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
  60%  { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
  100% { border-color: var(--border); box-shadow: none; }
}
.item-flash { animation: itemFlash 1.4s ease both; }

/* ── LOGIN: Google button ── */
.gsi-button {
  display: flex;
  justify-content: center;
  min-height: 44px;
}

/* ── API TOKENS ── */
.tokens-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

.token-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
}
.token-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.token-label { color: var(--text); font-size: 14px; }
.token-prefix {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text3);
}
.token-meta {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
}

.new-token-box {
  margin-top: 14px;
  background: var(--bg3);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.new-token-warn {
  color: var(--accent2);
  font-family: var(--font-mono);
  font-size: 12px;
  margin-bottom: 8px;
}
.new-token-row { display: flex; align-items: center; gap: 10px; }
.new-token-value {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  word-break: break-all;
  user-select: all;
}
