/* ─── Reset & Variables ─────────────────────────────────────────────────── */

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

:root {
  --bg:           #0f0f0f;
  --surface:      #1a1a1a;
  --surface-2:    #212121;
  --border:       rgba(232, 224, 208, 0.08);
  --border-hover: rgba(232, 224, 208, 0.26);
  --accent:       #e8e0d0;
  --accent-muted: rgba(232, 224, 208, 0.5);
  --accent-dim:   rgba(232, 224, 208, 0.22);
  --accent-faint: rgba(232, 224, 208, 0.07);
  --danger:       #c0392b;
  --danger-dim:   rgba(192, 57, 43, 0.15);

  --font-ui:   -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', system-ui, sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', ui-monospace, monospace;

  --radius:    7px;
  --radius-lg: 11px;
}

html { height: 100%; }

body {
  min-height: 100%;
  background-color: var(--bg);
  background-image: radial-gradient(rgba(232, 224, 208, 0.05) 1px, transparent 1px);
  background-size: 30px 30px;
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ─── Layout ─────────────────────────────────────────────────────────────── */

.page { max-width: 1360px; margin: 0 auto; padding: 0 32px 64px; }

/* ─── Topbar ─────────────────────────────────────────────────────────────── */

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

.topbar-logo {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent-muted);
  letter-spacing: 0.05em;
}

.topbar-nav { display: flex; gap: 8px; align-items: center; }

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 16px;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--accent-muted);
}
.btn-ghost:hover { border-color: var(--border-hover); color: var(--accent); background: var(--accent-faint); }

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.btn-primary:hover { opacity: 0.88; }

.btn-danger {
  background: transparent;
  border-color: transparent;
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger-dim); }

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ─── Clock (index only) ─────────────────────────────────────────────────── */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 32px 32px;
  text-align: center;
  user-select: none;
}

.clock {
  font-family: var(--font-mono);
  font-size: 80px;
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1;
  text-shadow: 0 0 48px rgba(232, 224, 208, 0.12);
}

.clock-date {
  margin-top: 8px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--accent-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

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

.search-wrap {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 24px auto 0;
}

.search-wrap svg {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--accent-dim);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 11px 16px 11px 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 14px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.search-input::placeholder { color: var(--accent-dim); }
.search-input:focus {
  border-color: rgba(232, 224, 208, 0.22);
  box-shadow: 0 0 0 3px rgba(232, 224, 208, 0.05);
}

/* ─── Sections ───────────────────────────────────────────────────────────── */

.sections { display: flex; flex-direction: column; gap: 36px; }

.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-muted);
  flex: 1;
}

/* ─── Bookmark Grid ──────────────────────────────────────────────────────── */

.bm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.bm-tile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  overflow: hidden;
  transition: border-color 0.16s, box-shadow 0.16s, transform 0.16s, background 0.16s;
}
.bm-tile:hover {
  border-color: var(--border-hover);
  box-shadow: 0 4px 18px rgba(0,0,0,0.38), 0 0 0 1px rgba(232,224,208,0.05);
  background: var(--surface-2);
  transform: translateY(-1px);
}

.bm-favicon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  border-radius: 3px;
  object-fit: contain;
}
.bm-favicon[src=""] { display: none; }

.bm-info { overflow: hidden; flex: 1; min-width: 0; }

.bm-name {
  display: block;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--accent);
}

.bm-domain {
  display: block;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--accent-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

/* ─── Manage: Bookmark list ──────────────────────────────────────────────── */

.bm-list { display: flex; flex-direction: column; gap: 4px; }

.bm-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s;
}
.bm-row:hover { border-color: rgba(232,224,208,0.14); }

.bm-row .bm-favicon { opacity: 0.85; }

.bm-row-info { flex: 1; overflow: hidden; min-width: 0; }

.bm-row-title {
  display: block;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--accent);
}

.bm-row-url {
  display: block;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--accent-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.bm-row-actions { display: flex; gap: 4px; flex-shrink: 0; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--accent-dim);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-icon:hover { background: var(--accent-faint); color: var(--accent); }
.btn-icon.danger:hover { background: var(--danger-dim); color: var(--danger); }
.btn-icon svg { width: 14px; height: 14px; }

/* ─── Editable folder name ───────────────────────────────────────────────── */

.folder-name-input {
  background: transparent;
  border: none;
  border-bottom: 1px dashed var(--border-hover);
  color: var(--accent-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-family: var(--font-ui);
  outline: none;
  width: 200px;
}

/* ─── Dialog / Modal ─────────────────────────────────────────────────────── */

dialog {
  background: #1c1c1c;
  border: 1px solid rgba(232,224,208,0.12);
  border-radius: var(--radius-lg);
  color: var(--accent);
  padding: 28px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.7);
}

dialog::backdrop {
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(2px);
}

.dialog-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--accent);
}

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }

.field label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent-muted);
}

.field input,
.field select {
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus,
.field select:focus { border-color: rgba(232,224,208,0.25); }

.field select option { background: #1c1c1c; }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* ─── Footer ─────────────────────────────────────────────────────────────── */

.site-footer {
  padding: 20px 32px;
  text-align: center;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--accent-dim);
}

/* ─── Empty state ────────────────────────────────────────────────────────── */

.empty {
  padding: 40px 0;
  text-align: center;
  color: var(--accent-dim);
  font-size: 13px;
}

/* ─── Scrollbar ──────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(232,224,208,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(232,224,208,0.2); }
