:root {
  --primary: #5b5bd6;
  --primary-hover: #4a4ac9;
  --bg: #f5f5fb;
  --bg-gradient-1: #eef0ff;
  --bg-gradient-2: #f8f4ff;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --border: rgba(91, 91, 214, 0.12);
  --text: #1c1c2e;
  --text-muted: #6b6b80;
  --danger: #e53935;
  --warning: #f57c00;
  --success: #43a047;
  --shadow: 0 8px 32px rgba(91, 91, 214, 0.08);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14141c;
    --bg-gradient-1: #1a1a2a;
    --bg-gradient-2: #1f1729;
    --surface: rgba(32, 32, 48, 0.72);
    --surface-strong: rgba(40, 40, 60, 0.92);
    --border: rgba(255, 255, 255, 0.08);
    --text: #ececf5;
    --text-muted: #9b9bb0;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.32);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, var(--bg-gradient-1), var(--bg-gradient-2));
  -webkit-font-smoothing: antialiased;
}

.view { min-height: 100vh; }
.hidden { display: none !important; }

/* Login */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.brand {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 4px;
}

.subtitle {
  color: var(--text-muted);
  margin: 0 0 24px;
  font-size: 14px;
}

/* Card */
.card {
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card h2 {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 600;
}

/* Forms */
form { display: flex; flex-direction: column; gap: 12px; }

form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  font-size: 14px;
  color: var(--text-muted);
}

input, select, textarea {
  font-family: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-strong);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
}

button {
  font-family: inherit;
  font-size: 15px;
  padding: 10px 16px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s, opacity 0.15s;
}

button.primary {
  background: var(--primary);
  color: white;
}
button.primary:hover { background: var(--primary-hover); }
button.primary:disabled { opacity: 0.6; cursor: not-allowed; }

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
button.ghost:hover { background: var(--surface-strong); }

button.link {
  background: transparent;
  color: var(--primary);
  padding: 4px;
  font-size: 14px;
}
button.link:hover { text-decoration: underline; }

button.icon {
  background: transparent;
  color: var(--text-muted);
  padding: 4px 8px;
  font-size: 18px;
  line-height: 1;
}
button.icon:hover { color: var(--danger); }

.error {
  color: var(--danger);
  font-size: 13px;
  background: rgba(229, 57, 53, 0.1);
  padding: 8px 12px;
  border-radius: 8px;
}

.info {
  color: var(--success);
  font-size: 13px;
  background: rgba(67, 160, 71, 0.1);
  padding: 8px 12px;
  border-radius: 8px;
}

/* Topbar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand-small {
  font-weight: 700;
  color: var(--primary);
  font-size: 18px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-email {
  font-size: 13px;
  color: var(--text-muted);
}

/* Container */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.filter-row label {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}
.filter-row select { flex: 1; max-width: 240px; }

/* Add row */
.add-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: 8px;
  flex-direction: row !important;
  margin-bottom: 16px;
}

.add-row input[type="text"] { min-width: 0; }

#idea-form.add-row {
  grid-template-columns: 1fr auto auto;
}

@media (max-width: 640px) {
  .add-row, #idea-form.add-row {
    grid-template-columns: 1fr;
  }
}

/* List */
.list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.list-item.completed {
  opacity: 0.55;
}

.list-item.completed .item-title {
  text-decoration: line-through;
}

.item-check {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.item-title {
  font-size: 15px;
  font-weight: 500;
  word-break: break-word;
}

.item-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
}

.priority-chip {
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.priority-high { background: rgba(229, 57, 53, 0.15); color: var(--danger); }
.priority-medium { background: rgba(245, 124, 0, 0.15); color: var(--warning); }
.priority-low { background: rgba(67, 160, 71, 0.15); color: var(--success); }

.context-chip {
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(91, 91, 214, 0.12);
  color: var(--primary);
  font-size: 11px;
  font-weight: 500;
}

.empty {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 14px;
}

/* Splash */
#splash-view {
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: var(--shadow);
  z-index: 100;
  max-width: 90vw;
}

.toast.error {
  background: var(--danger);
  color: white;
}
