/* links-digest gallery.css */

:root {
  --bg: #0c0c0c;
  --surface: #161616;
  --card: #1a1a1a;
  --border: #2a2a2a;
  --text: #f0f0f0;
  --text-muted: #a0a0a0;
  --text-dim: #666;
  --text-xdim: #444;
  --accent: #f59e0b;
  --accent-dim: rgba(245, 158, 11, 0.12);
  --red: #ef4444;
  --font: 'Plus Jakarta Sans', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

[data-theme="light"] {
  --bg: #fafafa;
  --surface: #f0f0f0;
  --card: #ffffff;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-muted: #555;
  --text-dim: #888;
  --text-xdim: #aaa;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* Layout */
.layout { max-width: 1400px; margin: 0 auto; padding: 24px 24px 64px; }

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding-bottom: 20px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.header-left h1 { font-size: 1.4rem; letter-spacing: -0.02em; }
.header-left h1 span { color: var(--accent); }
.header-left .sub { font-size: .78rem; margin-top: 4px; color: var(--text-muted); }
.header-right { display: flex; gap: 8px; align-items: center; }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 16px; padding: 8px 0; align-items: center; }
.ctrl { display: flex; align-items: center; gap: 8px; }
.ctrl-label { font-size: .68rem; color: var(--text-xdim); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }

/* Segments */
.segs { display: flex; gap: 4px; }
.seg {
  padding: 5px 10px;
  font-size: .72rem;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}
.seg:hover { border-color: var(--text-xdim); }
.seg.on { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.seg:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Search */
.search-input {
  width: 180px;
  padding: 6px 12px;
  font-size: .75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}
.search-input:focus { outline: none; border-color: var(--accent); }
.search-input::placeholder { color: var(--text-xdim); }

/* Size */
.size-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.size-btn:hover { border-color: var(--text-xdim); }
.size-label { min-width: 36px; text-align: center; font-family: var(--mono); font-size: .7rem; color: var(--text-xdim); }

/* Stats */
.stats { font-family: var(--mono); font-size: .7rem; color: var(--text-xdim); margin-left: auto; }

/* Theme button */
.theme-btn {
  width: 32px; height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  font-size: 1.1rem;
}

/* Download dropdown */
.dl-wrap { position: relative; }
.dl-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 500;
  background: var(--accent);
  color: #000;
  border: none;
  cursor: pointer;
}
.dl-toggle:hover { opacity: .85; }
.dl-toggle svg { width: 14px; height: 14px; }
.dl-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 200px;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
  z-index: 50;
  display: none;
}
.dl-menu.open { display: block; }
.dl-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  text-align: left;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: .75rem;
  color: var(--text);
}
.dl-item:hover { background: var(--surface); }
.dl-item-hint { font-size: .65rem; color: var(--text-xdim); margin-top: 2px; }

/* Group headers */
.group-hdr { display: flex; align-items: center; gap: 8px; margin: 24px 0 12px; padding: 6px 0; border-top: 1px solid var(--border); }
.group-hdr:first-child { margin-top: 0; border-top: none; }
.group-tag { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 4px 10px; border-radius: 6px; font-family: var(--mono); background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(245,158,11,.3); }
.group-cnt { font-family: var(--mono); font-size: .62rem; color: var(--text-xdim); }

/* Card grid */
.card-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
.link-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; transition: border-color .15s, transform .15s; cursor: pointer; }
.link-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.link-card.hidden { display: none; }

/* Card header */
.card-hdr { padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.card-date { font-size: .65rem; color: var(--text-xdim); font-family: var(--mono); margin-bottom: 4px; }
.card-title { font-size: .95rem; font-weight: 600; color: var(--text); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Card body */
.card-body { padding: 14px 16px; }
.card-summary { font-size: .78rem; color: var(--text-muted); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 12px; }

/* Source link */
.card-source { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-source a { font-size: .7rem; font-family: var(--mono); color: var(--accent); text-decoration: none; word-break: break-all; }
.card-source a:hover { text-decoration: underline; }

/* Tags */
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
.tag { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: .6rem; font-weight: 500; letter-spacing: .02em; background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(245,158,11,.2); }

/* Badges */
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.bdg { display: inline-block; padding: 2px 7px; border-radius: 4px; font-family: var(--mono); font-size: .6rem; font-weight: 600; letter-spacing: .04em; border: 1px solid; }
.bdg-github { background: rgba(36,41,46,0.8); color: #adbac7; border-color: #444c56; }
.bdg-x { background: rgba(29,155,240,0.15); color: #1d9bf0; border-color: rgba(29,155,240,.3); }
.bdg-web { background: rgba(34,197,94,0.15); color: #22c55e; border-color: rgba(34,197,94,.3); }
.bdg-reddit { background: rgba(255,69,0,0.15); color: #ff4500; border-color: rgba(255,69,0,.3); }
.bdg-gist { background: rgba(139,92,246,0.15); color: #8b5cf6; border-color: rgba(139,92,246,.3); }
.bdg-youtube { background: rgba(239,68,68,0.15); color: #ef4444; border-color: rgba(239,68,68,.3); }

/* Download button */
.dl-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 6px; font-size: .72rem; font-weight: 500; background: var(--accent); color: #000; border: none; cursor: pointer; transition: opacity .15s; }
.dl-btn:hover { opacity: .85; }
.dl-btn svg { width: 14px; height: 14px; }

/* Card actions */
.card-actions { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.expand-hint { font-size: .65rem; color: var(--text-xdim); font-style: italic; }

/* List view */
.list-view { display: flex; flex-direction: column; gap: 0; }
.list-row { display: grid; grid-template-columns: 100px 1fr auto auto; gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--card); cursor: pointer; transition: background .1s; }
.list-row:hover { background: var(--surface); }
.list-row:last-child { border-bottom: none; border-radius: 0 0 8px 8px; }
.list-date { font-family: var(--mono); font-size: .68rem; color: var(--text-xdim); }
.list-title { font-size: .82rem; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-source { font-size: .6rem; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; font-family: var(--mono); }
.list-tags { display: flex; gap: 4px; flex-wrap: nowrap; overflow: hidden; max-width: 200px; }
.list-tags .tag { font-size: .58rem; padding: 2px 5px; }

/* Content Modal */
.content-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 100; justify-content: center; align-items: flex-start; padding: 40px 24px; overflow-y: auto; }
.content-modal.active { display: flex; }
.modal-inner { max-width: 900px; width: 100%; background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: 0 24px 48px rgba(0,0,0,.4); }
.modal-hdr { display: flex; justify-content: space-between; align-items: flex-start; padding: 16px 20px; background: var(--surface); border-bottom: 1px solid var(--border); gap: 16px; }
.modal-hdr h3 { font-size: 1.1rem; font-weight: 600; color: var(--text); margin: 0; line-height: 1.4; }
.modal-date { font-size: .7rem; color: var(--text-xdim); margin-top: 4px; }
.modal-close { font-size: 20px; color: var(--text-xdim); cursor: pointer; background: none; border: none; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; max-height: 70vh; overflow-y: auto; }
.modal-body.loading { display: flex; align-items: center; justify-content: center; min-height: 200px; }
.modal-body.loading::after { content: "Loading..."; color: var(--text-xdim); font-size: .9rem; }
.modal-footer { display: flex; gap: 12px; padding: 16px 20px; background: var(--surface); border-top: 1px solid var(--border); }
.modal-footer a { font-size: .75rem; color: var(--accent); }

/* Markdown content */
.md-content { font-size: .85rem; line-height: 1.7; color: var(--text-muted); }
.md-content h1 { font-size: 1.3rem; font-weight: 600; color: var(--text); margin: 0 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.md-content h2 { font-size: 1.1rem; font-weight: 600; color: var(--text); margin: 24px 0 12px; }
.md-content p { margin: 0 0 12px; }
.md-content ul, .md-content ol { margin: 0 0 12px 20px; }
.md-content li { margin-bottom: 6px; }
.md-content code { font-family: var(--mono); font-size: .78rem; background: var(--surface); padding: 2px 6px; border-radius: 4px; }
.md-content pre { background: var(--surface); padding: 12px 16px; border-radius: 8px; overflow-x: auto; margin: 0 0 16px; }
.md-content pre code { background: none; padding: 0; }
.md-content table { width: 100%; border-collapse: collapse; margin: 0 0 16px; font-size: .78rem; }
.md-content th, .md-content td { padding: 8px 12px; border: 1px solid var(--border); text-align: left; }
.md-content th { background: var(--surface); font-weight: 600; color: var(--text); }
.md-content td { color: var(--text-dim); }
.md-content a { color: var(--accent); text-decoration: none; }
.md-content a:hover { text-decoration: underline; }
.md-content strong { color: var(--text); font-weight: 600; }
.md-content hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* Empty state */
.empty { text-align: center; padding: 60px 20px; color: var(--text-xdim); }

/* Toast */
.toast { position: fixed; bottom: 20px; right: 20px; padding: 12px 20px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; font-size: .78rem; color: var(--text); box-shadow: 0 8px 24px rgba(0,0,0,.3); z-index: 100; animation: toastIn .3s ease; }
.toast.err { border-color: var(--red); color: var(--red); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Responsive */
@media (max-width: 640px) {
  .card-grid { grid-template-columns: 1fr !important; }
  .toolbar { flex-wrap: wrap; }
  .search-input { width: 120px; }
  .content-modal { padding: 20px 12px; }
  .modal-body { max-height: 60vh; }
}
