:root {
  --bg: #F8F5F0;
  --card: #FFFFFF;
  --text: #30282B;
  --muted: #6E6266;
  --primary: #681D33;
  --primary-dark: #4E1326;
  --accent: #AD9683;
  --accent-soft: #F3EEE9;
  --border: #E8DED7;
  --focus: rgba(104, 29, 51, 0.28);
  --danger: #9B1C1C;
  --danger-bg: #FBEDEC;
  --ok-text: #245C3A;
  --ok-bg: #E9F4EC;
  --warn-bg: #FBF4E8;
  --warn-text: #7A5418;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(48, 40, 43, 0.06), 0 4px 14px rgba(48, 40, 43, 0.05);
  --font: "Inter", "Segoe UI", "Helvetica Neue", Arial, system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  overflow-x: hidden;
}
img, video { max-width: 100%; }

/* ---------- Navigasi utama ---------- */
.topbar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 24px;
  padding: 10px 32px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
/* ---------- Sidebar kiri + kolom utama ---------- */
.app-shell { display: flex; align-items: stretch; min-height: 100vh; position: relative; z-index: 1; }
.main-col { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.sidebar {
  flex: 0 0 248px; width: 248px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--card); border-right: 1px solid var(--border); padding: 18px 14px 20px;
  display: flex; flex-direction: column; gap: 18px; z-index: 30;
}
/* Desktop: sidebar bisa ditutup; konten melebar mengikuti ruang yang tersisa. */
.app-shell:not(.nav-buka) .sidebar { display: none; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; border-bottom: 1px solid var(--border); }
.sidebar-brand img { width: 44px; height: 44px; flex: 0 0 auto; display: block; }
.sidebar-keluar { margin-top: auto; width: 100%; }
.halaman-masuk { background: var(--bg); }
.masuk-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.masuk-kartu { width: 100%; max-width: 380px; text-align: center; padding: 28px 24px; }
.masuk-simbol { width: 72px; height: 72px; margin: 0 auto 6px; display: block; }
.masuk-kartu h1 { font-size: 1.35rem; margin-bottom: 6px; }
.masuk-kartu form { display: grid; gap: 14px; margin-top: 18px; text-align: left; }
.masuk-kartu .actions { justify-content: stretch; margin-top: 4px; }
.masuk-kartu .btn { width: 100%; }
.sidebar-brand .brand-teks { font-size: 1.12rem; }
.menu-utama { display: flex; flex-direction: column; gap: 4px; }
.menu-utama a {
  display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none;
  font-size: 0.97rem; font-weight: 500; padding: 10px 12px; border-radius: 10px;
  border-left: 3px solid transparent; transition: background 0.15s ease, color 0.15s ease;
}
.menu-utama a svg { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.menu-utama a:hover { background: var(--accent-soft); }
.menu-utama a[aria-current="page"] { color: var(--primary); font-weight: 600; background: #F6EDEF; border-left-color: var(--primary); }
.menu-utama a:focus-visible { outline: 3px solid var(--focus); outline-offset: -2px; }
.sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(48, 40, 43, 0.36); z-index: 25; }
[hidden] { display: none !important; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 12px 24px;
  background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.menu-toggle {
  position: relative; z-index: 31;
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px;
  border-radius: 10px; border: 1px solid #D6CAC1; background: #fff; color: var(--text);
  font-size: 1.3rem; line-height: 1; cursor: pointer; flex: 0 0 auto;
}
.menu-toggle:hover { background: var(--accent-soft); border-color: var(--accent); }
.menu-toggle:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.topbar-judul { font-family: Georgia, "Times New Roman", serif; font-weight: 700; color: var(--primary); letter-spacing: 0.08em; font-size: 1rem; }

/* Logo mengambang: dekorasi tetap di belakang konten, tidak menerima klik, tidak menambah scroll. */
.dekor { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.dekor-logo { position: absolute; width: min(60vw, 680px); height: auto; opacity: 0.04; user-select: none; }
.dekor-1 { right: -14vw; bottom: -12vh; animation: melayang-a 26s ease-in-out infinite; }
.dekor-2 { left: -22vw; top: -16vh; width: min(46vw, 520px); animation: melayang-b 31s ease-in-out infinite; }
@keyframes melayang-a { 0%, 100% { transform: translate3d(0, 0, 0); } 50% { transform: translate3d(-18px, -22px, 0); } }
@keyframes melayang-b { 0%, 100% { transform: translate3d(0, 0, 0); } 50% { transform: translate3d(16px, 20px, 0); } }

/* ---------- Tata letak ---------- */
.container { max-width: 1120px; margin: 0 auto; padding: 28px 24px 56px; }
h1 { font-size: 1.6rem; line-height: 1.25; font-weight: 700; margin: 0 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; line-height: 1.35; font-weight: 600; margin: 0 0 12px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.page-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 12px 16px; margin-bottom: 22px; }
.page-head p { max-width: 62ch; }

/* ---------- Daftar proyek ---------- */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.project-card { display: block; text-decoration: none; color: inherit; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.project-card:hover { border-color: var(--accent); box-shadow: 0 6px 18px rgba(48, 40, 43, 0.08); }
.project-card:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.project-card h3 { margin: 0 0 8px; font-size: 1.05rem; font-weight: 600; }
.tag {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--primary);
  margin: 2px 6px 2px 0;
}
.tag-muted { background: #F4F1EE; color: var(--muted); }
.tag-warn { background: var(--warn-bg); color: var(--warn-text); }

/* ---------- Formulir ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 20px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-size: 0.92rem; font-weight: 600; margin-bottom: 6px; color: var(--text); }
input, select, textarea {
  width: 100%;
  font: inherit;
  font-size: 0.97rem;
  padding: 10px 12px;
  border: 1px solid #D6CAC1;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder, textarea::placeholder { color: #A39892; }
textarea { min-height: 112px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
fieldset { margin: 0; }
legend { font-size: 0.92rem; font-weight: 600; padding: 0; margin-bottom: 8px; }
.opsi-kategori { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; margin-top: 6px; }
.opsi-kategori .opsi {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-weight: 500;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.opsi-kategori .opsi:hover { border-color: var(--accent); }
.opsi-kategori .opsi:has(input:checked) { border-color: var(--primary); background: #FBF6F7; box-shadow: inset 0 0 0 1px var(--primary); }
.opsi-kategori input[type="radio"] { width: 18px; height: 18px; margin: 2px 0 0; flex: 0 0 auto; accent-color: var(--primary); }
.hint { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }

/* ---------- Tombol ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid #D6CAC1;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); border-color: #E5B9B5; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; background: #F4F1EE; color: var(--muted); border-color: var(--border); }
.btn-primary:disabled { background: #B9A3AA; border-color: #B9A3AA; color: #fff; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 18px; }

/* ---------- Pesan status ---------- */
.msg { padding: 10px 14px; border-radius: var(--radius-sm); margin: 12px 0; font-size: 0.94rem; line-height: 1.45; }
.msg-ok { background: var(--ok-bg); color: var(--ok-text); }
.msg-err { background: var(--danger-bg); color: var(--danger); }
.note { background: var(--warn-bg); color: var(--warn-text); padding: 12px 14px; border-radius: var(--radius-sm); font-size: 0.93rem; margin-bottom: 14px; }
.breadcrumb { font-size: 0.92rem; margin-bottom: 10px; }
.breadcrumb a { color: var(--primary); }

/* ---------- Karakter tetap ---------- */
.karakter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.kartu-karakter { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 18px; }
.kartu-karakter h2 { font-size: 1rem; line-height: 1.4; margin: 0; min-height: 4.2em; overflow-wrap: anywhere; }
.foto-kotak {
  aspect-ratio: 3 / 4;
  width: 100%;
  background: #EFEAE5;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin: 0;
}
.foto-kotak img { width: 100%; height: 100%; object-fit: contain; display: block; }
.foto-kosong { color: var(--muted); font-size: 0.9rem; text-align: center; padding: 16px; }
.status-badge {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
}
.status-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-tersimpan { background: var(--ok-bg); color: var(--ok-text); }
.status-kosong { background: var(--accent-soft); color: #6B5A4B; }
.kartu-karakter .actions { margin-top: auto; }
.kartu-karakter .btn { width: 100%; }

/* ---------- Detail proyek dan hasil ---------- */
.assets { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-top: 12px; }
.asset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; background: #FCFAF8; }
.asset img { width: 100%; max-height: 240px; object-fit: contain; border-radius: 8px; background: #111; display: block; }
/* Video mengikuti proporsi aslinya (vertikal 9:16 tetap tinggi), tidak dipotong. */
.asset video { display: block; width: auto; max-width: 100%; height: auto; max-height: 480px; margin: 0 auto; border-radius: 8px; background: #111; object-fit: contain; }
.asset p { margin: 8px 0 0; font-size: 0.86rem; word-break: break-word; }
.scene { border: 1px dashed #D6CAC1; border-radius: var(--radius-sm); padding: 14px; margin-bottom: 12px; }
.scene-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 600; }
.ai-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.ai-row:last-child { border-bottom: none; }
.ai-pre { white-space: pre-wrap; word-break: break-word; background: #FCFAF8; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; font: inherit; font-size: 0.95rem; margin: 8px 0 14px; }

/* ---------- Responsif ---------- */
@media (max-width: 1023px) {
  .karakter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .topbar { padding: 10px 14px; }
  .sidebar-brand img { width: 40px; height: 40px; }
  .container { padding: 20px 16px 44px; }
  h1 { font-size: 1.4rem; }
  .form-grid { grid-template-columns: 1fr; }
  .actions .btn { flex: 1 1 auto; }
  .ai-row .btn { width: 100%; }
}
/* Ponsel dan tablet: sidebar tertutup default, terbuka sebagai panel dari kiri dengan overlay. */
@media (max-width: 899px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; height: 100vh; width: 272px; flex-basis: 272px;
    padding-top: 68px; /* ruang untuk tombol ☰ di pojok kiri atas, agar tidak menutupi logo */
    transform: translateX(-104%); transition: transform 0.22s ease; box-shadow: 0 10px 30px rgba(48, 40, 43, 0.18);
  }
  .app-shell:not(.nav-buka) .sidebar { display: flex; }
  .app-shell.nav-buka .sidebar { transform: none; }
  .topbar { position: relative; z-index: auto; } /* sticky membuat stacking context sendiri; di ponsel cukup relative agar ☰ bisa di atas panel */
  .dekor-2 { display: none; }
  .dekor-1 { width: 92vw; right: -34vw; bottom: -8vh; }
}
@media (max-width: 639px) {
  .karakter-grid { grid-template-columns: minmax(0, 1fr); }
  .kartu-karakter { max-width: 420px; width: 100%; margin: 0 auto; }
  .foto-kotak { aspect-ratio: 4 / 5; }
}
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
.card .card { box-shadow: none; background: #FCFAF8; margin: 14px 0 0; }
input[type="file"] { padding: 8px 10px; font-size: 0.92rem; cursor: pointer; }
input[type="file"]::file-selector-button {
  font: inherit; font-weight: 500; margin-right: 12px; padding: 6px 12px;
  border: 1px solid #D6CAC1; border-radius: 8px; background: #fff; color: var(--text); cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--accent-soft); }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .dekor-logo { animation: none !important; }
}

/* Kerangka memuat: denyut halus, dimatikan bila pengguna memilih reduced motion. */
.memuat { padding: 48px 0; text-align: center; color: var(--muted); }
.memuat p { margin: 0; animation: napas-memuat 1.6s ease-in-out infinite; }
@keyframes napas-memuat { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .memuat p { animation: none; } }
