/* Atribut hidden harus selalu menang atas display dari class */
[hidden] { display: none !important; }

/* Pratinjau langsung di form admin */
.admin-preview-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #fbfaf7;
}
.admin-preview-wrap iframe {
  width: 100%;
  height: 280px;
  border: 0;
  display: block;
}

:root {
  --paper: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --ink: #1d1d1f;
  --ink-2: #6e6e73;
  --ink-3: #8e8e93;
  --line: #e3e0d8;
  --line-2: #eceae4;
  --accent: #c96442;
  --accent-ink: #a3431f;
  --accent-surface: #a3431f;
  --accent-soft: #f6e9e1;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-pill: 980px;
  --shadow-card: 0 1px 2px rgba(29, 27, 24, .045), 0 6px 18px rgba(29, 27, 24, .055);
  --shadow-card-hover: 0 2px 6px rgba(29, 27, 24, .07), 0 16px 38px rgba(29, 27, 24, .11);
  --shadow-modal: 0 24px 80px rgba(20, 18, 16, .28), 0 4px 16px rgba(20, 18, 16, .14);
  --font-display: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sidebar-w: 256px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { font-weight: 400; margin: 0; }

button { font: inherit; color: inherit; }

a { color: var(--accent-ink); }

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(201, 100, 66, .4), 0 0 0 1px var(--accent);
  border-radius: 6px;
}

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 200;
  background: var(--ink); color: #fff; padding: 10px 16px;
  border-radius: var(--radius-md); font-size: 14px; text-decoration: none;
  transition: top .18s;
}
.skip-link:focus { top: 12px; }

/* ---------- Layout ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: none;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, .72);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  padding: 26px 18px 20px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  z-index: 40;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px 26px; text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  object-fit: cover; display: block;
}
.brand-name { font-family: var(--font-display); font-size: 22px; letter-spacing: -.015em; line-height: 1; }
.brand-sub { font-size: 11.5px; color: var(--ink-3); letter-spacing: .02em; line-height: 1.3; margin-top: 3px; }

.side-label { font-size: 11.5px; font-weight: 600; color: var(--ink-3); letter-spacing: .06em; text-transform: uppercase; padding: 0 8px 8px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border-radius: var(--radius-md); border: none;
  background: transparent; cursor: pointer; text-align: left;
  font-size: 14.5px; color: var(--ink-2);
  transition: background .18s, color .18s;
}
.nav-item:hover { background: var(--line-2); color: var(--ink); }
.nav-item[aria-current="true"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav-count { margin-left: auto; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.nav-item[aria-current="true"] .nav-count { color: var(--accent-ink); }

.theme-select {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-md);
  border: 1px solid var(--line-2); background: var(--bg-soft, #fff);
  font-size: 14px; color: var(--ink-2); cursor: pointer; outline: none;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 34px; margin-bottom: 6px;
}
.theme-select:focus { border-color: var(--accent, #0a84ff); }

.side-foot { margin-top: auto; padding: 16px 10px 0; border-top: 1px solid var(--line-2); font-size: 12.5px; color: var(--ink-3); line-height: 1.5; }
.side-foot a { text-decoration: none; }
.side-foot a:hover { text-decoration: underline; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  padding: 18px 32px 16px;
  background: rgba(247, 245, 240, .82);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}

.menu-btn {
  display: none; width: 42px; height: 42px; flex: none;
  border-radius: var(--radius-md); border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; position: relative;
}
.menu-btn span { position: absolute; left: 12px; width: 18px; height: 1.5px; background: var(--ink); border-radius: 2px; transition: transform .2s, opacity .2s; }
.menu-btn span:nth-child(1) { top: 15px; }
.menu-btn span:nth-child(2) { top: 20px; }
.menu-btn span:nth-child(3) { top: 25px; }
.menu-btn[aria-expanded="true"] span:nth-child(1) { transform: translateY(5px) rotate(45deg); }
.menu-btn[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-btn[aria-expanded="true"] span:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }

.search-wrap { position: relative; flex: 1; min-width: 220px; max-width: 420px; }
.search-wrap svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search {
  width: 100%; padding: 11px 14px 11px 38px;
  border-radius: var(--radius-pill); border: 1px solid var(--line);
  background: var(--surface); font-size: 15px; color: var(--ink);
  transition: border-color .2s, box-shadow .2s;
}
.search::placeholder { color: var(--ink-3); }
.search:hover { border-color: #cfcbbf; }
.search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(201, 100, 66, .16); }

.topbar-meta { font-size: 13.5px; color: var(--ink-2); margin-left: auto; font-variant-numeric: tabular-nums; }

.content { padding: 30px 32px 64px; max-width: 1180px; width: 100%; }

.page-head { margin-bottom: 26px; }
.page-title { font-size: clamp(32px, 4.6vw, 46px); line-height: 1.06; letter-spacing: -.022em; }
.page-title em { font-style: italic; color: var(--accent-ink); }
.page-sub { font-size: 16px; color: var(--ink-2); margin-top: 10px; max-width: 58ch; line-height: 1.5; }

/* ---------- Component grid ---------- */

.grid {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
}

.card {
  position: relative; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; overflow: hidden;
  transition: transform .28s cubic-bezier(.2, .8, .3, 1), box-shadow .28s, border-color .28s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-card-hover); border-color: #d8d4c8; }

.card-preview { position: relative; height: 158px; background: var(--surface-2); border-bottom: 1px solid var(--line-2); }
.card-preview iframe {
  width: 100%; height: 100%; border: 0; display: block;
  pointer-events: none; background: transparent;
}
.card-open {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border: none; background: transparent; cursor: pointer; border-radius: 0;
  color: transparent;
}
.card-open:hover { background: rgba(247, 245, 240, .001); }
.card-open:focus-visible { box-shadow: inset 0 0 0 3px rgba(201, 100, 66, .55); border-radius: 0; }
.card-open:hover ~ .card-foot .card-cta,
.card:hover .card-cta { color: var(--accent-ink); }

.card-foot { padding: 14px 16px 15px; display: flex; align-items: flex-end; gap: 10px; }
.card-title { font-size: 16.5px; letter-spacing: -.012em; }
.card-cat { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }
.card-cta {
  margin-left: auto; flex: none; font-size: 13px; font-weight: 600;
  color: var(--ink-3); padding: 6px 2px; transition: color .18s;
}

/* ---------- Empty / loading / error ---------- */

.state {
  border: 1px dashed var(--line); border-radius: var(--radius-lg);
  background: var(--surface-2); padding: 52px 28px; text-align: center;
}
.state-title { font-size: 22px; letter-spacing: -.015em; }
.state-text { font-size: 14.5px; color: var(--ink-2); margin-top: 8px; line-height: 1.5; }
.state .btn { margin-top: 18px; }

.skeleton-grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); }
.skeleton { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.skeleton-media { height: 158px; border-bottom: 1px solid var(--line-2); }
.skeleton-lines { padding: 16px; }
.skeleton-line { height: 11px; border-radius: 6px; margin-bottom: 9px; }
.skeleton-line:last-child { width: 45%; margin-bottom: 0; }
.shimmer {
  background: linear-gradient(100deg, #efece5 20%, #f8f6f2 40%, #efece5 60%);
  background-size: 220% 100%;
  animation: shimmer 1.35s linear infinite;
}
@keyframes shimmer { from { background-position: 140% 0; } to { background-position: -60% 0; } }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14.5px; font-weight: 600; padding: 10px 18px;
  border-radius: var(--radius-pill); border: 1px solid transparent; cursor: pointer;
  transition: background .2s, color .2s, border-color .2s, transform .14s cubic-bezier(.2, .8, .3, 1.2);
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent-surface); color: #fff; }
.btn-primary:hover { background: #8f3a19; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: var(--surface-2); border-color: #cfcbbf; }
.btn-quiet { background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--line-2); color: var(--ink); }
.btn-danger { background: var(--surface); color: #a3231c; border-color: #e8cfcc; }
.btn-danger:hover { background: #fdf3f2; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(24, 21, 18, .44);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid; place-items: center; padding: 24px;
  opacity: 0; transition: opacity .22s ease;
}
.modal-backdrop[hidden] { display: none; }
.modal-backdrop.is-open { opacity: 1; }

.modal {
  width: min(1180px, 100%); height: min(780px, calc(100vh - 48px));
  background: var(--surface); border-radius: 20px;
  box-shadow: var(--shadow-modal);
  display: flex; flex-direction: column; overflow: hidden;
  transform: scale(.965) translateY(10px); opacity: 0;
  transition: transform .26s cubic-bezier(.2, .8, .25, 1), opacity .2s ease;
}
.modal-backdrop.is-open .modal { transform: none; opacity: 1; }

.modal-head { padding: 18px 20px 0; border-bottom: 1px solid var(--line-2); }
.modal-head-row { display: flex; align-items: flex-start; gap: 14px; }
.modal-title { font-size: 26px; letter-spacing: -.02em; line-height: 1.15; }
.modal-cat { font-size: 12.5px; color: var(--ink-3); margin-top: 4px; }
.modal-close {
  margin-left: auto; flex: none; width: 36px; height: 36px; border-radius: 50%;
  border: none; background: var(--line-2); cursor: pointer; color: var(--ink-2);
  display: grid; place-items: center; transition: background .18s, color .18s;
}
.modal-close:hover { background: #dedad0; color: var(--ink); }

.tabs { display: flex; gap: 4px; margin-top: 16px; }
.tab {
  padding: 9px 16px; border: none; background: transparent; cursor: pointer;
  font-size: 14.5px; font-weight: 600; color: var(--ink-3);
  border-bottom: 2px solid transparent; border-radius: 8px 8px 0 0;
  transition: color .18s, border-color .18s;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

.modal-body { flex: 1; min-height: 0; display: flex; flex-direction: row; }

.pane-preview { flex: 1 1 50%; min-width: 0; display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line-2); }
.pane-preview iframe { flex: 1; width: 100%; border: 0; background: var(--surface-2); }
.preview-bar {
  padding: 10px 20px; border-top: 1px solid var(--line-2);
  font-size: 12.5px; color: var(--ink-3); background: var(--surface-2);
}

.pane-code { flex: 1 1 50%; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.code-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 16px; border-bottom: 1px solid var(--line-2); background: var(--surface-2);
}
.lang-tab {
  padding: 6px 13px; border-radius: var(--radius-pill); border: 1px solid transparent;
  background: transparent; cursor: pointer; font-size: 13px; font-weight: 600;
  color: var(--ink-3); transition: color .18s, background .18s, border-color .18s;
}
.lang-tab:hover { color: var(--ink); background: #f1efe9; }
.lang-tab[aria-selected="true"] { color: var(--accent-ink); background: var(--accent-soft); border-color: #ead8cb; }

.code-scroll { flex: 1; overflow: auto; background: #fbfaf7; }
pre.code-block {
  margin: 0; padding: 20px 22px; min-height: 100%;
  font-family: var(--font-mono); font-size: 13px; line-height: 1.72;
  color: var(--ink); tab-size: 2; white-space: pre;
}
.code-block .tok-c { color: #a1a1a6; font-style: italic; }
.code-block .tok-k { color: #b04a22; }
.code-block .tok-s { color: #3f6b4d; }
.code-block .tok-n { color: #8a5a13; }
.code-block .tok-a { color: #2f5d8a; }
.code-block .tok-t { color: #b04a22; }

.code-foot {
  padding: 14px 20px; border-top: 1px solid var(--line-2);
  display: flex; align-items: center; gap: 12px; background: var(--surface);
}
.code-foot .spacer { margin-left: auto; }
.copy-state { font-size: 13.5px; font-weight: 600; color: #3f6b4d; opacity: 0; transition: opacity .2s; }
.copy-state.is-visible { opacity: 1; }


/* ---------- Admin ---------- */

.admin-shell { max-width: 1080px; margin: 0 auto; padding: 40px 28px 80px; }
.admin-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.admin-head h1 { font-size: clamp(28px, 3.6vw, 38px); letter-spacing: -.02em; line-height: 1.1; }
.admin-head p { font-size: 14.5px; color: var(--ink-2); margin: 6px 0 0; }
.admin-head .btn { margin-left: auto; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.panel-head { padding: 16px 20px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 12px; }
.panel-head h2 { font-size: 19px; letter-spacing: -.012em; }
.panel-head .count { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.panel-body { padding: 20px; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.admin-table th { text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); padding: 0 12px 10px; border-bottom: 1px solid var(--line); }
.admin-table td { padding: 14px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table .t-title { font-weight: 600; }
.admin-table .t-meta { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; color: var(--ink-2);
  display: grid; place-items: center; transition: background .16s, color .16s, border-color .16s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); border-color: #cfcbbf; }
.icon-btn.danger:hover { background: #fdf3f2; color: #a3231c; border-color: #e8cfcc; }

.form-grid { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field.span-2 { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; }
.field input, .field select, .field textarea {
  font: inherit; font-size: 14.5px; padding: 10px 12px; width: 100%;
  border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); transition: border-color .2s, box-shadow .2s;
}
.field textarea { font-family: var(--font-mono); font-size: 12.5px; line-height: 1.7; resize: vertical; min-height: 130px; tab-size: 2; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: #cfcbbf; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(201, 100, 66, .16); }
.form-actions { display: flex; gap: 10px; margin-top: 4px; }
.form-note { font-size: 12.5px; color: var(--ink-3); margin: 0; }

.alert { border-radius: var(--radius-md); padding: 12px 14px; font-size: 13.5px; line-height: 1.5; margin-bottom: 16px; border: 1px solid; }
.alert-error { background: #fdf3f2; border-color: #e8cfcc; color: #8f241d; }
.alert-ok { background: #eef7f1; border-color: #cfe6d8; color: #265c3c; }

.login-card { max-width: 400px; margin: 12vh auto 0; padding: 30px 28px 28px; }
.login-card h1 { font-size: 28px; letter-spacing: -.02em; text-align: center; }
.login-card .lead { text-align: center; font-size: 14px; color: var(--ink-2); margin: 8px 0 22px; }
.login-card .field + .field { margin-top: 14px; }

/* ---------- 404 ---------- */

.not-found { max-width: 520px; margin: 16vh auto 0; text-align: center; padding: 0 24px; }
.not-found .num { font-family: var(--font-display); font-size: 88px; line-height: 1; color: var(--accent-ink); }
.not-found h1 { font-size: 26px; letter-spacing: -.02em; margin-top: 10px; }
.not-found p { font-size: 15px; color: var(--ink-2); margin: 10px 0 22px; line-height: 1.5; }

/* ---------- Scrim for mobile drawer ---------- */

.scrim {
  position: fixed; inset: 0; z-index: 35; background: rgba(24, 21, 18, .34);
  opacity: 0; pointer-events: none; transition: opacity .22s;
}
.scrim.is-open { opacity: 1; pointer-events: auto; }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .content { padding: 24px 22px 56px; }
  .topbar { padding: 14px 22px 14px; }
  .menu-btn { display: block; order: -1; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh;
    transform: translateX(-102%); transition: transform .26s cubic-bezier(.2, .8, .25, 1);
    box-shadow: 0 0 44px rgba(20, 18, 16, .2);
    background: rgba(255, 255, 255, .94);
  }
  body.drawer-open .sidebar { transform: none; }
  .form-grid { grid-template-columns: 1fr; }
  .admin-table thead { display: none; }
  .admin-table tr { display: block; border-bottom: 1px solid var(--line-2); padding: 6px 0; }
  .admin-table td { display: flex; justify-content: space-between; gap: 12px; border: none; padding: 7px 4px; }
  .admin-table td::before { content: attr(data-label); font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
  .row-actions { justify-content: flex-end; }
}

@media (max-width: 640px) {
  .modal-body { flex-direction: column; }
  .pane-preview { border-right: 0; border-bottom: 1px solid var(--line-2); flex-basis: 38%; }
  .grid, .skeleton-grid { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 0; }
  .modal { width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
  .modal-head { padding: 14px 16px 0; }
  .modal-title { font-size: 21px; }
  .code-foot { padding: 12px 16px; flex-wrap: wrap; }
  .topbar-meta { width: 100%; margin-left: 0; }
  .card-preview { height: 140px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
