:root {
  --bg: #FAF7F2;
  --panel: #FFFFFF;
  --ink: #35312C;
  --muted: #8A8378;
  --line: rgba(53,49,44,0.14);
  --accent: #7E8C77;
  --danger: #B0574F;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: Karla, system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar { position: sticky; top: 0; z-index: 10; padding: 10px clamp(12px, 4vw, 40px);
  background: rgba(250,247,242,0.95); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar .brand { font-family: 'Cormorant Garamond', Georgia, serif; font-size: 20px; font-weight: 500; }
.topbar nav { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav a { white-space: nowrap; padding: 8px 13px; border-radius: 999px; font-size: 13px; color: var(--ink); }
.topbar nav a:hover { background: rgba(53,49,44,0.06); text-decoration: none; }
.topbar nav a.active { background: var(--ink); color: #fff; }

/* admin language toggle */
.langs { display: flex; gap: 2px; background: rgba(53,49,44,0.06); border-radius: 999px; padding: 3px; flex: none; }
.langs a { font-size: 12px; color: var(--ink); padding: 5px 11px; border-radius: 999px; text-decoration: none; line-height: 1; }
.langs a.on { background: var(--ink); color: #fff; }
.langs a:hover { text-decoration: none; }
.langs-center { justify-content: center; width: max-content; margin: 0 auto 16px; }

.wrap { max-width: 900px; margin: 0 auto; padding: clamp(20px, 4vw, 40px) clamp(16px, 4vw, 40px) 80px; }
h1.page { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 400; font-size: clamp(28px, 4vw, 40px); margin: 6px 0 4px; }
.sub { color: var(--muted); margin: 0 0 26px; font-size: 14px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin-bottom: 18px;
  box-shadow: 0 10px 30px -24px rgba(45,41,36,0.4); }
.card h3 { margin: 0 0 14px; font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 500; font-size: 20px; }

label { display: block; font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin: 12px 0 6px; }
input[type=text], input[type=password], input[type=number], input[type=datetime-local], input[type=color], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink);
  font-family: inherit; font-size: 15px; }
input[type=color] { height: 44px; padding: 4px; }
textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.check input { width: auto; }
.check label { margin: 0; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--ink); }

.btn { display: inline-block; border: none; cursor: pointer; font-family: inherit; font-size: 14px;
  padding: 10px 18px; border-radius: 999px; background: var(--ink); color: #fff; }
.btn:hover { background: #201d1a; }
.btn.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.secondary:hover { background: rgba(53,49,44,0.05); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid rgba(176,87,79,0.4); }
.btn.danger:hover { background: rgba(176,87,79,0.08); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
.spacer { flex: 1; }

.thumb { width: 100%; max-width: 220px; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; margin-top: 8px; }
.thumb-none { display: flex; align-items: center; justify-content: center; color: var(--muted); font-style: italic;
  background: rgba(53,49,44,0.04); font-family: 'Cormorant Garamond', serif; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.tile { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; color: var(--ink); }
.tile:hover { text-decoration: none; border-color: var(--accent); box-shadow: 0 10px 30px -24px rgba(45,41,36,0.4); }
.tile h3 { margin: 0 0 4px; font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 500; font-size: 19px; }
.tile p { margin: 0; color: var(--muted); font-size: 13px; }

.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-size: 14px; }
.flash.ok { background: rgba(126,140,119,0.16); color: #4c5a45; }
.flash.err { background: rgba(176,87,79,0.14); color: #8a3d36; }

.center-card { max-width: 380px; margin: 12vh auto 0; }
.center-card .card { padding: 28px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 10px; line-height: 1.5; }
hr.sep { border: none; border-top: 1px solid var(--line); margin: 22px 0; }
.item-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.badge { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }

/* add-photos card */
.add-card { border: 1px dashed rgba(126,140,119,0.5); background: rgba(126,140,119,0.05); }
.filepick { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.filepick input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.filepick-btn { display: inline-block; background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; cursor: pointer; }
.filepick-btn:hover { background: #201d1a; }
.filepick-name { color: var(--muted); font-size: 13px; }

/* collapsible section-heading panel */
.details-card > summary { cursor: pointer; font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 500; font-size: 18px; list-style: none; }
.details-card > summary::-webkit-details-marker { display: none; }
.details-card > summary::after { content: ' ▾'; color: var(--muted); }
.details-card[open] > summary::after { content: ' ▴'; }

/* clean photo grid */
.g-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.g-tile { position: relative; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff;
  cursor: pointer; user-select: none; transition: box-shadow 160ms, transform 160ms; }
.g-tile:hover { box-shadow: 0 12px 28px -20px rgba(45,41,36,0.5); }
.g-tile.dragging { opacity: 0.4; }
.g-img { aspect-ratio: 1 / 1; background: rgba(53,49,44,0.04); }
.g-img img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.g-none { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; text-align: center; padding: 8px;
  color: var(--muted); font-family: 'Cormorant Garamond', serif; font-style: italic; font-size: 13px; }
.g-cap { font-size: 12px; color: var(--muted); padding: 8px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-actions { position: absolute; top: 6px; left: 6px; right: 6px; display: flex; justify-content: space-between; gap: 4px; }
.g-btn { width: 34px; height: 34px; border: none; border-radius: 9px; background: rgba(255,255,255,0.92); color: var(--ink);
  font-size: 18px; line-height: 1; cursor: pointer; box-shadow: 0 2px 8px -3px rgba(45,41,36,0.5); display: flex; align-items: center; justify-content: center; }
.g-btn:hover { background: #fff; }
.g-edit { font-size: 15px; }

/* modal */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(38,35,31,0.55); backdrop-filter: blur(2px); }
.modal-card { position: relative; background: var(--panel); border-radius: 16px; padding: 20px; width: 100%; max-width: 480px;
  max-height: 92vh; overflow: auto; box-shadow: 0 40px 90px -40px rgba(0,0,0,0.5); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-head h3 { margin: 0; font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 500; font-size: 22px; }
.modal-x { border: none; background: none; font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.modal-x:hover { color: var(--ink); }
.modal-thumb-wrap { margin: 6px 0 12px; }
.modal-thumb { width: 100%; max-height: 240px; object-fit: contain; border-radius: 10px; background: rgba(53,49,44,0.04); }
.modal-thumb.thumb-none { height: 160px; display: flex; align-items: center; justify-content: center; }

/* ---- mobile ---- */
@media (max-width: 640px) {
  .wrap { padding: 16px 14px 76px; }
  h1.page { font-size: 26px; }
  .card { padding: 16px; }
  .row { grid-template-columns: 1fr; }           /* stack EN/ID pairs vertically */
  input[type=text], input[type=password], input[type=number], input[type=datetime-local], textarea, select { font-size: 16px; }  /* avoid iOS zoom */
  .btn { padding: 12px 20px; font-size: 15px; }  /* larger touch targets */
  .actions { gap: 8px; }
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile { padding: 14px; }
  .g-grid { grid-template-columns: 1fr 1fr; }
  .thumb { max-width: 100%; }
}

/* ===== admin UX v2: collapsible items, uploads, file inputs ===== */

/* nicer native file inputs */
input[type=file] { font-family: inherit; font-size: 14px; color: var(--muted); }
input[type=file]::file-selector-button { font-family: inherit; font-size: 14px; margin-right: 10px;
  padding: 9px 15px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); cursor: pointer; }
input[type=file]::file-selector-button:hover { background: rgba(53,49,44,0.05); }

/* upload preview + status (injected by admin-upload.js) */
.upload-panel { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; align-items: center; }
.upload-status { font-size: 13px; color: var(--muted); font-style: italic; }
.upload-thumb { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.upload-thumb img { width: 64px; height: 64px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); }
.upload-thumb span { font-size: 10px; color: var(--muted); }

/* saving state */
.btn[disabled] { opacity: 0.6; cursor: default; }

/* collapsible add-new */
.add-details { margin: 0 0 18px; }
.add-details > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; font-size: 14px; }
.add-details > summary::-webkit-details-marker { display: none; }
.add-details > summary::before { content: '＋'; font-size: 16px; line-height: 1; }
.add-details[open] > summary { border-radius: 12px 12px 0 0; }
.add-details .add-body { border: 1px solid var(--line); border-top: none; border-radius: 0 12px 12px 12px;
  background: var(--panel); padding: 18px; }

/* collapsible item cards */
.item { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); margin-bottom: 12px; overflow: hidden;
  box-shadow: 0 8px 22px -20px rgba(45,41,36,0.5); }
.item > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.item > summary::-webkit-details-marker { display: none; }
.item-thumb { width: 54px; height: 54px; border-radius: 10px; object-fit: cover; flex: none; border: 1px solid var(--line); }
.item-thumb.none { display: flex; align-items: center; justify-content: center; background: rgba(53,49,44,0.05);
  color: var(--muted); font-family: 'Cormorant Garamond', serif; font-style: italic; font-size: 20px; }
.item-main { flex: 1; min-width: 0; }
.item-name { font-weight: 500; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-chev { color: var(--muted); flex: none; transition: transform 0.2s ease; font-size: 18px; }
.item[open] .item-chev { transform: rotate(90deg); }
.item-body { padding: 4px 14px 16px; border-top: 1px solid var(--line); }
.item-body .actions { margin-top: 14px; }
.item-delete { margin-top: 10px; text-align: right; }

@media (max-width: 640px) {
  .item-thumb { width: 46px; height: 46px; }
  .upload-thumb img { width: 56px; height: 56px; }
}

.tile-count { display: inline-block; min-width: 22px; text-align: center; font-family: Karla, sans-serif;
  font-size: 12px; font-weight: 500; color: #fff; background: var(--accent); border-radius: 999px; padding: 1px 8px; vertical-align: middle; }
