/* ============================================
   LaterBrain — Premium Dark Dashboard
   ============================================ */

:root {
  /* Surfaces */
  --bg-0: #0b0d10;
  --bg-1: #111418;
  --bg-2: #161a20;
  --bg-3: #1c2128;
  --bg-hover: #20262e;
  --bg-elev: #1a1f26;

  /* Borders */
  --border: #232a33;
  --border-strong: #2d3540;

  /* Text */
  --text-1: #e7ecf3;
  --text-2: #aab2bd;
  --text-3: #6b7380;
  --text-4: #4a5260;

  /* Accent */
  --accent: #7c9cff;
  --accent-hover: #95b0ff;
  --accent-soft: rgba(124, 156, 255, 0.12);

  /* Status */
  --success: #5eead4;
  --warn: #f5b971;
  --danger: #f47174;

  /* Category dots */
  --c-trend: #f6c177;
  --c-prompt: #c4a7e7;
  --c-idea: #9ccfd8;
  --c-ref: #7c9cff;
  --c-memo: #eb6f92;
  --c-exec: #5eead4;

  /* Layout */
  --sidebar-w: 248px;
  --detail-w: 420px;
  --radius: 10px;
  --radius-lg: 14px;

  /* Type */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Pretendard",
    "Inter", "Helvetica Neue", Arial, "Apple SD Gothic Neo", sans-serif;

  /* Shadow */
  --shadow-soft: 0 1px 0 rgba(255, 255, 255, 0.02) inset,
    0 1px 2px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-0);
  color: var(--text-1);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

.hidden { display: none !important; }

/* ============================================
   App Layout
   ============================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--detail-w);
  height: 100vh;
  overflow: hidden;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 22px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #7c9cff 0%, #5eead4 100%);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #0b0d10;
  font-size: 18px;
}

.brand-title {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.02em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-section-title {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-3);
  padding: 18px 10px 8px;
}

.nav-item {
  background: transparent;
  border: 0;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
  font-size: 13px;
  transition: background 0.12s, color 0.12s;
}

.nav-item:hover {
  background: var(--bg-2);
  color: var(--text-1);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--text-1);
}

.nav-label { flex: 1; }

.nav-count {
  font-size: 11px;
  color: var(--text-3);
  background: var(--bg-3);
  padding: 1px 7px;
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
}

.nav-item.active .nav-count {
  background: var(--accent);
  color: #0b0d10;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
}
.dot-trend  { background: var(--c-trend); }
.dot-prompt { background: var(--c-prompt); }
.dot-idea   { background: var(--c-idea); }
.dot-ref    { background: var(--c-ref); }
.dot-memo   { background: var(--c-memo); }
.dot-exec   { background: var(--c-exec); }

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

.storage-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-3);
  padding: 6px 10px;
  background: var(--bg-2);
  border-radius: 999px;
}

.storage-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}
.storage-dot-cf {
  background: #f6821f;
  box-shadow: 0 0 8px #f6821f;
}

.storage-usage {
  margin-top: 10px;
  padding: 0 4px;
}
.storage-usage-bar {
  height: 4px;
  background: var(--bg-3);
  border-radius: 999px;
  overflow: hidden;
}
.storage-usage-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  transition: width 0.3s ease;
}
.storage-usage-fill.warn { background: linear-gradient(90deg, var(--warn), var(--danger)); }
.storage-usage-text {
  margin-top: 6px;
  font-size: 10.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* ============================================
   Main
   ============================================ */
.main {
  background: var(--bg-0);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Quick Capture */
.capture {
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  padding: 22px 28px 20px;
}

.capture-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.capture-header h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: 0.01em;
}

.capture-hint {
  font-size: 11.5px;
  color: var(--text-3);
}

.capture-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.capture-title {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-1);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.capture-title::placeholder { color: var(--text-3); }

.capture-title:focus {
  border-color: var(--accent);
  background: var(--bg-elev);
}

.capture-content {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13.5px;
  color: var(--text-1);
  outline: none;
  resize: vertical;
  min-height: 44px;
  transition: border-color 0.15s;
}

.capture-content:focus { border-color: var(--accent); }
.capture-content::placeholder { color: var(--text-3); }

.capture-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 8px;
}

.capture-field {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.chip-label {
  flex-shrink: 0;
  width: 60px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  padding-top: 7px;
}

.chip-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.chip {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.05s;
  white-space: nowrap;
}
.chip:hover {
  background: var(--bg-hover);
  color: var(--text-1);
}
.chip:active { transform: translateY(1px); }
.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text-1);
}
.chip .dot { width: 7px; height: 7px; }


.chip-custom {
  width: 100%;
}

/* Capture parse preview */
.parse-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: 11.5px;
  color: var(--text-3);
  align-items: center;
}
.parse-preview-label {
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 10px;
  color: var(--text-3);
}
.parse-token {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  border: 1px solid rgba(124, 156, 255, 0.35);
  color: var(--text-1);
  padding: 3px 4px 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
}
.parse-token .parse-token-kind {
  color: var(--accent);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.parse-token .parse-token-dismiss {
  background: rgba(0, 0, 0, 0.25);
  color: var(--text-1);
  border: 0;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.parse-token .parse-token-dismiss:hover { background: var(--danger); }

/* ============================================
   Attachments
   ============================================ */
.attach-zone {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s, background 0.15s;
}
.attach-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.attach-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.attach-thumbs:empty { display: none; }

.thumb {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-3);
  border: 1px solid var(--border);
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb-file {
  width: 100%;
  height: 100%;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
  background: linear-gradient(135deg, var(--bg-3) 0%, var(--bg-elev) 100%);
}
.thumb-icon { font-size: 24px; line-height: 1; }
.thumb-ext {
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-weight: 600;
}
.thumb-name {
  font-size: 10px;
  color: var(--text-2);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thumb-pdf .thumb-icon   { color: var(--danger); }
.thumb-audio .thumb-icon { color: var(--c-prompt); }
.thumb-video .thumb-icon { color: var(--c-trend); }
.thumb-meta {
  position: absolute;
  left: 4px;
  bottom: 4px;
  font-size: 10px;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}
.thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.thumb-remove:hover { background: var(--danger); }

.attach-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.attach-hint {
  font-size: 11.5px;
  color: var(--text-3);
}

.btn-secondary {
  background: var(--bg-3);
  border-color: var(--border-strong);
  color: var(--text-1);
  padding: 7px 12px;
  font-size: 12.5px;
}
.btn-secondary:hover { background: var(--bg-hover); }

/* Card thumbnail */
.card-thumb {
  margin: -14px -16px 0;
  height: 140px;
  overflow: hidden;
  background: var(--bg-3);
  border-bottom: 1px solid var(--border);
}
.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card.has-thumb { padding-top: 0; }
.card.has-thumb .card-top { padding-top: 12px; }
.card-thumb { position: relative; }
.card-attach-count {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
}

/* Inputs / selects */
.input, .select {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text-1);
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}

.input::placeholder { color: var(--text-3); }
.input:focus, .select:focus { border-color: var(--accent); }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%236b7380' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 28px;
}

/* Buttons */
.btn {
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-1);
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
}

.btn:hover { background: var(--bg-hover); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0d10;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-danger {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(244, 113, 116, 0.08); }

.btn-ai {
  background: linear-gradient(135deg, rgba(124, 156, 255, 0.16) 0%, rgba(94, 234, 212, 0.16) 100%);
  border-color: rgba(124, 156, 255, 0.35);
  color: var(--text-1);
  font-weight: 500;
  position: relative;
}
.btn-ai:hover {
  background: linear-gradient(135deg, rgba(124, 156, 255, 0.28) 0%, rgba(94, 234, 212, 0.28) 100%);
  border-color: rgba(124, 156, 255, 0.55);
}
.btn-ai:disabled {
  opacity: 0.55;
  cursor: progress;
}

.icon-btn {
  background: transparent;
  border: 0;
  color: var(--text-3);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 14px;
}
.icon-btn:hover { background: var(--bg-2); color: var(--text-1); }

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-0);
}

.search-wrap { flex: 1; }

.search {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text-1);
  outline: none;
  transition: border-color 0.15s;
}
.search::placeholder { color: var(--text-3); }
.search:focus { border-color: var(--accent); }

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

.result-count {
  font-size: 12px;
  color: var(--text-3);
}

/* List */
.list {
  flex: 1;
  overflow-y: auto;
  padding: 18px 28px 40px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
  align-content: start;
}

.empty {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 60px 20px;
}
.empty-title { font-size: 16px; color: var(--text-2); margin-bottom: 6px; }
.empty-sub { font-size: 13px; color: var(--text-3); }

/* Card */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 130px;
}

.card:hover {
  border-color: var(--border-strong);
  background: var(--bg-elev);
}

.card.selected {
  border-color: var(--accent);
  background: var(--bg-elev);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card-cat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-2);
  background: var(--bg-2);
  padding: 3px 9px;
  border-radius: 999px;
}

.card-status {
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.s-inbox     { background: rgba(124, 156, 255, 0.14); color: var(--accent); }
.s-archive   { background: rgba(170, 178, 189, 0.14); color: var(--text-2); }
.s-candidate { background: rgba(94, 234, 212, 0.14); color: var(--success); }
.s-trash     { background: rgba(244, 113, 116, 0.14); color: var(--danger); }


.card-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -0.005em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-content {
  font-size: 12.5px;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  font-size: 11px;
  color: var(--text-3);
  background: var(--bg-2);
  padding: 2px 8px;
  border-radius: 5px;
}
.tag-clickable {
  cursor: pointer;
  transition: color 0.1s, background 0.1s;
}
.tag-clickable:hover {
  color: var(--text-2);
  background: var(--bg-3);
}
.tag-clickable.tag-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  font-size: 11px;
  color: var(--text-3);
}

.card-source {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.expires-warn { color: var(--warn); }
.expires-dead { color: var(--danger); }

/* ============================================
   Detail Panel
   ============================================ */
.detail {
  background: var(--bg-1);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 22px 22px 30px;
}

.detail-empty {
  height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--text-3);
}
.detail-empty-title {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 6px;
}
.detail-empty-sub { font-size: 12.5px; }

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

.detail-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.d-title {
  flex: 1;
  background: transparent;
  border: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-1);
  outline: none;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}
.d-title:focus { border-color: var(--border-strong); }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
}

.field textarea, .field .input, .field .select {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text-1);
  outline: none;
  resize: vertical;
  transition: border-color 0.15s;
}
.field textarea:focus, .field .input:focus, .field .select:focus {
  border-color: var(--accent);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-3);
  padding: 8px 2px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.meta span { display: block; margin-bottom: 2px; }
.meta b { color: var(--text-2); font-weight: 500; }

.detail-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}

/* ============================================
   Toast
   ============================================ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  color: var(--text-1);
  padding: 10px 14px 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  animation: toast-in 0.18s ease-out;
  display: inline-flex;
  align-items: center;
  gap: 14px;
}
.toast-action {
  background: var(--accent);
  border: 0;
  color: #0b0d10;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.toast-action:hover { background: var(--accent-hover); }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ============================================
   Lightbox
   ============================================ */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 40px;
  animation: lightbox-in 0.15s ease-out;
}
.lightbox.hidden { display: none; }
.lightbox img {
  max-width: 100%;
  max-height: calc(100vh - 120px);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.lightbox-close {
  position: absolute;
  top: 18px;
  right: 22px;
  background: rgba(255, 255, 255, 0.1);
  border: 0;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.25); }
.lightbox-caption {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-2);
  font-size: 12px;
  background: rgba(0, 0, 0, 0.5);
  padding: 6px 14px;
  border-radius: 999px;
  max-width: 80%;
  text-align: center;
}
@keyframes lightbox-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.thumb img, .card-thumb img { cursor: zoom-in; }

/* ============================================
   Cloudflare Sidebar Button
   ============================================ */
.cf-sidebar-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--text-3);
  cursor: pointer;
  margin-bottom: 8px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-align: left;
}
.cf-sidebar-btn:hover {
  background: var(--bg-hover);
  color: var(--text-2);
  border-color: var(--border-strong);
}
.cf-sidebar-btn.connected {
  border-color: var(--success);
  color: var(--success);
}
.cf-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cf-dot-off  { background: var(--text-4); }
.cf-dot-on   { background: var(--success); box-shadow: 0 0 6px var(--success); }
.cf-dot-err  { background: var(--danger); }

/* ============================================
   Cloudflare Setup Modal
   ============================================ */
.cf-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: help-in 0.15s ease-out;
}
.cf-modal.hidden { display: none; }

.cf-modal-inner {
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  animation: help-slide 0.18s ease-out;
  overflow: hidden;
}

.cf-modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.cf-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
}

.cf-modal-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }

.cf-modal-desc {
  font-size: 13px;
  color: var(--text-3);
  margin: 0;
  line-height: 1.6;
}

.cf-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cf-field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
}
.cf-field .input {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text-1);
  outline: none;
  transition: border-color 0.15s;
}
.cf-field .input:focus { border-color: var(--accent); }

.cf-field-hint {
  font-size: 11.5px;
  color: var(--text-4);
  line-height: 1.5;
}

.cf-test-result {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
}
.cf-test-result.ok  { background: rgba(94, 234, 212, 0.12); color: var(--success); border: 1px solid rgba(94,234,212,0.25); }
.cf-test-result.err { background: rgba(244, 113, 116, 0.12); color: var(--danger);  border: 1px solid rgba(244,113,116,0.25); }

.cf-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 0 20px 16px;
}

.cf-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px 14px;
  border-top: 1px solid var(--border);
}

.cf-status-badge {
  font-size: 12px;
  color: var(--text-3);
}
.cf-status-badge.active { color: var(--success); }

.cf-disconnect {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
}
.cf-disconnect:hover { opacity: 0.8; }

/* ============================================
   Sidebar Data Buttons (export / import)
   ============================================ */
.sidebar-data-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}
.sidebar-data-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 6px;
  font-size: 11.5px;
  color: var(--text-3);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.sidebar-data-btn:hover {
  background: var(--bg-hover);
  color: var(--text-2);
  border-color: var(--border-strong);
}

/* ============================================
   Sidebar Tag Filter
   ============================================ */
.nav-tag-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 4px;
}
.tag-filter-clear-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.1s;
}
.tag-filter-clear-btn:hover { background: var(--accent-soft); }

.tag-filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 2px 12px 10px;
  min-height: 8px;
}
.tag-filter-item {
  font-size: 11px;
  color: var(--text-3);
  background: var(--bg-2);
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
  user-select: none;
}
.tag-filter-item:hover {
  color: var(--text-2);
  border-color: var(--border);
}
.tag-filter-item.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* ============================================
   View Toggle (grid / compact)
   ============================================ */
.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  flex-shrink: 0;
}
.view-btn {
  background: none;
  border: none;
  color: var(--text-3);
  padding: 5px 9px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: background 0.1s, color 0.1s;
}
.view-btn:hover { background: var(--bg-hover); color: var(--text-2); }
.view-btn.active { background: var(--bg-hover); color: var(--text-1); }

/* ============================================
   Compact List View
   ============================================ */
#list.compact {
  grid-template-columns: 1fr;
  gap: 2px;
  padding: 12px 28px 40px;
}
#list.compact .card {
  flex-direction: row;
  align-items: center;
  min-height: 0;
  padding: 9px 14px;
  gap: 10px;
  border-radius: 8px;
}
#list.compact .card-thumb { display: none; }
#list.compact .card-top {
  flex-shrink: 0;
  flex-wrap: nowrap;
  gap: 6px;
}
#list.compact .card-title {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 500;
  -webkit-line-clamp: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}
#list.compact .card-content { display: none; }
#list.compact .card-tags { display: none; }
#list.compact .card-foot {
  flex-shrink: 0;
  margin-top: 0;
  margin-left: auto;
}

/* ============================================
   Sidebar Help Button
   ============================================ */
.help-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-3);
  font-size: 12.5px;
  cursor: pointer;
  margin-bottom: 10px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.help-btn:hover {
  background: var(--bg-hover);
  color: var(--text-2);
  border-color: var(--border-strong);
}
.help-btn-icon {
  width: 18px;
  height: 18px;
  background: var(--bg-2);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  color: var(--text-2);
}

/* ============================================
   Help Modal
   ============================================ */
.help-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: help-in 0.15s ease-out;
}
.help-modal.hidden { display: none; }

@keyframes help-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.help-modal-inner {
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  animation: help-slide 0.18s ease-out;
}

@keyframes help-slide {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.help-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-2);
  z-index: 1;
}

.help-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.01em;
}

.help-sections {
  padding: 6px 0 20px;
}

.help-section {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.help-section:last-child { border-bottom: none; }

.help-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 10px;
}

.help-table {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.help-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-2);
}

.help-row kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 11.5px;
  font-family: var(--font);
  color: var(--text-1);
  white-space: nowrap;
  min-width: 72px;
  flex-shrink: 0;
}

.help-row code {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 12px;
  font-family: "SF Mono", "Fira Code", monospace;
  color: var(--accent);
  white-space: nowrap;
  min-width: 108px;
  flex-shrink: 0;
}

.help-chip {
  display: inline-block;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11.5px;
  color: var(--text-2);
  white-space: nowrap;
  min-width: 72px;
  text-align: center;
  flex-shrink: 0;
}

.help-row span:last-child { color: var(--text-2); }
.help-row em { color: var(--text-3); font-style: normal; }

.help-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.65;
}
.help-desc strong { color: var(--text-1); }
.help-desc em { color: var(--text-3); font-style: normal; }

.help-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.help-dot.dot-trend  { background: var(--c-trend); }
.help-dot.dot-prompt { background: var(--c-prompt); }
.help-dot.dot-idea   { background: var(--c-idea); }
.help-dot.dot-ref    { background: var(--c-ref); }
.help-dot.dot-memo   { background: var(--c-memo); }
.help-dot.dot-exec   { background: var(--c-exec); }

/* ============================================
   Tag Autocomplete
   ============================================ */
.tag-ac {
  position: relative;
  min-width: 0;
  flex: 1;
}

/* Inside .capture-row (grid context) the wrapper should fill its cell */
.capture-row .tag-ac {
  min-width: 0;
}

/* Inside .field (flex column context) */
.field .tag-ac {
  display: flex;
  flex-direction: column;
}

.tag-ac > .input {
  width: 100%;
}

.tag-ac-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  z-index: 500;
  overflow: hidden;
  animation: tag-ac-in 0.1s ease-out;
}

@keyframes tag-ac-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.tag-ac-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-1);
  transition: background 0.1s;
}

.tag-ac-item:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

.tag-ac-item:hover,
.tag-ac-item.focused {
  background: var(--bg-hover);
}

.tag-ac-hash {
  color: var(--accent);
  font-weight: 600;
  font-size: 12px;
}

.tag-ac-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-ac-match {
  color: var(--accent);
}

.tag-ac-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-3);
  background: var(--bg-2);
  padding: 2px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}

/* ============================================
   Scrollbar
   ============================================ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #232a33;
  border-radius: 10px;
  border: 2px solid var(--bg-0);
}
::-webkit-scrollbar-thumb:hover { background: #2d3540; }

/* ============================================
   Responsive (smaller screens)
   ============================================ */
@media (max-width: 1280px) {
  :root {
    --sidebar-w: 220px;
    --detail-w: 360px;
  }
  .capture-row {
    grid-template-columns: 1fr 1fr;
  }
  .capture-row .btn { grid-column: 1 / -1; }
  .capture-field { flex-direction: column; gap: 6px; }
  .chip-label { width: auto; padding-top: 0; }
}

@media (max-width: 960px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar, .detail { display: none; }
}
