:root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #f0f1f8;
  --border: #e4e6f0;
  --text: #171a2c;
  --muted: #6a6f87;
  --primary: #4f46e5;
  --primary-2: #6d64ff;
  --primary-soft: #ecebff;
  --accent: #f59e0b;
  --accent-soft: #fff4dd;
  --success: #10a36b;
  --success-soft: #e3f7ee;
  --danger: #e0434f;
  --danger-soft: #fde9eb;
  --shadow: 0 1px 2px rgba(20, 22, 50, .04), 0 8px 24px rgba(20, 22, 50, .06);
  --radius: 16px;
  --sidebar-w: 256px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1120;
    --surface: #171a2d;
    --surface-2: #1f2338;
    --border: #2a2e47;
    --text: #eceefa;
    --muted: #9aa0bd;
    --primary: #7c74ff;
    --primary-2: #9a93ff;
    --primary-soft: #26254a;
    --accent: #fbbf24;
    --accent-soft: #3a2e14;
    --success: #34d399;
    --success-soft: #133328;
    --danger: #f87171;
    --danger-soft: #3b1a1e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
button { font: inherit; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  transition: transform .25s ease;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; color: var(--text); }
.logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; font-weight: 800; font-size: 17px;
  display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(79, 70, 229, .35);
}
.brand-text { display: flex; flex-direction: column; }
.brand-text strong { font-size: 15px; }
.brand-text span { font-size: 12px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 12px;
  color: var(--muted); font-weight: 600; font-size: 14.5px;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }

.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.admin-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  background: var(--accent-soft); color: var(--text); font-size: 13px; margin-bottom: 8px;
}
.admin-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 18px 32px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
}
.topbar h1 { font-size: 22px; font-weight: 800; }
.topbar-right { margin-left: auto; display: flex; gap: 8px; }
.icon-btn.menu-btn { display: none; }
.view { padding: 8px 32px 48px; max-width: 1240px; }
.backdrop { display: none; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 700; font-size: 14px; cursor: pointer;
  background: var(--surface-2); color: var(--text);
  transition: transform .1s, background .15s, opacity .15s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.sm { padding: 7px 11px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  display: inline-grid; place-items: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 9px; }
.icon-btn.sm svg { width: 16px; height: 16px; }
.icon-btn.star.on { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.icon-btn.star.on svg { fill: currentColor; }
.icon-btn.del:hover { color: var(--danger); background: var(--danger-soft); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 700; }
.field .hint { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; padding: 11px 13px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: 14.5px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea.input { resize: vertical; min-height: 90px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkbox { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; cursor: pointer; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--primary); }

.form-error {
  background: var(--danger-soft); color: var(--danger);
  padding: 10px 12px; border-radius: 10px; font-size: 13.5px; font-weight: 600; margin-bottom: 14px;
}

/* ---------- Hero & stats ---------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: 22px; padding: 32px;
  background: linear-gradient(120deg, #4f46e5 0%, #7c3aed 55%, #db2777 100%);
  color: #fff; margin-bottom: 22px;
}
.hero::after {
  content: ""; position: absolute; right: -60px; top: -60px;
  width: 260px; height: 260px; border-radius: 50%;
  background: rgba(255, 255, 255, .12);
}
.hero::before {
  content: ""; position: absolute; right: 120px; bottom: -90px;
  width: 200px; height: 200px; border-radius: 50%;
  background: rgba(255, 255, 255, .08);
}
.hero > * { position: relative; z-index: 1; }
.eyebrow { font-size: 13px; font-weight: 700; opacity: .85; margin: 0 0 6px; letter-spacing: .3px; }
.hero h2 { font-size: 28px; font-weight: 800; max-width: 560px; }
.hero p.sub { opacity: .9; max-width: 520px; margin: 10px 0 20px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero .btn.primary { background: #fff; color: #4f46e5; }
.hero .btn.ghost { color: #fff; border-color: rgba(255, 255, 255, .45); }
.hero .btn.ghost:hover { background: rgba(255, 255, 255, .12); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 14px;
}
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; }
.stat-icon.c1 { background: var(--primary-soft); color: var(--primary); }
.stat-icon.c2 { background: #e0f2fe; color: #0284c7; }
.stat-icon.c3 { background: var(--success-soft); color: var(--success); }
.stat-icon.c4 { background: var(--accent-soft); color: var(--accent); }
@media (prefers-color-scheme: dark) { .stat-icon.c2 { background: #0c2a3d; color: #38bdf8; } }
.stat b { font-size: 24px; font-weight: 800; display: block; line-height: 1.1; }
.stat span { font-size: 13px; color: var(--muted); font-weight: 600; }

/* ---------- Panels ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h3 { font-size: 16px; font-weight: 800; }
.panel-head a { font-size: 13px; font-weight: 700; }

.mini-list { display: flex; flex-direction: column; gap: 4px; }
.mini-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px; border-radius: 12px; cursor: pointer;
  color: var(--text); background: none; border: none; text-align: left; width: 100%;
}
.mini-item:hover { background: var(--surface-2); }
.mini-thumb { width: 72px; aspect-ratio: 16/9; border-radius: 8px; object-fit: cover; background: var(--surface-2); }
.mini-body { min-width: 0; flex: 1; }
.mini-body b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-body span { font-size: 12.5px; color: var(--muted); }

/* ---------- Toolbar & chips ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar .search { position: relative; flex: 1; min-width: 220px; }
.toolbar .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }
.toolbar .search .input { padding-left: 40px; }
.toolbar select.input { width: auto; min-width: 170px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font-weight: 700; font-size: 13.5px; cursor: pointer;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--text); color: var(--surface); border-color: var(--text); }

/* ---------- Materi cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  transition: transform .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(20, 22, 50, .05), 0 14px 30px rgba(20, 22, 50, .1); }
.thumb { position: relative; aspect-ratio: 16/9; background: var(--surface-2); cursor: pointer; overflow: hidden; border: none; padding: 0; width: 100%; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.play {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: linear-gradient(to top, rgba(0, 0, 0, .35), transparent 60%);
}
.play span {
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255, 255, 255, .95); color: var(--primary);
  display: grid; place-items: center; box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
  transition: transform .15s;
}
.thumb:hover .play span { transform: scale(1.08); }
.play svg { fill: currentColor; stroke: none; margin-left: 3px; }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-body h4 { font-size: 15.5px; font-weight: 800; }
.card-body p { margin: 0; color: var(--muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 8px; }
.card-actions { display: flex; gap: 6px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 800;
  background: var(--primary-soft); color: var(--primary); width: fit-content;
}
.badge.cat-AI { background: #ede9fe; color: #7c3aed; }
.badge.cat-Figma { background: #ffe4e6; color: #e11d48; }
.badge.cat-Adobe-Illustrator { background: #ffedd5; color: #c2410c; }
.badge.cat-Adobe-Photoshop { background: #dbeafe; color: #1d4ed8; }
.badge.cat-Lainnya { background: var(--surface-2); color: var(--muted); }
@media (prefers-color-scheme: dark) {
  .badge.cat-AI { background: #2e2350; color: #c4b5fd; }
  .badge.cat-Figma { background: #3d1a24; color: #fda4af; }
  .badge.cat-Adobe-Illustrator { background: #3b2412; color: #fdba74; }
  .badge.cat-Adobe-Photoshop { background: #172a4d; color: #93c5fd; }
}
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.wait { background: var(--surface-2); color: var(--muted); }
.badge.star { background: var(--accent-soft); color: var(--accent); }
.badge svg { width: 12px; height: 12px; }

/* ---------- Tugas list ---------- */
.sub-list { display: flex; flex-direction: column; gap: 10px; }
.sub-row {
  display: grid; grid-template-columns: 1.4fr 1.4fr auto auto; gap: 16px; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow);
}
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px;
}
.who-text { min-width: 0; }
.who-text b { display: block; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-text span { font-size: 12.5px; color: var(--muted); }
.sub-title { min-width: 0; }
.sub-title b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700; color: var(--muted);
  background: var(--surface-2); padding: 3px 8px; border-radius: 8px;
}
.pill svg { width: 13px; height: 13px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- Galeri ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.gallery.small { grid-template-columns: repeat(3, 1fr); }
.art {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  cursor: pointer; transition: transform .15s; text-align: left; padding: 0; color: var(--text);
  display: flex; flex-direction: column;
}
.art:hover { transform: translateY(-3px); }
.art-cover { aspect-ratio: 4/3; background: var(--surface-2); position: relative; overflow: hidden; }
.art-cover img { width: 100%; height: 100%; object-fit: cover; }
.art-placeholder {
  width: 100%; height: 100%; display: grid; place-items: center; color: #fff;
  font-size: 40px; font-weight: 800;
}
.art-cover .badge { position: absolute; top: 10px; left: 10px; box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }
.art-body { padding: 14px 16px 16px; }
.art-body h4 { font-size: 15px; font-weight: 800; margin-bottom: 4px; }
.art-body .by { font-size: 13px; color: var(--muted); }
.art-body .quote { font-size: 13px; color: var(--muted); margin-top: 8px; font-style: italic; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Empty & loading ---------- */
.empty {
  text-align: center; padding: 48px 20px;
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
  color: var(--muted);
}
.empty svg { width: 40px; height: 40px; color: var(--primary); margin-bottom: 10px; }
.empty h4 { color: var(--text); font-size: 16px; margin-bottom: 4px; }
.empty p { margin: 0 0 14px; font-size: 14px; }
.empty.compact { padding: 22px; border: none; background: var(--surface-2); }
.loading { padding: 40px; text-align: center; color: var(--muted); font-weight: 600; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 12, 30, .55); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 20px;
  animation: fade .15s ease;
}
.modal[hidden] { display: none; }
.modal-card {
  position: relative; width: 100%; max-width: 520px; max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--surface); border-radius: 20px; padding: 26px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  animation: pop .18s ease;
}
.modal-card.wide { max-width: 860px; }
.modal-close {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  width: 34px; height: 34px; border-radius: 10px; border: none;
  background: var(--surface-2); color: var(--text); cursor: pointer; display: grid; place-items: center;
}
.modal h3 { font-size: 20px; font-weight: 800; margin-bottom: 4px; padding-right: 40px; }
.modal .lead { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.video-wrap { aspect-ratio: 16/9; border-radius: 14px; overflow: hidden; background: #000; margin: 14px 0; }
.video-wrap iframe { width: 100%; height: 100%; border: 0; }
.yt-preview { display: flex; gap: 10px; align-items: center; margin-top: 8px; font-size: 13px; color: var(--success); font-weight: 700; }
.yt-preview img { width: 96px; border-radius: 8px; }

.detail-img { border-radius: 14px; overflow: hidden; margin: 14px 0; background: var(--surface-2); }
.detail-img img { width: 100%; max-height: 420px; object-fit: contain; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; font-size: 14px; margin: 14px 0; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }
.links { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.grade-box { border-radius: 14px; padding: 16px; background: var(--surface-2); }
.grade-box.done { background: var(--success-soft); }
.grade-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grade-score { font-size: 32px; font-weight: 800; color: var(--success); line-height: 1; }
.grade-score small { font-size: 14px; color: var(--muted); }
.grade-box p { margin: 10px 0 0; white-space: pre-wrap; font-size: 14px; }
.current-file { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 13.5px; margin-bottom: 8px; }
.current-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200;
  background: var(--text); color: var(--surface);
  padding: 12px 18px; border-radius: 12px; font-weight: 700; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25); animation: up .2s ease;
  max-width: calc(100vw - 32px);
}
.toast.err { background: var(--danger); color: #fff; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes up { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .sub-row { grid-template-columns: 1fr 1fr; }
  .sub-row .status-cell { justify-self: start; }
}
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .gallery.small { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0, 0, 0, .2); }
  .backdrop.show { display: block; position: fixed; inset: 0; background: rgba(10, 12, 30, .45); z-index: 30; }
  .main { margin-left: 0; }
  .icon-btn.menu-btn { display: inline-grid; }
  .topbar { padding: 14px 16px; }
  .topbar h1 { font-size: 19px; }
  .view { padding: 4px 16px 40px; }
  .hero { padding: 24px 20px; }
  .hero h2 { font-size: 22px; }
}
@media (max-width: 560px) {
  .stats { gap: 10px; }
  .stat { padding: 14px; gap: 10px; }
  .stat-icon { width: 38px; height: 38px; }
  .stat b { font-size: 20px; }
  .sub-row { grid-template-columns: 1fr; gap: 10px; }
  .row-actions { justify-content: flex-start; }
  .row-2 { grid-template-columns: 1fr; gap: 0; }
  .gallery.small { grid-template-columns: 1fr; }
  .modal { padding: 10px; }
  .modal-card { padding: 20px 18px; }
  .kv { grid-template-columns: 90px 1fr; }
  .topbar-right .btn span { display: none; }
}
