:root {
  --bg: #121316;
  --panel: #1a1b1f;
  --panel-2: #212227;
  --line: #2b2d33;
  --text: #d9dadd;
  --muted: #8a8d95;
  --accent: #e9b44c;
  --accent-ink: #1b1406;
  --focus: #f3cd7f;
  --danger: #e5484d;
  --radius: 6px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: grid;
  grid-template-rows: 46px 1fr 92px;
  overflow: hidden;
  user-select: none;
}
button, input, select { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 10px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-size: 15px; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; margin-right: 8px; white-space: nowrap; }
.brand b { color: var(--accent); font-weight: 600; }
.logo { width: 18px; height: 18px; border-radius: 50%; background: conic-gradient(from 200deg, #e9b44c, #e5484d, #8d5cf2, #3a7ff2, #3ec7c2, #e9b44c); box-shadow: inset 0 0 0 4px var(--panel); }
.spacer { flex: 1; }
.tb-group { display: flex; gap: 2px; }
.btn { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 12px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.hold { touch-action: none; }
.btn.hold.on { border-color: var(--accent); color: var(--accent); }
.btn.install { border-color: rgba(233,180,76,.5); color: var(--accent); }
.btn.install:hover:not(:disabled) { background: rgba(233,180,76,.1); }
.install-steps { margin: 0 0 12px; padding-left: 20px; line-height: 1.7; }
.btn.accent-soft { color: var(--accent); border-color: rgba(233,180,76,.4); }
.btn:hover:not(:disabled) { border-color: #3a3d45; background: #272930; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: #2a2c33; }
.btn.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.accent:hover:not(:disabled) { background: var(--focus); }
.btn.small { padding: 5px 8px; font-size: 12px; }
.btn.block { width: 100%; margin-top: 8px; }
.btn.danger { color: #ff8a8d; }
.btn.on { border-color: var(--accent); color: var(--accent); }
.icon-btn { width: 30px; height: 30px; display: grid; place-items: center; background: transparent; border: 1px solid transparent; border-radius: var(--radius); cursor: pointer; font-size: 16px; }
.icon-btn:hover:not(:disabled) { background: var(--panel-2); border-color: var(--line); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 2px; }
.seg button { background: transparent; border: 0; padding: 4px 10px; border-radius: 4px; cursor: pointer; color: var(--muted); }
.seg button.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.seg.small button { padding: 3px 8px; font-size: 11.5px; }
.seg.full { display: flex; width: 100%; }
.seg.full button { flex: 1; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 244px 1fr 330px; min-height: 0; }
.panel { background: var(--panel); min-height: 0; display: flex; flex-direction: column; }
.panel.left { border-right: 1px solid var(--line); overflow-y: auto; }
.panel.right { border-left: 1px solid var(--line); }
.pane { padding: 12px; border-bottom: 1px solid var(--line); }
.pane.grow { flex: 1; min-height: 120px; }
.pane h3 { margin: 0 0 8px; font-size: 11px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.span2 { grid-column: span 2; }

.preset-list { max-height: 46vh; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.preset { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 0; border: 0; background: none; cursor: pointer; text-align: left; color: var(--text); }
.preset img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 5px; background: var(--panel-2); display: block; box-shadow: 0 0 0 1px var(--line); transition: box-shadow .12s; }
.preset img:not([src]) { visibility: hidden; }
.preset:hover img, .preset:focus-visible img { box-shadow: 0 0 0 2px var(--accent); }
.preset-name { font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #c9cbd0; }
.preset:hover .preset-name { color: var(--text); }
.preset .x { position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; border-radius: 50%; background: rgba(0,0,0,.7); color: #fff; font-size: 10px; display: grid; place-items: center; opacity: 0; }
.preset:hover .x { opacity: 1; }
.preset-list.no-photo .preset-grid { grid-template-columns: 1fr; gap: 2px; }
.preset-list.no-photo .preset img { display: none; }
.preset-list.no-photo .preset { padding: 5px 6px; border-radius: 4px; }
.preset-list.no-photo .preset:hover { background: var(--panel-2); }
.preset-group { font-size: 10.5px; color: var(--muted); margin: 10px 0 6px; text-transform: uppercase; letter-spacing: .6px; }
.preset-group:first-child { margin-top: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.chip { border: 1px solid var(--line); background: var(--bg); color: var(--muted); border-radius: 12px; padding: 3px 9px; font-size: 11.5px; cursor: pointer; }
.chip:hover { color: var(--text); border-color: #3a3d45; }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.preset-strength { margin: 0 0 10px; padding: 8px 10px 10px; border-radius: 7px; background: rgba(233,180,76,.07); border: 1px solid rgba(233,180,76,.25); }
.preset-strength .ps-name { font-weight: 600; color: var(--accent); font-size: 12px; }
.preset-strength .srow { margin-top: 2px; }
.h3-note { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 4px; color: #6d7079; }

.history { list-style: none; margin: 0; padding: 0; overflow-y: auto; max-height: calc(100% - 20px); }
.history li { padding: 4px 8px; border-radius: 4px; cursor: pointer; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history li:hover { background: var(--panel-2); color: var(--text); }
.history li.current { color: var(--text); background: var(--panel-2); box-shadow: inset 2px 0 0 var(--accent); }
.history li.future { opacity: .45; }

/* ---------- stage ---------- */
.stage { position: relative; min-width: 0; min-height: 0; background: #131417; overflow: hidden; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#ovCanvas { touch-action: none; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; cursor: pointer; }
.empty-box { text-align: center; padding: 48px 56px; border: 1.5px dashed #3a3d45; border-radius: 14px; color: var(--muted); transition: border-color .15s, background .15s; }
.empty-box h2 { margin: 12px 0 4px; color: var(--text); font-weight: 500; font-size: 18px; }
.empty-box p { margin: 0; }
.empty-icon { width: 54px; height: 54px; margin: 0 auto; border-radius: 12px; background: var(--panel-2); position: relative; }
.empty-icon::before { content: ""; position: absolute; inset: 14px 12px 16px; border-radius: 3px; background: linear-gradient(160deg, transparent 55%, var(--accent) 56%); box-shadow: inset 0 0 0 2px var(--muted); }
.empty-icon::after { content: ""; position: absolute; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); top: 18px; right: 17px; }
body.dragging .empty-box, .empty:hover .empty-box { border-color: var(--accent); background: rgba(233, 180, 76, .04); }
body.dragging .stage::after { content: "Lepas untuk import"; position: absolute; inset: 12px; border: 2px dashed var(--accent); border-radius: 12px; display: grid; place-items: center; font-size: 18px; color: var(--accent); background: rgba(18, 19, 22, .7); pointer-events: none; }
.infobar { position: absolute; left: 10px; bottom: 8px; color: var(--muted); font-size: 11.5px; pointer-events: none; text-shadow: 0 1px 2px #000; }
.toast { position: absolute; left: 50%; top: 14px; transform: translate(-50%, -8px); background: #26282e; border: 1px solid var(--line); padding: 7px 14px; border-radius: 20px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- right panel ---------- */
.histo-wrap { padding: 10px 12px 4px; border-bottom: 1px solid var(--line); }
#histo { width: 100%; height: 100px; display: block; border-radius: 4px; background: #111215; }
.histo-info { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; padding: 4px 0 2px; min-height: 20px; }
.tools { display: flex; gap: 2px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.tools button { flex: 1; padding: 7px 6px; background: transparent; border: 1px solid transparent; border-radius: var(--radius); cursor: pointer; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.tools button:hover { color: var(--text); }
.tools button.active { background: var(--panel-2); border-color: var(--line); color: var(--accent); }
.tool-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.panel.right.disabled .tool-scroll, .panel.right.disabled .tools { opacity: .4; pointer-events: none; }
.tool-panel { padding-bottom: 24px; }

.edit-top { display: flex; gap: 6px; padding: 10px 12px; align-items: center; border-bottom: 1px solid var(--line); }
.edit-top .seg { flex: 1; }
.edit-top .seg button { flex: 1; }

details.sec { border-bottom: 1px solid var(--line); }
details.sec > summary { list-style: none; padding: 11px 12px; cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.sec-icon { display: grid; color: var(--muted); }
details.sec[open] .sec-icon { color: var(--accent); }
.sec-title { flex: 1; }
.sec-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.sec-reset { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 4px; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0; }
.sec-reset:hover { background: var(--panel-2); color: var(--text); }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; margin-right: 2px; }
details.sec[open] > summary::before { transform: rotate(45deg); }
details.sec > summary:hover { background: #1e1f24; }
.sec-body { padding: 2px 12px 12px; }
.sub { font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin: 12px 0 2px; }

/* slider row */
.srow { display: grid; grid-template-columns: 1fr 52px; grid-template-areas: "lab num" "rng rng"; align-items: center; margin-top: 6px; }
.slab { grid-area: lab; color: #c4c6cb; cursor: default; }
.slab:hover { color: var(--text); }
.snum { grid-area: num; width: 52px; text-align: right; background: transparent; border: 1px solid transparent; border-radius: 3px; padding: 1px 4px; color: var(--muted); font-variant-numeric: tabular-nums; }
.snum:hover, .snum:focus { border-color: var(--line); background: var(--bg); color: var(--text); outline: none; }
.srng { grid-area: rng; width: 100%; height: 18px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer;
  --a: 0%; --b: 0%; --track: none; }
.srng::-webkit-slider-runnable-track { height: 3px; border-radius: 2px;
  background: linear-gradient(90deg, #383a41 var(--a), var(--accent) var(--a), var(--accent) var(--b), #383a41 var(--b)); }
.srng::-moz-range-track { height: 3px; border-radius: 2px;
  background: linear-gradient(90deg, #383a41 var(--a), var(--accent) var(--a), var(--accent) var(--b), #383a41 var(--b)); }
.srng.custom::-webkit-slider-runnable-track { background: var(--track); height: 4px; }
.srng.custom::-moz-range-track { background: var(--track); height: 4px; }
.srng::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5.5px; border-radius: 50%; background: #e8e9ec; border: 2px solid #1a1b1f; box-shadow: 0 0 0 1px #50535b; }
.srng.custom::-webkit-slider-thumb { margin-top: -5px; }
.srng::-moz-range-thumb { width: 9px; height: 9px; border-radius: 50%; background: #e8e9ec; border: 2px solid #1a1b1f; box-shadow: 0 0 0 1px #50535b; }
.srng:hover::-webkit-slider-thumb { background: #fff; }
.srng:focus-visible { outline: none; }
.srng:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 2px var(--focus); }

/* curve */
.curve-wrap { position: relative; margin-top: 8px; }
canvas.curve { width: 100%; aspect-ratio: 1; display: block; border-radius: 4px; background: #111215; cursor: crosshair; touch-action: none; }
.hint { color: var(--muted); font-size: 11px; margin: 6px 0 0; line-height: 1.45; }

/* wheels */
.wheels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.wheel-box { text-align: center; }
.wheel-box .wl { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.wheel { position: relative; width: 100%; aspect-ratio: 1; border-radius: 50%; cursor: crosshair; touch-action: none;
  background: radial-gradient(circle closest-side, #7d7d7d 0%, rgba(125,125,125,.85) 25%, rgba(125,125,125,0) 100%),
    conic-gradient(from 90deg, #f33, #ff3, #3f3, #3ff, #33f, #f3f, #f33);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.4); filter: saturate(.75) brightness(.9); }
.wheel .dot { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #000; pointer-events: none; }
.wheel-box .srow { margin-top: 2px; grid-template-columns: 1fr; grid-template-areas: "rng"; }
.wheel-box .slab, .wheel-box .snum { display: none; }
.wheel-val { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* masks */
.mask-intro { margin: 12px 12px 0; padding: 12px 14px; border-radius: 8px; background: rgba(233,180,76,.07); border: 1px solid rgba(233,180,76,.25); }
.mask-intro-title { font-weight: 600; margin-bottom: 6px; color: var(--accent); }
.steps { margin: 0; padding-left: 18px; color: #c4c6cb; line-height: 1.6; }
.mask-head { display: flex; justify-content: space-between; padding: 12px 12px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 600; }
.mask-add { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 0 12px 12px; border-bottom: 1px solid var(--line); }
.mask-card { display: grid; grid-template-columns: 22px 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center; text-align: left; padding: 9px 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; }
.mask-card svg { grid-row: span 2; width: 20px; height: 20px; color: var(--accent); }
.mask-card b { font-weight: 600; }
.mask-card small { color: var(--muted); font-size: 11px; line-height: 1.3; }
.mask-card:hover:not(:disabled) { border-color: var(--accent); background: #272930; }
.mask-card:disabled { opacity: .4; cursor: default; }
.mask-card:first-child:nth-last-child(odd) { grid-column: span 2; }
.mask-add.compact { grid-template-columns: repeat(5, 1fr); gap: 4px; }
.mask-add.compact .mask-card { grid-template-columns: 1fr; justify-items: center; padding: 7px 2px; gap: 3px; grid-column: auto; }
.mask-add.compact .mask-card svg { grid-row: auto; }
.mask-add.compact .mask-card b { font-size: 10.5px; font-weight: 500; }
.mask-add.compact small { display: none; }
.mi-icon { display: grid; color: var(--accent); }
.hintbar { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); max-width: calc(100% - 32px); background: rgba(20,21,24,.88); border: 1px solid var(--line); color: #dcdde0; padding: 7px 14px; border-radius: 20px; font-size: 12px; pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; backdrop-filter: blur(6px); }
.welcome-steps { list-style: none; display: flex; gap: 18px; justify-content: center; padding: 0; margin: 22px 0 0; }
.welcome-steps li { display: flex; align-items: center; gap: 8px; color: #c4c6cb; }
.welcome-steps b { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2); color: var(--accent); font-size: 11px; }
.mask-count { grid-column: span 1; align-self: center; text-align: center; color: var(--muted); font-size: 11px; }
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.quick-grid .btn { white-space: normal; text-align: left; }
.mask-list { padding: 8px 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.mask-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 5px; border: 1px solid var(--line); cursor: pointer; background: var(--bg); }
.mask-item.sel { border-color: var(--accent); }
.mask-item .mi-name { flex: 1; }
.mask-item .mi-type { color: var(--muted); font-size: 11px; }
.mask-item button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px 4px; }
.mask-item button:hover { color: var(--text); }
.chk { display: flex; align-items: center; gap: 6px; margin: 8px 0 0; cursor: pointer; color: #c4c6cb; }
.chk input { accent-color: var(--accent); }
.row-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.empty-note { color: var(--muted); padding: 12px; line-height: 1.5; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -3px; margin-left: 6px; box-shadow: 0 0 0 1px #000; }

/* crop */
.crop-panel { padding: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; color: #c4c6cb; }
.field select, .field input[type=text], .field input[type=number] { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px; }
.field input[type=range] { accent-color: var(--accent); }

/* filmstrip */
.filmstrip { background: var(--panel); border-top: 1px solid var(--line); display: flex; gap: 6px; padding: 8px 10px; overflow-x: auto; align-items: center; }
.film { position: relative; flex: 0 0 auto; height: 72px; border-radius: 4px; overflow: hidden; cursor: pointer; border: 2px solid transparent; background: #0f1012; }
.film img { height: 100%; display: block; }
.film.sel { border-color: var(--accent); }
.film:hover .film-x { opacity: 1; }
.film-x { position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; border: 0; background: rgba(0,0,0,.7); color: #fff; cursor: pointer; opacity: 0; font-size: 11px; line-height: 18px; padding: 0; }
.film-edited { position: absolute; left: 4px; bottom: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px #000; }
.film-note { color: var(--muted); padding: 0 8px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 10; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 20px 22px; width: min(420px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal-box h2 { margin: 0 0 16px; font-size: 16px; font-weight: 600; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.keys { width: 100%; border-collapse: collapse; }
.keys td { padding: 5px 0; border-bottom: 1px solid var(--line); }
.keys td:first-child { white-space: nowrap; padding-right: 14px; }
kbd { background: var(--bg); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 1px 6px; font: 11px ui-monospace, Consolas, monospace; }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2e3037; border-radius: 6px; border: 2px solid var(--panel); }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 1250px) {
  .btn.hold span, #zoomSeg button:last-child { display: none; }
}
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr 290px; }
  .panel.left { display: none; }
  .brand { display: none; }
}
@media (max-width: 680px) {
  body { grid-template-rows: auto 1fr 80px; }
  .topbar { flex-wrap: wrap; padding: 6px 10px; height: auto; }
  .layout { grid-template-columns: 1fr; grid-template-rows: 55% 45%; }
  .panel.right { border-left: 0; border-top: 1px solid var(--line); }
  .film { height: 60px; }
}
