/* ═══════════════════════════════════════════
   GTD Flow — Dark Industrial PWA
   ═══════════════════════════════════════════ */

:root {
  --bg: #0a0a0f;
  --bg-card: #131318;
  --bg-elevated: #1a1a22;
  --bg-hover: #22222e;
  --border: #2a2a35;
  --border-light: #1e1e28;
  --text: #e8e6f0;
  --text-dim: #8a8899;
  --text-muted: #5a5868;
  --accent: #6ee7b7;
  --accent-dim: #2d6b55;
  --warn: #fbbf24;
  --danger: #f87171;
  --blue: #60a5fa;
  --purple: #a78bfa;
  --radius: 12px;
  --radius-sm: 8px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: 'DM Sans', -apple-system, sans-serif;
  --mono: 'Space Mono', monospace;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  overflow: hidden;
}

/* ── Offline banner ── */
.offline-banner {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 1000;
  background: var(--warn);
  color: #000;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  padding: 4px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: transform 0.3s;
}
.offline-banner.hidden { transform: translateY(-100%); }

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) 20px 10px;
  background: var(--bg);
  position: relative;
  z-index: 10;
}
.header-left { display: flex; align-items: baseline; gap: 4px; }
.header-logo {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 20px;
  color: var(--accent);
  letter-spacing: 2px;
}
.header-dot { color: var(--text-muted); font-size: 18px; }
.header-sub {
  font-size: 16px;
  font-weight: 300;
  color: var(--text-dim);
  letter-spacing: 1px;
}
.header-right { display: flex; gap: 6px; }
.icon-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  cursor: pointer;
  transition: all 0.2s;
}
.icon-btn:active { background: var(--bg-elevated); color: var(--accent); }
.icon-btn.syncing svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { position: relative; }
.sync-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--warn);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  display: grid; place-items: center;
  padding: 0 4px;
  line-height: 1;
}
.sync-badge.hidden { display: none; }

/* Pending sync indicator */
.item-tag.pending-sync {
  color: var(--warn);
  border: 1px solid rgba(251,191,36,0.3);
  background: rgba(251,191,36,0.1);
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.item-card.pending { border-left: 3px solid var(--warn); }

/* ── Stats bar ── */
.stats-bar {
  display: flex;
  gap: 2px;
  padding: 8px 16px 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.stats-bar::-webkit-scrollbar { display: none; }
.stat {
  flex: 1;
  min-width: 60px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
  transition: border-color 0.2s;
}
.stat-num {
  display: block;
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
.stat-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-top: 2px;
}
.stat[data-key="inbox"] .stat-num { color: var(--warn); }
.stat[data-key="done"] .stat-num { color: var(--accent); }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 20px;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.25s;
  -webkit-tap-highlight-color: transparent;
}
.tab.active {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text);
}
.tab.active svg { stroke: var(--accent); }
.tab span { pointer-events: none; }

/* ── Content ── */
.content {
  flex: 1;
  overflow: hidden;
  position: relative;
  height: calc(100vh - 200px - var(--safe-top));
}
.panel {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 0 16px calc(var(--safe-bottom) + 20px);
  opacity: 0;
  transform: translateX(20px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  -webkit-overflow-scrolling: touch;
}
.panel.active {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 8px 0;
  z-index: 5;
}
.panel-header h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
}
.add-btn {
  background: var(--accent-dim);
  color: var(--accent);
  border: none;
  border-radius: 20px;
  padding: 6px 14px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.add-btn:active { background: var(--accent); color: var(--bg); }

/* ── Item list ── */
.item-list { display: flex; flex-direction: column; gap: 6px; }

.item-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: all 0.2s;
  animation: fadeIn 0.3s ease-out;
}
.item-card:active { background: var(--bg-hover); }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.item-check {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  flex-shrink: 0;
  margin-top: 1px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.2s;
}
.item-check:active {
  border-color: var(--accent);
  background: var(--accent);
}
.item-check.checked {
  border-color: var(--accent);
  background: var(--accent);
}
.item-check.checked::after {
  content: '✓';
  color: var(--bg);
  font-size: 14px;
  font-weight: 700;
}

.item-body { flex: 1; min-width: 0; }
.item-text {
  font-size: 15px;
  font-weight: 400;
  color: var(--text);
  word-break: break-word;
}
.item-card.done .item-text {
  text-decoration: line-through;
  color: var(--text-muted);
}
.item-meta {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.item-tag {
  font-size: 11px;
  font-family: var(--mono);
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--text-dim);
  letter-spacing: 0.5px;
}
.item-tag.context { color: var(--blue); border: 1px solid rgba(96,165,250,0.2); background: rgba(96,165,250,0.08); }
.item-tag.waiting-for { color: var(--warn); border: 1px solid rgba(251,191,36,0.2); background: rgba(251,191,36,0.08); }
.item-tag.project { color: var(--purple); border: 1px solid rgba(167,139,250,0.2); background: rgba(167,139,250,0.08); }
.item-tag.category { color: var(--accent); border: 1px solid rgba(110,231,183,0.2); background: rgba(110,231,183,0.08); }
.item-tag.source { color: var(--text-muted); }

.item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.item-action {
  width: 30px; height: 30px;
  background: none;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 14px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.15s;
}
.item-action:active { background: var(--bg-elevated); }
.item-action.danger:active { background: rgba(248,113,113,0.15); color: var(--danger); }

/* ── Inbox-specific: process button ── */
.item-process {
  background: var(--accent-dim);
  color: var(--accent);
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.item-process:active { background: var(--accent); color: var(--bg); }

/* ── Empty state ── */
.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}
.empty-state.visible { display: flex; }
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.6; }
.empty-state p { color: var(--text-muted); font-size: 14px; }

/* ── Context filter pills ── */
.context-filter, .category-pills {
  display: flex;
  gap: 6px;
  padding-bottom: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.context-filter::-webkit-scrollbar, .category-pills::-webkit-scrollbar { display: none; }
.pill {
  padding: 5px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
}
.pill.active { background: var(--bg-elevated); color: var(--text); border-color: var(--accent-dim); }

/* ── Search bar ── */
.search-bar {
  margin-bottom: 10px;
}
.search-bar input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.search-bar input:focus { border-color: var(--accent-dim); }
.search-bar input::placeholder { color: var(--text-muted); }

/* ── Note card extras ── */
.note-summary {
  font-size: 13px;
  color: var(--accent);
  font-style: italic;
  margin-top: 4px;
  padding-left: 10px;
  border-left: 2px solid var(--accent-dim);
}
.note-content-preview {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ── Project card ── */
.project-outcome {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px;
  padding-bottom: calc(var(--safe-bottom) + 20px);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
}

.modal-body label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 6px;
  margin-top: 14px;
}
.modal-body label:first-child { margin-top: 0; }

.modal-body input,
.modal-body textarea,
.modal-body select {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}
.modal-body input:focus,
.modal-body textarea:focus,
.modal-body select:focus {
  border-color: var(--accent-dim);
}
.modal-body textarea {
  min-height: 80px;
  resize: vertical;
}
.modal-body select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8899' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.modal-submit {
  width: 100%;
  margin-top: 20px;
  padding: 14px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.modal-submit:active { opacity: 0.8; }
.modal-submit:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Settings ── */
.setting-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.setting-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
}
.setting-input:focus { border-color: var(--accent-dim); }
.setting-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.save-btn {
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 20px);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  z-index: 200;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--accent-dim); }
.toast.error { border-color: rgba(248,113,113,0.3); }

/* ── Inline select row ── */
.inline-row {
  display: flex;
  gap: 8px;
}
.inline-row > * { flex: 1; }
