:root {
  --bg: #f5f7fa; --surface: #fff; --sunken: #f9fafb; --text: #111; --text-2: #4b5260; --muted: #6b7280;
  --line: #e4e7ec; --line-2: #eef0f3; --accent: #ee4d2d; --accent-ink: #b8341a; --accent-btn: #d63d1f; --accent-soft: #fff1ed; --accent-tint: #fff7f4;
  --blue: #0519b0; --blue-soft: #eef0ff; --danger: #c62828;
  --r: 8px; --r-lg: 12px; --font: 'Inter', system-ui, sans-serif; --display: 'Plus Jakarta Sans', 'Inter', sans-serif;
  --shadow-1: 0 1px 2px rgba(17, 24, 39, .04), 0 1px 1px rgba(17, 24, 39, .03);
  --shadow-2: 0 8px 24px rgba(17, 24, 39, .10), 0 2px 6px rgba(17, 24, 39, .06);
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; }
::selection { background: #ffd9cf; color: var(--text); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
* { scrollbar-width: thin; scrollbar-color: #cfd4dc transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cfd4dc; border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
[hidden] { display: none !important; }
h1, h2 { font-family: var(--display); margin: 0; letter-spacing: -0.015em; text-wrap: balance; }
h1 { font-size: 22px; line-height: 1.25; } h2 { font-size: 16px; }
a { color: inherit; text-underline-offset: 3px; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.err { color: var(--danger); min-height: 1em; margin: 6px 0 0; font-size: 13px; }
.pad { padding: 16px; }
.r { text-align: right; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* controls */
.btn { display: inline-flex; align-items: center; gap: 6px; font: 500 13px var(--font); border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: var(--r); padding: 0 12px; height: 36px; cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s, color .15s; }
.btn:hover { border-color: #c9ced6; background: var(--sunken); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent-btn); border-color: var(--accent-btn); color: #fff; box-shadow: 0 1px 2px rgba(199, 58, 30, .25); }
.btn.primary:hover { background: #c73a1e; border-color: #c73a1e; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--line-2); }
.btn.icon { width: 36px; padding: 0; justify-content: center; }
.btn.block { width: 100%; justify-content: center; height: 42px; }
.btn:disabled { opacity: .6; cursor: default; }
input, select, textarea { font: 14px var(--font); color: var(--text); background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; width: 100%; transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: #8b919b; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
label { display: block; font-weight: 500; font-size: 13px; margin-bottom: 12px; }
label > input, label > select, label > textarea { margin-top: 5px; font-weight: 400; }
.field { position: relative; display: flex; align-items: center; }
.field svg.i { position: absolute; left: 10px; color: var(--muted); pointer-events: none; }
.field input { padding-left: 32px; height: 36px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 32px 24px 24px; width: 100%; max-width: 340px; text-align: center; box-shadow: var(--shadow-1); }
.login-card h1 { margin: 12px 0 4px; font-size: 20px; }
.login-card p { margin: 0 0 18px; }
.pinwrap { position: relative; margin-bottom: 10px; }
.pinwrap input { padding-right: 44px; text-align: center; letter-spacing: .3em; font-size: 18px; height: 44px; }
.eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; cursor: pointer; color: var(--muted); width: 34px; height: 34px; display: grid; place-items: center; border-radius: 6px; }
.eye:hover { color: var(--text); background: var(--line-2); }

/* shell */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 20px; padding-top: max(10px, env(safe-area-inset-top)); background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; font: 700 15px var(--display); }
.top-actions { display: flex; gap: 6px; }
main { max-width: 1180px; margin: 0 auto; padding: 22px 20px 64px; }
.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 14px; }
.head-row p { margin: 6px 0 0; }
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; color: var(--muted); font-size: 13px; }
.meta .dot { width: 3px; height: 3px; border-radius: 50%; background: #c3c8d0; }
.search { width: 280px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); text-decoration: none; font-size: 13px; margin: -4px 0 10px -4px; padding: 4px; border-radius: 6px; }
.back:hover { color: var(--text); background: var(--line-2); }

/* collections list */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-1); }
.lrow { display: grid; grid-template-columns: minmax(0, 1fr) 140px 64px 110px 20px; gap: 14px; align-items: center; padding: 14px 16px; border-top: 1px solid var(--line-2); text-decoration: none; transition: background .15s; }
.lrow:first-child { border-top: 0; }
a.lrow:hover { background: var(--accent-tint); }
a.lrow:hover .go { color: var(--accent); transform: translateX(2px); }
.go { color: #b8bec8; transition: transform .2s var(--ease), color .15s; }
.lhead { font-size: 12px; color: var(--muted); font-weight: 500; background: var(--sunken); padding: 9px 16px; }
.ltitle { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ltitle b { font-weight: 600; font-size: 14.5px; }
.ltitle small { color: var(--text-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; }
.meta .tag { margin-left: 2px; }
.tag { font-style: normal; font-size: 11.5px; color: var(--text-2); background: var(--line-2); border-radius: 5px; padding: 1px 7px; }
.chip { display: inline-flex; align-items: center; font-style: normal; font-size: 12px; font-weight: 500; border-radius: 999px; padding: 2px 9px; background: var(--line-2); color: var(--text-2); white-space: nowrap; }
.chip.claude-extension { background: var(--accent-soft); color: var(--accent-ink); }
.chip.claude-code { background: var(--blue-soft); color: var(--blue); }
.empty { padding: 48px 16px; text-align: center; color: var(--text-2); }
.empty svg.i { width: 28px; height: 28px; color: #b8bec8; margin-bottom: 8px; }

/* detail */
.toolbar { position: sticky; top: 57px; z-index: 3; display: flex; align-items: center; gap: 8px; padding: 10px 0; margin-bottom: 2px; background: var(--bg); }
.toolbar .field { flex: 0 1 300px; }
.toolbar .spacer { flex: 1; }
.toolbar .count { font-size: 13px; color: var(--muted); white-space: nowrap; }
.sortsel { display: none; }
.note { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); margin: 0 0 6px; color: var(--text-2); font-size: 13.5px; line-height: 1.6; max-width: 80ch; }
.note summary { display: flex; align-items: center; gap: 10px; padding: 9px 14px; cursor: pointer; list-style: none; border-radius: var(--r-lg); user-select: none; }
.note summary::-webkit-details-marker { display: none; }
.note summary:hover { background: var(--sunken); }
.note-label { font-weight: 600; color: var(--text); flex: none; }
.note-peek { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.note-act { flex: none; font-size: 12.5px; font-weight: 500; color: var(--blue); }
.note-act::after { content: "Tampilkan"; }
.note[open] .note-act::after { content: "Sembunyikan"; }
.note[open] .note-peek { visibility: hidden; }
.note-body { padding: 0 16px 12px; }
.note p { margin: 0 0 6px; } .note > :last-child { margin-bottom: 0; }
.note b { color: var(--text); font-weight: 600; }
.note ul { margin: 0 0 6px; padding: 0; list-style: none; display: grid; gap: 4px; }
.note li { position: relative; padding-left: 16px; }
.note li::before { content: ""; position: absolute; left: 3px; top: .68em; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 180px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-2); padding: 4px; z-index: 10; transform-origin: top right; animation: pop .18s var(--ease); }
.menu-pop button { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; font: 500 13px var(--font); padding: 8px 10px; border-radius: 6px; cursor: pointer; color: var(--text); text-align: left; }
.menu-pop button:hover { background: var(--line-2); }
.menu-pop button.danger { color: var(--danger); }
.menu-pop button.danger:hover { background: #fdecec; }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(-4px); } }

.tablewrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: clip; box-shadow: var(--shadow-1); }
.preview .tablewrap { overflow: auto; }
table { border-collapse: separate; border-spacing: 0; width: 100%; }
th, td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th { position: sticky; top: 0; background: var(--sunken); font-size: 12px; font-weight: 600; color: var(--text-2); white-space: nowrap; z-index: 1; padding-top: 9px; padding-bottom: 9px; }
th .sortbtn { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; border-radius: 4px; }
th .sortbtn:hover { color: var(--text); }
th .sortbtn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
th .arrow { width: 12px; height: 12px; opacity: 0; transition: opacity .15s; }
th .sortbtn:hover .arrow { opacity: .35; }
th.sorted { color: var(--accent-ink); }
th.sorted .arrow { opacity: 1; }
th.r .sortbtn { flex-direction: row-reverse; }
th.r, td.r { text-align: right; }
td.num { white-space: nowrap; }
td.sorted { background: var(--accent-tint); }
td.sorted.num { font-weight: 600; }
td.idx, th.idx { color: var(--muted); width: 44px; font-variant-numeric: tabular-nums; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: var(--sunken); }
tbody tr:hover td.sorted { background: #fff0ea; }
td.main { font-weight: 500; min-width: 260px; line-height: 1.4; }
td.main a { text-decoration: none; display: inline; }
td.main a:hover { color: var(--accent-ink); text-decoration: underline; text-decoration-color: #f4b3a3; }
td.main a svg.i { width: 13px; height: 13px; margin-left: 4px; vertical-align: -1px; color: var(--muted); opacity: 0; transition: opacity .15s; }
td.main a:hover svg.i { opacity: 1; color: var(--accent); }
.nores { padding: 32px; text-align: center; color: var(--muted); }


/* view toggle */
.seg { display: inline-flex; background: var(--line-2); border-radius: var(--r); padding: 3px; gap: 2px; }
.seg button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; font: 500 13px var(--font); color: var(--text-2); padding: 0 10px; height: 30px; border-radius: 6px; cursor: pointer; transition: background .15s, color .15s, box-shadow .15s; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }

/* thumbnail di tabel */
.withthumb { display: flex; align-items: center; gap: 12px; }
.thumb { width: 44px; height: 44px; flex: none; border-radius: 8px; object-fit: cover; background: var(--line-2); border: 1px solid var(--line-2); }

/* mode kartu */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 14px; }
.pcard { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; text-decoration: none; box-shadow: var(--shadow-1); transition: box-shadow .2s var(--ease), transform .2s var(--ease), border-color .2s; }
a.pcard:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); border-color: #dcdfe5; }
a.pcard:hover .pname { color: var(--accent-ink); }
.pimg { position: relative; aspect-ratio: 1; background: var(--line-2); }
.pimg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pno { position: absolute; top: 8px; left: 8px; min-width: 24px; height: 22px; padding: 0 7px; border-radius: 6px; background: rgba(255, 255, 255, .92); color: var(--text-2); font: 600 11.5px var(--font); display: grid; place-items: center; font-variant-numeric: tabular-nums; box-shadow: var(--shadow-1); }
.pbody { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.pname { font-weight: 500; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.8em; transition: color .15s; }
.pstats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; margin: auto 0 0; }
.pstats div { min-width: 0; }
.pstats dt { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pstats dd { margin: 1px 0 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pstats .sorted dt { color: var(--accent-ink); }
.pstats .sorted dd { color: var(--accent-ink); font-weight: 700; }
.cards .nores { grid-column: 1 / -1; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }

/* dialog */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 24px); box-shadow: var(--shadow-2); }
dialog[open] { animation: pop .22s var(--ease); }
dialog::backdrop { background: rgba(17, 24, 39, .32); }
.dlg { padding: 20px 22px; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 12px; }
.preview { font-size: 13px; margin-bottom: 4px; padding: 10px 12px; background: var(--sunken); border-radius: var(--r); }
.preview .tablewrap { margin-top: 8px; max-height: 160px; box-shadow: none; border-radius: var(--r); }
.preview td, .preview th { padding: 6px 10px; color: var(--text); }
.preview th { top: 0 !important; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; z-index: 50; box-shadow: var(--shadow-2); animation: toast .3s var(--ease); }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (max-width: 700px) {
  main { padding: 16px 16px 56px; }
  .top { padding-left: 16px; padding-right: 16px; }
  .top .btn .lbl-long { display: none; }
  h1 { font-size: 19px; }
  .search { width: 100%; }
  .lrow { grid-template-columns: minmax(0, 1fr) auto 16px; padding: 13px 14px; }
  .lrow > .c-src, .lrow > .c-date { display: none; }
  .lhead { display: none; }
  .toolbar { top: 55px; flex-wrap: wrap; }
  .toolbar .field { flex: 1 1 100%; order: -1; }
  .toolbar .spacer { display: none; }
  .sortsel { display: block; flex: 1; min-width: 0; width: auto; height: 36px; padding: 0 8px; }
  .toolbar { flex-wrap: wrap; }
  .toolbar .count { display: none; }
  .note { font-size: 13px; }
  .note summary { padding: 9px 12px; }
  .note-body { padding: 0 14px 12px; }
  .meta .tag { margin-left: 0; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }

  .seg button span { display: none; }
  .seg button { padding: 0 9px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .pbody { padding: 10px 11px 12px; gap: 8px; }
  .pname { font-size: 13.5px; }
  .pstats { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .pstats div { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
  .pstats dt { flex: 1 1 auto; min-width: 0; font-size: 11px; }
  .pstats dd { margin: 0; font-size: 12.5px; flex: none; overflow: visible; }
  .data td.main .withthumb { align-items: flex-start; }

  /* tabel → kartu */
  .tablewrap.data { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .data table, .data tbody { display: block; }
  .data thead { display: none; }
  .data tbody tr { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--shadow-1); }
  .data tbody tr:hover td, .data td.sorted { background: none; }
  .data td { border: 0; padding: 0; text-align: left !important; min-width: 0; }
  .data td.idx { display: none; }
  .data td.main { grid-column: 1 / -1; min-width: 0; font-size: 14.5px; }
  .data td.main a svg.i { opacity: 1; }
  .data td:not(.main)::before { content: attr(data-label); display: block; font-size: 11.5px; font-weight: 500; color: var(--muted); margin-bottom: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .data td.sorted { color: var(--accent-ink); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
