/* Login Screen */
.login-screen {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 18% 18%, rgba(66, 133, 244, 0.16), transparent 44%),
    radial-gradient(circle at 82% 82%, rgba(155, 114, 203, 0.16), transparent 44%),
    #131314;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-box {
  background: rgba(30, 31, 32, 0.94);
  backdrop-filter: blur(22px);
  border: 1px solid var(--border-strong);
  border-radius: 28px;
  padding: 32px 26px;
  width: 100%;
  max-width: 390px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.68);
  animation: modalPop 0.4s var(--spring);
}
.brand-logo { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 25px; font-weight: 700; }
.login-sub { text-align: center; font-size: 13px; color: var(--text-secondary); margin-top: -6px; margin-bottom: 4px; }

/* Sidebar (Gemini App Drawer) */
.sidebar {
  width: 304px;
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  transition: transform 0.32s var(--spring);
  z-index: 120;
  flex-shrink: 0;
}
.sidebar-top {
  padding: 14px 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sb-brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; }

.new-chat-btn {
  width: calc(100% - 28px);
  margin: 4px auto 10px;
  padding: 11px 16px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface-2);
  color: var(--text-primary);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.16s var(--spring), background 0.2s, border-color 0.2s;
}
.new-chat-btn:hover { background: var(--bg-hover); border-color: rgba(168, 199, 250, 0.45); }
.new-chat-btn:active { transform: scale(0.96); }

.sb-search-wrap {
  padding: 0 14px 10px;
  position: relative;
}
.sb-search {
  width: 100%;
  background: #131314;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 8px 34px 8px 12px;
  color: var(--text-primary);
  font-size: 12.5px;
  outline: none;
}
.sb-search:focus { border-color: rgba(168, 199, 250, 0.45); }
.sb-search-ic {
  position: absolute;
  right: 25px;
  top: 9px;
  color: var(--text-muted);
  pointer-events: none;
}

.sb-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin: 0 14px 8px;
  padding: 4px;
  background: #131314;
  border-radius: 14px;
  border: 1px solid var(--border);
}
.sb-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 7px 6px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
}
.sb-tab.active { background: var(--bg-surface-2); color: var(--text-primary); font-weight: 600; }

.sb-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sb-group-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 10px 4px;
}

.list-item {
  padding: 10px 12px;
  border-radius: 14px;
  cursor: pointer;
  background: transparent;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  transition: background 0.16s, border-color 0.16s;
  border: 1px solid transparent;
}
.list-item:hover { background: rgba(255, 255, 255, 0.055); }
.list-item.active { background: var(--accent-bg); border-color: rgba(168, 199, 250, 0.35); }
.item-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.item-title {
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-sub {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-actions { display: flex; gap: 2px; flex-shrink: 0; }

.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.sidebar-link {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 9px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.16s;
  text-align: right;
}
.sidebar-link:hover { background: rgba(255, 255, 255, 0.07); }

/* Workspace Split */
.workspace {
  flex: 1;
  display: flex;
  min-width: 0;
  position: relative;
  overflow: hidden;
}
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

/* Exact Gemini App Single-Line Topbar */
.topbar {
  height: 58px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(19, 19, 20, 0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 50;
  flex-shrink: 0;
}
.topbar-right { display: flex; align-items: center; gap: 4px; min-width: 0; flex: 1; }
.topbar-left { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.model-trigger {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid transparent;
  padding: 6px 10px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  transition: background 0.18s, border-color 0.18s;
}
.model-trigger:hover { background: rgba(255, 255, 255, 0.07); border-color: var(--border); }
.model-trigger-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 190px;
}
.model-trigger-tier {
  font-size: 10.5px;
  background: rgba(168, 199, 250, 0.15);
  color: var(--accent);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.model-trigger-tier.pro { background: rgba(197, 138, 249, 0.16); color: var(--purple); }
.model-trigger-tier.paid { background: rgba(253, 214, 99, 0.16); color: var(--warning); }

.server-pill {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 6px 11px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  max-width: 135px;
  transition: background 0.18s, border-color 0.18s;
}
.server-pill:hover { background: var(--bg-surface-2); border-color: rgba(168, 199, 250, 0.45); }
.server-pill-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar-top {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4285f4, #9b72cb);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  flex-shrink: 0;
}

/* Gemini App Bottom Sheet / Popover Model Picker */
.sheet-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(4px);
  z-index: 260;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.sheet-overlay.open { display: flex; }
.model-sheet {
  background: #1e1f20;
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  width: 100%;
  max-width: 440px;
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.72);
  animation: modalPop 0.28s var(--spring);
}
.sheet-handle { display: none; width: 40px; height: 4px; background: rgba(255,255,255,0.22); border-radius: 4px; margin: 10px auto 4px; }
.sheet-header {
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sheet-title { font-size: 15px; font-weight: 700; margin: 0; }
.sheet-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 14px 4px;
}
.sheet-tab {
  flex: 1;
  background: var(--bg-main);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 7px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.sheet-tab.active { background: rgba(76, 141, 246, 0.18); border-color: rgba(168,199,250,0.45); color: var(--accent); font-weight: 600; }

.model-list-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.model-card {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, transform 0.14s;
}
.model-card:hover { background: rgba(255, 255, 255, 0.06); }
.model-card:active { transform: scale(0.985); }
.model-card.selected { background: rgba(0, 74, 119, 0.42); border-color: rgba(168, 199, 250, 0.5); }
.model-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 3px; }
.model-card-name { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.model-card-id { font-size: 11px; color: var(--text-muted); font-family: ui-monospace, monospace; direction: ltr; text-align: right; margin-bottom: 5px; }
.model-card-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.55; }
.model-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.model-tag { font-size: 10.5px; padding: 2px 8px; border-radius: var(--radius-pill); background: rgba(255,255,255,0.06); color: var(--text-secondary); }
.sheet-note {
  padding: 10px 16px;
  background: rgba(253, 214, 99, 0.08);
  border-top: 1px solid rgba(253, 214, 99, 0.18);
  font-size: 11.5px;
  color: #e6d39c;
  line-height: 1.6;
}

/* Modals */
.modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  align-items: center;
  justify-content: center;
  z-index: 320;
  padding: 16px;
  backdrop-filter: blur(6px);
}
.modal-bg.open { display: flex; }
.modal {
  background: #1e1f20;
  padding: 22px;
  border-radius: 24px;
  width: 100%;
  max-width: 460px;
  max-height: 88dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--border-strong);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
  animation: modalPop 0.28s var(--spring);
}
.modal.wide { max-width: 740px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.modal h3 { margin: 0; font-size: 16px; }
.form-row { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
.status-msg { font-size: 12px; min-height: 16px; line-height: 1.5; }

.menu-btn { display: none; }
.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.56);
  backdrop-filter: blur(3px);
  z-index: 110;
}
.backdrop.open { display: block; }

@media (max-width: 920px) {
  .sidebar { position: fixed; right: 0; top: 0; bottom: 0; transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: inline-flex; }
  .model-trigger-name { max-width: 135px; font-size: 14px; }
  .model-trigger-tier { display: none; }
  .server-pill { max-width: 104px; padding: 5px 9px; font-size: 11.5px; }

  /* Mobile True Bottom Sheet */
  .sheet-overlay { align-items: flex-end; padding: 0; }
  .model-sheet {
    max-width: 100%;
    border-radius: 24px 24px 0 0;
    border-bottom: none;
    max-height: 84dvh;
    animation: sheetUp 0.32s var(--spring);
  }
  .sheet-handle { display: block; }
}


/* Dual Engine Provider Switcher & Google Account OAuth Card */
.provider-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.provider-opt {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.18s;
}
.provider-opt.active {
  background: rgba(76, 141, 246, 0.18);
  border-color: rgba(168, 199, 250, 0.45);
  color: var(--accent);
  font-weight: 700;
}
.oauth-card {
  border-radius: 14px;
  padding: 11px 13px;
  font-size: 12px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.oauth-card.ok {
  background: rgba(129, 201, 149, 0.1);
  border: 1px solid rgba(129, 201, 149, 0.32);
  color: #cdebd5;
}
.oauth-card.warn {
  background: rgba(253, 214, 99, 0.1);
  border: 1px solid rgba(253, 214, 99, 0.32);
  color: #f4e2a6;
}
.oauth-cmd-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  direction: ltr;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: #a8c7fa;
}
