:root {
  --bg: #f4f6fb; --surface: #ffffff; --text: #1a2233; --muted: #667085;
  --border: #dde3ee; --accent: #0e7a5f; --accent-ink: #ffffff;
  --err: #b42318; --ok: #067647;
}
[data-theme="dark"] {
  --bg: #0f1420; --surface: #171e2e; --text: #e6eaf2; --muted: #94a0b8;
  --border: #2a3448; --accent: #2fbf9b; --accent-ink: #06281f;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { font-weight: 800; font-size: 20px; }
.brand small { color: var(--muted); font-weight: 400; font-size: 13px; }
.logo { display: inline-flex; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); align-items: center; justify-content: center; margin-right: 6px; }
.top-actions button, button { cursor: pointer; }
button { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 600; }
button:hover { opacity: .9; }
main { max-width: 960px; margin: 0 auto; padding: 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; max-width: 420px; margin: 40px auto; }
.card h1 { margin-top: 0; }
label { display: block; margin: 12px 0; font-size: 14px; }
input, select { width: 100%; padding: 9px 10px; margin-top: 4px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.inline-form input, .inline-form select { width: auto; flex: 1; min-width: 140px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.tabs button.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tab h2 { margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.grid > div { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.grid b { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 14px; }
.muted { color: var(--muted); font-size: 13px; }
.err { color: var(--err); }
.ok { color: var(--ok); }
.hidden { display: none !important; }
.filelist { list-style: none; padding: 0; }
.filelist li { padding: 8px 10px; border-bottom: 1px solid var(--border); background: var(--surface); }
footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }
code { background: var(--border); padding: 1px 5px; border-radius: 4px; }

/* ---------- v0.4.0: responsif mobile + file manager ---------- */

/* Ukuran dasar: font >= 14px, tanpa lebar tetap yang meluap. */
input, select, textarea, button { font-size: 14px; }
button { min-height: 36px; }
input[type="checkbox"] { width: auto; min-height: 0; }

/* Tabel: bungkus bisa di-scroll horizontal + pecah kata panjang. */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 12px 0; }
.table-wrap table { min-width: 560px; }
th, td { word-break: break-word; overflow-wrap: anywhere; }

/* Akses cepat file manager + nama file yang bisa diklik. */
.quick-access { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.quick-access button { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.file-name { cursor: pointer; }
.file-name:hover { text-decoration: underline; }
.filelist li { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: space-between; }
.file-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.file-actions button { padding: 6px 10px; }
.check-label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 14px; white-space: nowrap; }
.check-label input { margin-top: 0; }

/* Editor file. */
.editor { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-top: 16px; }
.editor-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.editor-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.editor-body { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
#editorGutter { margin: 0; padding: 10px 8px 10px 10px; background: var(--bg); color: var(--muted); text-align: right; font: 14px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace; overflow: hidden; user-select: none; flex: 0 0 auto; }
#editorText { flex: 1; min-width: 0; min-height: 300px; margin: 0; border: 0; border-radius: 0; padding: 10px; font: 14px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace; resize: vertical; }
#editorPreview { margin: 12px 0 0; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); overflow-x: auto; white-space: pre-wrap; word-break: break-word; font: 14px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace; }
#editorPreview code { background: none; padding: 0; }
.hl-kw { color: #7c3aed; font-weight: 700; }
.hl-str { color: #067647; }
.hl-com { color: #667085; font-style: italic; }
[data-theme="dark"] .hl-kw { color: #c4b5fd; }
[data-theme="dark"] .hl-str { color: #6ee7b7; }
[data-theme="dark"] .hl-com { color: #94a0b8; }
.editor.fullscreen { position: fixed; inset: 0; z-index: 100; margin: 0; border-radius: 0; display: flex; flex-direction: column; }
.editor.fullscreen .editor-body { flex: 1; }
.editor.fullscreen #editorText { min-height: 0; flex: 1; }

/* Hamburger: hanya tampil di mobile. */
#menuBtn { display: none; }
#navBackdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 40; }

/* Target sentuh >= 44px di layar sentuh. */
@media (pointer: coarse) {
  button, input, select, textarea { min-height: 44px; }
  input[type="checkbox"] { min-height: 24px; min-width: 24px; }
  .tabs button { min-height: 44px; }
  .file-actions button { min-height: 44px; }
}

/* Tablet ke bawah (<= 768px): nav jadi drawer, form menumpuk. */
@media (max-width: 768px) {
  main { padding: 12px; }
  .topbar { padding: 10px 12px; gap: 8px; }
  .brand { font-size: 18px; }
  .brand small { display: none; }
  #menuBtn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; min-height: 44px; padding: 0; font-size: 20px; background: var(--surface); color: var(--text); border: 1px solid var(--border); }
  .tabs { position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; width: min(280px, 85vw); flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 4px; margin: 0; padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; transform: translateX(-100%); transition: transform .2s ease; }
  .tabs.open { transform: none; }
  .tabs button { text-align: left; width: 100%; }
  .inline-form { flex-direction: column; }
  .inline-form input, .inline-form select { width: 100%; min-width: 0; }
  .inline-form button { width: 100%; }
  .card { margin: 20px auto; padding: 20px; }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .editor-actions button { flex: 1 1 40%; }
  .filelist li { flex-direction: column; align-items: flex-start; }
}

/* Ponsel kecil (<= 480px): kartu 1 kolom. */
@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr; }
  .top-actions #whoami { display: none; }
  .editor-actions button { flex: 1 1 100%; }
}
