/* Science Process Sudria — shared design system (guest + admin) */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e4e8f0;
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-soft: #eef0ff;
  --accent: #0ea5a4;
  --danger: #e11d48;
  --danger-soft: #ffe4ea;
  --success: #059669;
  --success-soft: #d9f7ec;
  --warn: #d97706;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 10px 30px -12px rgba(15, 23, 42, .18);
  --shadow-lg: 0 24px 60px -20px rgba(79, 70, 229, .35);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b1020;
  --surface: #121933;
  --surface-2: #19213f;
  --text: #e8ecf8;
  --muted: #94a0c0;
  --border: #243055;
  --primary: #818cf8;
  --primary-600: #6366f1;
  --primary-soft: #1d2447;
  --accent: #2dd4bf;
  --danger: #fb7185;
  --danger-soft: #3a1522;
  --success: #34d399;
  --success-soft: #0f2e27;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6);
  --shadow-lg: 0 24px 60px -20px rgba(99, 102, 241, .4);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.02em; }

.container { width: min(1180px, 100% - 2.5rem); margin-inline: auto; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .65rem 1.1rem; border-radius: 12px; border: 1px solid transparent;
  font: 600 .92rem/1 var(--font); cursor: pointer; text-decoration: none !important;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary-600); color: #fff; box-shadow: 0 8px 20px -8px var(--primary-600); }
.btn-primary:hover { background: var(--primary); box-shadow: 0 12px 24px -8px var(--primary-600); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: .45rem .75rem; font-size: .82rem; border-radius: 10px; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: 12px; }

/* Chips */
.chip {
  display: inline-flex; align-items: center; padding: .2rem .65rem; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary); font-size: .76rem; font-weight: 600;
}
.chip-muted { background: var(--surface-2); color: var(--muted); }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* Forms */
.field { margin-bottom: 1.25rem; }
.label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .4rem; }
.hint { color: var(--muted); font-size: .8rem; margin-top: .3rem; }
.input, .textarea, select.input {
  width: 100%; padding: .75rem .95rem; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: 500 .95rem var(--font);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 20%, transparent);
}
.error-text { color: var(--danger); font-size: .82rem; margin-top: .3rem; }

/* Theme toggle */
.theme-toggle { cursor: pointer; background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.theme-toggle:hover { background: var(--surface-2); }

/* Alerts */
.alert { padding: .9rem 1.1rem; border-radius: 12px; margin-bottom: 1rem; font-size: .92rem; }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert ul { margin: .35rem 0 0; padding-left: 1.1rem; }

/* ================= Guest ================= */
.site-nav {
  position: sticky; top: 0; z-index: 50; backdrop-filter: saturate(180%) blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent); border-bottom: 1px solid var(--border);
}
.site-nav .container { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.brand { display: flex; align-items: center; gap: .7rem; font-weight: 800; color: var(--text); letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand img { height: 44px; width: 44px; object-fit: contain; background: #fff; border-radius: 12px; padding: 2px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.brand span { line-height: 1.1; font-size: 1.02rem; }
.brand small { display: block; font-weight: 600; font-size: .72rem; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.nav-actions { display: flex; gap: .6rem; align-items: center; }

.hero {
  position: relative; overflow: hidden; padding: 5rem 0 4rem; text-align: center;
  background:
    radial-gradient(60% 60% at 15% 0%, color-mix(in srgb, var(--primary) 22%, transparent), transparent 70%),
    radial-gradient(50% 60% at 90% 10%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 70%);
}
.hero .logo { width: min(260px, 60%); margin-bottom: 1.5rem; filter: drop-shadow(0 10px 24px rgba(0,0,0,.12)); }
.hero h1 { font-size: clamp(2rem, 5vw, 3.4rem); font-weight: 800; }
.hero h1 span { background: linear-gradient(90deg, var(--primary), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { max-width: 760px; margin: 1rem auto 0; color: var(--muted); font-size: 1.05rem; }
.hero .badges { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; margin-bottom: 1.2rem; }

.section { padding: 3.5rem 0; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.6rem; }
.section-head h2 { font-size: 1.7rem; margin: 0; }
.search {
  position: relative; width: min(360px, 100%);
}
.search i { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 2.6rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.4rem; }
.article-card {
  display: flex; flex-direction: column; padding: 1.5rem; height: 100%;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  color: var(--text);
}
.article-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--primary); text-decoration: none; }
.article-card .icon {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; font-size: 1.15rem;
}
.article-card h3 { font-size: 1.15rem; margin-bottom: .5rem; }
.article-card p { color: var(--muted); font-size: .92rem; margin: 0 0 1rem; flex: 1; }
.article-card .meta { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.article-card .tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1rem; }
.empty { text-align: center; padding: 4rem 1rem; color: var(--muted); }

.page-hero { padding: 3.5rem 0 2rem; background: radial-gradient(60% 80% at 20% 0%, color-mix(in srgb, var(--primary) 18%, transparent), transparent 70%); }
.page-hero h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 800; }
.crumbs { color: var(--muted); font-size: .88rem; margin-bottom: 1rem; }
.prose { font-size: 1.05rem; color: var(--text); }
.prose p { margin: 0 0 1rem; }
.prose img { border-radius: 12px; height: auto; }
.prose table { border-collapse: collapse; width: 100%; }
.prose td, .prose th { border: 1px solid var(--border); padding: .5rem .7rem; }

.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.2rem; }
.doc-card { padding: 1.4rem; text-align: center; }
.doc-card .pdf {
  width: 64px; height: 64px; margin: 0 auto 1rem; border-radius: 18px; display: grid; place-items: center;
  background: var(--danger-soft); color: var(--danger); font-size: 1.7rem;
}
.doc-card h3 { font-size: 1.05rem; }
.doc-card .btn { width: 100%; }

.site-footer { border-top: 1px solid var(--border); padding: 2rem 0; color: var(--muted); font-size: .88rem; text-align: center; }

/* ================= Auth ================= */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art {
  position: relative; padding: 3rem; color: #fff; display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(140deg, #4338ca, #0ea5a4);
  overflow: hidden;
}
.auth-art::before, .auth-art::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,.08); }
.auth-art::before { width: 420px; height: 420px; right: -120px; top: -120px; }
.auth-art::after { width: 300px; height: 300px; left: -80px; bottom: -80px; }
.auth-art h2 { font-size: 2.2rem; position: relative; z-index: 1; }
.auth-art p { position: relative; z-index: 1; opacity: .9; max-width: 420px; }
.auth-art .logo-pill { background: #fff; border-radius: 16px; padding: .6rem 1rem; display: inline-block; position: relative; z-index: 1; }
.auth-art .logo-pill img { height: 40px; display: block; }
.auth-form { display: grid; place-items: center; padding: 2rem; }
.auth-form .box { width: min(400px, 100%); }
.auth-form h1 { font-size: 1.9rem; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .9rem; color: var(--muted); margin-bottom: 1.2rem; }

/* ================= Admin ================= */
.admin { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 1.4rem 1rem; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
}
.sidebar .brand { padding: 0 .6rem 1.2rem; }
.side-title { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding: .8rem .8rem .4rem; font-weight: 700; }
.side-link {
  display: flex; align-items: center; gap: .8rem; padding: .7rem .8rem; border-radius: 12px; color: var(--muted);
  font-weight: 600; font-size: .93rem; margin-bottom: .2rem;
}
.side-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.side-link.active { background: var(--primary-soft); color: var(--primary); }
.side-link i { width: 1.1rem; text-align: center; }
.side-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 1rem; }
.user-pill { display: flex; align-items: center; gap: .7rem; padding: .4rem .6rem; margin-bottom: .6rem; }
.avatar {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
}
.user-pill small { color: var(--muted); display: block; line-height: 1.2; }

.admin-main { min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 2rem;
  border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 1.35rem; margin: 0; }
.menu-btn { display: none; }
.admin-content { padding: 2rem; max-width: 1200px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1.2rem; margin-bottom: 1.8rem; }
.stat { padding: 1.4rem; display: flex; align-items: center; gap: 1rem; }
.stat .ico { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 1.3rem; background: var(--primary-soft); color: var(--primary); }
.stat .ico.teal { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.stat .ico.rose { background: var(--danger-soft); color: var(--danger); }
.stat b { font-size: 1.9rem; display: block; line-height: 1.1; letter-spacing: -.03em; }
.stat span { color: var(--muted); font-size: .86rem; }

.panel { padding: 1.5rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.panel-head h2 { font-size: 1.15rem; margin: 0; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .7rem 1rem; border-bottom: 1px solid var(--border); }
.table td { padding: 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .title { font-weight: 700; }
.table .actions { display: flex; gap: .4rem; justify-content: flex-end; }
.table .desc { color: var(--muted); font-size: .88rem; max-width: 380px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pagination { display: flex; gap: .3rem; justify-content: center; margin-top: 1.4rem; flex-wrap: wrap; }
.pagination a, .pagination span {
  min-width: 38px; height: 38px; padding: 0 .7rem; display: inline-grid; place-items: center; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600; font-size: .88rem;
}
.pagination a:hover { text-decoration: none; background: var(--surface-2); }
.pagination .active span { background: var(--primary-600); color: #fff; border-color: var(--primary-600); }
.pagination .disabled span { opacity: .45; }

.file-drop {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 1.6rem; text-align: center; color: var(--muted);
  background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; display: block;
}
.file-drop:hover, .file-drop.drag { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.file-drop input { display: none; }
.file-drop i { font-size: 1.8rem; display: block; margin-bottom: .4rem; }
.file-list { list-style: none; margin: .8rem 0 0; padding: 0; display: grid; gap: .5rem; }
.file-list li { display: flex; align-items: center; gap: .7rem; padding: .6rem .9rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); font-size: .88rem; }
.file-list li i { color: var(--danger); }
.file-list label { margin-left: auto; display: flex; align-items: center; gap: .4rem; color: var(--danger); font-size: .82rem; cursor: pointer; }
.form-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.5rem; padding-top: 1.2rem; border-top: 1px solid var(--border); }

/* Modal (delete confirm) */
.modal-back { position: fixed; inset: 0; background: rgba(8, 12, 28, .55); backdrop-filter: blur(4px); display: none; place-items: center; z-index: 100; padding: 1rem; }
.modal-back.open { display: grid; }
.modal { width: min(420px, 100%); padding: 1.8rem; text-align: center; box-shadow: var(--shadow); }
.modal .ico { width: 56px; height: 56px; margin: 0 auto 1rem; border-radius: 18px; background: var(--danger-soft); color: var(--danger); display: grid; place-items: center; font-size: 1.4rem; }
.modal .row { display: flex; gap: .6rem; justify-content: center; margin-top: 1.4rem; }

.toast {
  position: fixed; right: 1.2rem; bottom: 1.2rem; z-index: 120; padding: .9rem 1.2rem; border-radius: 14px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); display: flex; gap: .6rem; align-items: center;
  animation: toast-in .3s ease, toast-out .4s ease 3.6s forwards;
}
.toast.ok i { color: var(--success); } .toast.err i { color: var(--danger); }
@keyframes toast-in { from { transform: translateY(14px); opacity: 0; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(14px); } }

/* PDF viewer (inline + fullscreen + reader page) */
.pdfv { position: relative; display: flex; flex-direction: column; background: #0a0e1d; color: #e8ecf8; border: 1px solid #243055; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.pdfv + .pdfv { margin-top: 1.6rem; }
.pdfv-bar { min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .5rem 1rem; background: #121933; border-bottom: 1px solid #243055; flex-wrap: wrap; }
.pdfv-bar .title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pdfv-left { display: flex; align-items: center; gap: .8rem; min-width: 0; }
.pdfv-tools { display: flex; align-items: center; gap: .4rem; }
.pdfv-tools .btn, .pdfv-bar .btn-dark { background: #19213f; color: #e8ecf8; border: 1px solid #243055; text-decoration: none; }
.pdfv-tools .btn:hover, .pdfv-bar .btn-dark:hover { background: #243055; }
.pdfv-tools .pg { font-size: .82rem; color: #94a0c0; padding: 0 .5rem; white-space: nowrap; min-width: 3.2rem; text-align: center; }
.pdfv-stage { height: min(78vh, 900px); overflow: auto; padding: 1.2rem .8rem 2rem; position: relative; }
.pdfv-full .pdfv-stage, .pdfv:fullscreen .pdfv-stage, .pdfv:-webkit-full-screen .pdfv-stage { height: calc(100vh - 56px); }
.pdfv-full { border-radius: 0; border: 0; height: 100vh; }
.pdfv:fullscreen { border-radius: 0; border: 0; width: 100vw; height: 100vh; }
.pdfv:-webkit-full-screen { border-radius: 0; border: 0; width: 100vw; height: 100vh; }
.pdf-page { position: relative; margin: 0 auto 1.2rem; width: fit-content; max-width: 100%; box-shadow: 0 20px 50px -20px #000; border-radius: 6px; overflow: hidden; background: #fff; }
.pdf-page canvas { display: block; max-width: 100%; height: auto !important; pointer-events: none; }
.wm { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }
.wm span { position: absolute; left: 50%; top: 50%; white-space: nowrap; transform: translate(-50%, -50%) rotate(-30deg); font-weight: 800; font-size: clamp(1.2rem, 4vw, 2.4rem); color: rgba(79, 70, 229, .13); letter-spacing: .08em; }
.pdfv-state { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: #94a0c0; padding: 2rem; }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 4px solid #243055; border-top-color: #818cf8; animation: spin .8s linear infinite; margin: 0 auto 1rem; }
@keyframes spin { to { transform: rotate(360deg); } }
.pdfv-lock { position: absolute; inset: 0; z-index: 5; background: #0a0e1d; color: #e8ecf8; display: none; place-items: center; text-align: center; padding: 2rem; }
.pdfv.locked .pdfv-lock { display: grid; }
.pdfv-lock i { font-size: 2.2rem; color: #fb7185; margin-bottom: 1rem; display: block; }
.reader-page { background: #0a0e1d; margin: 0; height: 100vh; overflow: hidden; }
@media print { .pdfv { display: none !important; } }

/* Responsive */
@media (max-width: 960px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .admin { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 90; width: 270px; transform: translateX(-100%); transition: transform .25s ease; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .menu-btn { display: inline-flex; }
  .topbar, .admin-content { padding-inline: 1.2rem; }
}
@media (max-width: 560px) {
  .hero { padding: 3rem 0 2.5rem; }
  .table .hide-sm { display: none; }
}

/* Admin: moderation, members */
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.chip-ok { background: var(--success-soft); color: var(--success); }
.cell-user { display: flex; align-items: center; gap: .8rem; }
.cell-avatar { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; overflow: hidden; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--primary), var(--accent)); }
.cell-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mod-item { display: flex; gap: 1rem; padding: 1.1rem 0; border-top: 1px solid var(--border); }
.mod-item:first-of-type { border-top: 0; }
.mod-main { flex: 1; min-width: 0; }
.mod-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.mod-head small, .mod-meta { color: var(--muted); font-size: .82rem; }
.mod-quote { margin-top: .4rem; padding: .4rem .7rem; border-left: 3px solid var(--border); color: var(--muted); font-size: .86rem; background: var(--surface-2); border-radius: 0 8px 8px 0; }
.mod-body { margin: .45rem 0 .3rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.mod-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .8rem; }
.reply-box { margin-top: .8rem; }
.reply-box .textarea { min-height: 0; }
