/* ========================================================
   METAPHORE — Page 2 Prototype Styles
   Premium, minimal, Apple-inspired. White-first canvas.
   ======================================================== */

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f7;
  --bg-card: #fbfbfd;
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #a1a1a6;
  --border: #d2d2d7;
  --border-light: #e8e8ed;
  --cta-dark: #111111;
  --cta-hover: #000000;
  --accent-blue: #0071e3;
  --accent-blue-hover: #0077ed;
  --sidebar-bg: #fafafa;
  --sidebar-width: 260px;
  --sidebar-collapsed: 60px;
  --input-bg: #ffffff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.10);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --transition: 0.2s ease;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Layout ─────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  transition: width var(--transition);
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
}

.sidebar-brand {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .sidebar-brand {
  display: none;
}

.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background: var(--border-light);
  color: var(--text-primary);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  color: var(--text-secondary);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-decoration: none;
}

.sidebar-item:hover {
  background: var(--border-light);
  color: var(--text-primary);
}

.sidebar-item.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.sidebar-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-item:hover svg {
  opacity: 1;
}

.sidebar-item-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar.collapsed .sidebar-item-label {
  display: none;
}

.sidebar.collapsed .sidebar-item {
  justify-content: center;
  padding: 10px 8px;
}

.sidebar-footer {
  border-top: 1px solid var(--border-light);
  padding: 12px 8px;
}

/* ── Sidebar Groups ─────────────────────────── */
.sidebar-group {
  margin-bottom: 2px;
}

.sidebar-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: background var(--transition), color var(--transition);
}

.sidebar-group-header:hover {
  background: var(--border-light);
  color: var(--text-primary);
}

.sidebar-group-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-group-left svg {
  width: 16px;
  height: 16px;
  opacity: 0.7;
}

.sidebar-group-chevron {
  display: flex;
  transition: transform 0.2s ease;
}

.sidebar-group-chevron svg {
  width: 14px;
  height: 14px;
  opacity: 0.4;
}

.sidebar-group.expanded .sidebar-group-chevron {
  transform: rotate(90deg);
}

.sidebar-group-children {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.sidebar-group.expanded .sidebar-group-children {
  max-height: 200px;
}

.sidebar-child {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px 7px 38px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-decoration: none;
}

.sidebar-child:hover {
  background: var(--border-light);
  color: var(--text-primary);
}

.sidebar-child svg {
  width: 15px;
  height: 15px;
  opacity: 0.55;
  flex-shrink: 0;
}

.sidebar-child:hover svg {
  opacity: 0.85;
}

/* Collapsed sidebar: hide children and labels */
.sidebar.collapsed .sidebar-group-children {
  display: none;
}

.sidebar.collapsed .sidebar-group-header {
  justify-content: center;
  padding: 10px 8px;
}

.sidebar.collapsed .sidebar-group-chevron {
  display: none;
}

/* ── Main Content ───────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

/* ── Top Bar ────────────────────────────────── */
.top-bar {
  padding: 12px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  background: var(--bg-primary);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-bar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Hidden on desktop — shown via media query on mobile */
.mobile-menu-btn {
  display: none;
}

.mobile-back-btn {
  display: none;
}

.mobile-brand {
  display: none;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.mobile-brand:hover {
  opacity: 0.65;
}

.top-bar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.lang-switch {
  font-size: 13px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--transition);
}

.lang-switch:hover {
  border-color: var(--text-secondary);
}

/* ── Input Section ──────────────────────────── */
.input-section {
  padding: 24px 32px 16px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-primary);
}

/* Pinned files */
.pinned-files {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.pinned-files:empty {
  display: none;
  margin-bottom: 0;
}

.pinned-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text-secondary);
  animation: fadeIn 0.2s ease;
}

.pinned-file svg {
  width: 14px;
  height: 14px;
  opacity: 0.6;
}

.pinned-file-remove {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  color: var(--text-tertiary);
  border-radius: 4px;
  display: flex;
  transition: color var(--transition), background var(--transition);
}

.pinned-file-remove:hover {
  color: var(--text-primary);
  background: var(--border-light);
}

/* Input field */
.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--input-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrapper:focus-within {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.input-actions-left {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}

.input-textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-primary);
  background: transparent;
  min-height: 24px;
  max-height: 160px;
  overflow-y: auto;
}

.input-textarea::placeholder {
  color: var(--text-tertiary);
}

.input-actions-right {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 7px;
  border-radius: 8px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}

.btn-icon:hover {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.btn-icon svg {
  width: 20px;
  height: 20px;
}

.btn-send {
  background: var(--accent-blue);
  border: none;
  cursor: pointer;
  padding: 7px 14px;
  border-radius: 8px;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  transition: background var(--transition), transform 0.1s ease;
}

.btn-send:hover {
  background: var(--accent-blue-hover);
}

.btn-send:active {
  transform: scale(0.97);
}

.btn-send svg {
  width: 16px;
  height: 16px;
}

/* ── Options Bar ────────────────────────────── */
.options-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 12px;
  align-items: center;
}

.option-dropdown {
  position: relative;
}

.option-trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: var(--bg-primary);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition);
  white-space: nowrap;
}

.option-trigger:hover {
  border-color: var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.option-trigger.has-value {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  background: rgba(0, 113, 227, 0.04);
}

.option-trigger svg {
  width: 12px;
  height: 12px;
  transition: transform var(--transition);
}

.option-trigger.open svg {
  transform: rotate(180deg);
}

.option-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 180px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 100;
  padding: 4px;
  display: none;
  animation: dropdownIn 0.15s ease;
}

.option-menu.visible {
  display: block;
}

.option-menu-item {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.option-menu-item:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.option-menu-item.selected {
  background: rgba(0, 113, 227, 0.08);
  color: var(--accent-blue);
  font-weight: 500;
}

/* ── Output Section ─────────────────────────── */
.output-section {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.output-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--text-tertiary);
  gap: 8px;
}

.output-empty svg {
  width: 48px;
  height: 48px;
  opacity: 0.3;
  margin-bottom: 8px;
}

.output-empty h3 {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-secondary);
}

.output-empty p {
  font-size: 14px;
  max-width: 380px;
}

/* Output result card */
.output-result {
  max-width: 720px;
  margin: 0 auto;
  animation: fadeInUp 0.3s ease;
}

.output-result h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.output-section-block {
  margin-bottom: 24px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
}

.output-section-block h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: 10px;
}

.output-section-block p {
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.7;
}

/* ── Animations ─────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Scrollbar ──────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* ── Hidden file input ──────────────────────── */
.file-input-hidden {
  display: none;
}

/* ── Responsive ─────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .mobile-menu-btn {
    display: flex !important;
  }
  .mobile-back-btn {
    display: flex !important;
  }
  .mobile-brand {
    display: block !important;
  }
  .input-section {
    padding: 16px;
  }
  .output-section {
    padding: 16px;
  }
  .options-bar {
    gap: 4px;
  }
}

/* ── Mobile overlay ─────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 199;
}

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

/* ── Panel Views ────────────────────────────── */
.panel-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  animation: fadeInUp 0.25s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-header {
  margin-bottom: 28px;
}

.panel-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.panel-section {
  margin-bottom: 32px;
}

.panel-section h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-section h2 svg {
  width: 18px;
  height: 18px;
  opacity: 0.5;
}

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 20px;
}

.panel-card + .panel-card {
  margin-top: 12px;
}

.panel-card-danger {
  border-color: #fecaca;
  background: #fef2f2;
}

.panel-card-muted {
  opacity: 0.6;
}

.card-subtitle {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Form Elements ──────────────────────────── */
.form-row {
  margin-bottom: 16px;
}

.form-row:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  transition: border-color var(--transition);
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(0,113,227,0.1);
}

.form-textarea {
  resize: vertical;
}

.form-hint {
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.5;
  margin-top: 2px;
}

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

.mkey-code {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ── Buttons ────────────────────────────────── */
.btn-small {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  background: var(--cta-dark);
  color: white;
  transition: background var(--transition);
}

.btn-small:hover {
  background: var(--cta-hover);
}

.btn-outline {
  background: var(--bg-primary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.btn-danger {
  background: #ef4444;
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-primary {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  background: var(--accent-blue);
  color: white;
  transition: background var(--transition);
}

.btn-primary:hover {
  background: var(--accent-blue-hover);
}

/* ── Language Grid ──────────────────────────── */
.lang-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.lang-chip {
  padding: 6px 14px;
  font-size: 13px;
  border: 1px solid var(--border-light);
  border-radius: 20px;
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.lang-chip:hover {
  border-color: var(--border);
  background: var(--bg-secondary);
}

.lang-chip.active {
  border-color: var(--accent-blue);
  background: rgba(0,113,227,0.06);
  color: var(--accent-blue);
  font-weight: 500;
}

/* ── Privacy Rows ───────────────────────────── */
.privacy-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

.privacy-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.privacy-row:first-child {
  padding-top: 0;
}

/* ── Badges ─────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 12px;
  white-space: nowrap;
}

.badge-green {
  background: #dcfce7;
  color: #16a34a;
}

.badge-blue {
  background: rgba(0,113,227,0.08);
  color: var(--accent-blue);
}

.badge-small {
  font-size: 11px;
  padding: 2px 7px;
  background: var(--bg-secondary);
  color: var(--text-tertiary);
  border-radius: 8px;
}

/* ── Usage Bar ──────────────────────────────── */
.plan-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.plan-description {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 6px;
}

.usage-bar-container {
  margin-bottom: 20px;
}

.usage-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.usage-bar-count {
  font-weight: 600;
  color: var(--accent-blue);
}

.usage-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
}

.usage-bar-fill {
  height: 100%;
  background: var(--accent-blue);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.usage-stats {
  display: flex;
  gap: 24px;
}

.usage-stat {
  display: flex;
  flex-direction: column;
}

.usage-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.usage-stat-label {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* ── Channel List ───────────────────────────── */
.channel-list {
  display: flex;
  flex-direction: column;
}

.channel-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
  color: var(--text-primary);
}

.channel-row:last-child {
  border-bottom: none;
}

.channel-row.muted {
  color: var(--text-tertiary);
}

/* ── History ────────────────────────────────── */
.history-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}

.search-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  transition: border-color var(--transition);
}

.search-bar:focus-within {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(0,113,227,0.1);
}

.search-bar svg {
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.search-input {
  border: none;
  outline: none;
  flex: 1;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: transparent;
}

.saved-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.saved-toggle svg {
  width: 14px;
  height: 14px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  transition: background var(--transition);
  cursor: pointer;
}

.history-item:hover {
  background: var(--bg-secondary);
}

.history-item-main {
  flex: 1;
  min-width: 0;
}

.history-input {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-date {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
  display: block;
}

.history-tags {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.tag {
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-tertiary);
  white-space: nowrap;
}

.history-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.btn-icon-sm {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  color: var(--text-tertiary);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all var(--transition);
}

.btn-icon-sm:hover {
  background: var(--border-light);
  color: var(--text-primary);
}

.btn-icon-sm--primary {
  background: var(--accent, #6366f1);
  color: #fff;
}

.btn-icon-sm--primary:hover {
  background: var(--accent-hover, #4f46e5);
  color: #fff;
}

.btn-icon-sm svg {
  width: 14px;
  height: 14px;
}

/* ── How It Works Steps ─────────────────────── */
.how-step {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-light);
}

.how-step:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.how-step:first-child {
  padding-top: 0;
}

.step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-blue);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Examples ───────────────────────────────── */
.example-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: opacity var(--transition);
}

.example-item:hover {
  opacity: 0.7;
}

.example-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.example-item:first-child {
  padding-top: 0;
}

.example-item .tag {
  margin-top: 6px;
}

/* ── FAQ ────────────────────────────────────── */
.faq-item {
  border-bottom: 1px solid var(--border-light);
  padding: 14px 0;
}

.faq-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.faq-item:first-child {
  padding-top: 0;
}

.faq-item summary {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::before {
  content: "+";
  font-size: 16px;
  font-weight: 400;
  color: var(--text-tertiary);
  transition: transform var(--transition);
}

.faq-item[open] summary::before {
  content: "−";
}

.faq-item p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-top: 10px;
  padding-left: 22px;
}

/* ── Sidebar Brand Clickable ────────────────── */
.sidebar-brand {
  text-decoration: none;
  cursor: pointer;
  transition: opacity var(--transition);
}

.sidebar-brand:hover {
  opacity: 0.65;
}

/* ── Active Sidebar Group ───────────────────── */
.sidebar-group.active-group > .sidebar-group-header {
  color: var(--accent-blue);
}

.sidebar-group.active-group > .sidebar-group-header svg {
  opacity: 1;
}

/* ── Onboarding Screens ─────────────────────── */
.onboarding-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-secondary);
  padding: 24px;
}

.onboarding-card {
  background: var(--bg-primary);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  padding: 40px 36px;
  max-width: 440px;
  width: 100%;
}

.onboarding-brand {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-blue);
  margin-bottom: 24px;
}

.onboarding-card h1 {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.onboarding-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 0;
}

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

/* ── mkey Reveal ────────────────────────────── */
.mkey-success-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.mkey-reveal-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 20px;
}

.mkey-reveal-box code {
  flex: 1;
  font-family: "SF Mono", SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-all;
  line-height: 1.5;
}

.mkey-warning {
  font-size: 13px;
  color: #b45309;
  background: #fef3c7;
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 12px;
  line-height: 1.5;
}

.mkey-display {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mkey-code {
  font-family: "SF Mono", SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  padding: 4px 8px;
  border-radius: 6px;
}

/* ── Gate Modal Overlay ─────────────────────── */
.gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}

.gate-modal {
  background: var(--bg-primary);
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
  padding: 32px;
  max-width: 520px;
  width: 100%;
  position: relative;
  animation: slideUp 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.gate-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  width: 24px;
  height: 24px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background var(--transition);
}

.gate-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.gate-close svg {
  width: 16px;
  height: 16px;
}

.gate-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.gate-modal h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.gate-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 20px;
}

.gate-providers {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.gate-provider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.gate-provider-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 160px;
  flex-shrink: 0;
}

.gate-provider-info span:first-child {
  font-size: 14px;
  color: var(--text-primary);
}

.gate-key-input {
  flex: 1;
  min-width: 180px;
}

.gate-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
}

.gate-actions .btn-primary {
  width: 100%;
}

/* ── Plan Features (gate subscribe) ─────────── */
.plan-features-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.plan-feature {
  font-size: 14px;
  color: var(--text-primary);
  padding: 6px 0;
  line-height: 1.4;
}

/* ── Provider Cards (LLM Keys Panel) ────────── */
.provider-card {
  border: 1px solid var(--border);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.provider-card.provider-preferred {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 1px var(--accent-blue);
}

.provider-card.provider-empty {
  border-style: dashed;
  background: var(--bg-secondary);
}

.provider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.provider-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-primary);
}

.provider-name svg {
  width: 16px;
  height: 16px;
  opacity: 0.6;
}

.provider-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.provider-badges {
  display: flex;
  gap: 6px;
  align-items: center;
}

.provider-key-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.provider-meta {
  margin-top: 8px;
}

.provider-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.provider-add-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.provider-add-row .form-input {
  flex: 1;
  min-width: 200px;
}

/* ── Danger + muted button variants ─────────── */
.btn-danger-text {
  color: #dc2626 !important;
  border-color: #fecaca !important;
}

.btn-danger-text:hover {
  background: #fef2f2 !important;
}

/* ── Badge variants ─────────────────────────── */
.badge-red {
  background: #fef2f2;
  color: #dc2626;
}

.badge-muted {
  background: var(--bg-secondary);
  color: var(--text-tertiary);
}

.badge-small {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent-blue);
  color: #fff;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: middle;
  margin-left: 4px;
}

/* ── Model Selector ─────────────────────────── */
.model-trigger {
  font-weight: 500;
}

.model-trigger.no-keys {
  opacity: 0.6;
  border-style: dashed;
}

.model-cost {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-left: auto;
  padding-left: 12px;
  white-space: nowrap;
}

/* ── Transform Counter ──────────────────────── */
.transform-counter {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.counter-pro {
  background: #dbeafe;
  color: #1d4ed8;
}

.counter-trial {
  background: #dcfce7;
  color: #16a34a;
}

.counter-byollm {
  background: #fef3c7;
  color: #b45309;
}

/* ── Plan Comparison Grid ───────────────────── */
.plan-comparison {
  padding: 0 !important;
  overflow: hidden;
}

.plan-compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.plan-col {
  padding: 24px;
}

.plan-col h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.plan-col-current {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
}

.plan-col-upgrade {
  background: var(--bg-primary);
}

.plan-price {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.plan-price small {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-tertiary);
}

.plan-feature-item {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 5px 0;
  line-height: 1.4;
}

.plan-col-upgrade .plan-feature-item {
  color: var(--text-primary);
}

/* ── Channel list (billing) ─────────────────── */
.channel-row.muted {
  opacity: 0.4;
}

.panel-card-muted {
  opacity: 0.65;
}

/* ── Panel Responsive ───────────────────────── */
@media (max-width: 768px) {
  .panel-scroll {
    padding: 20px 16px;
  }
  .plan-header {
    flex-direction: column;
  }
  .usage-stats {
    flex-wrap: wrap;
    gap: 16px;
  }
  .history-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .history-tags {
    flex-wrap: wrap;
  }
  .privacy-row {
    flex-direction: column;
    gap: 8px;
  }
  .onboarding-card {
    padding: 28px 20px;
  }
  .gate-modal {
    padding: 24px 20px;
    margin: 16px;
  }
  .gate-provider-row {
    flex-direction: column;
    align-items: stretch;
  }
  .gate-provider-info {
    min-width: unset;
  }
  .provider-add-row {
    flex-direction: column;
  }
  .provider-add-row .form-input {
    min-width: unset;
  }
  .plan-compare-grid {
    grid-template-columns: 1fr;
  }
  .plan-col-current {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

/* ── Install Cards ──────────────────────────── */
.install-card {
  position: relative;
}

.install-card .badge-small {
  position: absolute;
  top: 16px;
  right: 16px;
}

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

.install-header strong {
  font-size: 15px;
  color: var(--text-primary);
}

.install-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.install-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.install-steps .how-step {
  padding: 6px 0;
  border-bottom: none;
}

.install-code {
  font-family: "SF Mono", SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  background: var(--bg-secondary);
  padding: 2px 7px;
  border-radius: 5px;
  color: var(--text-primary);
  word-break: break-all;
}

/* ── Disabled language chips ────────────────── */
.lang-chip-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Loading spinner ───────────────────────── */
.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--text-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

.loading-spinner-sm {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.btn-send-loading {
  background: var(--text-tertiary) !important;
  cursor: not-allowed;
}

.btn-send:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Error toast ───────────────────────────── */
.error-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #dc2626;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 10000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: toast-in 0.3s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Output markdown styling ───────────────── */
.output-markdown h2 { font-size: 20px; font-weight: 700; margin: 24px 0 12px; }
.output-markdown h3 { font-size: 17px; font-weight: 600; margin: 20px 0 8px; color: var(--text-primary); }
.output-markdown h4 { font-size: 15px; font-weight: 600; margin: 16px 0 6px; color: var(--text-secondary); }
.output-markdown p { margin: 8px 0; line-height: 1.7; }
.output-markdown ul { margin: 8px 0; padding-left: 20px; }
.output-markdown li { margin: 4px 0; line-height: 1.6; }
.output-markdown strong { font-weight: 600; }
.output-markdown em { font-style: italic; }

/* ── Output meta line ──────────────────────── */
.output-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
