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

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface2: #1e1e1e;
  --border: #2a2a2a;
  --text: #e5e5e5;
  --text-dim: #888;
  --accent: #f59e0b;
  --accent-dim: #b45309;
  --tag-bg: #1a1a2e;
  --tag-text: #7c8cf5;
  --green: #22c55e;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

.screen { min-height: 100dvh; }
.hidden { display: none !important; }

/* Login */
.login-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 2rem;
  gap: 1rem;
}
.login-box h1 { font-size: 4rem; }
.login-box h2 { font-size: 1.5rem; font-weight: 600; color: var(--text-dim); }
.login-box input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1.25rem;
  color: var(--text);
  font-size: 1rem;
  width: 100%;
  max-width: 300px;
  outline: none;
  transition: border-color 0.2s;
}
.login-box input:focus { border-color: var(--accent); }
.login-box button {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 0.875rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  max-width: 300px;
  transition: opacity 0.2s;
}
.login-box button:active { opacity: 0.8; }
.error { color: #ef4444; font-size: 0.875rem; }

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: calc(var(--safe-top) + 1rem) 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
header h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.75rem; }
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.search-box { flex: 1; }
.search-box input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.625rem 1rem;
  color: var(--text);
  font-size: 0.9375rem;
  outline: none;
}
.search-box input:focus { border-color: var(--accent); }
.badge {
  background: var(--surface);
  border-radius: 20px;
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-dim);
  white-space: nowrap;
}

/* Categories */
nav#categories {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
nav#categories::-webkit-scrollbar { display: none; }
.cat-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.5rem 1rem;
  color: var(--text-dim);
  font-size: 0.8125rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.cat-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
}

/* Ideas list */
#ideas-list {
  padding: 0.5rem 1rem calc(var(--safe-bottom) + 2rem);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.idea-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: all 0.15s;
}
.idea-card:active { transform: scale(0.98); background: var(--surface2); }
.idea-card .title {
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 0.375rem;
  line-height: 1.4;
}
.idea-card .excerpt {
  color: var(--text-dim);
  font-size: 0.8125rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.idea-card .meta {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.tag {
  background: var(--tag-bg);
  color: var(--tag-text);
  padding: 0.125rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
}
.cat-label {
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 500;
}
.date-label {
  color: var(--text-dim);
  font-size: 0.75rem;
  margin-left: auto;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-content {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 85dvh;
  overflow-y: auto;
  padding: 1.5rem 1.25rem calc(var(--safe-bottom) + 1.5rem);
  position: relative;
  animation: slideUp 0.25s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--surface2);
  border: none;
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

#idea-detail h1, #idea-detail h2, #idea-detail h3 {
  font-weight: 700;
  margin: 1rem 0 0.5rem;
}
#idea-detail h1 { font-size: 1.375rem; }
#idea-detail h2 { font-size: 1.125rem; }
#idea-detail p { line-height: 1.7; margin-bottom: 0.75rem; color: var(--text); }
#idea-detail ul, #idea-detail ol { padding-left: 1.25rem; margin-bottom: 0.75rem; }
#idea-detail li { line-height: 1.6; margin-bottom: 0.25rem; }
#idea-detail code {
  background: var(--surface2);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: 0.875rem;
}
#idea-detail .idea-tags { display: flex; gap: 0.375rem; flex-wrap: wrap; margin-bottom: 1rem; }
#idea-detail .idea-date { color: var(--text-dim); font-size: 0.8125rem; margin-bottom: 0.5rem; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-dim);
}
.empty-state .emoji { font-size: 3rem; margin-bottom: 1rem; }

@media (min-width: 768px) {
  #ideas-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
  .modal-content {
    border-radius: var(--radius);
    max-height: 80vh;
    margin-bottom: 2rem;
  }
  .modal { align-items: center; }
}
