@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&family=Newsreader:opsz,wght@6..72,400;6..72,500&display=swap");

:root {
  font-family: "DM Sans", sans-serif;
  color: #26241f;
  background: #f7f6f2;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, textarea:focus-visible { outline: 2px solid #b45c3b; outline-offset: 2px; }

.app-shell { display: flex; height: 100vh; min-height: 650px; overflow: hidden; background: #f8f7f4; }

/* ---------- sidebar ---------- */
.sidebar {
  z-index: 30; display: flex; width: 272px; flex: 0 0 272px; flex-direction: column;
  border-right: 1px solid #e4e0d8; background: #eeece5; padding: 24px 14px 16px;
  overflow-y: auto; overscroll-behavior: contain;
}
.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 23px; }
.brand {
  display: flex; align-items: center; gap: 10px; border: 0; background: transparent;
  font-family: "Newsreader", serif; font-size: 23px; font-weight: 500; cursor: pointer;
}
.brand-mark, .welcome-mark, .assistant-mark { display: grid; place-items: center; color: #ad5738; }
.brand-mark { width: 27px; height: 27px; border: 1px solid #c86744; border-radius: 8px; transform: rotate(-3deg); }
.icon-button {
  display: grid; width: 36px; height: 36px; place-items: center; border: 0;
  border-radius: 9px; background: transparent; cursor: pointer;
}
.icon-button:hover { background: #e4e0d7; }
.mobile-close { display: none; }
.sidebar-nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; width: 100%; height: 42px; align-items: center; gap: 12px; border: 0;
  border-radius: 10px; background: transparent; padding: 0 12px; color: #55514a;
  font-size: 14px; text-align: left; cursor: pointer; transition: background 160ms ease, color 160ms ease;
}
.nav-item svg { width: 18px; height: 18px; }
.nav-item:hover { background: #e3dfd6; color: #292722; }
.nav-item-primary { margin-bottom: 7px; background: #e1ddd3; color: #28251f; font-weight: 500; }
.recent-section { min-height: 0; flex: 1; margin-top: 31px; overflow-y: auto; }
.section-label {
  margin: 0 12px 9px; color: #8b867e; font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.recent-list { display: flex; flex-direction: column; }
.recent-item {
  display: flex; width: 100%; height: 39px; align-items: center; justify-content: space-between;
  border: 0; border-radius: 9px; background: transparent; padding: 0 11px; color: #666159;
  font-size: 13px; text-align: left; cursor: pointer;
}
.recent-item > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-item:hover { background: #e5e1d8; color: #2c2924; }
.recent-item.aktif { background: #e1ddd3; color: #28251f; font-weight: 500; }
.recent-del { opacity: 0; border: 0; background: transparent; color: #a09488; cursor: pointer; font-size: 14px; padding: 0 2px; }
.recent-item:hover .recent-del { opacity: 1; }
.sidebar-footer { border-top: 1px solid #ddd9d0; padding-top: 13px; }

/* ---------- sisa kuota ---------- */
.kuota-section { margin-top: 14px; border-top: 1px solid #e0dcd3; padding-top: 12px; }
.kuota-head {
  display: flex; width: 100%; height: 34px; align-items: center; justify-content: space-between;
  border: 0; border-radius: 9px; background: transparent; padding: 0 12px;
  color: #6d6861; font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; cursor: pointer;
}
.kuota-head:hover { background: #e5e1d8; color: #3a362f; }
.kuota-head-left { display: flex; align-items: center; gap: 9px; }
.kuota-head-left svg { width: 15px; height: 15px; color: #a59d92; }
.kuota-caret { transition: transform 200ms ease; color: #a59d92; }
.kuota-caret.terbuka { transform: rotate(180deg); }
.kuota-body { display: none; padding: 4px 6px 2px; }
.kuota-body.terbuka { display: block; }
.kuota-loading { margin: 4px 8px; color: #a09a91; font-size: 12px; }
.kuota-item { padding: 7px 8px 8px; border-radius: 9px; }
.kuota-item:hover { background: #e7e3da; }
.kuota-item + .kuota-item { margin-top: 2px; }
.kuota-item-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.kuota-nama { color: #3a362f; font-size: 12.5px; font-weight: 500; }
.kuota-angka { color: #7d776e; font-size: 11px; font-variant-numeric: tabular-nums; }
.kuota-bar { margin-top: 5px; height: 4px; border-radius: 3px; background: #ded9cf; overflow: hidden; }
.kuota-bar > i { display: block; height: 100%; border-radius: 3px; background: #6f9c74; transition: width 400ms ease; }
.kuota-bar > i.sedang { background: #d8a13f; }
.kuota-bar > i.rendah { background: #c25a44; }
.kuota-note { margin: 7px 8px 2px; color: #a09a91; font-size: 10.5px; line-height: 1.45; }

/* ---------- aturan global ---------- */
.aturan-section { border-top: 1px solid #e0dcd3; padding-top: 4px; }
.aturan-jumlah {
  margin-left: auto; margin-right: 7px; min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 9px; background: #ddd7cb; color: #6d6861;
  font-size: 10.5px; font-weight: 600; line-height: 17px; text-align: center;
}
.aturan-jumlah:empty { display: none; }
.aturan-item {
  display: flex; align-items: flex-start; gap: 8px; padding: 7px 8px;
  border-radius: 9px;
}
.aturan-item:hover { background: #e7e3da; }
.aturan-item + .aturan-item { margin-top: 2px; }
.aturan-teks { flex: 1; color: #4a463f; font-size: 12px; line-height: 1.45; word-break: break-word; }
.aturan-item.mati .aturan-teks { color: #a8a29a; text-decoration: line-through; }
.aturan-aksi { display: flex; gap: 2px; flex: 0 0 auto; }
.aturan-aksi button {
  width: 21px; height: 21px; display: grid; place-items: center; border: 0;
  border-radius: 6px; background: transparent; color: #a59d92; cursor: pointer;
}
.aturan-aksi button:hover { background: #d9d4c9; color: #57534b; }
.aturan-aksi svg { width: 13px; height: 13px; }
.aturan-input {
  width: 100%; margin-top: 6px; border: 1px solid #dbd6cc; border-radius: 9px;
  background: #f6f4ef; padding: 8px 10px; color: #3a362f;
  font-size: 12px; line-height: 1.45; resize: none;
}
.aturan-input::placeholder { color: #b0a99f; }
.aturan-input:focus { outline: 2px solid #c86744; outline-offset: 1px; border-color: transparent; }
.aturan-tambah {
  width: 100%; margin-top: 6px; height: 30px; border: 0; border-radius: 9px;
  background: #ded9cf; color: #4a463f; font-size: 12px; font-weight: 500; cursor: pointer;
}
.aturan-tambah:hover { background: #d3cdc1; color: #2c2924; }
.profile-card {
  display: flex; width: 100%; align-items: center; gap: 10px; border: 0;
  border-radius: 10px; background: transparent; padding: 7px 8px; text-align: left;
}
.avatar {
  display: grid; width: 33px; height: 33px; flex: 0 0 33px; place-items: center;
  border-radius: 50%; background: #56685d; color: #fff; font-size: 11px; font-weight: 600;
}
.profile-copy { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.profile-copy strong { font-size: 12px; font-weight: 600; }
.profile-copy small { margin-top: 1px; color: #88837a; font-size: 11px; }

/* ---------- main ---------- */
.main-content {
  position: relative; display: flex; min-width: 0; flex: 1; flex-direction: column;
  background: radial-gradient(circle at 50% 20%, rgb(255 255 255 / 70%), transparent 38%), #f8f7f4;
}
.topbar {
  position: relative; z-index: 10; display: flex; height: 64px; flex: 0 0 64px;
  align-items: center; justify-content: center; padding: 0 25px;
}
.model-selector, .ghost-button { border: 0; background: transparent; cursor: pointer; }
.model-selector {
  display: flex; align-items: center; gap: 5px; border-radius: 8px; padding: 7px 9px;
  color: #46433d; font-size: 13px; font-weight: 600;
}
.model-selector:hover { background: #efede8; }
.model-selector .versi { color: #9d5b40; }
.ghost-button {
  position: absolute; right: 25px; border: 1px solid #dedad3; border-radius: 9px;
  padding: 7px 13px; color: #5b5750; font-size: 12px;
}
.ghost-button:hover { background: #f0eee9; }
.menu-button { position: absolute; left: 17px; display: none; }

/* dropdown model */
.model-menu {
  position: absolute; top: 56px; left: 50%; transform: translateX(-50%); z-index: 50;
  width: 340px; max-width: calc(100vw - 32px); border: 1px solid #e1ded7; border-radius: 14px;
  background: #fff; box-shadow: 0 18px 45px rgb(55 46 34 / 14%); padding: 7px; display: none;
}
.model-menu.terbuka { display: block; }
.model-opsi {
  display: flex; width: 100%; flex-direction: column; gap: 2px; border: 0; border-radius: 10px;
  background: transparent; padding: 10px 12px; text-align: left; cursor: pointer;
}
.model-opsi:hover { background: #f6f4f0; }
.model-opsi.aktif { background: #fbf1ea; }
.model-opsi .nm { font-size: 13px; font-weight: 600; color: #34312b; display: flex; align-items: center; gap: 6px; }
.model-opsi .tag {
  font-size: 10px; font-weight: 600; color: #a45437; background: #f7e8df;
  padding: 2px 7px; border-radius: 99px;
}
.model-opsi .ds { font-size: 11.5px; color: #8b867e; line-height: 1.45; }

/* ---------- percakapan ---------- */
.conversation {
  display: flex; min-height: 0; flex: 1; flex-direction: column; align-items: center;
  overflow-y: auto; padding: 0 32px;
}
.welcome { width: 100%; max-width: 820px; margin: auto 0; padding: 50px 0 28px; }
.welcome-heading { display: flex; align-items: flex-start; gap: 19px; margin-bottom: 42px; }
.welcome-mark {
  width: 45px; height: 45px; flex: 0 0 45px; border: 1px solid #d9a18d; border-radius: 14px;
  background: #fbf4ee; box-shadow: 0 6px 18px rgb(130 68 42 / 8%);
}
.eyebrow { margin: 1px 0 4px; color: #89847c; font-size: 12px; font-weight: 500; }
h1 {
  margin: 0; color: #292621; font-family: "Newsreader", serif;
  font-size: clamp(38px, 4.3vw, 54px); font-weight: 400; letter-spacing: -0.035em; line-height: 1.06;
}
.prompt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.prompt-card {
  position: relative; display: flex; min-height: 154px; flex-direction: column; align-items: flex-start;
  border: 1px solid #e1ded7; border-radius: 16px; background: rgb(255 255 255 / 51%);
  padding: 19px; text-align: left; cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}
.prompt-card:hover {
  transform: translateY(-3px); border-color: #d1c8bd; background: #fff;
  box-shadow: 0 14px 32px rgb(71 58 43 / 8%);
}
.prompt-number { margin-bottom: 24px; color: #b26447; font-family: "Newsreader", serif; font-size: 12px; }
.prompt-title { margin-bottom: 5px; color: #34312b; font-size: 13px; font-weight: 600; }
.prompt-text { max-width: 190px; color: #7a756d; font-size: 12px; line-height: 1.5; }
.prompt-arrow {
  position: absolute; top: 17px; right: 18px; color: #a6a098; font-size: 15px;
  opacity: 0; transition: opacity 180ms ease;
}
.prompt-card:hover .prompt-arrow { opacity: 1; }

/* thread */
.chat-thread { display: flex; width: 100%; max-width: 760px; flex: 1; flex-direction: column; gap: 30px; padding: 60px 0 40px; }
.user-message {
  max-width: 72%; align-self: flex-end; border-radius: 17px 17px 4px 17px;
  background: #eae6de; padding: 12px 16px; color: #35322d; font-size: 14px; line-height: 1.55;
  white-space: pre-wrap;
}
.assistant-message {
  display: flex; max-width: 100%; gap: 14px; color: #45413b;
  font-family: "Newsreader", serif; font-size: 17.5px; line-height: 1.65;
}
.assistant-mark {
  width: 30px; height: 30px; flex: 0 0 30px; border: 1px solid #dec2b5;
  border-radius: 9px; background: #fbf4ee; margin-top: 2px;
}
.assistant-body { min-width: 0; flex: 1; }
.assistant-name {
  margin: 0 0 8px; color: #a45437; font-family: "DM Sans", sans-serif;
  font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
}
.assistant-body p { margin: 0 0 12px; }
.assistant-body p:last-child { margin-bottom: 0; }
.assistant-body ul, .assistant-body ol { margin: 0 0 12px; padding-left: 22px; }
.assistant-body li { margin-bottom: 5px; }
.assistant-body h2, .assistant-body h3 {
  font-family: "DM Sans", sans-serif; font-size: 14px; font-weight: 600;
  color: #34312b; margin: 18px 0 8px;
}
.assistant-body strong { color: #2c2924; font-weight: 600; }
.assistant-body code {
  font-family: ui-monospace, monospace; font-size: 0.88em; background: #f1efeb;
  padding: 1px 5px; border-radius: 4px;
}
.assistant-body pre {
  background: #f1efeb; padding: 12px 14px; border-radius: 10px; overflow-x: auto;
  font-size: 0.82em; font-family: ui-monospace, monospace; line-height: 1.55;
}
.assistant-body pre code { background: none; padding: 0; }
.assistant-body blockquote {
  border-left: 3px solid #e1ded7; margin: 0 0 12px; padding-left: 14px; color: #6d6861;
}
.kursor {
  display: inline-block; width: 7px; height: 17px; background: #b45d3d;
  vertical-align: text-bottom; margin-left: 2px; animation: kedip 1s steps(2) infinite;
}
@keyframes kedip { 0%, 50% { opacity: 1 } 51%, 100% { opacity: 0 } }
.typing { display: flex; gap: 4px; padding: 6px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: #c3bdb4; animation: naik 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s } .typing i:nth-child(3) { animation-delay: .3s }
@keyframes naik { 0%, 60%, 100% { transform: translateY(0); opacity: .5 } 30% { transform: translateY(-5px); opacity: 1 } }

/* composer */
.composer-wrap { width: 100%; max-width: 820px; margin-top: auto; padding: 0 0 16px; }
.composer {
  border: 1px solid #d8d4cc; border-radius: 18px; background: #fff; padding: 16px 16px 12px;
  box-shadow: 0 1px 2px rgb(43 38 30 / 4%), 0 12px 35px rgb(55 46 34 / 7%);
}
.composer:focus-within {
  border-color: #bbb4aa;
  box-shadow: 0 0 0 3px rgb(180 92 59 / 7%), 0 12px 35px rgb(55 46 34 / 8%);
}
.composer textarea {
  display: block; width: 100%; min-height: 54px; max-height: 200px; resize: none;
  border: 0; outline: 0; background: transparent; color: #302d28; font-size: 15px; line-height: 1.5;
}
.composer textarea::placeholder { color: #9b968e; }
.composer-actions { display: flex; align-items: center; gap: 6px; }
.composer-tool, .thinking-button, .send-button {
  display: grid; place-items: center; border: 0; cursor: pointer;
}
.composer-tool { width: 34px; height: 34px; border-radius: 9px; background: transparent; color: #777169; }
.composer-tool:hover { background: #f1efeb; }
.composer-tool svg { width: 18px; height: 18px; }
.thinking-button {
  display: flex; height: 34px; align-items: center; gap: 7px; border-radius: 9px;
  background: transparent; padding: 0 9px; color: #777169; font-size: 12px;
}
.thinking-button:hover { background: #f1efeb; }
.thinking-button svg { width: 15px; height: 15px; }
.send-button {
  width: 34px; height: 34px; margin-left: auto; border-radius: 10px; background: #b45d3d;
  color: white; transition: transform 150ms ease, background 150ms ease;
}
.send-button:hover:not(:disabled) { transform: translateY(-1px); background: #9e4e33; }
.send-button:disabled { background: #ddd9d2; color: #aaa59d; cursor: default; }
.disclaimer { margin: 9px 0 0; color: #98938c; font-size: 10px; text-align: center; }

/* ---------- kanvas ---------- */
.work-area { display: flex; min-height: 0; flex: 1; }
.work-area.ada-kanvas .conversation { max-width: none; }
.work-area.ada-kanvas .chat-thread,
.work-area.ada-kanvas .composer-wrap,
.work-area.ada-kanvas .welcome { max-width: 560px; }

.kanvas {
  display: none; min-width: 0; flex: 1 1 0; flex-direction: column;
  border-left: 1px solid #e4e0d8; background: #fff;
}
.kanvas.terbuka { display: flex; }
.kanvas-head {
  display: flex; height: 46px; flex: 0 0 46px; align-items: center; gap: 9px;
  border-bottom: 1px solid #ebe7e0; padding: 0 12px 0 16px;
}
.kanvas-tab { color: #3a362f; font-size: 12.5px; font-weight: 600; }
.kanvas-status {
  border-radius: 99px; background: #f0ede7; padding: 3px 9px;
  color: #8b867e; font-size: 10.5px; font-variant-numeric: tabular-nums;
}
.kanvas-status.aktif { background: #fbf1ea; color: #a45437; }
.kanvas-aksi { display: flex; gap: 2px; margin-left: auto; }
.kanvas-aksi button {
  display: grid; width: 30px; height: 30px; place-items: center; border: 0;
  border-radius: 8px; background: transparent; color: #8b867e; cursor: pointer;
}
.kanvas-aksi button:hover { background: #f2efe9; color: #46433d; }
.kanvas-aksi svg { width: 15px; height: 15px; }

.kanvas-isi { position: relative; min-height: 0; flex: 1; overflow: auto; }
.kanvas-frame { width: 100%; height: 100%; border: 0; background: #fff; }
.kanvas-kode {
  margin: 0; padding: 16px 18px; color: #3a362f;
  font-family: ui-monospace, monospace; font-size: 12px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
}
.kanvas-lembar {
  max-width: 680px; margin: 0 auto; padding: 44px 44px 80px; color: #26241f;
  font-family: "Newsreader", serif; font-size: 16.5px; line-height: 1.8;
}
.kanvas-lembar h2 {
  margin: 30px 0 12px; font-family: "DM Sans", sans-serif;
  font-size: 15px; font-weight: 600; letter-spacing: 0.01em;
}
.kanvas-lembar h3 { margin: 22px 0 8px; font-family: "DM Sans", sans-serif; font-size: 13.5px; font-weight: 600; }
.kanvas-lembar h2:first-child, .kanvas-lembar h3:first-child { margin-top: 0; }
.kanvas-lembar p { margin: 0 0 14px; text-align: justify; }
.kanvas-lembar ul, .kanvas-lembar ol { margin: 0 0 14px; padding-left: 24px; }
.kanvas-lembar li { margin-bottom: 6px; }
.kanvas-lembar strong { font-weight: 600; color: #1f1d19; }
.kanvas-lembar blockquote { border-left: 3px solid #e1ded7; margin: 0 0 14px; padding-left: 16px; color: #6d6861; }
.kanvas-lembar code { font-family: ui-monospace, monospace; font-size: 0.85em; background: #f1efeb; padding: 1px 5px; border-radius: 4px; }
.kanvas-lembar pre { background: #f6f4f0; padding: 13px 15px; border-radius: 10px; overflow-x: auto; font-size: 0.8em; }

.kanvas-kosong {
  display: flex; height: 100%; flex-direction: column; align-items: center;
  justify-content: center; gap: 9px; padding: 30px; color: #a9a39a; text-align: center;
}
.kanvas-kosong p { margin: 0; color: #7d776e; font-size: 13px; }
.kanvas-kosong small { font-size: 11.5px; line-height: 1.6; }

/* tombol mode di composer */
.mode-button {
  display: flex; height: 34px; align-items: center; gap: 7px; border-radius: 9px;
  border: 0; background: transparent; padding: 0 9px; color: #777169;
  font-size: 12px; cursor: pointer;
}
.mode-button:hover { background: #f1efeb; }
.mode-button.aktif { background: #fbf1ea; color: #a45437; font-weight: 500; }
.mode-button svg { width: 15px; height: 15px; }

.sidebar-backdrop {
  position: fixed; z-index: 20; inset: 0; display: none; border: 0; background: rgb(27 25 21 / 38%);
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; transform: translateX(-100%);
    box-shadow: 18px 0 45px rgb(31 27 22 / 14%); transition: transform 220ms ease;
  }
  .sidebar-open { transform: translateX(0); }
  .sidebar-backdrop { display: block; }
  .mobile-close, .menu-button { display: grid; }
}
@media (max-width: 680px) {
  .app-shell { min-height: 570px; }
  .topbar { height: 58px; flex-basis: 58px; padding: 0 14px; }
  .ghost-button { right: 14px; padding: 6px 10px; }
  .conversation { padding: 0 16px; }
  .welcome { padding-top: 24px; }
  .welcome-heading { gap: 13px; margin-bottom: 28px; }
  .welcome-mark { width: 39px; height: 39px; flex-basis: 39px; border-radius: 12px; }
  h1 { font-size: 34px; }
  .prompt-grid { grid-template-columns: 1fr; gap: 8px; }
  .prompt-card { min-height: auto; padding: 14px 15px 14px 53px; }
  .prompt-number { position: absolute; top: 16px; left: 15px; margin: 0; }
  .prompt-text { max-width: none; }
  .prompt-arrow { display: none; }
  .composer-wrap { padding-bottom: 10px; }
  .composer { border-radius: 16px; padding: 13px 13px 10px; }
  .composer textarea { min-height: 46px; }
  .chat-thread { padding-top: 30px; gap: 24px; }
  .user-message { max-width: 87%; }
  .assistant-message { font-size: 16.5px; }

  /* kanvas di HP: tumpuk atas-bawah */
  .work-area.ada-kanvas { flex-direction: column; }
  .work-area.ada-kanvas .conversation { flex: 0 0 auto; max-height: 46vh; padding: 0 16px; }
  .work-area.ada-kanvas .welcome { display: none !important; }
  .work-area.ada-kanvas .chat-thread,
  .work-area.ada-kanvas .composer-wrap { max-width: none; }
  .kanvas { flex: 1 1 auto; border-left: 0; border-top: 1px solid #e4e0d8; }
  .kanvas-lembar { padding: 24px 20px 60px; font-size: 16px; }
  .mode-button span, .thinking-button span { display: none; }
  .mode-button, .thinking-button { padding: 0 8px; }
  .mode-button.aktif span { display: inline; }
}
