/* ─── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0f172a;
  --surface:      #1e293b;
  --surface-2:    #273548;
  --border:       #334155;
  --border-light: #3d4f68;

  --text:         #f1f5f9;
  --text-2:       #94a3b8;
  --text-3:       #64748b;

  --accent:       #38bdf8;
  --accent-dim:   rgba(56, 189, 248, 0.12);

  --red:          #f87171;
  --red-dim:      rgba(248, 113, 113, 0.12);
  --amber:        #fbbf24;
  --amber-dim:    rgba(251, 191, 36, 0.12);
  --green:        #34d399;
  --green-dim:    rgba(52, 211, 153, 0.1);
  --blue:         #60a5fa;
  --blue-dim:     rgba(96, 165, 250, 0.12);
  --purple:       #a78bfa;
  --purple-dim:   rgba(167, 139, 250, 0.1);
  --gray-dim:     rgba(148, 163, 184, 0.08);

  --radius:       8px;
  --radius-lg:    12px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', system-ui, sans-serif;
  --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;

  --transition: 140ms ease;
}

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.auth-locked {
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* ─── Auth gate ────────────────────────────────────────────────────────────── */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at top, rgba(56, 189, 248, 0.16), transparent 35%),
    rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(14px);
}

.auth-card {
  width: min(100%, 420px);
  background: linear-gradient(180deg, rgba(39, 53, 72, 0.96), rgba(30, 41, 59, 0.96));
  border: 1px solid rgba(125, 211, 252, 0.18);
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.45);
  padding: 28px;
}

.auth-eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.auth-title {
  font-size: 1.8rem;
  line-height: 1.1;
  margin-bottom: 10px;
}

.auth-copy {
  color: var(--text-2);
  margin-bottom: 18px;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-label {
  font-size: 0.8rem;
  color: var(--text-2);
}

.auth-input {
  width: 100%;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 1rem;
  letter-spacing: 0.18em;
  padding: 14px 16px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.auth-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.14);
}

.auth-submit {
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #7dd3fc, #38bdf8);
  color: #082f49;
  font-family: var(--font);
  font-weight: 800;
  font-size: 0.95rem;
  padding: 13px 18px;
  cursor: pointer;
  transition: transform var(--transition), opacity var(--transition);
}

.auth-submit:hover {
  transform: translateY(-1px);
}

.auth-submit:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.auth-error {
  margin-top: 14px;
  border: 1px solid rgba(248, 113, 113, 0.28);
  border-radius: 12px;
  background: rgba(127, 29, 29, 0.24);
  color: #fca5a5;
  padding: 10px 12px;
  font-size: 0.9rem;
}

/* ─── Layout ────────────────────────────────────────────────────────────────── */
.app {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px 80px;
}

/* ─── Header ────────────────────────────────────────────────────────────────── */
.header {
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 22px;
  color: var(--accent);
  line-height: 1;
}

.logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.header-meta {
  font-size: 0.8rem;
  color: var(--text-3);
}

/* ─── Command section ───────────────────────────────────────────────────────── */
.command-section {
  margin-bottom: 36px;
}

.command-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.command-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
}

.command-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.command-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  line-height: 1.6;
  padding: 10px 14px;
  resize: vertical;
  min-height: 56px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.command-input::placeholder { color: var(--text-3); }

.command-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.submit-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #0f172a;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 700;
  padding: 10px 18px;
  cursor: pointer;
  white-space: nowrap;
  height: 44px;
  transition: background var(--transition), transform var(--transition), opacity var(--transition);
  flex-shrink: 0;
}

.submit-btn:hover { background: #7dd3fc; }
.submit-btn:active { transform: scale(0.97); }
.submit-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.mic-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 1.2rem;
  width: 44px;
  height: 44px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.mic-btn:hover { background: var(--surface-3); border-color: var(--accent); }
.mic-btn:active { transform: scale(0.97); }
.mic-btn.listening {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
  animation: mic-pulse 1s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  50%       { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}

.submit-icon {
  font-size: 1.1rem;
  line-height: 1;
}

/* ─── Feedback bar ──────────────────────────────────────────────────────────── */
.feedback {
  margin-top: 12px;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.88rem;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  animation: slidein 0.2s ease;
}

.feedback.hidden { display: none; }

.feedback.success {
  background: var(--green-dim);
  border: 1px solid rgba(52, 211, 153, 0.25);
  color: var(--green);
}

.feedback.error {
  background: var(--red-dim);
  border: 1px solid rgba(248, 113, 113, 0.25);
  color: var(--red);
}

.feedback.info {
  background: var(--accent-dim);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: var(--accent);
}

@keyframes slidein {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Board ──────────────────────────────────────────────────────────────────── */
.board {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ─── Section ───────────────────────────────────────────────────────────────── */
.section {
  animation: fadein 0.2s ease;
}

@keyframes fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.section-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.section-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

.section-count {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-3);
  background: var(--surface-2);
  border-radius: 20px;
  padding: 1px 8px;
  margin-left: auto;
}

/* Section colour themes */
.section--overdue   .section-dot { background: var(--red); }
.section--today     .section-dot { background: var(--amber); }
.section--this-week .section-dot { background: var(--accent); }
.section--upcoming  .section-dot { background: var(--blue); }
.section--no-date   .section-dot { background: var(--text-3); }
.section--completed .section-dot { background: var(--green); }

.section-divider {
  height: 1px;
  background: var(--border);
  margin-bottom: 10px;
  opacity: 0.5;
}

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

.item-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
}

.item-card:hover { background: var(--surface-2); }

/* Left border accent per section */
.section--overdue   .item-card { border-left-color: var(--red); }
.section--today     .item-card { border-left-color: var(--amber); }
.section--this-week .item-card { border-left-color: var(--accent); }
.section--upcoming  .item-card { border-left-color: var(--blue); }
.section--no-date   .item-card { border-left-color: var(--border); }
.section--completed .item-card { border-left-color: var(--green); }

/* Completed style */
.item-card.status-completed {
  opacity: 0.55;
}

.item-card.status-completed .item-content {
  text-decoration: line-through;
  color: var(--text-2);
}

/* ─── Item body ──────────────────────────────────────────────────────────────── */
.item-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.item-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 20px;
  flex-shrink: 0;
}

.badge-todo {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.2);
}

.badge-note {
  background: var(--purple-dim);
  color: var(--purple);
  border: 1px solid rgba(167, 139, 250, 0.2);
}

.badge-overdue {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.2);
}

.item-date {
  font-size: 0.75rem;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.item-date.overdue-date { color: var(--red); }
.item-date.today-date   { color: var(--amber); }

.item-content {
  font-size: 0.93rem;
  color: var(--text);
  line-height: 1.5;
  word-break: break-word;
}

/* ─── Item actions ─────────────────────────────────────────────────────────── */
.item-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition);
}

.item-card:hover .item-actions,
.item-card:focus-within .item-actions {
  opacity: 1;
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background var(--transition), color var(--transition);
  color: var(--text-3);
}

.action-btn:hover { color: var(--text); }

.btn-complete:hover { background: var(--green-dim); color: var(--green); }
.btn-reopen:hover   { background: var(--blue-dim);  color: var(--blue); }
.btn-delete:hover   { background: var(--red-dim);   color: var(--red); }

/* ─── Empty state ────────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 64px 24px;
  color: var(--text-3);
  text-align: center;
}

.empty-icon {
  font-size: 2.5rem;
  opacity: 0.4;
}

.empty-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-2);
}

.empty-hint {
  font-size: 0.85rem;
  color: var(--text-3);
  max-width: 360px;
}

/* ─── Loading state ─────────────────────────────────────────────────────────── */
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px;
  color: var(--text-3);
  font-size: 0.9rem;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Highlight (for query results) ─────────────────────────────────────────── */
.item-card.highlighted {
  background: var(--surface-2);
  border-color: var(--accent);
}

.section.dimmed { opacity: 0.35; }

/* ─── Scrollbar ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ─── Two-column board layout ───────────────────────────────────────────────── */
.board-layout {
  display: grid;
  grid-template-columns: 1fr 270px;
  gap: 24px;
  align-items: start;
}

.main-panel {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ─── Completed panel (right column) ────────────────────────────────────────── */
.completed-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  position: sticky;
  top: 16px;
}

.completed-panel .section-header { margin-bottom: 10px; }
.completed-panel .section-divider { margin-bottom: 10px; }

.completed-panel-empty {
  color: var(--text-3);
  font-size: 0.82rem;
  text-align: center;
  padding: 20px 0;
}

/* Tighten cards inside the narrow panel */
.completed-panel .item-card {
  border-left-color: var(--green);
  padding: 9px 12px;
}

/* ─── Mobile tab bar ────────────────────────────────────────────────────────── */
.tab-bar {
  display: none;
}

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .command-row { flex-wrap: wrap; }
  .command-input { width: 100%; }
  .mic-btn { flex: 0 0 44px; }
  .submit-btn { flex: 1; justify-content: center; }
  .submit-label { display: inline; }
  .header-meta { display: none; }
  .item-actions { opacity: 1; }

  /* Stack layout to single column */
  .board-layout {
    grid-template-columns: 1fr;
  }

  /* Show tab bar */
  .tab-bar {
    display: flex;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    gap: 4px;
    margin-bottom: 16px;
  }

  .tab {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    background: transparent;
    color: var(--text-2);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
  }

  .tab.tab--active {
    background: var(--surface-2);
    color: var(--text);
  }

  .tab:hover:not(.tab--active) { color: var(--text); }

  /* Tab panel visibility */
  .board.show-completed .main-panel     { display: none; }
  .board:not(.show-completed) .completed-panel { display: none; }

  /* Completed panel: remove sticky/border when shown as tab */
  .completed-panel {
    position: static;
    border: none;
    background: transparent;
    padding: 0;
  }
}
