:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --soft: #f5f5f4;
  --soft-2: #efefed;
  --line: #e8e8e6;
  --ink: #0d0d0d;
  --ink-2: #4a4a48;
  --ink-3: #8a8a86;
  --solid: #0d0d0d;
  --solid-ink: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 1px 3px rgba(0,0,0,.06), 0 8px 24px -12px rgba(0,0,0,.16);
  --shadow-lg: 0 2px 6px rgba(0,0,0,.06), 0 18px 50px -20px rgba(0,0,0,.24);
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --ok: #15803d;
  --ok-bg: #ecfdf3;
  --bad: #b42318;
  --bad-bg: #fef3f2;
}

body.dark {
  --bg: #0b0b0b;
  --panel: #121212;
  --soft: #171717;
  --soft-2: #1e1e1e;
  --line: #262626;
  --ink: #f2f2f0;
  --ink-2: #a8a8a4;
  --ink-3: #6f6f6b;
  --solid: #f2f2f0;
  --solid-ink: #0b0b0b;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.5);
  --shadow-md: 0 1px 3px rgba(0,0,0,.6), 0 8px 24px -12px rgba(0,0,0,.8);
  --shadow-lg: 0 2px 6px rgba(0,0,0,.6), 0 18px 50px -20px rgba(0,0,0,.9);
  --ok: #6ee7a8;
  --ok-bg: rgba(22,163,74,.12);
  --bad: #fca5a5;
  --bad-bg: rgba(220,38,38,.14);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
.hidden { display: none !important; }
.mt-8{margin-top:8px}.mt-10{margin-top:10px}.mt-12{margin-top:12px}.mt-14{margin-top:14px}
.mt-16{margin-top:16px}.mt-18{margin-top:18px}.mt-20{margin-top:20px}.mt-22{margin-top:22px}.mt-24{margin-top:24px}
.row-8{display:flex;align-items:center;gap:8px;flex-wrap:wrap}

/* ---------- marks & type ---------- */
.mark { display: inline-flex; align-items: center; gap: 7px; }
.mark-dot { width: 9px; height: 9px; border-radius: 2px; background: var(--ink); display: inline-block; transform: rotate(45deg); }
.mark-dot.sm { width: 8px; height: 8px; }
.mark-name { font-size: 13px; font-weight: 550; letter-spacing: -.01em; }

.h-serif {
  margin: 0; font-family: var(--serif); font-weight: 400;
  font-size: 34px; line-height: 1.08; letter-spacing: -.01em;
}
.hero {
  margin: 0; font-family: var(--serif); font-weight: 400;
  font-size: 42px; line-height: 1.02; letter-spacing: -.02em; max-width: 12ch;
}
.hero-sub { margin: 10px 0 0; color: var(--ink-3); font-size: 13.5px; max-width: 34ch; line-height: 1.5; }
.muted { margin: 0; color: var(--ink-3); font-size: 13px; line-height: 1.55; }
.muted-sm { color: var(--ink-3); font-size: 11.5px; }
.hint { color: var(--ink-3); font-size: 11px; }
.section-label {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3); margin: 26px 0 12px;
}

/* ---------- panels / chips ---------- */
.panel { background: var(--panel); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 30px 26px; }
.center-shell {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; padding: 24px;
  background: var(--bg);
}
.center-card { width: 100%; max-width: 400px; }
.chip-soft {
  display: inline-flex; align-items: center; height: 24px; padding: 0 10px;
  border-radius: 999px; background: var(--soft); color: var(--ink-2);
  font-size: 10.5px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap;
}

/* ---------- forms ---------- */
.stack { display: flex; flex-direction: column; gap: 10px; }
.code-input {
  width: 100%; height: 50px; border: 0; border-radius: 14px; background: var(--soft);
  color: var(--ink); text-align: center; font-family: var(--mono); font-size: 15px;
  letter-spacing: .16em; text-transform: uppercase; outline: none;
  transition: box-shadow .15s, background .15s;
}
.code-input::placeholder { letter-spacing: .12em; color: var(--ink-3); }
.code-input:focus { background: var(--panel); box-shadow: 0 0 0 1.5px var(--ink); }
.code-field { display: flex; flex-direction: column; gap: 7px; }
.code-label { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
.mark + .h-serif { margin-top: 16px; }

.btn-solid {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 44px; padding: 0 20px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--solid); color: var(--solid-ink);
  font-family: inherit; font-size: 13.5px; font-weight: 500; letter-spacing: -.005em;
  transition: opacity .15s, transform .1s;
}
.btn-solid:active { transform: scale(.985); }
.btn-solid:disabled { opacity: .38; cursor: not-allowed; }
.btn-solid.full { width: 100%; }
.btn-ghost {
  height: 36px; padding: 0 14px; border: 0; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--ink-2); font-family: inherit; font-size: 12.5px;
}
.btn-ghost:hover { background: var(--soft); }

.err-box {
  padding: 10px 12px; border-radius: 10px; background: var(--bad-bg); color: var(--bad);
  font-size: 12.5px; line-height: 1.45;
}

/* ---------- HOME ---------- */
.home-shell {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  background: var(--bg);
}
.home-top {
  flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 16px 20px; width: 100%; max-width: 760px; margin: 0 auto;
}
.home-note { font-size: 11.5px; color: var(--ink-3); letter-spacing: .02em; }
.home-body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 8px 20px 28px; max-width: 760px; width: 100%; margin: 0 auto;
  display: flex; flex-direction: column; justify-content: space-between;
}

/* galeri gaya */
.preset-gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px;

}
.preset-card {
  position: relative; display: flex; flex-direction: column; gap: 0; padding: 0;
  border: 0; border-radius: 16px; background: var(--soft); overflow: hidden;
  cursor: pointer; text-align: left; color: inherit; font-family: inherit;
  transition: transform .16s ease, box-shadow .16s ease;
}
.preset-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.preset-card.active { box-shadow: 0 0 0 1.5px var(--ink); }
.preset-card.active .pc-swatch::after {
  content: '✓'; position: absolute; top: 10px; right: 10px; width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
  background: var(--ink); color: var(--bg); font-size: 10px; font-weight: 700;
  box-shadow: 0 0 0 2px var(--bg);
}

.pc-name { display: block; }
.pc-swatch { display: block; height: 92px; width: 100%; position: relative; }
.pc-name { display: block; padding: 9px 11px 10px; font-size: 11px; color: var(--ink-2); letter-spacing: -.005em; }
.pc-vercel { background: linear-gradient(150deg, #ffffff 0 46%, #0d0d0d 46% 100%); }
.pc-linear { background: linear-gradient(150deg, #101014 0 60%, #2c2c38 60% 100%); }
.pc-editorial { background: linear-gradient(150deg, #f6f1e6 0 55%, #c4b69c 55% 100%); }
.pc-neo { background: linear-gradient(150deg, #ffe14d 0 58%, #101010 58% 100%); }
.pc-mono { background: linear-gradient(150deg, #ffffff 0 50%, #d8d8d4 50% 100%); }

/* ---------- COMPOSER (floating) ---------- */
.composer-wrap {
  position: sticky; bottom: 0; flex-shrink: 0;
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 62%, transparent);
}
.pane-chat .composer-wrap { background: var(--bg); padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); }
.composer {
  max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 2px;
  background: var(--panel); border-radius: 22px; padding: 10px 12px 8px;
  box-shadow: var(--shadow-md), 0 0 0 1px var(--line);
}
.proj-input {
  width: 100%; border: 0; background: transparent; color: var(--ink);
  font-family: inherit; font-size: 13px; font-weight: 500; padding: 2px 2px 4px; outline: none;
}
.proj-input::placeholder { color: var(--ink-3); font-weight: 400; letter-spacing: 0; }
.field-label { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 2px 2px 0; }
.proj-input { padding-bottom: 2px; }
.composer-divider { height: 1px; background: var(--soft-2); margin: 4px 0 6px; }
.composer-input {
  width: 100%; border: 0; background: transparent; color: var(--ink);
  font-family: inherit; font-size: 14.5px; line-height: 1.5; padding: 2px 2px 6px;
  outline: none; resize: none; max-height: 140px; min-height: 28px;
}
.composer-input::placeholder { color: var(--ink-3); }
.composer-tools { display: flex; align-items: center; gap: 8px; }
.round-btn {
  width: 30px; height: 30px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 50%;
  background: transparent; color: var(--ink-2); font-size: 16px; line-height: 1;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.round-btn:hover { background: var(--soft); }
.model-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 46%; overflow: hidden;
  border: 0; background: transparent; border-radius: 999px; padding: 5px 8px;
  font-family: inherit; font-size: 11.5px; color: var(--ink-2); cursor: pointer;
  white-space: nowrap; text-overflow: ellipsis;
}
.model-chip:hover { background: var(--soft); }
.model-chip #modelChipLabel { font-family: var(--mono); font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.model-dot { width: 5px; height: 5px; border-radius: 50%; background: #16a34a; flex: 0 0 auto; }
.caret { opacity: .5; font-size: 11px; margin-left: -1px; }
.send-btn {
  margin-left: auto; width: 32px; height: 32px; flex: 0 0 auto; border: 0; border-radius: 50%;
  background: var(--solid); color: var(--solid-ink); font-size: 15px; line-height: 1;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: opacity .15s, transform .1s;
}
.send-btn:active { transform: scale(.94); }
.send-btn:disabled { opacity: .3; cursor: not-allowed; }

/* ---------- WORKSPACE ---------- */
.studio-shell { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }
.topbar {
  flex-shrink: 0; height: 52px; padding: 0 14px; display: flex; align-items: center;
  justify-content: space-between; gap: 10px; background: var(--bg);
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tb-timer { font-family: var(--mono); font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.meters { display: flex; align-items: center; gap: 4px; }
.meter {
  display: inline-flex; align-items: baseline; gap: 4px; padding: 3px 7px;
  border-radius: 999px; background: var(--soft); font-family: var(--mono); font-size: 10.5px;
}
.meter-k { color: var(--ink-3); font-size: 9.5px; letter-spacing: .04em; }
.meter-v { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.icon-btn {
  width: 30px; height: 30px; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--ink-2);
  font-size: 14px; line-height: 1; cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--soft); }

.mob-pane-bar {
  display: none; flex-shrink: 0; gap: 2px; padding: 0 14px 6px;
}
.mob-pane-btn {
  flex: 0 0 auto; height: 30px; padding: 0 14px; border: 0; border-radius: 999px;
  background: transparent; color: var(--ink-3);
  font-family: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer;
}
.mob-pane-btn.active { background: var(--soft); color: var(--ink); }

.split-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 440px minmax(0, 1fr); }
.pane-chat { display: flex; flex-direction: column; min-height: 0; background: var(--bg); border-right: 1px solid var(--line); }

.chat-scroll {
  flex: 1; min-height: 0; overflow-y: auto; scroll-behavior: smooth; overscroll-behavior: contain;
  padding: 18px 16px 26px; display: flex; flex-direction: column; gap: 14px;

}
.chat-scroll::-webkit-scrollbar { width: 6px; }
.chat-scroll::-webkit-scrollbar-thumb { background: var(--soft-2); border-radius: 99px; }

/* bubbles: user = pill solid, ai = teks bersih tanpa kotak */
.msg-bubble { flex: 0 0 auto; font-size: 14px; line-height: 1.62; white-space: pre-wrap; word-break: break-word; }
.msg-user {
  align-self: flex-end; max-width: 84%; background: var(--soft); color: var(--ink);
  padding: 10px 14px; border-radius: 18px 18px 5px 18px; font-size: 13.5px; line-height: 1.5;
}
.msg-ai { align-self: stretch; max-width: 100%; color: var(--ink); padding: 0 2px; }
.msg-ai strong { font-weight: 600; }
.trace-card {
  align-self: stretch; padding: 8px 10px; border-radius: 10px; background: var(--soft);
  font-family: var(--mono); font-size: 11px; color: var(--ink-2); line-height: 1.5;
}
.trace-ok { color: var(--ok); }
.trace-err { color: var(--bad); }

/* langkah agent */
.steps-group {
  flex: 0 0 auto; flex-shrink: 0; align-self: stretch;
  border-radius: 12px; background: var(--soft); overflow: hidden;
}
.steps-head {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 12px;
  background: transparent; border: 0; cursor: pointer; text-align: left; color: var(--ink-2);
  font-family: inherit; font-size: 12px;
}
.steps-head:hover { background: var(--soft-2); }
.steps-ico { font-size: 9px; opacity: .55; width: 9px; }
.steps-label { font-weight: 500; letter-spacing: -.005em; }
.steps-body { display: none; padding: 2px 12px 10px; }
.steps-group.open .steps-body { display: block; }
.steps-group.open .steps-head { color: var(--ink); }
.step-row {
  display: flex; align-items: baseline; gap: 7px; padding: 4px 0;
  font-size: 11px; flex-wrap: wrap; border-top: 1px solid var(--line);
}
.step-row:first-child { border-top: 0; }
.step-name { font-family: var(--mono); font-size: 10px; color: var(--ink); }
.step-arg { flex: 1 1 110px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-3); font-family: var(--mono); font-size: 10px; }
.step-state { font-size: 9px; letter-spacing: .05em; text-transform: uppercase; padding: 1px 5px; border-radius: 4px; }
.step-state.running { background: var(--soft-2); color: var(--ink-2); }
.step-state.ok { background: var(--ok-bg); color: var(--ok); }
.step-state.fail { background: var(--bad-bg); color: var(--bad); }
.step-preview { flex: 1 1 100%; font-size: 10px; color: var(--ink-3); padding-top: 2px; }

/* preview pane */
.pane-preview { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.preview-toolbar {
  flex-shrink: 0; min-height: 46px; padding: 8px 12px; display: flex; align-items: center;
  justify-content: space-between; gap: 8px; flex-wrap: wrap;
}
.subtab-group { display: flex; align-items: center; gap: 2px; padding: 2px; border-radius: 999px; background: var(--soft); }
.subtab {
  height: 28px; padding: 0 12px; border: 0; border-radius: 999px; background: transparent;
  color: var(--ink-3); font-family: inherit; font-size: 12px; font-weight: 500; cursor: pointer;
}
.subtab.active { background: var(--panel); color: var(--ink); box-shadow: var(--shadow-sm); }
.preview-controls { display: flex; align-items: center; gap: 2px; }
.port-input {
  width: 62px; height: 28px; padding: 0 6px; border: 0; border-radius: 8px; background: var(--soft);
  color: var(--ink-2); font-family: var(--mono); font-size: 11px; text-align: center; outline: none;
}

.rtab-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.iframe-stage { flex: 1; min-height: 0; display: flex; justify-content: center; align-items: stretch; padding: 12px; }
.iframe-stage iframe {
  width: 100%; height: 100%; border: 0; border-radius: 14px; background: #fff;
  box-shadow: var(--shadow-md), 0 0 0 1px var(--line); transition: width .2s ease;
}
.iframe-stage.mobile-mode iframe { width: 390px; max-width: 100%; }

.files-split { display: grid; grid-template-columns: 210px minmax(0, 1fr); }
.file-tree {
  overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 1px;
  font-family: var(--mono); font-size: 11.5px; border-right: 1px solid var(--line);
}
.file-item { padding: 6px 8px; border-radius: 7px; cursor: pointer; color: var(--ink-2); word-break: break-all; }
.file-item:hover, .file-item.active { background: var(--soft); color: var(--ink); }
.file-viewer {
  margin: 0; padding: 14px 16px; overflow: auto; font-family: var(--mono);
  font-size: 11.5px; line-height: 1.6; color: var(--ink-2); background: var(--bg);
}
.media-grid { padding: 14px; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; align-content: start; }
.media-card { background: var(--panel); border-radius: 14px; box-shadow: var(--shadow-md), 0 0 0 1px var(--line); padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.media-card video, .media-card img { width: 100%; border-radius: 8px; background: #000; max-height: 220px; object-fit: contain; }

/* ---------- SHEET MODEL ---------- */
.sheet-scrim {
  position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.34);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadein .16s ease;
}
@keyframes fadein { from { opacity: 0 } to { opacity: 1 } }
.sheet-card {
  width: 100%; max-width: 480px; background: var(--panel);
  border-radius: 22px 22px 0 0; padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg); animation: slideup .22s cubic-bezier(.32,.72,0,1);
}
@keyframes slideup { from { transform: translateY(18px); opacity: .6 } to { transform: none; opacity: 1 } }
.sheet-grab { width: 34px; height: 4px; border-radius: 99px; background: var(--soft-2); margin: 6px auto 14px; }
.sheet-title { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; }
.sheet-list { display: flex; flex-direction: column; gap: 1px; }
.sheet-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 11px 10px; border: 0; border-radius: 12px; background: transparent;
  color: inherit; cursor: pointer; text-align: left; font-family: inherit;
}
.sheet-item:hover { background: var(--soft); }
.sheet-item.active { background: var(--soft); }
.si-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.si-name { font-family: var(--mono); font-size: 12.5px; }
.si-desc { font-size: 11px; color: var(--ink-3); }
.si-check { font-size: 13px; color: var(--ink); }
.sheet-note { font-size: 10.5px; color: var(--ink-3); margin-top: 12px; line-height: 1.5; }

/* ---------- markdown ---------- */
.md-pre {
  margin: 10px 0; padding: 12px 14px; border-radius: 12px; background: var(--soft);
  font-family: var(--mono); font-size: 11.5px; line-height: 1.6;
  overflow-x: auto; white-space: pre; color: var(--ink-2);
}
.md-code { font-family: var(--mono); font-size: 12px; padding: 1px 5px; border-radius: 5px; background: var(--soft); }
.md-h { font-weight: 600; margin-top: 12px; font-size: 13.5px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .mark-name { display: none; }
  .home-shell .mark-name { display: inline; }
  .hero { font-size: 36px; }
  .mob-pane-bar { display: flex; }
  .split-main { grid-template-columns: 1fr; }
  .pane-chat { border-right: 0; }
  .pane-chat.mob-hidden, .pane-preview.mob-hidden { display: none; }
  .files-split { grid-template-columns: 1fr; grid-template-rows: 150px 1fr; }
  .topbar { height: 48px; padding: 0 10px; gap: 6px; }
  .topbar .meters { gap: 2px; }
  .meter { padding: 2px 6px; font-size: 10px; }
  .pane-preview .subtab-group { display: none; }
  .preview-toolbar { min-height: 40px; padding: 6px 10px; justify-content: flex-end; }
  .preview-toolbar .subtab-group { display: none; }
  .preset-gallery { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .pc-swatch { height: 84px; }
  .chat-scroll { padding: 14px 14px 6px; gap: 12px; }
  .panel { padding: 26px 22px; }
  .h-serif { font-size: 30px; }
}

@media (max-width: 380px) {
  .meter-k { display: none; }
  .hero { font-size: 32px; }
  .preset-gallery { grid-template-columns: 1fr; }
}

/* aksi di bawah jawaban AI */
.msg-actions { display: flex; align-items: center; gap: 2px; margin-top: 6px; opacity: 0; transition: opacity .15s; }
.msg-bubble:hover .msg-actions, .msg-actions.show { opacity: 1; }
.msg-act {
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 7px; background: transparent; color: var(--ink-3);
  font-size: 12px; cursor: pointer; line-height: 1;
}
.msg-act:hover { background: var(--soft); color: var(--ink); }
@media (max-width: 900px) { .msg-actions { opacity: 1; } }

.msg-ai-label {
  display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
  font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3);
}
.msg-ai-label .d { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-3); }

@media (min-width: 901px) {
  .preset-gallery { grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .home-top, .home-body { max-width: 768px; }
  .composer { max-width: 728px; }
  .pc-swatch { height: 104px; }
}
