:root {
  --bg: #111827;
  --panel: #1a2333;
  --panel-2: #212c40;
  --text: #e5e7eb;
  --muted: #8b93a7;
  --accent: #6ee7b7;
  --accent-dim: #2d5a4a;
  --danger: #f87171;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.85rem; }
.error { color: var(--danger); font-size: 0.85rem; }

/* Login */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card {
  background: var(--panel);
  padding: 2rem;
  border-radius: var(--radius);
  width: 100%;
  max-width: 320px;
  text-align: center;
}
.login-card input {
  width: 100%;
  padding: 0.7rem;
  margin: 1rem 0;
  border-radius: 8px;
  border: 1px solid #333;
  background: var(--panel-2);
  color: var(--text);
}
.login-card button {
  width: 100%;
  padding: 0.7rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #0b1220;
  font-weight: 600;
  cursor: pointer;
}
.login-card .switch-link { margin: 0.8rem 0 0; }
.login-card .switch-link a { color: var(--accent); }

/* Account / change-password panel — reuses .login-card styling but sits
   inline in the tab content rather than centered full-screen. */
.account-card { margin: 0; max-width: 360px; text-align: left; }
.account-card button { width: auto; padding: 0.6rem 1.2rem; }

/* App header / current user */
.header-top { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.header-top h1 { margin: 0; }
.header-user { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; }
#logout-btn {
  background: none;
  border: 1px solid #2c3549;
  color: var(--muted);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  font-size: 0.78rem;
  cursor: pointer;
}
#logout-btn:hover { border-color: var(--danger); color: var(--danger); }

/* App shell */
#app { max-width: 720px; margin: 0 auto; padding: 1rem; padding-bottom: 3rem; }

header { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1rem; }
header h1 { margin: 0; font-size: 1.3rem; }

nav { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.tab-btn {
  background: var(--panel);
  color: var(--muted);
  border: none;
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
}
.tab-btn.active { background: var(--accent-dim); color: var(--accent); }

#capture-panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 0.8rem;
  margin-bottom: 1.2rem;
}
#capture-content {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid #2c3549;
  color: var(--text);
  border-radius: 8px;
  padding: 0.6rem;
  font-size: 1rem;
  resize: vertical;
}
.capture-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.capture-row input {
  flex: 1 1 140px;
  min-width: 0;
  background: var(--panel-2);
  border: 1px solid #2c3549;
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem;
}
#capture-btn, .bookmarklet-btn {
  background: var(--accent);
  color: #0b1220;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  flex: 1 1 auto;
  white-space: nowrap;
}

#mic-btn, #photo-btn {
  background: var(--panel-2);
  border: 1px solid #2c3549;
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  font-size: 1rem;
  cursor: pointer;
  flex: 0 0 auto;
}
#mic-btn.recording {
  background: var(--danger);
  border-color: var(--danger);
  color: #2b0d0d;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

#photo-preview-wrap {
  position: relative;
  display: inline-block;
  margin-bottom: 0.6rem;
}
#photo-preview {
  max-height: 160px;
  max-width: 100%;
  border-radius: 8px;
  display: block;
}
#photo-remove-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--danger);
  color: #2b0d0d;
  border: none;
  border-radius: 999px;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
}

.item-card .item-photo {
  height: 84px;
  width: auto;
  max-width: 100%;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  margin-bottom: 0.4rem;
  cursor: pointer;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.6rem; }

#search-input {
  width: 100%;
  padding: 0.6rem;
  border-radius: 8px;
  border: 1px solid #2c3549;
  background: var(--panel-2);
  color: var(--text);
  margin-bottom: 0.8rem;
}

.item-list { display: flex; flex-direction: column; gap: 0.6rem; }

.item-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
}
.item-card .item-title { font-weight: 600; margin-bottom: 0.2rem; word-break: break-word; }
.item-card .item-content { white-space: pre-wrap; word-break: break-word; margin-bottom: 0.4rem; }
.item-card a.item-url { color: var(--accent); font-size: 0.85rem; word-break: break-all; }
.item-card .item-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 0.5rem; flex-wrap: wrap; gap: 0.4rem; }
.item-card .item-tags { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.chip {
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}
.item-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.item-actions button {
  background: none;
  border: 1px solid #2c3549;
  color: var(--muted);
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
  font-size: 0.78rem;
  cursor: pointer;
}
.item-actions button:hover { border-color: var(--accent); color: var(--accent); }
.item-actions button.danger:hover { border-color: var(--danger); color: var(--danger); }

/* Per-item inline edit form */
.item-edit { margin-top: 0.3rem; }
.item-edit input[type="text"],
.item-edit textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid #2c3549;
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem;
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
  font-family: inherit;
  box-sizing: border-box;
}
.item-edit textarea { resize: vertical; }
.edit-actions { display: flex; gap: 0.4rem; }
.edit-actions button {
  border-radius: 8px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.edit-actions button[data-action="save-edit"] {
  background: var(--accent);
  color: #0b1220;
  border: none;
  font-weight: 600;
}
.edit-actions button[data-action="cancel-edit"] {
  background: none;
  border: 1px solid #2c3549;
  color: var(--muted);
}

.tag-cloud { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tag-pill {
  background: var(--panel);
  color: var(--text);
  border: none;
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.tag-pill .count { color: var(--muted); margin-left: 0.3rem; }
.tag-pill.active { background: var(--accent-dim); color: var(--accent); }

#bookmarklet-code {
  width: 100%;
  font-family: monospace;
  font-size: 0.75rem;
  background: var(--panel-2);
  color: var(--muted);
  border-radius: 8px;
  border: 1px solid #2c3549;
  padding: 0.5rem;
}

.empty-state { color: var(--muted); text-align: center; padding: 2rem 0; }
