/* ── Reset & Base ──────────────────────────────────────────────────────────── */

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

:root {
  --bg:       #0f0f13;
  --surface:  #17171f;
  --border:   #2a2a38;
  --accent:   #7c6af7;
  --accent-h: #9585ff;
  --text:     #e8e8f0;
  --muted:    #7a7a96;
  --error:    #f97070;
  --success:  #5fde9b;
  --radius:   10px;
  --font:     -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
}

/* ── Utilities ─────────────────────────────────────────────────────────────── */

.hidden { display: none !important; }

.error   { color: var(--error);   font-size: 13px; margin-top: 8px; }
.success { color: var(--success); font-size: 13px; }

/* ── Gate ──────────────────────────────────────────────────────────────────── */

.gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.gate-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.gate-icon { font-size: 48px; margin-bottom: 16px; }

.gate-box h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.gate-sub {
  color: var(--muted);
  margin-top: 6px;
  margin-bottom: 28px;
  font-size: 14px;
}

.gate-box input[type="password"] {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.15s;
}

.gate-box input[type="password"]:focus {
  border-color: var(--accent);
}

.gate-box button[type="submit"] {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.gate-box button[type="submit"]:hover { background: var(--accent-h); }
.gate-box button[type="submit"]:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── App Shell ─────────────────────────────────────────────────────────────── */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 740px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ── Header ────────────────────────────────────────────────────────────────── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-icon { font-size: 22px; }

.header-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */

.btn-primary {
  padding: 10px 22px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-h); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  padding: 7px 14px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }

/* ── Tabs ──────────────────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 4px;
  padding: 12px 0 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab {
  padding: 8px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Tab Content ───────────────────────────────────────────────────────────── */

.tab-content { padding-bottom: 48px; }

.tab-hint {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
}

/* ── Capture Form ──────────────────────────────────────────────────────────── */

#capture-form textarea {
  width: 100%;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
  margin-bottom: 12px;
}

#capture-form textarea:focus { border-color: var(--accent); }

.meta-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.meta-row input {
  flex: 1;
  padding: 9px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.meta-row input:focus { border-color: var(--accent); }

.status {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}

/* ── Search Form ───────────────────────────────────────────────────────────── */

.search-row {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.search-row input {
  flex: 1;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}

.search-row input:focus { border-color: var(--accent); }

/* ── Results ───────────────────────────────────────────────────────────────── */

.results { display: flex; flex-direction: column; gap: 14px; }

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
}

.result-card:hover { border-color: var(--muted); }

.result-content {
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.result-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.result-date {
  color: var(--muted);
  font-size: 12px;
}

.result-similarity {
  background: #7c6af720;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}

.result-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  background: #2a2a38;
  color: var(--muted);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
}

.delete-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  padding: 4px 6px;
  border-radius: 6px;
}

.result-card:hover .delete-btn { opacity: 1; }
.delete-btn:hover { color: var(--error); background: #f9707015; }

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

.spinner {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 24px 0;
}

/* ── Recent Header ─────────────────────────────────────────────────────────── */

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

.recent-header .tab-hint { margin-bottom: 0; }

/* ── Mobile ────────────────────────────────────────────────────────────────── */

@media (max-width: 500px) {
  .meta-row { flex-direction: column; }
  .search-row { flex-direction: column; }
  .gate-box { padding: 36px 24px; }
}
