:root{
  /* Bright modern UI — DigitalPedia inspired */
  --bg:#F4F7FF;
  --surface:#FFFFFF;
  --card:#FFFFFF;
  --border:#E5EAF3;
  --border-soft: rgba(23,32,51,0.08);
  --text:#172033;
  --text-1:#33405C;
  --muted:#64748B;
  --text-3:#94A1B7;
  --panel: rgba(37,99,235,0.06);
  --panel-strong: rgba(37,99,235,0.12);
  --primary:#2563EB;
  --secondary:#3B82F6;
  --accent-cyan:#18A9E8;
  --accent: #2563EB;
  --accent-contrast:#ffffff;
  --grad-brand: linear-gradient(135deg, #2563EB 0%, #18A9E8 100%);
  --danger:#EF4444;
  --ok:#16A34A;
  --radius-lg:24px;
  --radius-md:16px;
  --radius-sm:12px;
  --shadow-soft: 0 10px 34px rgba(37,99,235,0.12);
  --shadow-pop: 0 8px 26px rgba(23,32,51,0.12);
  --ease: cubic-bezier(.4,0,.2,1);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}
html[data-theme="dark"]{
  --bg:#0B1220;
  --surface:#0F1728;
  --card:#141F35;
  --border:#22314E;
  --border-soft: rgba(255,255,255,0.08);
  --text:#EEF2FF;
  --text-1:#C7D2E8;
  --muted:#8B99B8;
  --text-3:#5C6B8A;
  --panel: rgba(59,130,246,0.10);
  --panel-strong: rgba(59,130,246,0.18);
  --primary:#3B82F6;
  --secondary:#60A5FA;
  --accent-cyan:#22C1F0;
  --accent:#3B82F6;
  --accent-contrast:#0B1220;
  --grad-brand: linear-gradient(135deg, #2563EB 0%, #18A9E8 100%);
  --shadow-soft: 0 10px 40px rgba(0,0,0,0.45);
  --shadow-pop: 0 6px 24px rgba(0,0,0,0.4);
}

*{ box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html,body{
  margin:0; padding:0; height:100%;
  background:var(--bg); color:var(--text);
  font-family: "Inter","Manrope",-apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif;
  overflow:hidden;
}
button, input, textarea{ font-family: inherit; }
img{ max-width:100%; display:block; }

#app{ display:flex; height:100vh; height:100dvh; width:100%; position:relative; }
.hidden{ display:none !important; }

/* ============ SIDEBAR ============ */
.sidebar{
  width:270px; min-width:270px; height:100%;
  background: linear-gradient(180deg, var(--surface), var(--bg));
  border-right:1px solid var(--border-soft);
  display:flex; flex-direction:column;
  padding:16px 12px calc(16px + var(--safe-bottom));
  position:relative; z-index:20;
  transition: transform .3s var(--ease);
}
.brand{ display:flex; align-items:center; gap:10px; padding:8px 8px 18px; }
.brand-mark{
  width:32px; height:32px; border-radius:10px;
  background: var(--grad-brand); border:1px solid var(--border);
  display:flex; align-items:center; justify-content:center;
  font-size:16px; color:#fff; flex-shrink:0;
  box-shadow: 0 4px 12px rgba(37,99,235,0.28);
}
.brand-text{ display:flex; flex-direction:column; line-height:1.15; }
.brand-text .name{ font-weight:700; font-size:15.5px; }
.brand-text .sub{ font-size:11px; color:var(--muted); }

.btn-new{
  display:flex; align-items:center; gap:8px; width:100%;
  padding:12px 14px; margin-bottom:14px; min-height:44px;
  border-radius:var(--radius-md); border:1px solid var(--border);
  background:var(--panel); color:var(--text); font-size:13.5px; font-weight:600;
  cursor:pointer; transition: background .18s var(--ease), border-color .18s var(--ease);
}
.btn-new:active{ background:var(--panel-strong); }
@media (hover:hover){ .btn-new:hover{ background:var(--panel-strong); border-color: var(--text-3); } }

.nav-menu{ display:flex; flex-direction:column; gap:2px; margin-bottom:10px; }
.nav-item{
  display:flex; align-items:center; gap:10px; padding:10px; min-height:40px;
  border-radius:var(--radius-sm); font-size:13px; color:var(--text-1);
  background:none; border:none; text-align:left; cursor:pointer; width:100%;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.nav-item.active{ background:var(--panel-strong); color:var(--text); }
@media (hover:hover){ .nav-item:hover{ background:var(--panel); color:var(--text); } }

.sidebar-scroll{ flex:1; overflow-y:auto; display:flex; flex-direction:column; gap:2px; padding-right:2px; -webkit-overflow-scrolling:touch; }
.sidebar-scroll::-webkit-scrollbar{ width:5px; }
.sidebar-scroll::-webkit-scrollbar-thumb{ background:var(--border); border-radius:4px; }

.section-label{
  font-size:11px; color:var(--text-3); text-transform:uppercase; letter-spacing:.6px;
  padding:12px 10px 6px; font-weight:600;
}
.list-item{
  display:flex; align-items:center; gap:8px; padding:10px; min-height:40px;
  border-radius:var(--radius-sm); cursor:pointer; position:relative;
  font-size:12.8px; color:var(--text-1);
  transition: background .16s var(--ease);
}
.list-item.active{ background:var(--panel-strong); color:var(--text); }
@media (hover:hover){ .list-item:hover{ background:var(--panel); } }
.list-item .ltitle{ flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.list-item .lmenu-btn{
  width:26px; height:26px; border-radius:6px; flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
  color:var(--muted); cursor:pointer; background:none; border:none;
}
@media (hover:hover){ .lmenu-btn:hover{ background: var(--panel-strong); color:var(--text); } }

.item-menu-pop{
  position:absolute; right:6px; top:36px; z-index:40;
  background: var(--card); border:1px solid var(--border);
  border-radius:10px; box-shadow:var(--shadow-pop); padding:4px; min-width:110px;
  animation: popIn .14s var(--ease);
}
@keyframes popIn{ from{opacity:0; transform:translateY(-4px) scale(.96);} to{opacity:1; transform:translateY(0) scale(1);} }
.item-menu-pop button{
  width:100%; text-align:left; background:none; border:none;
  color:var(--danger); font-size:12.5px; padding:8px 9px; border-radius:7px;
  cursor:pointer; font-family:inherit;
}
@media (hover:hover){ .item-menu-pop button:hover{ background: rgba(239,90,111,.12); } }

.empty-hint{ padding:10px; font-size:12px; color:var(--text-3); }

.nav-item-apk{
  display:flex; align-items:center; gap:10px; padding:10px 12px; min-height:44px; margin-top:6px;
  border-radius:var(--radius-sm); font-size:13px; font-weight:700; color:#fff;
  background: var(--grad-brand); border:none; text-align:left; cursor:pointer; width:100%;
  box-shadow: 0 6px 16px rgba(37,99,235,0.25);
  transition: transform .16s var(--ease), box-shadow .16s var(--ease);
}
.nav-item-apk:active{ transform: scale(.98); }
@media (hover:hover){ .nav-item-apk:hover{ box-shadow: 0 8px 20px rgba(37,99,235,0.34); } }

.apk-card{
  background: var(--panel); border:1px solid var(--border-soft); border-radius:var(--radius-md);
  padding:16px; display:flex; flex-direction:column; gap:10px;
}
.apk-card-top{ display:flex; align-items:center; gap:12px; }
.apk-card-icon{
  width:42px; height:42px; border-radius:12px; background:var(--grad-brand); flex-shrink:0;
  display:flex; align-items:center; justify-content:center; color:#fff; font-size:18px;
  box-shadow:0 4px 12px rgba(37,99,235,0.25);
}
.apk-card-text .t{ font-size:13.5px; font-weight:700; color:var(--text); }
.apk-card-text .s{ font-size:11.5px; color:var(--muted); margin-top:1px; }
.apk-download-btn{
  width:100%; text-align:center; padding:11px; min-height:44px; border-radius:12px; border:none;
  background: var(--grad-brand); color:#fff; font-size:13.5px; font-weight:700; cursor:pointer; font-family:inherit;
  box-shadow: 0 6px 16px rgba(37,99,235,0.25);
}

.sidebar-footer{
  border-top:1px solid var(--border-soft); padding-top:12px; margin-top:8px;
  display:flex; align-items:center; justify-content:space-between;
}
.sf-info{ display:flex; flex-direction:column; line-height:1.3; }
.sf-info .n{ font-size:12.5px; font-weight:600; }
.sf-info .s{ font-size:10.5px; color:var(--muted); }
.status-dot{ display:flex; align-items:center; gap:5px; font-size:10.5px; color:var(--ok); }
.status-dot::before{ content:""; width:6px; height:6px; border-radius:50%; background:var(--ok); box-shadow:0 0 0 3px rgba(51,199,142,.18); }

.overlay{
  position:fixed; inset:0; background:rgba(0,0,0,.5);
  z-index:15; opacity:0; pointer-events:none;
  transition: opacity .28s var(--ease); backdrop-filter: blur(2px);
}
.overlay.show{ opacity:1; pointer-events:auto; }

/* ============ MAIN ============ */
.main{ flex:1; min-width:0; display:flex; flex-direction:column; height:100%; position:relative; background:var(--bg); }

.chat-header{
  position:sticky; top:0; z-index:10; padding-top: var(--safe-top);
  display:flex; align-items:center; gap:10px;
  padding-left:16px; padding-right:16px; padding-bottom:13px;
  padding-top: calc(13px + var(--safe-top));
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom:1px solid var(--border-soft);
}
.hdr-left{ display:flex; flex-direction:column; line-height:1.15; flex:1; min-width:0; }
.hdr-left .n{ font-size:14.5px; font-weight:700; }
.hdr-left .s{ font-size:11px; color:var(--muted); }
.hdr-right{ display:flex; align-items:center; gap:8px; }

.icon-btn{
  width:44px; height:44px; border-radius:10px;
  display:flex; align-items:center; justify-content:center;
  background:transparent; border:1px solid transparent; color:var(--text-1); cursor:pointer;
  transition: background .16s var(--ease), border-color .16s var(--ease);
}
@media (hover:hover){ .icon-btn:hover{ background:var(--panel); border-color:var(--border-soft); color:var(--text); } }
.hamburger{ display:none; }

.mode-switch{ display:flex; background:var(--panel); border:1px solid var(--border-soft); border-radius:12px; padding:3px; gap:2px; }
.mode-btn{
  border:none; background:transparent; color:var(--muted); font-size:12px; font-weight:600;
  padding:8px 12px; min-height:38px; border-radius:9px; cursor:pointer; white-space:nowrap;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.mode-btn.active{ background:var(--card); color:var(--text); border:1px solid var(--border); }

/* ============ CHAT AREA ============ */
.chat-scroll{ flex:1; overflow-y:auto; -webkit-overflow-scrolling:touch; scroll-behavior:smooth; overscroll-behavior-y:contain; }
.chat-scroll::-webkit-scrollbar{ width:7px; }
.chat-scroll::-webkit-scrollbar-thumb{ background:var(--border); border-radius:4px; }
.chat-inner{ max-width:760px; margin:0 auto; padding:24px 20px 40px; }

.welcome{
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  text-align:center; min-height:58vh; padding:20px;
}
.welcome-mark{
  width:56px; height:56px; border-radius:18px;
  background:var(--grad-brand); border:1px solid var(--border);
  display:flex; align-items:center; justify-content:center;
  font-size:26px; color:#fff; margin-bottom:18px;
  box-shadow: 0 8px 22px rgba(37,99,235,0.25);
}
.welcome h1{ font-size:23px; margin:0 0 8px; font-weight:700; letter-spacing:-.3px; }
.welcome p.lead{ margin:0 0 24px; color:var(--text-1); font-size:14.5px; max-width:440px; line-height:1.6; }

.suggest-grid{ display:grid; grid-template-columns:1fr 1fr; gap:10px; width:100%; max-width:560px; }
.suggest-card{
  text-align:left; padding:14px; border-radius:var(--radius-md); min-height:44px;
  background:var(--panel); border:1px solid var(--border-soft); color:var(--text-1);
  font-size:12.8px; cursor:pointer; line-height:1.4;
  transition: background .18s var(--ease), border-color .18s var(--ease);
}
@media (hover:hover){ .suggest-card:hover{ background:var(--panel-strong); border-color: var(--text-3); } }
.suggest-card.suggest-image{ font-weight:600; }

/* Messages */
.msg{ display:flex; gap:12px; margin-bottom:26px; }
.msg.user{ flex-direction:row-reverse; }
.avatar{
  width:30px; height:30px; border-radius:9px; flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
  font-size:13px; font-weight:700; margin-top:2px;
}
.avatar.ai{ background:var(--grad-brand); border:1px solid var(--border); color:#fff; box-shadow:0 4px 10px rgba(37,99,235,0.25); }
.avatar.user{ background:var(--panel-strong); border:1px solid var(--border); color:var(--text-1); }

.msg-body{ max-width:78%; display:flex; flex-direction:column; gap:6px; min-width:0; }
.msg.user .msg-body{ align-items:flex-end; }
.msg-role{ font-size:11.5px; font-weight:700; color:var(--text-1); margin-bottom:2px; }

.bubble-user{
  background:var(--panel-strong); border:1px solid var(--border);
  padding:11px 15px; border-radius:16px 16px 4px 16px;
  font-size:14.2px; line-height:1.6; white-space:pre-wrap; word-break:break-word;
}
.bubble-ai{ font-size:14.2px; line-height:1.7; color:var(--text); word-break:break-word; animation: sweepIn .2s var(--ease); }
@keyframes sweepIn{
  from{ opacity:0; transform: translateY(3px); }
  to{ opacity:1; transform: translateY(0); }
}
.bubble-ai p{ margin:0 0 10px; }
.bubble-ai p:last-child{ margin-bottom:0; }
.bubble-ai h1,.bubble-ai h2,.bubble-ai h3{ margin:16px 0 8px; line-height:1.35; }
.bubble-ai h1:first-child,.bubble-ai h2:first-child,.bubble-ai h3:first-child{ margin-top:0; }
.bubble-ai ul,.bubble-ai ol{ margin:0 0 10px; padding-left:22px; }
.bubble-ai li{ margin-bottom:4px; }
.bubble-ai a{ color: var(--text); text-decoration:underline; text-underline-offset:2px; }
.bubble-ai strong{ font-weight:700; }
.bubble-ai blockquote{
  margin:0 0 10px; padding:8px 14px; border-left:3px solid var(--border);
  color:var(--text-1); background:var(--panel);
  border-radius:0 8px 8px 0;
}
.bubble-ai code.inline{
  background:var(--panel-strong); border:1px solid var(--border-soft);
  padding:2px 6px; border-radius:5px; font-size:12.6px; font-family: "SF Mono",Consolas,Menlo,monospace;
}
.code-block{ background:var(--surface); border:1px solid var(--border); border-radius:12px; overflow:hidden; margin:10px 0; }
.code-head{ display:flex; align-items:center; justify-content:space-between; padding:8px 12px; border-bottom:1px solid var(--border-soft); font-size:11.5px; color:var(--muted); text-transform:uppercase; letter-spacing:.4px; }
.code-head-actions{ display:flex; gap:6px; }
.code-copy, .code-download{
  display:flex; align-items:center; gap:5px;
  background:none; border:1px solid var(--border); color:var(--text-1); font-size:11px;
  padding:5px 10px; min-height:28px; border-radius:6px; cursor:pointer; font-family:inherit;
  transition: background .12s var(--ease), border-color .12s var(--ease);
}
@media (hover:hover){ .code-copy:hover, .code-download:hover{ background:var(--panel-strong); border-color:var(--text-3); } }
.code-download{ color: var(--primary); border-color: var(--panel-strong); }
.code-block pre{ margin:0; padding:12px 14px; overflow-x:auto; -webkit-overflow-scrolling:touch; font-size:12.6px; line-height:1.6; font-family:"SF Mono",Consolas,Menlo,monospace; }

.msg-actions{ display:flex; gap:4px; }
.action-btn{
  display:flex; align-items:center; gap:4px; background:none; border:none; color:var(--text-3);
  font-size:11px; cursor:pointer; padding:6px 8px; min-height:32px; border-radius:6px; font-family:inherit;
  transition: background .15s var(--ease), color .15s var(--ease);
}
@media (hover:hover){ .action-btn:hover{ background:var(--panel); color:var(--text-1); } }

.typing-row{ display:flex; gap:12px; margin-bottom:26px; }
.typing-dots{ display:flex; align-items:center; gap:4px; padding:8px 0; }
.typing-dots span{ width:6px; height:6px; border-radius:50%; background:var(--text-3); animation: dotPulse 1s ease-in-out infinite; }
.typing-dots span:nth-child(2){ animation-delay:.12s; }
.typing-dots span:nth-child(3){ animation-delay:.24s; }
@keyframes dotPulse{ 0%,60%,100%{ opacity:.3; transform:scale(.8);} 30%{ opacity:1; transform:scale(1);} }

/* Coding progress card (indikator "menulis kode" ala Claude) */
.coding-progress{
  background:var(--surface); border:1px solid var(--border); border-radius:12px;
  padding:12px 14px; display:flex; flex-direction:column; gap:10px; min-width:220px;
  animation: sweepIn .2s var(--ease);
}
.coding-progress-head{
  display:flex; align-items:center; gap:9px; cursor:pointer; user-select:none;
  margin:-2px -2px 0; padding:2px; border-radius:8px;
}
@media (hover:hover){ .coding-progress-head:hover{ background:var(--panel); } }
.coding-progress-head:focus-visible{ outline:2px solid var(--primary); outline-offset:2px; }
.coding-progress-spinner{
  width:14px; height:14px; border-radius:50%; flex-shrink:0;
  border:2px solid var(--border); border-top-color:var(--primary);
  animation: codingSpin .7s linear infinite;
}
@keyframes codingSpin{ to{ transform: rotate(360deg); } }
.coding-progress-title{ font-size:12.8px; font-weight:700; color:var(--text-1); flex:1; }
.coding-progress-timer{ font-weight:500; color:var(--text-3); margin-left:2px; }
.coding-progress-chevron{
  color:var(--text-3); flex-shrink:0; transition: transform .18s var(--ease);
}
.coding-progress.is-expanded .coding-progress-chevron{ transform: rotate(180deg); }
.coding-progress-steps{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:7px; }
.coding-progress-steps li{
  display:flex; align-items:center; gap:8px; font-size:12.4px; color:var(--text-3);
  animation: sweepIn .2s var(--ease);
}
.coding-progress-steps li[data-active="1"]{ color:var(--text-1); }
.coding-progress-steps li[data-done="1"]{ color:var(--text-3); }
.coding-progress-steps .step-dot{
  width:6px; height:6px; border-radius:50%; flex-shrink:0; background:var(--text-3);
}
.coding-progress-steps li[data-active="1"] .step-dot{
  background:var(--primary); animation: dotPulse 1s ease-in-out infinite;
}
.coding-progress-steps li[data-done="1"] .step-dot{
  background:transparent; position:relative; border:none;
}
.coding-progress-steps li[data-done="1"] .step-dot::before{
  content:"✓"; position:absolute; inset:-6px; display:flex; align-items:center; justify-content:center;
  font-size:10px; color:var(--primary); font-weight:700;
}

/* Panel kode live di dalam kartu progres (muncul saat expanded) */
.coding-progress-code-wrap{
  display:none; border-top:1px solid var(--border-soft); padding-top:10px; margin-top:2px;
}
.coding-progress.is-expanded .coding-progress-code-wrap{ display:block; }
.coding-progress-code-head{
  display:flex; align-items:center; justify-content:space-between;
  font-size:11px; color:var(--text-3); text-transform:uppercase; letter-spacing:.4px;
  margin-bottom:6px;
}
.coding-progress-skip{
  background:none; border:1px solid var(--border); color:var(--text-1); font-size:11px;
  padding:4px 9px; border-radius:6px; cursor:pointer; font-family:inherit; text-transform:none; letter-spacing:0;
}
@media (hover:hover){ .coding-progress-skip:hover{ background:var(--panel-strong); } }
.coding-progress-code-scroll{
  max-height:240px; overflow:auto; background:var(--panel); border:1px solid var(--border-soft);
  border-radius:8px; padding:10px 12px; -webkit-overflow-scrolling:touch;
}
.coding-progress-code-scroll pre{ margin:0; }
.coding-progress-code-scroll code{
  font-family:"SF Mono",Consolas,Menlo,monospace; font-size:12px; line-height:1.6;
  color:var(--text-1); white-space:pre-wrap; word-break:break-word;
}
.coding-progress-code-scroll code:empty::before{
  content:"Menunggu kode dari AI…"; color:var(--text-3); font-family:inherit; font-style:italic;
}
.coding-progress-cursor{
  display:inline-block; color:var(--primary); font-weight:700;
  animation: cursorBlink 1s step-end infinite;
}
@keyframes cursorBlink{ 0%,100%{ opacity:1; } 50%{ opacity:0; } }

/* Tombol Download ZIP di msg-actions */
.zip-btn{ color:var(--primary); }
.zip-btn:disabled{ opacity:.6; cursor:default; }

.error-note{
  background: rgba(239,90,111,.09); border:1px solid rgba(239,90,111,.3);
  color:#ff8b98; padding:12px 14px; border-radius:12px; font-size:13px; line-height:1.5;
  display:flex; flex-direction:column; gap:8px; align-items:flex-start;
}
.retry-btn{
  background:var(--panel-strong); border:1px solid var(--border); color:var(--text);
  font-size:12px; font-weight:600; padding:7px 13px; min-height:32px; border-radius:8px; cursor:pointer; font-family:inherit;
}

/* Image message */
.image-card{ background:var(--surface); border:1px solid var(--border); border-radius:18px; overflow:hidden; max-width:340px; }
.image-card img{ width:100%; display:block; border-radius:0; object-fit:contain; background:var(--card); }
.image-card .image-skel{
  width:100%; aspect-ratio:1/1; background: linear-gradient(100deg, var(--card) 30%, var(--panel-strong) 50%, var(--card) 70%);
  background-size:200% 100%; animation: shimmer .9s ease-in-out infinite;
  display:flex; align-items:center; justify-content:center; flex-direction:column; gap:10px; color:var(--muted); font-size:12.5px;
}
@keyframes shimmer{ 0%{ background-position:200% 0; } 100%{ background-position:-200% 0; } }
.image-card .image-caption{ padding:10px 12px 4px; font-size:12px; color:var(--muted); }
.image-card .image-actions{ display:flex; gap:6px; padding:8px 12px 12px; flex-wrap:wrap; }
.image-actions .action-btn{ background:var(--panel); border:1px solid var(--border-soft); }

/* ============ INPUT AREA ============ */
.input-wrap{ padding:14px 16px calc(16px + var(--safe-bottom)); background: linear-gradient(180deg, transparent, var(--bg) 30%); }
.input-inner{ max-width:760px; margin:0 auto; }
.input-box{
  display:flex; align-items:flex-end; gap:8px;
  background:var(--panel-strong); border:1px solid var(--border);
  border-radius:22px; padding:8px 8px 8px 8px;
  box-shadow: var(--shadow-soft); position:relative;
  transition: border-color .18s var(--ease);
}
.input-box:focus-within{ border-color: var(--text-3); }

.plus-btn{
  width:36px; height:36px; min-height:36px; border-radius:12px; flex-shrink:0;
  border:1px solid var(--border-soft); cursor:pointer; background:var(--panel); color:var(--text-1);
  display:flex; align-items:center; justify-content:center; transition: background .16s var(--ease);
}
.plus-menu{
  position:absolute; left:8px; bottom:52px; z-index:30;
  background:var(--card); border:1px solid var(--border); border-radius:12px;
  box-shadow:var(--shadow-pop); padding:5px; display:none; min-width:170px;
}
.plus-menu.show{ display:block; animation: popIn .14s var(--ease); }
.plus-menu button{
  width:100%; text-align:left; background:none; border:none; color:var(--text-1);
  font-size:13px; padding:9px 10px; min-height:38px; border-radius:8px; cursor:pointer; font-family:inherit;
}
@media (hover:hover){ .plus-menu button:hover{ background:var(--panel-strong); } }

textarea#chatInput{
  flex:1; resize:none; border:none; outline:none; background:transparent; color:var(--text);
  font-size:14.5px; line-height:1.5; font-family:inherit;
  min-height:32px; max-height:150px; padding:8px 4px;
}
textarea#chatInput::placeholder{ color:var(--text-3); }

.send-btn{
  width:38px; height:38px; min-height:38px; border-radius:12px; flex-shrink:0; border:none; cursor:pointer;
  background: var(--panel); color:var(--text-3);
  display:flex; align-items:center; justify-content:center;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.send-btn.active{ background:var(--grad-brand); color:#fff; box-shadow:0 4px 12px rgba(37,99,235,0.3); }
.send-btn.stopping{ background:var(--danger); color:#fff; }
.send-btn:disabled{ cursor:not-allowed; }
.send-btn .ic-stop{ display:none; }
.send-btn.stopping .ic-send{ display:none; }
.send-btn.stopping .ic-stop{ display:block; }

.footer-note{ text-align:center; font-size:11px; color:var(--text-3); margin-top:10px; }

/* ============ MODAL ============ */
.modal-overlay{
  position:fixed; inset:0; background:rgba(0,0,0,.55);
  display:flex; align-items:center; justify-content:center; z-index:100;
  opacity:0; pointer-events:none; transition: opacity .2s var(--ease); padding:20px;
}
.modal-overlay.show{ opacity:1; pointer-events:auto; }
.modal{
  background:var(--surface); border:1px solid var(--border); border-radius:20px;
  width:100%; max-width:400px; box-shadow:var(--shadow-soft);
  transform: translateY(8px) scale(.97); opacity:0;
  transition: transform .22s var(--ease), opacity .22s var(--ease);
  max-height:86vh; overflow-y:auto;
}
.modal-overlay.show .modal{ transform:translateY(0) scale(1); opacity:1; }
.modal-head{ display:flex; align-items:center; justify-content:space-between; padding:18px 20px; border-bottom:1px solid var(--border-soft); }
.modal-head h3{ margin:0; font-size:15.5px; font-weight:700; }
.modal-body{ padding:18px 20px 22px; display:flex; flex-direction:column; gap:20px; }
.setting-row{ display:flex; align-items:center; justify-content:space-between; gap:14px; }
.setting-label{ font-size:13.5px; font-weight:600; }
.setting-hint{ font-size:11.5px; color:var(--muted); margin-top:2px; }

.segmented{ display:flex; background:var(--panel); border:1px solid var(--border-soft); border-radius:10px; padding:3px; gap:2px; }
.segmented button{
  border:none; background:transparent; color:var(--muted); font-size:12px; padding:7px 11px; min-height:34px;
  border-radius:8px; cursor:pointer; font-family:inherit; transition: background .15s var(--ease), color .15s var(--ease);
}
.segmented button.on{ background:var(--card); color:var(--text); border:1px solid var(--border); }

.switch{ position:relative; width:42px; height:24px; flex-shrink:0; }
.switch input{ opacity:0; width:0; height:0; }
.slider{ position:absolute; inset:0; background:var(--panel-strong); border:1px solid var(--border); border-radius:20px; cursor:pointer; transition: background .2s var(--ease); }
.slider::before{ content:""; position:absolute; width:18px; height:18px; left:2px; top:2px; background:var(--bg); border:1px solid var(--border); border-radius:50%; transition: transform .2s var(--ease); }
.switch input:checked + .slider{ background:var(--text); }
.switch input:checked + .slider::before{ transform:translateX(18px); background:var(--bg); }

.toast{
  position:fixed; bottom:calc(22px + var(--safe-bottom)); left:50%; transform:translateX(-50%) translateY(20px);
  background:var(--card); border:1px solid var(--border); color:var(--text);
  padding:10px 18px; border-radius:12px; font-size:13px; box-shadow:var(--shadow-pop);
  z-index:200; opacity:0; pointer-events:none; transition: opacity .22s var(--ease), transform .22s var(--ease);
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }

/* ============ SIDEBAR: nav-item Generate Gambar HD ============ */
.nav-item-imagegen{
  display:flex; align-items:center; gap:10px; padding:10px; min-height:40px;
  border-radius:var(--radius-sm); font-size:13px; font-weight:600;
  color: var(--primary); background: var(--panel); border:1px solid var(--border-soft);
  text-align:left; cursor:pointer; width:100%;
  transition: background .16s var(--ease), border-color .16s var(--ease);
}
.nav-item-imagegen svg{ flex-shrink:0; }
.nav-item-imagegen span{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
@media (hover:hover){ .nav-item-imagegen:hover{ background:var(--panel-strong); border-color:var(--text-3); } }

/* ============ IMAGE GENERATOR HD — halaman terpisah ============ */
.imagegen-page{
  position:fixed; inset:0; z-index:60; background:var(--bg);
  display:flex; flex-direction:column; height:100%; height:100dvh;
  animation: sweepIn .18s var(--ease);
}
.imagegen-topbar{
  position:sticky; top:0; z-index:5; padding: calc(14px + var(--safe-top)) 16px 12px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom:1px solid var(--border-soft);
}
.imagegen-back{
  display:inline-flex; align-items:center; gap:8px;
  background:none; border:none; color:var(--text-1); font-size:13.5px; font-weight:600;
  padding:8px 6px; min-height:38px; border-radius:8px; cursor:pointer; font-family:inherit;
  transition: background .16s var(--ease), color .16s var(--ease);
}
@media (hover:hover){ .imagegen-back:hover{ background:var(--panel); color:var(--text); } }
.imagegen-back:disabled{ opacity:.35; cursor:not-allowed; }

.imagegen-scroll{ flex:1; overflow-y:auto; -webkit-overflow-scrolling:touch; }
.imagegen-inner{ max-width:560px; margin:0 auto; padding:28px 20px calc(48px + var(--safe-bottom)); }

.imagegen-view{ display:flex; flex-direction:column; align-items:center; text-align:center; }

.imagegen-mark{
  width:64px; height:64px; border-radius:20px;
  background: var(--grad-brand); border:1px solid var(--border);
  display:flex; align-items:center; justify-content:center;
  font-size:24px; font-weight:800; color:#fff; margin-bottom:20px;
  box-shadow: 0 10px 26px rgba(37,99,235,0.32), 8px 8px 0 0 rgba(37,99,235,0.18);
}
.imagegen-title{ font-size:26px; font-weight:800; margin:0 0 8px; letter-spacing:-.4px; }
.imagegen-subtitle{ font-size:14.5px; color:var(--muted); margin:0 0 28px; }

.imagegen-card{
  width:100%; background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius-lg); box-shadow:var(--shadow-soft);
  padding:22px; display:flex; flex-direction:column; gap:14px; text-align:left;
}
.imagegen-label{ font-size:13.5px; font-weight:700; color:var(--text); }
.imagegen-textarea{
  width:100%; resize:vertical; min-height:130px; max-height:320px;
  border:1px solid var(--border); border-radius:var(--radius-md); outline:none;
  background:var(--panel); color:var(--text); font-family:inherit;
  font-size:14.5px; line-height:1.6; padding:14px 16px;
  transition: border-color .16s var(--ease);
}
.imagegen-textarea::placeholder{ color:var(--text-3); }
.imagegen-textarea:focus{ border-color:var(--primary); }

.imagegen-generate-btn{
  width:100%; min-height:52px; border:none; border-radius:var(--radius-md); cursor:pointer;
  background: var(--grad-brand); color:#fff; font-size:15px; font-weight:700; font-family:inherit;
  box-shadow: 0 8px 20px rgba(37,99,235,0.3);
  transition: transform .14s var(--ease), opacity .14s var(--ease);
}
.imagegen-generate-btn:active{ transform: scale(.98); }
.imagegen-generate-btn:disabled{ opacity:.5; cursor:not-allowed; box-shadow:none; }

/* Loading */
.imagegen-loading-card{
  width:100%; background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius-lg); box-shadow:var(--shadow-soft);
  padding:44px 26px; display:flex; flex-direction:column; align-items:center; gap:14px;
  margin-top:12px;
}
.imagegen-spinner{
  width:46px; height:46px; border-radius:50%;
  border:4px solid var(--panel-strong); border-top-color:var(--primary);
  animation: codingSpin .8s linear infinite;
}
.imagegen-loading-title{ font-size:17px; font-weight:700; margin:6px 0 0; }
.imagegen-loading-sub{ font-size:13.5px; color:var(--muted); margin:0; }
.imagegen-countdown{
  margin-top:10px; display:flex; flex-direction:column; align-items:center; gap:2px;
  background:var(--panel); border:1px solid var(--border-soft); border-radius:var(--radius-md);
  padding:12px 24px;
}
.igc-label{ font-size:11.5px; color:var(--muted); font-weight:600; }
.igc-value{ font-size:22px; font-weight:800; color:var(--primary); font-variant-numeric:tabular-nums; }

/* Result */
.imagegen-result-card{
  width:100%; background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius-lg); box-shadow:var(--shadow-soft);
  padding:20px; display:flex; flex-direction:column; align-items:center; gap:12px;
}
.imagegen-result-badge{ font-size:14.5px; font-weight:700; color:var(--ok); margin:0; }
.imagegen-result-imgwrap{
  width:100%; border-radius:var(--radius-md); overflow:hidden; background:var(--panel);
  display:flex; align-items:center; justify-content:center;
}
.imagegen-result-imgwrap img{ width:100%; height:auto; display:block; object-fit:contain; }
.imagegen-result-time{ font-size:12.5px; color:var(--muted); margin:0; }
.imagegen-result-actions{ width:100%; display:flex; flex-direction:column; gap:10px; margin-top:4px; }
.imagegen-download-btn{
  width:100%; min-height:50px; border:none; border-radius:var(--radius-md); cursor:pointer;
  background: var(--grad-brand); color:#fff; font-size:14.5px; font-weight:700; font-family:inherit;
  box-shadow: 0 8px 20px rgba(37,99,235,0.3);
  transition: transform .14s var(--ease);
}
.imagegen-download-btn:active{ transform: scale(.98); }
.imagegen-regen-btn{
  width:100%; min-height:50px; border:1px solid var(--border); border-radius:var(--radius-md); cursor:pointer;
  background: var(--panel); color:var(--text); font-size:14.5px; font-weight:700; font-family:inherit;
  transition: background .16s var(--ease);
}
@media (hover:hover){ .imagegen-regen-btn:hover{ background:var(--panel-strong); } }

@media (max-width:480px){
  .imagegen-inner{ padding:20px 14px 40px; }
  .imagegen-title{ font-size:22px; }
  .imagegen-card, .imagegen-loading-card, .imagegen-result-card{ padding:16px; }
  .imagegen-mark{ width:56px; height:56px; font-size:20px; }
}

/* ============ RESPONSIVE / WEBVIEW ============ */
@media (max-width:860px){
  .sidebar{
    position:fixed; left:0; top:0; bottom:0; z-index:30;
    transform: translateX(-100%); box-shadow: 4px 0 30px rgba(0,0,0,.4);
    width:82vw; max-width:300px; min-width:0;
  }
  .sidebar.open{ transform:translateX(0); }
  .hamburger{ display:flex; }
  .mode-switch .mode-btn{ padding:8px 9px; font-size:11px; }
  .chat-inner{ padding:18px 14px 30px; }
  .msg-body{ max-width:88%; }
  .suggest-grid{ grid-template-columns:1fr; }
  .input-wrap{ padding:10px 10px calc(12px + var(--safe-bottom)); }
  .welcome h1{ font-size:20px; }
}
@media (max-width:400px){
  .brand-text .name{ font-size:14px; }
  .hdr-left .n{ font-size:13.5px; }
  .hdr-left{ display:none; }
}

html{ overflow-x:hidden; }
body{ overflow-x:hidden; }

@media (prefers-reduced-motion: reduce){
  *{ animation-duration:.001ms !important; transition-duration:.001ms !important; }
}
body.no-animations *{ animation:none !important; transition:none !important; }
