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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface-hover: #252525;
  --border: #333;
  --text: #e8e8e8;
  --text-muted: #888;
  --accent: #4ade80;
  --accent-hover: #22c55e;
  --danger: #ef4444;
  --radius: 12px;
}

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

.hidden {
  display: none !important;
}

/* Login */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--surface);
  padding: 2.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-card h1 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}

.login-card p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.login-card input {
  width: 100%;
  padding: 0.85rem;
  margin-bottom: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
}

.login-card input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-card button {
  width: 100%;
  padding: 0.85rem;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.login-card button:hover {
  background: var(--accent-hover);
}

.error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/* Nav */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

nav h1 {
  font-size: 1.2rem;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  background: var(--surface-hover);
}

.badge {
  background: var(--accent);
  color: #000;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 10px;
  margin-left: 0.3rem;
}

#logout-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

#logout-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

/* Main */
main {
  padding: 1.5rem;
  max-width: 900px;
  margin: 0 auto;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.page h2 {
  margin-bottom: 0.5rem;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

/* Recipe Card */
.recipe-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.2s;
}

.recipe-card:hover {
  transform: translateY(-2px);
}

.recipe-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
}

.recipe-card-body {
  padding: 1rem;
}

.recipe-card-body h3 {
  font-size: 1rem;
  margin-bottom: 0.3rem;
}

.recipe-card-body p {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 0.8rem;
  line-height: 1.4;
}

.recipe-card-body .servings {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-bottom: 0.8rem;
}

.btn-todo {
  width: 100%;
  padding: 0.6rem;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-todo:hover {
  background: var(--accent-hover);
}

.btn-todo:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* Todo List */
.todo-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.8rem;
}

.todo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}

.todo-header h3 {
  font-size: 1rem;
}

.todo-header .todo-date {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.todo-ingredients {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.8rem;
}

.todo-ingredients li {
  background: var(--bg);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-remove {
  padding: 0.5rem 1rem;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
}

.btn-remove:hover {
  opacity: 0.9;
}

/* Add Recipe Form */
#add-recipe-form input,
#add-recipe-form textarea {
  width: 100%;
  padding: 0.85rem;
  margin-bottom: 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
}

#add-recipe-form textarea {
  min-height: 80px;
  resize: vertical;
}

#add-recipe-form input:focus,
#add-recipe-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}

#add-recipe-form h3 {
  margin-bottom: 0.8rem;
  font-size: 0.95rem;
}

.ingredient-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.ingredient-row input:first-child {
  flex: 2;
}

.ingredient-row input:nth-child(2),
.ingredient-row input:nth-child(3) {
  flex: 1;
}

#add-ingredient-btn {
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  padding: 0.6rem;
  width: 100%;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

#add-ingredient-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#add-recipe-form button[type="submit"] {
  width: 100%;
  padding: 0.85rem;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

/* Status bar */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

.btn-small {
  padding: 0.4rem 0.8rem;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-small:hover {
  background: var(--accent-hover);
}

.btn-primary {
  padding: 0.7rem 1.5rem;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 1rem;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

/* Import */
.import-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.import-tab {
  padding: 0.6rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
}

.import-tab.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

.import-content {
  display: none;
}

.import-content.active {
  display: block;
}

#import-url-form,
#import-json-form {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

#import-url-form input,
#import-json-form textarea {
  width: 100%;
  padding: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
}

#import-json-form textarea {
  min-height: 150px;
  font-family: monospace;
  font-size: 0.85rem;
}

#import-url-form input:focus,
#import-json-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}

#import-url-form button,
#import-json-form button {
  padding: 0.85rem;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.help-text {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.8rem;
}

#import-result {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

#import-result.success {
  border-color: var(--accent);
}

#import-result.error {
  border-color: var(--danger);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  color: var(--text);
  padding: 0.8rem 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  z-index: 1000;
  transition: opacity 0.3s;
}

.toast.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Mobile */
@media (max-width: 600px) {
  nav {
    flex-direction: column;
    gap: 0.8rem;
  }

  .nav-links {
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
  }

  .grid {
    grid-template-columns: 1fr;
  }
}
