/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --bg:         #0f0f0f;
  --surface:    #1a1a1a;
  --card:       #222222;
  --border:     #2e2e2e;
  --text:       #e8e8e8;
  --muted:      #777;
  --accent:     #6366f1;
  --accent-dim: rgba(99, 102, 241, 0.15);

  --cat-idea:    #6366f1;
  --cat-todo:    #f59e0b;
  --cat-project: #10b981;

  --cat-idea-bg:    rgba(99, 102, 241, 0.12);
  --cat-todo-bg:    rgba(245, 158, 11, 0.12);
  --cat-project-bg: rgba(16, 185, 129, 0.12);

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'SF Mono', 'Fira Code', monospace;
}

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

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

/* ── Screens ────────────────────────────────────────────────────────────── */
.screen {
  display: none;
  min-height: 100dvh;
}
.screen.active { display: flex; }

/* ── PIN Screen ─────────────────────────────────────────────────────────── */
#pin-screen {
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.pin-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 40px 24px;
  width: 100%;
  max-width: 320px;
}

.pin-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.pin-label {
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.pin-boxes {
  display: flex;
  gap: 12px;
}

.pin-digit {
  width: 56px;
  height: 64px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 24px;
  font-family: var(--mono);
  text-align: center;
  caret-color: transparent;
  outline: none;
  transition: border-color 0.15s;
  -webkit-text-security: disc;
}

.pin-digit:focus {
  border-color: var(--accent);
}

.pin-boxes.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

.pin-error {
  min-height: 20px;
  color: #f87171;
  font-size: 13px;
  text-align: center;
}

/* ── App Screen ─────────────────────────────────────────────────────────── */
#app-screen {
  flex-direction: column;
  background: var(--bg);
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  padding-top: max(16px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.btn-icon:hover { color: var(--text); background: var(--border); }

/* Main */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 16px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

/* Capture card */
.capture-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

/* Category pills */
.category-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  padding: 5px 14px;
  border-radius: 99px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}
.pill:hover { border-color: var(--accent); color: var(--accent); }

.pill.active[data-cat="idea"]    { background: var(--cat-idea-bg);    border-color: var(--cat-idea);    color: var(--cat-idea); }
.pill.active[data-cat="todo"]    { background: var(--cat-todo-bg);    border-color: var(--cat-todo);    color: var(--cat-todo); }
.pill.active[data-cat="project"] { background: var(--cat-project-bg); border-color: var(--cat-project); color: var(--cat-project); }

/* Textarea */
.idea-textarea {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  padding: 12px 14px;
  resize: none;
  outline: none;
  min-height: 80px;
  transition: border-color 0.15s;
  field-sizing: content; /* auto-grow where supported */
}
.idea-textarea::placeholder { color: var(--muted); }
.idea-textarea:focus { border-color: var(--accent); }

/* Save button */
.btn-save {
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.btn-save:hover  { opacity: 0.9; }
.btn-save:active { transform: scale(0.98); }
.btn-save:disabled { opacity: 0.4; cursor: not-allowed; }

/* List section */
.ideas-list-section { flex: 1; }

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

.list-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.list-count {
  font-size: 12px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px 8px;
}

.ideas-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Idea item */
.idea-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 6px 12px;
  animation: fadeIn 0.2s ease;
}

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

.idea-content {
  grid-column: 1;
  grid-row: 1;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
}

.idea-meta {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  align-items: center;
  gap: 8px;
}

.idea-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 99px;
}

.idea-badge.idea    { background: var(--cat-idea-bg);    color: var(--cat-idea); }
.idea-badge.todo    { background: var(--cat-todo-bg);    color: var(--cat-todo); }
.idea-badge.project { background: var(--cat-project-bg); color: var(--cat-project); }

.idea-time {
  font-size: 12px;
  color: var(--muted);
}

.btn-delete {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: center;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.btn-delete:hover { color: #f87171; background: rgba(248, 113, 113, 0.1); }

/* Empty state */
.empty-state {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 40px 0;
}

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 500;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
  z-index: 100;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Desktop ────────────────────────────────────────────────────────────── */
@media (min-width: 640px) {
  .pin-digit {
    width: 64px;
    height: 72px;
  }

  .app-main {
    padding: 28px 24px;
  }

  .capture-card {
    padding: 20px;
  }

  .idea-textarea {
    font-size: 15px;
  }
}
