/* v2 */
/* ═══════════════════════════════════════════
   GlobalApp — Styles
   Warm beige aesthetic, Inter + Lora
═══════════════════════════════════════════ */

:root {
  --bg:      #f2f0eb;
  --surface: #ffffff;
  --border:  #e3e1dc;
  --border2: #ccc9c2;
  --text:    #1a1a1a;
  --muted:   #6b6860;
  --muted2:  #a09d96;
  --sidebar: 236px;
  --topbar:  52px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  height: 100vh;
  height: 100dvh; /* dvh accounts for mobile browser chrome */
  display: flex;
  overflow: hidden;
  font-size: 13px;
}

/* ══════════════════════
   SIDEBAR
══════════════════════ */
.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg);
  transition: transform 0.2s ease, width 0.2s ease;
  overflow: hidden;
  z-index: 100;
}

.sidebar.collapsed {
  width: 0;
  border-right: none;
}

/* (2) Logo is now an <a> tag */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 15px 16px 12px;
  cursor: pointer;
  flex-shrink: 0;
  text-decoration: none;
  color: inherit;
}

.sidebar-logo:hover .logo-word { opacity: 0.75; }

.logo-img {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 50%;
  flex-shrink: 0;
}

/* (1) DM Sans bold — matches app.ai2bundle.co */
.logo-word {
  font-family: 'DM Sans', 'Inter', sans-serif;
  font-style: normal;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  letter-spacing: -0.3px;
  white-space: nowrap;
}

.sidebar-nav {
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex-shrink: 0;
}

.sn-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  transition: all 0.12s;
  border: none;
  background: none;
  font-family: 'Inter', sans-serif;
  width: 100%;
  text-align: left;
  white-space: nowrap;
}

.sn-btn:hover { background: rgba(0,0,0,0.05); color: var(--text); }
.sn-icon { font-size: 15px; opacity: 0.65; flex-shrink: 0; }

/* Sidebar search */
.sidebar-search-wrap {
  padding: 4px 12px 6px;
  flex-shrink: 0;
}
.sidebar-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 8px;
  font-size: 13px;
  background: rgba(0,0,0,0.04);
  outline: none;
  color: var(--text);
}
.sidebar-search-input:focus {
  border-color: rgba(0,0,0,0.25);
  background: #fff;
}

/* Sidebar history */
#sidebarHistory {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

#sidebarHistory::-webkit-scrollbar { width: 3px; }
#sidebarHistory::-webkit-scrollbar-thumb { background: #dedad4; border-radius: 4px; }

.sidebar-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted2);
  padding: 12px 18px 4px;
  letter-spacing: 0.2px;
}

.sidebar-hist {
  padding: 0 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.hist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--muted);
  font-size: 12.5px;
  transition: all 0.12s;
  min-width: 0;
}

.hist-item:hover { background: rgba(0,0,0,0.05); color: var(--text); }
.hist-item.active { background: rgba(0,0,0,0.07); color: var(--text); }
.hi-ico { font-size: 13px; flex-shrink: 0; opacity: 0.55; }
.hi-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }

/* Sidebar item 3-dot context menu (same pattern as app.ai2bundle.co) */
.hi-menu-wrap { position: relative; flex-shrink: 0; }
.hi-menu-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 17px; line-height: 1;
  padding: 2px 6px; border-radius: 5px;
  opacity: 0; transition: opacity 0.12s, background 0.12s;
}
.hist-item:hover .hi-menu-btn,
.hist-item.active .hi-menu-btn { opacity: 1; }
.hi-menu-btn:hover { background: rgba(0,0,0,0.08); color: var(--text); }
.hi-dropdown {
  position: fixed; background: #fff;
  border-radius: 10px; box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  border: 1px solid var(--border2); z-index: 500;
  display: none; overflow: hidden; min-width: 120px;
}
.hi-dropdown.open { display: block; }
.hi-dd-item {
  width: 100%; border: none; background: none;
  padding: 10px 14px; font: inherit; font-size: 13px;
  text-align: left; cursor: pointer; color: var(--text);
  display: block; transition: background 0.1s;
}
.hi-dd-item:hover { background: #f5f7fa; }
.hi-dd-item.danger { color: #c0392b; }
.hi-dd-item.danger:hover { background: rgba(220,53,69,0.06); }

/* File attachment chips (Arena.ai style) */
.attach-preview {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 6px 10px 2px;
}
.attach-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: 20px; padding: 4px 8px 4px 10px;
  font-size: 12px; color: var(--text); max-width: 220px;
}
.attach-chip-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1;
}
.attach-chip-ico { font-size: 14px; flex-shrink: 0; }
.attach-chip-remove {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 14px; line-height: 1; padding: 0 2px; flex-shrink: 0;
  border-radius: 50%;
}
.attach-chip-remove:hover { color: #c0392b; background: rgba(192,57,43,0.08); }

/* Retrieve History button */
.retrieve-history-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  width: calc(100% - 36px);
  margin: 6px 18px 2px;
  padding: 8px 12px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.retrieve-history-btn:hover { background: #f0ede8; color: var(--text); }
.retrieve-history-btn.loading { opacity: 0.6; pointer-events: none; }

.sidebar-footer {
  padding: 10px 18px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 14px;
  flex-shrink: 0;
}

/* (6) sf-lnk is now an <a> tag */
.sf-lnk {
  font-size: 11px;
  color: var(--muted2);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.sf-lnk:hover { color: var(--muted); text-decoration: underline; }

/* Sidebar mobile overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  z-index: 99;
}

/* ══════════════════════
   MAIN
══════════════════════ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ══════════════════════
   TOPBAR
══════════════════════ */
.topbar {
  height: var(--topbar);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 8px;
  flex-shrink: 0;
  position: relative;
  z-index: 50;
}

.tb-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: all 0.12s;
  flex-shrink: 0;
}

.tb-icon-btn:hover { background: rgba(0,0,0,0.06); color: var(--text); }

/* vs divider */
.tb-vs {
  font-size: 11px;
  color: var(--muted2);
  font-weight: 500;
  flex-shrink: 0;
  letter-spacing: 0.3px;
}

/* ── Mode selector ── */
.mode-wrap { position: relative; }

.mode-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: none;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
}

.mode-btn:hover { background: rgba(0,0,0,0.04); }
.mode-btn-ico { font-size: 14px; }
.mode-btn-caret { font-size: 10px; color: var(--muted2); transition: transform 0.15s; }
.mode-wrap.open .mode-btn-caret { transform: rotate(180deg); }
.mode-wrap.open .mode-btn { background: rgba(0,0,0,0.04); }

/* Mode dropdown */
.mode-dd {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 6px 22px rgba(0,0,0,0.10);
  min-width: 260px;
  overflow: hidden;
  z-index: 200;
}

.mode-wrap.open .mode-dd { display: block; }

.mode-opt {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid #f4f2ee;
}

.mode-opt:last-child { border-bottom: none; }
.mode-opt:hover { background: #f7f5f1; }
.mode-opt.selected { background: #eeece8; }

.mo-ico { font-size: 18px; flex-shrink: 0; margin-top: 1px; opacity: 0.75; }
.mo-name { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.mo-sub  { font-size: 11.5px; color: var(--muted); line-height: 1.4; }

/* ── Model pills ── */
.model-pill-wrap { position: relative; }

.model-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: none;
  font-family: 'Inter', sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
  max-width: 200px;
}

.model-pill:hover { background: rgba(0,0,0,0.04); }
.mp-label { overflow: hidden; text-overflow: ellipsis; }
.mp-caret { font-size: 10px; color: var(--muted2); transition: transform 0.15s; flex-shrink: 0; }
.model-pill-wrap.open .mp-caret { transform: rotate(180deg); }

/* Model dropdown */
.model-dd {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 6px 22px rgba(0,0,0,0.10);
  width: 300px;
  z-index: 200;
  overflow: hidden;
}

.model-pill-wrap.open .model-dd { display: flex; flex-direction: column; max-height: 380px; }

.mdd-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid #f0ede8;
  background: #fafaf8;
  flex-shrink: 0;
}

.mdd-search input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text);
}

.mdd-search input::placeholder { color: #c0bdb6; }
.mdd-si { color: #c0bdb6; font-size: 13px; }
.mdd-cnt { font-size: 10px; color: #c0bdb6; background: #eeece8; padding: 2px 6px; border-radius: 3px; white-space: nowrap; }

.mdd-list { overflow-y: auto; flex: 1; }
.mdd-list::-webkit-scrollbar { width: 4px; }
.mdd-list::-webkit-scrollbar-thumb { background: #dedad4; border-radius: 4px; }

.mdd-section-hdr {
  padding: 10px 14px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #1a1a1a;
  background: var(--bg);
  border-top: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}
.mdd-section-hdr:first-child { border-top: none; }

.mdd-grp {
  padding: 8px 14px 3px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #c0bdb6;
  border-top: 1px solid #f4f2ee;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mdd-grp:first-child { border-top: none; }
.mdd-grp-n { font-size: 10px; color: #ccc9c2; font-weight: 400; text-transform: none; letter-spacing: 0; }

.mdd-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.1s;
}

.mdd-item:hover { background: #f7f5f1; }
.mdd-item.sel { background: #eeece8; }
.mdd-item.hidden { display: none; }

.mdd-abbr {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: #e8e5de;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9.5px;
  font-weight: 700;
  color: #777;
  flex-shrink: 0;
  letter-spacing: -0.3px;
}

.mdd-info { flex: 1; min-width: 0; }
.mdd-iname { font-size: 12.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mdd-isub  { font-size: 10.5px; color: var(--muted2); margin-top: 1px; }
.mdd-right { display: flex; align-items: center; gap: 5px; margin-left: auto; flex-shrink: 0; }

.mdd-tag {
  font-size: 9px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 3px;
  background: #eeece8;
  color: #888;
  border: 1px solid #dedad4;
}

.mdd-tag.free { background: #eefaf2; color: #4a9; border-color: #c2e8d4; }
.mdd-tag.top  { background: #fff0e8; color: #c06020; border-color: #f0d0b8; }
.mdd-tag.new  { background: #eef3fa; color: #4070c0; border-color: #c0d4f0; }
.mdd-tag-smart { background: linear-gradient(135deg, #fff8e1, #fef3c7); color: #b45309; border: 1px solid #fcd34d; font-size: 9px; font-weight: 700; padding: 2px 5px; border-radius: 3px; }

/* Smart AI dropdown item */
.smart-ai-item { border-bottom: 1px solid #f0ede7; margin-bottom: 2px; }
.smart-ai-item:hover { background: #fffbf0; }
.smart-ai-item.sel   { background: #fef9ec; }

/* Smart AI abbreviation badge — gold star */
.mdd-abbr-smart {
  width: 26px; height: 26px; border-radius: 6px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #fff; flex-shrink: 0;
}

.mdd-price { font-size: 10.5px; color: var(--muted2); }
.mdd-chk   { font-size: 11px; font-weight: 700; color: var(--text); }

/* ── Topbar right ── */
.tb-spacer { flex: 1; }

/* ── 3-dot dropdown (Arena.ai style) ── */
.dots-wrap { position: relative; }

.tb-dots {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: all 0.12s;
}

.tb-dots:hover { background: rgba(0,0,0,0.06); color: var(--text); }
.dots-wrap.open .tb-dots { background: rgba(0,0,0,0.06); color: var(--text); }

.dots-dd {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 6px 22px rgba(0,0,0,0.10);
  min-width: 200px;
  overflow: hidden;
  z-index: 200;
  padding: 5px;
}

.dots-wrap.open .dots-dd { display: block; }

.dots-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: background 0.1s;
}

.dots-item:hover { background: #f7f5f1; }

.dots-item-ico {
  color: var(--muted2);
  flex-shrink: 0;
}

.dots-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.dots-item-danger { color: #c0392b; }
.dots-item-danger .dots-item-ico { color: #c0392b; }

/* Usage panel inside dots dropdown */
.usage-panel {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.usage-plan-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--text);
  color: #fff;
  padding: 2px 8px;
  border-radius: 20px;
  margin-bottom: 4px;
  align-self: flex-start;
}

.usage-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}

.usage-label { color: var(--muted); }
.usage-val   { color: var(--text); font-weight: 500; }

.usage-bar-track {
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 3px;
}

.usage-bar-fill {
  height: 100%;
  background: #3b82f6;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.usage-bar-warn { background: #ef4444; }

.usage-email {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 8px;
  word-break: break-all;
  border-top: 1px solid var(--border);
  padding-top: 7px;
}

.usage-upgrade-btn {
  display: block;
  margin-top: 10px;
  text-align: center;
  padding: 7px 12px;
  background: #3b82f6;
  color: #fff;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.13s;
}
.usage-upgrade-btn:hover { background: #2563eb; }

.tb-login {
  background: var(--text);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
}

.tb-login:hover { background: #333; }
.tb-login.logged-in { background: none; color: var(--muted); border: 1px solid var(--border2); }
.tb-login.logged-in:hover { background: rgba(0,0,0,0.04); color: var(--text); }

/* ══════════════════════
   CONTENT AREA
══════════════════════ */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* ══════════════════════
   PANELS ZONE
══════════════════════ */
.panels-zone {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.top-panels {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* Judge zone */
.judge-zone {
  display: none;
  border-top: 1px solid var(--border);
  height: 36%;
  flex-shrink: 0;
}

.judge-zone.show { display: flex; }

/* ══════════════════════
   INDIVIDUAL PANEL
══════════════════════ */
.panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: visible;   /* allows panel model dropdown to overflow */
  min-width: 0;
  background: var(--bg);
  transition: flex 0.2s ease;
}

.panel:last-child { border-right: none; }
.panel.hidden { display: none; }

/* Panel topbar */
.panel-topbar {
  display: flex;
  align-items: center;
  padding: 10px 16px 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  gap: 8px;
  position: relative;   /* allows absolute dropdown to escape */
  overflow: visible;
}

/* (9) Panel model selector — replaces topbar pill */
.pt-model-selector {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  flex: 1;
  min-width: 0;
  padding: 3px 6px;
  border-radius: 7px;
  transition: background 0.12s;
  position: relative;
  user-select: none;
}

.pt-model-selector:hover { background: rgba(0,0,0,0.05); }
.pt-model-selector.open  { background: rgba(0,0,0,0.05); }

.pt-model-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pt-model-caret {
  font-size: 10px;
  color: var(--muted2);
  flex-shrink: 0;
  transition: transform 0.15s;
}

.pt-model-selector.open .pt-model-caret { transform: rotate(180deg); }

/* Panel model dropdown */
.pt-model-dd {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: -6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 6px 22px rgba(0,0,0,0.12);
  width: 300px;
  z-index: 300;
  overflow: hidden;
}

.pt-model-selector.open .pt-model-dd { display: flex; flex-direction: column; max-height: 360px; }

.pt-actions { display: flex; align-items: center; gap: 2px; }

.pt-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted2);
  font-size: 14px;
  transition: all 0.12s;
}

.pt-btn:hover { background: rgba(0,0,0,0.06); color: var(--text); }
.pt-btn:disabled { opacity: 0.3; cursor: default; }

/* Panel body */
.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  font-size: 13.5px;
  line-height: 1.72;
  color: #3a3835;
}

.panel-body::-webkit-scrollbar { width: 4px; }
.panel-body::-webkit-scrollbar-thumb { background: #dedad4; border-radius: 3px; }

/* Panel body in direct chat mode — thread handles its own padding */
.panel-body:has(.dc-thread) { padding: 0; }

/* Panel empty state */
.panel-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted2);
  font-size: 12.5px;
}

.panel-empty-ico { font-size: 28px; opacity: 0.35; }

/* ── Direct Chat thread ────────────────────────────────── */
.dc-thread {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 20px 20px 16px;
  overflow-y: auto;
  flex: 1;
}
.dc-msg-images {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.dc-msg-img {
  max-width: 220px;
  max-height: 180px;
  border-radius: 10px;
  object-fit: cover;
  display: block;
  cursor: pointer;
}
.dc-msg-img:hover { opacity: 0.92; }

.dc-msg-user {
  align-self: flex-end;
  background: #e3dfd7;
  border-radius: 16px 16px 4px 16px;
  padding: 9px 14px;
  max-width: 82%;
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.dc-msg-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.dc-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(0,0,0,0.08);
  border-radius: 8px;
  padding: 4px 9px 4px 7px;
  font-size: 12px;
  max-width: 220px;
}
.dc-file-chip-ico { font-size: 14px; flex-shrink: 0; }
.dc-file-chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
.dc-file-chip.clickable { cursor: pointer; }
.dc-file-chip.clickable:hover { background: rgba(0,0,0,0.14); }
/* Generated image in chat */
.dc-msg-ai-image {
  margin-left: 40px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.dc-gen-image {
  width: 340px;
  max-width: 100%;
  height: 210px;
  object-fit: cover;
  border-radius: 12px;
  display: block;
  cursor: zoom-in;
  box-shadow: 0 2px 16px rgba(0,0,0,0.14);
  transition: opacity 0.15s, transform 0.15s;
}
.dc-gen-image:hover { opacity: 0.92; transform: scale(1.01); }
.dc-gen-image-hint {
  font-size: 11px;
  color: var(--muted);
  padding-left: 2px;
}

/* ── Image Lightbox ─────────────────────────────────────────────────── */
.img-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.84);
  z-index: 900;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.img-lightbox.show { display: flex; }
.img-lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  object-fit: contain;
  cursor: default;
}
.img-lightbox-close {
  position: absolute;
  top: 18px;
  right: 22px;
  font-size: 26px;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 6px;
}
.img-lightbox-close:hover { color: #fff; background: rgba(255,255,255,0.12); }

/* ── PDF Side Panel ─────────────────────────────────────────────────── */
.pdf-panel {
  position: fixed;
  top: 0;
  right: -520px;
  width: 480px;
  height: 100vh;
  background: var(--bg);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 28px rgba(0,0,0,0.13);
  z-index: 800;
  display: flex;
  flex-direction: column;
  transition: right 0.28s cubic-bezier(.4,0,.2,1);
}
.pdf-panel.open { right: 0; }
.pdf-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}
.pdf-panel-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pdf-panel-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--muted);
  padding: 2px 7px;
  border-radius: 5px;
  line-height: 1;
}
.pdf-panel-close:hover { background: var(--border2); color: var(--text); }
.pdf-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: #f0ede8;
}
.pdf-panel-canvas-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}
.pdf-panel-canvas-wrap canvas {
  max-width: 100%;
  height: auto;
  box-shadow: 0 2px 14px rgba(0,0,0,0.18);
  border-radius: 3px;
  background: #fff;
}
.pdf-panel-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
  justify-content: center;
}
.pdf-nav-btn {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 6px;
  padding: 5px 16px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}
.pdf-nav-btn:hover:not(:disabled) { background: var(--border2); }
.pdf-nav-btn:disabled { opacity: 0.38; cursor: default; }
.pdf-nav-page {
  font-size: 12px;
  color: var(--muted);
  min-width: 80px;
  text-align: center;
}

.dc-ai-block {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-start;
}
.dc-ai-model-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  padding-left: 46px;
  letter-spacing: 0.01em;
}
.dc-msg-ai {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 4px 16px 16px 16px;
  padding: 12px 16px;
  max-width: 88%;
  margin-left: 40px;
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.6;
  word-break: break-word;
}
.dc-msg-ai p:first-child { margin-top: 0; }
.dc-msg-ai p:last-child { margin-bottom: 0; }
.dc-msg-ai pre { font-size: 12px; overflow-x: auto; }
.dc-msg-ai code { font-size: 12px; }

/* Thinking spinner inside dc-ai-block */
.dc-ai-block .pb-thinking { margin: 0; padding: 8px 14px; }

/* Thinking indicator */
.pb-thinking {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted2);
  margin-bottom: 14px;
}

.pb-thinking-dots span {
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted2);
  margin: 0 1px;
  animation: blink 1.2s infinite;
}

.pb-thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.pb-thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.2; }
  40% { opacity: 1; }
}

/* Streaming cursor */
.stream-cursor {
  display: inline-block;
  width: 2px;
  height: 14px;
  background: var(--text);
  margin-left: 2px;
  vertical-align: middle;
  animation: cursor-blink 0.8s infinite;
}

@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── Response markdown rendering ─────────────────────────── */
.resp { line-height: 1.7; color: var(--text); }
.resp > *:first-child { margin-top: 0 !important; }
.resp > *:last-child  { margin-bottom: 0 !important; }

.resp p { margin: 0 0 10px; }
.resp strong { font-weight: 600; }
.resp em     { font-style: italic; }

/* Inline code */
.resp code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 11.5px;
  background: rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 4px;
  padding: 1px 5px;
  color: #2d2d2d;
}

/* Code blocks */
.resp pre {
  background: #1e1e1e;
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 12px 0;
}
.resp pre code {
  font-size: 12px;
  background: none;
  border: none;
  padding: 0;
  color: #d4d4d4;
  line-height: 1.65;
}

/* Headings */
.resp h1, .resp h2, .resp h3,
.resp h4, .resp h5, .resp h6 {
  font-weight: 600;
  color: var(--text);
  margin: 18px 0 6px;
  line-height: 1.35;
}
.resp h1 { font-size: 17px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.resp h2 { font-size: 15px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.resp h3 { font-size: 13.5px; }
.resp h4, .resp h5, .resp h6 { font-size: 13px; }

/* Lists */
.resp ul, .resp ol { margin: 8px 0 10px; padding-left: 22px; }
.resp ul { list-style: disc; }
.resp ol { list-style: decimal; }
.resp li { margin: 3px 0; line-height: 1.65; }
.resp li > ul, .resp li > ol { margin: 4px 0 4px 4px; }

/* Blockquote */
.resp blockquote {
  border-left: 3px solid var(--border2);
  margin: 12px 0;
  padding: 6px 14px;
  color: var(--muted);
  background: rgba(0,0,0,0.02);
  border-radius: 0 6px 6px 0;
}
.resp blockquote p { margin: 0; }

/* Horizontal rule */
.resp hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* Tables */
.resp table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 12.5px; }
.resp th, .resp td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.resp th { background: rgba(0,0,0,0.03); font-weight: 600; }
.resp tr:nth-child(even) td { background: rgba(0,0,0,0.015); }

/* Callout */
.resp .callout {
  background: rgba(0,0,0,0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 14px;
  margin: 12px 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

/* Judge panel */
.judge-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  background: var(--bg);
}

.judge-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.judge-badge {
  font-size: 10px;
  font-weight: 700;
  background: var(--text);
  color: #fff;
  padding: 3px 9px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.judge-title { font-size: 13px; font-weight: 600; color: var(--text); flex: 1; }
.judge-powered { font-size: 11px; color: var(--muted2); }

/* ── Judge Scorecard ────────────────────────────────────── */
.judge-scorecard {
  padding: 14px 18px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.jsc-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.jsc-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  width: 110px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.jsc-bar-wrap { flex: 1; }

.jsc-bar-track {
  position: relative;
  height: 18px;
  border-radius: 50px;
  background: linear-gradient(to right, #e74c3c, #e67e22, #f1c40f, #2ecc71);
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.15), 0 1px 0 rgba(255,255,255,0.7);
  overflow: visible;
}

.jsc-bar-fill {
  position: absolute;
  inset: 0;
  background: rgba(240,238,234,0.65);
  border-radius: 50px;
  right: 0;
  left: 0;
  /* Filled from right — width set via JS: fill covers (100-score)% from the right */
  transition: width 1s cubic-bezier(0.34,1.56,0.64,1);
}

.jsc-thumb {
  position: absolute;
  width: 28px;
  height: 28px;
  background: #fff;
  border-radius: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  left: 0%;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2), 0 0 0 3px #2ecc71;
  transition: left 1s cubic-bezier(0.34,1.56,0.64,1), box-shadow 1s;
  z-index: 2;
}

.jsc-score {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  width: 52px;
  text-align: right;
  flex-shrink: 0;
}

.jsc-winner {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  padding: 8px 0 2px;
  border-top: 1px solid var(--border);
}

/* ══════════════════════
   SATISFIED BAR
══════════════════════ */
.satisfied-bar {
  display: none;
  justify-content: center;
  gap: 10px;
  padding: 0 0 14px 0;
  flex-shrink: 0;
}

.satisfied-bar.show { display: flex; }

.sat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 24px;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--text);
  white-space: nowrap;
  min-width: 180px;
  justify-content: center;
}

.sat-btn:hover { background: #eeece8; border-color: #b0ada6; }
.sat-ico { font-size: 14px; }

/* ══════════════════════
   FULLSCREEN OVERLAY
══════════════════════ */
/* When a panel is in fullscreen, dim everything else */
body.has-fs-overlay .sidebar,
body.has-fs-overlay .topbar,
body.has-fs-overlay .panels-zone > *:not(.fs-overlay),
body.has-fs-overlay .prompt-section,
body.has-fs-overlay .satisfied-bar {
  visibility: hidden;
  pointer-events: none;
}

.fs-overlay {
  position: fixed !important;
  inset: 0 !important;
  z-index: 600 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  border-radius: 0 !important;
  border: none !important;
  display: flex !important;
  flex-direction: column !important;
  background: var(--surface) !important;
  visibility: visible !important;
  pointer-events: all !important;
  overflow: hidden !important;
}

/* Panel body inside fullscreen fills remaining height */
.fs-overlay .panel-body,
.fs-overlay #judgePanelBody {
  flex: 1 !important;
  height: auto !important;
  overflow-y: auto !important;
}

/* Judge zone fullscreen needs to show as flex column */
.fs-overlay.judge-zone {
  flex-direction: column !important;
}
.fs-overlay .judge-panel {
  flex: 1 !important;
  overflow: hidden !important;
}

/* ══════════════════════
   PROMPT SECTION
══════════════════════ */
/* (3) Lifted higher + mobile safe-area padding */
.prompt-section {
  background: var(--bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  padding: 14px 20px 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

.prompt-hero {
  text-align: center;
  font-family: 'Lora', serif;
  font-style: italic;
  font-size: 28px;
  color: var(--text);
  margin-bottom: 14px;
  letter-spacing: -0.3px;
  opacity: 0.85;
}

/* Hide hero when there's content in panels */
.has-content .prompt-hero { display: none; }

.prompt-box {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 14px;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: border-color 0.15s;
  max-width: 800px;
  margin: 0 auto 10px;
}

.prompt-box:focus-within { border-color: #b0ada6; }

.prompt-box input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text);
}

.prompt-box input::placeholder { color: #c0bdb6; }
.prompt-box input:disabled { opacity: 0.5; }

/* Prompt toolbar */
.prompt-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 800px;
  margin: 0 auto;
}

.ptb-left { display: flex; align-items: center; gap: 4px; }

/* Base toolbar button */
.ptb-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all 0.12s;
  white-space: nowrap;
}

.ptb-btn:hover { background: rgba(0,0,0,0.05); color: var(--text); }
.ptb-btn svg { flex-shrink: 0; }

/* Add files — slightly bordered, Arena.ai style */
.ptb-attach {
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--muted);
  padding: 5px 10px;
}

.ptb-attach:hover { background: #f0ede8; border-color: #b8b4ac; color: var(--text); }

/* Divider between attach and feature buttons */
.ptb-divider {
  width: 1px;
  height: 20px;
  background: var(--border2);
  margin: 0 2px;
  flex-shrink: 0;
}

/* PPT / Video feature buttons */
.ptb-feature {
  color: var(--muted);
  gap: 5px;
}

.ptb-feature:hover { background: rgba(0,0,0,0.05); color: var(--text); }

/* PRO badge inside toolbar button */
.ptb-pro {
  font-size: 8.5px;
  font-weight: 700;
  background: var(--text);
  color: #fff;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.3px;
  margin-left: 2px;
}

.ptb-right { display: flex; align-items: center; gap: 8px; }

.ptb-layout-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--border2);
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted2);
  transition: all 0.12s;
}

.ptb-layout-icon:hover { background: rgba(0,0,0,0.04); color: var(--text); }

.ptb-send {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--text);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.12s;
}

.ptb-send:hover { background: #333; }
.ptb-send:disabled { background: #ccc9c2; cursor: default; }

/* Stop button (during streaming) */
.ptb-send.stop { background: #c0392b; }
.ptb-send.stop:hover { background: #a93226; }

/* ══════════════════════
   BOTTOM NOTE
══════════════════════ */
.bottom-note {
  text-align: center;
  font-size: 11px;
  color: var(--muted2);
  padding: 6px 0 4px;
}

/* ══════════════════════
   DOWNLOAD OVERLAY
══════════════════════ */
.dl-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.30);
  z-index: 500;
  align-items: center;
  justify-content: center;
}

.dl-overlay.show { display: flex; }

.dl-modal {
  background: var(--surface);
  border-radius: 16px;
  padding: 24px;
  width: 310px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
}

.dl-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.dl-sub   { font-size: 12px; color: #999; margin-bottom: 18px; }

.dl-options { display: flex; flex-direction: column; gap: 8px; }

.dl-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s;
}

.dl-opt:hover { background: #f7f5f1; }

.dl-opt-ico {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.dl-opt-name { font-size: 13px; font-weight: 500; color: var(--text); }
.dl-opt-sub  { font-size: 11px; color: #aaa; margin-top: 1px; }

.dl-pro-badge {
  font-size: 9px;
  font-weight: 700;
  background: var(--text);
  color: #fff;
  padding: 2px 6px;
  border-radius: 3px;
  flex-shrink: 0;
}

.dl-cancel {
  width: 100%;
  margin-top: 14px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: none;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: #888;
  transition: background 0.12s;
}

.dl-cancel:hover { background: #f7f5f1; }

/* ══════════════════════
   UPGRADE MODAL
══════════════════════ */
.upgrade-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 700;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}
.upgrade-overlay.show { display: flex; }

.upgrade-modal {
  background: var(--surface);
  border-radius: 20px;
  padding: 32px 28px 28px;
  width: 100%;
  max-width: 780px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.22);
  position: relative;
  text-align: center;
}

.upgrade-close {
  position: absolute;
  top: 14px; right: 16px;
  background: none; border: none;
  font-size: 18px; color: #aaa;
  cursor: pointer; line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.12s;
}
.upgrade-close:hover { background: #f0ede8; color: #555; }

.upgrade-icon { font-size: 32px; margin-bottom: 10px; }
.upgrade-title { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.upgrade-sub   { font-size: 14px; color: var(--muted); margin-bottom: 20px; }

/* Toggle */
.upgrade-toggle {
  display: inline-flex;
  background: #f0ede8;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  margin-bottom: 24px;
}
.utog-btn {
  background: none; border: none;
  padding: 7px 18px;
  border-radius: 8px;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
  display: flex; align-items: center; gap: 6px;
}
.utog-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.10); }
.utog-save {
  font-size: 10px; font-weight: 700;
  background: #22c55e; color: #fff;
  padding: 2px 6px; border-radius: 4px;
}

/* Plan cards */
.upgrade-plans {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 20px;
  text-align: left;
}

.uplan {
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s;
  position: relative;
}
.uplan:hover { border-color: #a0c4ff; }

.uplan-featured {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}

.uplan-popular {
  position: absolute;
  top: -10px; left: 50%;
  transform: translateX(-50%);
  background: #3b82f6;
  color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

.uplan-name { font-size: 14px; font-weight: 700; color: var(--text); }

.uplan-price {
  font-size: 26px; font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.uplan-per { font-size: 13px; font-weight: 400; color: var(--muted); }

.uplan-features {
  list-style: none;
  display: flex; flex-direction: column; gap: 5px;
  font-size: 12px; color: var(--muted);
  flex: 1;
}

.uplan-btn {
  display: block;
  text-align: center;
  padding: 10px 14px;
  border-radius: 9px;
  border: 1.5px solid var(--border2);
  background: none;
  color: var(--text);
  font-size: 13px; font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.13s, border-color 0.13s;
}
.uplan-btn:hover { background: #f0ede8; }

.uplan-btn-featured {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
}
.uplan-btn-featured:hover { background: #2563eb; border-color: #2563eb; }

.upgrade-note {
  font-size: 12px; color: #aaa;
  margin-top: 4px;
}

/* Mobile */
@media (max-width: 600px) {
  .upgrade-modal { padding: 24px 16px 20px; }
  .upgrade-plans { grid-template-columns: 1fr; }
  .uplan-featured { order: -1; }
}

/* ══════════════════════
   TOAST
══════════════════════ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--text);
  color: #fff;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 600;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ══════════════════════
   RESPONSIVE — MOBILE
══════════════════════ */
@media (max-width: 820px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    transform: translateX(-100%);
    width: var(--sidebar);
  }

  .sidebar.mobile-open { transform: translateX(0); }

  .sidebar.collapsed {
    width: var(--sidebar);
    transform: translateX(-100%);
  }

  .sidebar-overlay.show { display: block; }

  /* ── Panels zone: flex:1 so it fills space between topbar and prompt,
        scrollable so all panels are reachable — prompt always stays pinned ── */
  .panels-zone {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  /* top-panels stacks vertically and grows to natural content height */
  .top-panels {
    flex: none;
    flex-direction: column;
    overflow: visible;
  }

  .panel {
    flex: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow: visible;
    min-height: 0;
  }
  .panel:last-child { border-bottom: none; }

  /* Panel body: natural height, outer panels-zone handles scrolling */
  .panel-body {
    flex: none !important;
    height: auto !important;
    min-height: 120px;
    max-height: 50vh;
    overflow-y: auto;
  }

  .panel-empty {
    height: auto;
    min-height: 110px;
  }

  /* Judge zone: fixed min-height instead of 36% (which was relative to nothing) */
  .judge-zone {
    height: auto !important;
    min-height: 200px;
  }

  /* Prompt section: safe-area padding for iOS home bar + Android nav */
  .prompt-section {
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 8px));
    flex-shrink: 0;
  }

  /* Compact the prompt hero on mobile so it doesn't eat too much space */
  .prompt-hero {
    font-size: 20px;
    margin-bottom: 10px;
  }

  .sat-btn { min-width: 130px; padding: 8px 14px; font-size: 12px; }

  /* Hide feature buttons on mobile — keep only Attach + Send */
  .ptb-feature { display: none; }
  .ptb-divider { display: none; }
}

@media (max-width: 480px) {
  .topbar { gap: 5px; padding: 0 10px; }
  .mode-btn { padding: 5px 8px; font-size: 12px; }
  .tb-login { padding: 6px 12px; font-size: 12px; }
}

/* ══════════════════════
   SIDEBAR MODES
══════════════════════ */
.sidebar-modes {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 4px 8px 6px;
  flex-shrink: 0;
  box-sizing: border-box;
}

.sm-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  background: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 12.5px;
  color: var(--muted);
  text-align: left;
  transition: all 0.12s;
  white-space: nowrap;
  position: relative;
}

.sm-btn:hover { background: rgba(0,0,0,0.05); color: var(--text); }

.sm-btn.sm-active {
  background: rgba(59,130,246,0.1);
  color: #2563eb;
  font-weight: 500;
}

.sm-ico { font-size: 14px; flex-shrink: 0; opacity: 0.8; }

.sm-new {
  margin-left: auto;
  background: #f59e0b;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 2px 5px;
  border-radius: 4px;
  flex-shrink: 0;
}

/* ══════════════════════
   CONTENT STUDIO
══════════════════════ */
.cs-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 20px 24px;
  gap: 16px;
  min-height: 0;
}

.cs-panel::-webkit-scrollbar { width: 3px; }
.cs-panel::-webkit-scrollbar-thumb { background: #dedad4; border-radius: 4px; }

.cs-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.cs-header-ico { font-size: 18px; }

.cs-header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  font-family: 'DM Sans', 'Inter', sans-serif;
}

.cs-header-sub {
  font-size: 12px;
  color: var(--muted);
}

.cs-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.cs-row-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  flex-shrink: 0;
  min-width: 60px;
}

.cs-platforms, .cs-tones {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.cs-platform-btn, .cs-tone-btn {
  padding: 5px 13px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  background: var(--surface);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.12s;
}

.cs-platform-btn:hover, .cs-tone-btn:hover {
  border-color: #2563eb;
  color: #2563eb;
}

.cs-platform-active {
  background: #2563eb !important;
  border-color: #2563eb !important;
  color: #fff !important;
  font-weight: 500;
}

.cs-tone-active {
  background: #16a34a !important;
  border-color: #16a34a !important;
  color: #fff !important;
  font-weight: 500;
}

.cs-idea-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.cs-idea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border2);
  border-radius: 10px;
  background: var(--surface);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text);
  resize: none;
  outline: none;
  transition: border-color 0.12s;
  box-sizing: border-box;
  line-height: 1.5;
}

.cs-idea:focus { border-color: #2563eb; }
.cs-idea::placeholder { color: var(--muted2); }

.cs-idea-hint {
  font-size: 11.5px;
  color: var(--muted2);
  padding-left: 2px;
}

.cs-generate-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  align-self: flex-start;
  padding: 9px 20px;
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: 9px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.12s;
  flex-shrink: 0;
}

.cs-generate-btn:hover { opacity: 0.85; }
.cs-generate-btn:disabled { opacity: 0.5; pointer-events: none; }

.cs-outputs {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.cs-outputs-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.cs-outputs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.cs-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 160px;
}

.cs-card-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.cs-card-model-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cs-dot-blue { background: #2563eb; }
.cs-dot-orange { background: #f59e0b; }

.cs-card-model-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}

.cs-card-body {
  flex: 1;
  padding: 10px 14px;
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.6;
  overflow-y: auto;
  min-height: 80px;
}

.cs-card-body::-webkit-scrollbar { width: 3px; }
.cs-card-body::-webkit-scrollbar-thumb { background: #dedad4; border-radius: 4px; }

.cs-card-actions {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.cs-action-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 7px;
  font-family: 'Inter', sans-serif;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.12s;
}

.cs-auto-post {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.cs-auto-post:hover { background: #1d4ed8; border-color: #1d4ed8; }

.cs-schedule {
  background: transparent;
  color: var(--muted);
  border-color: var(--border2);
}

.cs-schedule:hover { background: rgba(0,0,0,0.04); color: var(--text); }

/* ── Generate Image toggle button ── */
.cs-img-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1.5px dashed var(--border2);
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-family: 'Inter', sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.cs-img-btn:hover {
  border-color: #2563eb;
  color: #2563eb;
  background: rgba(37,99,235,0.04);
}

.cs-faq-note {
  font-size: 11.5px;
  color: #6b7280;
  margin: 4px 0 0 0;
  padding: 0;
}
.cs-faq-note a {
  color: #2563eb;
  text-decoration: none;
}
.cs-faq-note a:hover {
  text-decoration: underline;
}

.cs-img-hint {
  font-size: 11.5px;
  color: #2563eb;
  padding: 4px 2px;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.cs-img-btn.cs-img-btn-on {
  border-style: solid;
  border-color: #2563eb;
  background: rgba(37,99,235,0.08);
  color: #2563eb;
  font-weight: 600;
}

/* ── Social Connect Modal ── */
.sc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.sc-modal {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sc-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sc-platform-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sc-platform-ico { font-size: 15px; }

.sc-close {
  background: none;
  border: none;
  font-size: 15px;
  color: var(--muted2);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
}
.sc-close:hover { background: var(--bg); color: var(--text); }

.sc-modal-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: -8px;
  line-height: 1.5;
}

.sc-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sc-section-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sc-connect-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 11px 18px;
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.12s;
  justify-content: center;
}
.sc-connect-btn:hover { opacity: 0.85; }

.sc-connect-note {
  font-size: 11.5px;
  color: var(--muted2);
  line-height: 1.5;
}

.sc-or-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  color: var(--muted2);
}
.sc-or-divider::before,
.sc-or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.sc-manual-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sc-copy-post-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: var(--surface);
  font-family: 'Inter', sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.12s;
}
.sc-copy-post-btn:hover { background: var(--bg); }

.sc-open-link {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 500;
  color: #2563eb;
  text-decoration: none;
  margin-left: auto;
}
.sc-open-link:hover { text-decoration: underline; }

.sc-cancel-btn {
  width: 100%;
  padding: 9px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.12s;
}
.sc-cancel-btn:hover { background: var(--bg); color: var(--text); }

/* Account connection status line */
.sc-account-status {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin: 0 0 10px;
  padding: 7px 11px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* Post Now button (primary green action) */
.sc-postnow-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 10px 16px;
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  justify-content: center;
  transition: opacity 0.12s;
}
.sc-postnow-btn:hover:not(:disabled) { opacity: 0.87; }
.sc-postnow-btn:disabled { opacity: 0.5; cursor: default; }

/* Schedule modal: datetime input */
.sch-datetime-input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border2);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  box-sizing: border-box;
  margin-top: 6px;
}
.sch-datetime-input:focus { outline: none; border-color: var(--accent); }

/* Schedule modal: action row */
.sch-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
.sch-actions .sc-cancel-btn { margin: 0; flex: 0 0 auto; width: auto; padding: 9px 18px; }
.sch-actions .sc-postnow-btn { flex: 1; }

/* ── Char counter bar ── */
.cs-char-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px;
}

.cs-char-count {
  font-size: 11px;
  color: var(--muted2);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.cs-char-count.cs-char-warn { color: #d97706; }
.cs-char-count.cs-char-over { color: #dc2626; font-weight: 600; }

/* ── Generate row (button + image toggle) ── */
.cs-gen-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.cs-img-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.cs-img-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: #2563eb;
  cursor: pointer;
}

.cs-img-toggle:hover { color: var(--text); }

/* ── Card image area ── */
.cs-card-img {
  width: 100%;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
}

.cs-card-img img {
  width: 100%;
  display: block;
  cursor: zoom-in;
  transition: opacity 0.2s;
}

.cs-card-img img:hover { opacity: 0.92; }

.cs-img-error {
  padding: 10px 14px;
  font-size: 11.5px;
  color: #c0392b;
  background: #fef2f2;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cs-img-error button {
  background: none;
  border: 1px solid #c0392b;
  border-radius: 5px;
  color: #c0392b;
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
}

.cs-img-error button:hover { background: #fef2f2; }

.cs-img-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  font-size: 12px;
  color: var(--muted);
}

.cs-img-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border2);
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ── Copy button ── */
.cs-copy {
  background: transparent;
  color: var(--muted);
  border-color: var(--border2);
  margin-left: auto;
}

.cs-copy:hover { background: rgba(0,0,0,0.04); color: var(--text); }

@media (max-width: 700px) {
  .cs-outputs-grid { grid-template-columns: 1fr; }
  .cs-panel { padding: 14px 16px; }
  .cs-gen-row { gap: 10px; }
}
