:root {
  --bg: #f5f6fb; --surface: #ffffff; --text: #111827; --muted: #5b6477; --border: #e3e6f0;
  --accent: #5b5bf0; --accent-2: #8b5cf6; --accent-soft: #eef0ff; --danger: #dc2626;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 14px rgba(16,24,40,.05);
  --shadow-hover: 0 10px 30px rgba(91,91,240,.18);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0e17; --surface: #151827; --text: #eceef7; --muted: #99a1b8; --border: #262a3f;
    --accent: #8083ff; --accent-2: #a78bfa; --accent-soft: #1f2340;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-hover: 0 10px 30px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  --bg: #0c0e17; --surface: #151827; --text: #eceef7; --muted: #99a1b8; --border: #262a3f;
  --accent: #8083ff; --accent-2: #a78bfa; --accent-soft: #1f2340;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-hover: 0 10px 30px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  transition: background .25s, color .25s;
}
.wrap { width: min(1160px, 100% - 32px); margin-inline: auto; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; color: var(--text); text-decoration: none; }
.logo { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: #fff; font-size: .8rem; font-weight: 800; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.actions { display: flex; align-items: center; gap: 8px; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; padding: 9px 14px; font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; transition: transform .15s, background .2s, box-shadow .2s, border-color .2s; }
.btn:active { transform: scale(.97); }
.btn:focus-visible, .card:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 4px 14px rgba(91,91,240,.35); }
.btn-primary:hover { box-shadow: 0 6px 20px rgba(91,91,240,.5); }
.btn-ghost { color: var(--text); background: var(--surface); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-danger { color: #fff; background: var(--danger); }
.icon-btn { padding: 9px; }

/* hero */
.hero { padding: 48px 0 24px; text-align: center; }
.hero h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.1; letter-spacing: -.02em; background: linear-gradient(135deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { margin: 12px 0 0; color: var(--muted); font-size: 1.1rem; }

/* toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0 8px; }
.search { flex: 1 1 280px; display: flex; align-items: center; gap: 10px; padding: 0 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; color: var(--muted); transition: border-color .2s, box-shadow .2s; }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { flex: 1; min-width: 0; border: 0; background: none; color: var(--text); font: inherit; padding: 12px 0; outline: none !important; }
.datefilter { display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; color: var(--muted); font-size: .9rem; }
.datefilter input { border: 0; background: none; color: var(--text); font: inherit; padding: 11px 0; }
.meta { margin: 12px 2px; color: var(--muted); font-size: .9rem; min-height: 1.4em; }

/* grid + cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 20px; padding-bottom: 40px; }
.card { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 22px; color: inherit; text-decoration: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; transition: transform .25s ease, box-shadow .25s ease, border-color .25s; animation: rise .4s ease both; }
.card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); opacity: .85; }
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); border-color: var(--accent); }
.card.new { animation: rise .4s ease both, glow 2.4s ease 2; }
.eyebrow { font-size: .72rem; font-weight: 700; letter-spacing: .12em; color: var(--accent); }
.date { margin: 0; font-size: 1.5rem; line-height: 1.2; letter-spacing: -.01em; }
.title { margin: 0; font-size: .95rem; font-weight: 600; color: var(--text); }
.desc { margin: 0; color: var(--muted); font-size: .93rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { margin-top: auto; padding-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.badge { font-size: .78rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.read { font-weight: 700; color: var(--accent); font-size: .92rem; white-space: nowrap; }
.read span { display: inline-block; transition: transform .2s; }
.card:hover .read span { transform: translateX(4px); }
mark { background: color-mix(in srgb, var(--accent-2) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

.empty { text-align: center; padding: 60px 16px; color: var(--muted); }
.empty h2 { color: var(--text); margin: 0 0 6px; }
.footer { text-align: center; padding: 20px 0 32px; color: var(--muted); font-size: .85rem; }
code { background: var(--accent-soft); color: var(--accent); padding: 1px 6px; border-radius: 6px; }

/* skeleton */
.skeleton { height: 210px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface), var(--accent-soft), var(--surface)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border: 1px solid var(--border); }

/* drop zone, toasts, dialog */
.dropzone { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 22%, transparent); backdrop-filter: blur(4px); pointer-events: none; }
.dropzone div { padding: 28px 40px; border: 3px dashed var(--accent); border-radius: 20px; background: var(--surface); font-weight: 700; font-size: 1.2rem; }
.toasts { position: fixed; z-index: 60; right: 16px; bottom: 16px; left: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.toast { max-width: 420px; padding: 12px 16px; border-radius: 12px; color: #fff; font-weight: 600; font-size: .92rem; box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: rise .3s ease both; }
.toast.ok { background: #16a34a; } .toast.err { background: var(--danger); } .toast.info { background: #334155; }
dialog { width: min(420px, calc(100% - 32px)); padding: 24px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog h2 { margin: 0 0 8px; font-size: 1.15rem; }
dialog p { margin: 0 0 20px; color: var(--muted); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }

@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes glow { 50% { box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-hover); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* responsive */
@media (max-width: 640px) {
  .topbar-inner { height: 58px; }
  .brand span:last-child { font-size: .98rem; }
  .btn-primary span { display: none; } /* icon-only upload button on small phones */
  .btn-primary { padding: 9px 12px; }
  .hero { padding: 32px 0 12px; }
  .datefilter { flex: 1 1 100%; }
  .datefilter input { flex: 1; }
  .grid { grid-template-columns: 1fr; gap: 14px; }
  .toasts { align-items: stretch; } .toast { max-width: none; }
}
@media (min-width: 641px) and (max-width: 900px) { .grid { grid-template-columns: repeat(2, 1fr); } }

.linkbtn { margin-left: 8px; padding: 0; border: 0; background: none; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }
