/* ── Kymacache PWA Styles ────────────────────────────────────────────────────── */
/* Aesthetic: dark editorial — tight monospace accents, generous whitespace */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=DM+Mono:wght@300;400&family=DM+Sans:wght@300;400;500&display=swap');

:root {
  --bg:       #0f0f0f;
  --bg2:      #1a1a1a;
  --bg3:      #242424;
  --border:   #2e2e2e;
  --text:     #e8e6e1;
  --muted:    #7a7870;
  --accent:   #c8b97a;   /* warm gold */
  --accent2:  #5c8f6e;   /* forest green */
  --danger:   #c0675a;
  --radius:   10px;
  --font-ui:  'DM Sans', sans-serif;
  --font-mono:'DM Mono', monospace;
  --font-disp:'DM Serif Display', serif;
  --transition: 160ms ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-weight: 300;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

#app {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ── Header ──────────────────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 50;
}

.logo { display: flex; align-items: baseline; gap: 0; }

.logo-mark {
  font-family: var(--font-disp);
  font-size: 28px;
  color: var(--accent);
  line-height: 1;
}

.logo-name {
  font-family: var(--font-disp);
  font-size: 22px;
  color: var(--text);
  opacity: 0.7;
  line-height: 1;
}

.header-actions { display: flex; gap: 8px; }

.icon-btn {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: grid; place-items: center;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}
.icon-btn:hover { color: var(--text); border-color: var(--muted); }
.icon-btn svg   { width: 16px; height: 16px; }

#offline-indicator { display: none; }
#offline-indicator.active { display: grid; color: var(--danger); border-color: var(--danger); }

/* ── Search ──────────────────────────────────────────────────────────────────── */
.search-bar {
  padding: 12px 0 0;
  position: relative;
}

.search-bar input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  outline: none;
  transition: border-color var(--transition);
}
.search-bar input:focus { border-color: var(--accent); }

.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 100;
  max-height: 320px;
  overflow-y: auto;
}

.search-result-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg3); }
.search-result-item .sr-content { font-size: 14px; color: var(--text); line-height: 1.4; }
.search-result-item .sr-meta    { font-size: 12px; color: var(--muted); margin-top: 4px; font-family: var(--font-mono); }

/* ── Capture Panel ───────────────────────────────────────────────────────────── */
.capture-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin: 16px 0;
  overflow: hidden;
  transition: box-shadow var(--transition);
}
.capture-panel:focus-within { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }

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

.tab {
  padding: 10px 14px;
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.05em;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab:hover:not(.active) { color: var(--text); }

.tab-content { display: none; padding: 12px; }
.tab-content.active { display: block; }

textarea, input[type="url"], input[type="text"] {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  padding: 4px;
}
textarea::placeholder, input::placeholder { color: var(--muted); }

input[type="url"] {
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-radius: 0;
}

/* File drop zone */
.file-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px 16px;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  transition: border-color var(--transition), color var(--transition);
  margin-bottom: 10px;
}
.file-drop:hover, .file-drop.dragging { border-color: var(--accent); color: var(--text); }
.file-drop svg { width: 32px; height: 32px; }
.file-name { font-family: var(--font-mono); font-size: 12px; color: var(--accent2); word-break: break-all; }

.capture-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 14px;
}

.status-msg {
  font-size: 13px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.capture-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #0f0f0f;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
}
.capture-btn:hover    { opacity: 0.9; transform: translateY(-1px); }
.capture-btn:active   { transform: translateY(0); }
.capture-btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.capture-btn svg      { width: 16px; height: 16px; }

/* ── Feed ────────────────────────────────────────────────────────────────────── */
.feed-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 14px;
}

.feed-header h2 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 400;
}

.label-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.label-chip {
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  background: transparent;
  transition: all var(--transition);
}
.label-chip.active { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.label-chip:hover:not(.active) { border-color: var(--muted); color: var(--text); }

.entries-list { display: flex; flex-direction: column; gap: 10px; padding-bottom: 32px; }

/* Entry card */
.entry-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
  animation: fadeIn 200ms ease;
}
.entry-card:hover { border-color: var(--muted); transform: translateY(-1px); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.entry-content {
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-summary {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
  font-style: italic;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.entry-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.entry-label {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg3);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.entry-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.ai-badge {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
}
.ai-badge.pending    { background: var(--muted); }
.ai-badge.processing { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.ai-badge.done       { background: var(--accent2); }
.ai-badge.failed     { background: var(--danger); }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

.entry-file-thumb {
  width: 48px; height: 48px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
  margin-bottom: 10px;
}

.delete-btn {
  opacity: 0;
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: opacity var(--transition);
}
.entry-card:hover .delete-btn { opacity: 1; }
.delete-btn svg { width: 14px; height: 14px; }

/* Loading / empty states */
.loading-state, .empty-state {
  text-align: center;
  padding: 48px 0;
  color: var(--muted);
  font-size: 14px;
  font-family: var(--font-mono);
}

.load-more {
  display: block;
  width: 100%;
  padding: 12px;
  margin-bottom: 24px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}
.load-more:hover { border-color: var(--accent); color: var(--accent); }

/* ── Toast ───────────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
  pointer-events: none;
}

.toast {
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--font-mono);
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  animation: slideUp 200ms ease;
  pointer-events: auto;
  white-space: nowrap;
}
.toast.success { border-color: var(--accent2); color: var(--accent2); }
.toast.error   { border-color: var(--danger);  color: var(--danger); }

@keyframes slideUp { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:none; } }

/* ── Utilities ───────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
