@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap');

:root {
  --bg: #131316;
  --sidebar: #18181c;
  --surface: #1f1f25;
  --surface-hover: #282830;
  --border: rgba(255, 255, 255, 0.075);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f3f3f6;
  --muted: #9b9aa6;
  --accent: #e14b4b;
  --accent-hover: #eb5a5a;
  --accent-soft: rgba(225, 75, 75, 0.13);
  --input: #1b1b20;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.32);
  --glass: rgba(24, 24, 28, 0.78);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-ar: 'IBM Plex Sans Arabic', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

html[dir="rtl"],
html[dir="rtl"] body {
  direction: rtl;
  text-align: right;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 65% 12%, rgba(225, 75, 75, 0.055), transparent 45%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body[dir="rtl"],
[dir="rtl"] body {
  font-family: var(--font-ar);
  line-height: 1.65;
}

button,
textarea,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

/* Focus-visible accessibility ring */
:where(button, [href], input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid rgba(225, 75, 75, 0.65);
  outline-offset: 2px;
}

/* Subtle custom scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.24);
}

body.light-theme ::-webkit-scrollbar-thumb {
  background: rgba(24, 24, 27, 0.14);
}

body.light-theme ::-webkit-scrollbar-thumb:hover {
  background: rgba(24, 24, 27, 0.25);
}

.app {
  display: flex;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

/* SIDEBAR */

.sidebar {
  width: 268px;
  min-width: 268px;
  background: var(--sidebar);
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px 14px;
  z-index: 20;
  transition: transform 0.25s var(--ease-out);
}

.sidebar-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 6px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.35px;
  text-decoration: none;
}

[dir="rtl"] .brand {
  letter-spacing: 0;
}

.brand-logo {
  width: 26px;
  height: 26px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  display: block;
  box-shadow: 0 2px 10px rgba(225, 75, 75, 0.2);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 9px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

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

.icon-btn svg,
.language-btn svg,
.new-chat-btn svg,
.send-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.close-sidebar {
  display: none;
}

.new-chat-btn {
  width: 100%;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.new-chat-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.new-chat-btn svg {
  color: var(--accent);
}

.shortcut {
  margin-inline-start: auto;
  color: var(--muted);
  font-size: 11px;
  font-family: inherit;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  padding: 1.5px 6px;
  border-radius: 6px;
  direction: ltr;
}

.sidebar-section {
  margin-top: 24px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.section-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.7px;
  padding: 0 8px;
}

[dir="rtl"] .section-label {
  letter-spacing: 0;
  font-size: 12px;
}

.history-list {
  margin-top: 10px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
}

.empty-history {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.65;
  padding: 8px;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 2px 4px;
  border-radius: 9px;
  transition: background 0.15s ease;
}

.history-row:hover,
.history-row.active {
  background: var(--surface-hover);
}

.history-item {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius-sm);
  text-align: start;
  padding: 8px 6px;
  font-size: 13px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  unicode-bidi: plaintext;
  transition: color 0.15s ease;
}

.history-row:hover .history-item,
.history-row.active .history-item {
  color: var(--text);
}

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

.archive-chat-btn,
.delete-chat-btn {
  width: 26px;
  height: 26px;
  min-width: 26px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.65;
  transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.history-row:hover .archive-chat-btn,
.history-row:hover .delete-chat-btn,
.history-row.active .archive-chat-btn,
.history-row.active .delete-chat-btn,
.archive-chat-btn:focus-visible,
.delete-chat-btn:focus-visible {
  opacity: 1;
}

.archive-chat-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.delete-chat-btn:hover {
  background: rgba(239, 68, 68, 0.16);
  color: #ef4444;
}

.archive-chat-btn svg,
.delete-chat-btn svg {
  width: 14px;
  height: 14px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* SIDEBAR BOTTOM & USER CARD */

.sidebar-bottom {
  position: relative;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
}

.user-card-btn {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 11px;
  text-align: start;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.user-card-btn:hover,
.user-card-btn[aria-expanded="true"] {
  background: var(--surface-hover);
  border-color: var(--border);
}

.avatar {
  width: 34px;
  height: 34px;
  min-width: 34px;
  background: linear-gradient(135deg, rgba(225, 75, 75, 0.22), rgba(225, 75, 75, 0.08));
  border: 1px solid rgba(225, 75, 75, 0.28);
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 700;
  color: #ff7b7b;
}

.avatar.avatar-lg {
  width: 46px;
  height: 46px;
  min-width: 46px;
  font-size: 16px;
  border-radius: 13px;
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.user-info strong {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  unicode-bidi: plaintext;
}

.user-info span {
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  unicode-bidi: plaintext;
}

.online-dot {
  width: 7px;
  height: 7px;
  min-width: 7px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.45);
}

/* CENTERED SETTINGS MODAL & TABS */

.settings-backdrop {
  z-index: 45;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: backdropFade 0.2s ease both;
}

.settings-modal-card {
  width: min(540px, 100%);
  max-height: min(86dvh, 720px);
  overflow-y: auto;
  border-radius: 20px;
  padding: 22px;
  transform-origin: center;
  animation: modalPopIn 0.26s var(--ease-out) both;
}

.settings-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-account-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px;
  border-radius: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.settings-user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.settings-user-meta strong {
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  unicode-bidi: plaintext;
}

.settings-user-meta span {
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  unicode-bidi: plaintext;
}

.popover-account-link {
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(225, 75, 75, 0.3);
  background: var(--accent-soft);
  color: #ff8484;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.popover-account-link:hover {
  background: rgba(225, 75, 75, 0.2);
}

.settings-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border-radius: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.settings-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.settings-tab:hover {
  color: var(--text);
}

.settings-tab.active {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(225, 75, 75, 0.26);
}

.settings-tab.active .archive-badge {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

.settings-panel {
  display: none;
  animation: tabSwitchIn 0.22s var(--ease-out) both;
}

.settings-panel.active {
  display: block;
}

.preferences-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.popover-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.popover-tile-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.popover-select {
  width: 100%;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--text);
  font-size: 12px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.popover-select:focus {
  border-color: var(--border-strong);
}

.theme-segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--input);
  padding: 3px;
  border-radius: 9px;
  border: 1px solid var(--border);
}

.theme-seg-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 5px 6px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.theme-seg-btn.active {
  background: var(--surface-hover);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.archive-badge,
.current-plan-pill {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #ff8484;
}

/* ARCHIVE GATE & PASSWORD FLOW */

.archive-gate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
}

.archive-gate[hidden],
.archive-pass-form[hidden],
.archive-unlocked-box[hidden],
.activation-box[hidden],
.popover-inline-error[hidden],
.popover-inline-success[hidden],
.popover-input[hidden] {
  display: none;
}

.archive-gate-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.archive-open-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(225, 75, 75, 0.3);
  background: var(--accent-soft);
  color: #ff8484;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.archive-open-btn:hover {
  background: rgba(225, 75, 75, 0.2);
}

.archive-open-btn svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.archive-pass-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border-strong);
}

.archive-pass-title {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.popover-input {
  width: 100%;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--text);
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.15s ease;
}

.popover-input:focus {
  border-color: var(--border-strong);
}

.archive-pass-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.popover-primary-btn {
  flex: 1;
  padding: 7px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

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

.popover-inline-error {
  margin: 0;
  font-size: 11px;
  color: #f87171;
}

.popover-inline-success {
  margin: 0;
  font-size: 11px;
  color: #4ade80;
}

.archive-unlocked-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.archive-unlocked-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.archive-unlocked-label {
  font-size: 11.5px;
  color: var(--muted);
}

.archive-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 155px;
  overflow-y: auto;
}

.archive-empty {
  font-size: 11.5px;
  color: var(--muted);
  padding: 4px 2px;
}

.archive-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.archive-item-title {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  unicode-bidi: plaintext;
}

.archive-item-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.archive-mini-btn {
  border: 1px solid var(--border);
  background: var(--surface-hover);
  color: var(--text);
  border-radius: 7px;
  padding: 3.5px 8px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.archive-mini-btn:hover {
  border-color: var(--border-strong);
  color: #ff8484;
}

.archive-mini-btn.del:hover {
  border-color: #ef4444;
  color: #ef4444;
}

/* SUBSCRIPTION PLANS & 12-CHAR CODE */

.plans-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.plan-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: start;
  gap: 6px;
  padding: 11px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.plan-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  transform: translateY(-1px);
}

.plan-card.active {
  border-color: rgba(225, 75, 75, 0.5);
  background: var(--accent-soft);
}

.plan-card-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.plan-card-head strong {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
}

.plan-price {
  font-size: 11px;
  font-weight: 700;
  color: #ff8484;
  direction: ltr;
}

.plan-features {
  margin: 0;
  padding-inline-start: 14px;
  font-size: 11px;
  line-height: 1.55;
  color: var(--muted);
}

.activation-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  animation: fadeUp 0.2s ease both;
}

.activation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.code-input {
  font-family: var(--font-mono);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-align: center;
  font-weight: 700;
  direction: ltr;
}

.activation-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.code-counter {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  direction: ltr;
}

.popover-footer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.popover-logout-btn {
  width: 100%;
  padding: 8px 12px;
}

/* MAIN */

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: transparent;
}

.topbar {
  position: relative;
  z-index: 10;
  height: 60px;
  min-height: 60px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.menu-btn,
.mobile-brand {
  display: none;
}

.model-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.model-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(225, 75, 75, 0.5);
}

.model-version {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 2.5px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  direction: ltr;
}

.language-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6.5px 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.language-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.language-btn svg {
  width: 15px;
  height: 15px;
  color: #ff8484;
}

/* CHAT AREA */

.chat-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}

.welcome-screen {
  width: min(700px, calc(100% - 40px));
  margin: auto;
  padding: 36px 0 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: start;
  animation: fadeUp 0.35s ease both;
}

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

@keyframes modalPopIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

@keyframes sceneEnter {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes orbFloat {
  from {
    transform: translate(0, 0) scale(1);
  }
  to {
    transform: translate(-10px, 8px) scale(1.12);
  }
}

@keyframes pulseRing {
  0% {
    box-shadow: 0 0 0 0 rgba(225, 75, 75, 0.55);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(225, 75, 75, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(225, 75, 75, 0);
  }
}

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

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

.eyebrow {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid rgba(225, 75, 75, 0.22);
  color: #ff8484;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

[dir="rtl"] .eyebrow {
  letter-spacing: 0;
  text-transform: none;
  font-size: 12px;
}

.welcome-heading h1 {
  margin: 14px 0 10px;
  font-size: clamp(30px, 4.2vw, 42px);
  line-height: 1.2;
  letter-spacing: -0.8px;
  font-weight: 700;
  color: var(--text);
}

[dir="rtl"] .welcome-heading h1 {
  letter-spacing: 0;
}

.highlight-text {
  background: linear-gradient(120deg, #ff7b7b, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
}

.welcome-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
  max-width: 56ch;
}

.suggestions {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 28px;
}

.suggestion-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  padding: 15px 17px;
  text-align: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.suggestion-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.suggestion-card strong {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  unicode-bidi: plaintext;
}

.suggestion-card small {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  unicode-bidi: plaintext;
}

/* MESSAGES */

.messages {
  width: min(740px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  animation: fadeUp 0.2s ease both;
}

.message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  border: 1px solid rgba(225, 75, 75, 0.28);
  color: #ff8484;
  font-weight: 700;
  font-size: 12.5px;
}

.message.user .message-avatar {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text);
}

.message-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
  display: block;
}

.message-content {
  max-width: 82%;
  padding: 13px 17px;
  border-radius: 15px;
  background: transparent;
  font-size: 14.5px;
  line-height: 1.75;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message.user .message-content {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.message-name {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  margin-bottom: 4px;
  unicode-bidi: plaintext;
}

.message-body {
  white-space: normal;
  unicode-bidi: plaintext;
}

.md-line {
  margin: 0 0 6px;
}

.md-line:last-child {
  margin-bottom: 0;
}

.md-heading {
  margin: 10px 0 6px;
  font-weight: 700;
  line-height: 1.35;
}

.md-list {
  margin: 6px 0 10px;
  padding-inline-start: 20px;
}

.md-list li {
  margin-bottom: 4px;
}

.inline-code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.88em;
  direction: ltr;
  unicode-bidi: isolate;
}

.code-block {
  margin: 10px 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: #0f0f13;
  overflow: hidden;
  direction: ltr;
  text-align: left;
}

body.light-theme .code-block {
  background: #141417;
  color: #ececef;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11.5px;
  color: #a1a1aa;
}

.copy-code-btn {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #ececef;
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.copy-code-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.code-block pre {
  margin: 0;
  padding: 12px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
}

.code-block code {
  font-family: inherit;
}


/* MESSAGE ACTION BUTTONS (Copy, Read aloud, Regenerate) */

.message-actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.msg-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.msg-action-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text);
}

.msg-action-btn svg {
  width: 14px;
  height: 14px;
  min-width: 14px;
  max-width: 14px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* GENERATED PDF & EXCEL ACTIONS */

.generated-files-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.file-export-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 9px;
  border: 1px solid rgba(225, 75, 75, 0.3);
  background: var(--accent-soft);
  color: #ff8484;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.file-export-btn:hover:not(:disabled) {
  background: rgba(225, 75, 75, 0.2);
}

.file-export-btn.secondary {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.file-export-btn.secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: #ff8484;
}

.file-export-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.message-content.error-card {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: var(--text);
}

.message.error-message .message-avatar {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.32);
  color: #f87171;
}

.message.error-message .message-name {
  color: #f87171;
}

body.light-theme .message-content.error-card {
  background: rgba(220, 38, 38, 0.06);
  border-color: rgba(220, 38, 38, 0.22);
}

body.light-theme .message.error-message .message-name,
body.light-theme .message.error-message .message-avatar {
  color: #dc2626;
}

.retry-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 14px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface-hover);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.retry-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #ff8484;
}

/* ATTACHMENTS */

.composer-tools {
  display: flex;
  align-items: center;
  gap: 7px;
}

.attach-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.attach-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-strong);
}

.attach-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.attachment-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 10px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 8px 6px 10px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.attachment-thumb {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  object-fit: cover;
  display: block;
}

.attachment-badge {
  padding: 4px 6px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: #ff8484;
  font-size: 10.5px;
  font-weight: 700;
}

.attachment-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.attachment-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  unicode-bidi: plaintext;
}

.attachment-size {
  font-size: 11px;
  color: var(--muted);
  direction: ltr;
}

.remove-attachment-btn {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.remove-attachment-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.msg-attachment {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.msg-attachment-img {
  max-width: 260px;
  max-height: 220px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.msg-attachment-name {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  unicode-bidi: plaintext;
}

/* COMPOSER & MODERN SCENE IMAGE GENERATOR */

.composer-area {
  width: min(740px, calc(100% - 40px));
  margin: 0 auto;
  padding: 8px 0 18px;
}

.image-gen-panel {
  position: relative;
  overflow: hidden;
  margin-bottom: 10px;
  padding: 15px;
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, rgba(31, 31, 38, 0.96), rgba(20, 20, 25, 0.98));
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: sceneEnter 0.28s var(--ease-out) both;
}

.image-gen-panel[hidden] {
  display: none;
}

.gen-scene-backdrop {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.gen-orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(28px);
  opacity: 0.3;
  animation: orbFloat 7s ease-in-out infinite alternate;
}

.gen-orb-1 {
  width: 150px;
  height: 150px;
  top: -45px;
  inset-inline-end: -30px;
  background: radial-gradient(circle, var(--accent), transparent 70%);
}

.gen-orb-2 {
  width: 120px;
  height: 120px;
  bottom: -45px;
  inset-inline-start: -25px;
  background: radial-gradient(circle, rgba(225, 75, 75, 0.45), transparent 70%);
  animation-delay: -3s;
}

.gen-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: radial-gradient(circle at center, black 35%, transparent 88%);
}

.image-gen-head,
.image-gen-controls,
.image-gen-stage {
  position: relative;
  z-index: 1;
}

.image-gen-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.gen-title-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.gen-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(225, 75, 75, 0.6);
  animation: pulseRing 2s infinite;
}

.gen-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.image-aspect-select {
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--text);
  font-size: 11.5px;
  outline: none;
  cursor: pointer;
}

.image-gen-close-btn {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.image-gen-close-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.image-gen-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.image-gen-input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(18, 18, 23, 0.85);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.image-gen-input:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.image-gen-run-btn {
  padding: 9px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s ease, background 0.15s ease;
}

.image-gen-run-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.image-gen-run-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.image-gen-stage {
  margin-top: 10px;
  min-height: 82px;
  border-radius: 13px;
  border: 1px dashed var(--border);
  background: rgba(15, 15, 19, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.gen-stage-placeholder {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.gen-stage-placeholder[hidden] {
  display: none;
}

.gen-shimmer-ring {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: spinRing 1.1s linear infinite;
}

.image-gen-preview {
  width: 100%;
  animation: fadeUp 0.25s ease both;
}

.image-gen-preview[hidden] {
  display: none;
}

/* Composer box */
.composer {
  border: 1px solid var(--border);
  background: var(--input);
  border-radius: var(--radius-lg);
  padding: 13px 15px 11px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.composer:focus-within {
  border-color: var(--border-strong);
  box-shadow: var(--shadow), 0 0 0 3px rgba(255, 255, 255, 0.04);
}

.composer textarea {
  display: block;
  width: 100%;
  min-height: 30px;
  max-height: 180px;
  resize: none;
  outline: none;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
  padding: 2px 0;
  unicode-bidi: plaintext;
}

.composer textarea::placeholder {
  color: var(--muted);
}

.composer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.composer-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
}

.hint-dot {
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 50%;
}

.send-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  color: #ffffff;
  background: var(--accent);
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
}

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

.send-btn:not(:disabled):hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.disclaimer {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  margin: 10px 0 0;
  opacity: 0.85;
}

.legal-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.legal-links a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.16s ease;
}

.legal-links a:hover {
  color: var(--text);
  text-decoration: underline;
}

.legal-links .legal-sep {
  opacity: 0.6;
}

.legal-links.auth-legal {
  margin: 14px 0 0;
  flex-wrap: wrap;
  text-align: center;
  line-height: 1.6;
}

/* ACCOUNT MODAL */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: min(430px, 100%);
  background: var(--sidebar);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 20px 22px 22px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.2s ease both;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--surface);
  padding: 4px;
  border-radius: 11px;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.auth-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.auth-tab.active {
  background: var(--accent);
  color: #ffffff;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.field-group input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--text);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s ease;
  unicode-bidi: plaintext;
}

.field-group input:focus {
  border-color: var(--border-strong);
}

.primary-btn {
  padding: 10px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

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

.primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.danger-btn {
  padding: 10px 14px;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.danger-btn:hover {
  background: rgba(239, 68, 68, 0.2);
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.modal-actions .primary-btn {
  flex: 1;
}

.profile-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.muted-text {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.auth-error {
  margin: 0;
  font-size: 12px;
  color: #f87171;
}

.auth-success {
  margin: 0;
  font-size: 12px;
  color: #4ade80;
}

/* LIGHT THEME */

body.light-theme {
  --bg: #f8f7f4;
  --sidebar: #f1efe9;
  --surface: #ffffff;
  --surface-hover: #eae7e0;
  --border: rgba(24, 24, 27, 0.08);
  --border-strong: rgba(24, 24, 27, 0.15);
  --text: #18181b;
  --muted: #67666e;
  --accent: #d9383a;
  --accent-hover: #c52e30;
  --accent-soft: rgba(217, 56, 58, 0.1);
  --input: #ffffff;
  --shadow: 0 10px 28px rgba(24, 24, 27, 0.06);
  --glass: rgba(248, 247, 244, 0.82);
  background:
    radial-gradient(circle at 65% 12%, rgba(217, 56, 58, 0.045), transparent 45%),
    var(--bg);
}

body.light-theme .avatar {
  color: var(--accent);
}

body.light-theme .eyebrow,
body.light-theme .plan-price,
body.light-theme .archive-badge,
body.light-theme .current-plan-pill,
body.light-theme .popover-account-link,
body.light-theme .archive-open-btn,
body.light-theme .file-export-btn,
body.light-theme .language-btn svg,
body.light-theme .highlight-text {
  color: var(--accent);
  background-image: none;
}

body.light-theme .image-gen-panel {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(241, 239, 233, 0.98));
}

body.light-theme .image-gen-input {
  background: #ffffff;
}

body.light-theme .image-gen-stage {
  background: rgba(248, 247, 244, 0.85);
}

body.light-theme .composer:focus-within {
  border-color: var(--border-strong);
  box-shadow: var(--shadow), 0 0 0 3px rgba(24, 24, 27, 0.04);
}

body.light-theme .send-btn {
  color: #ffffff;
  background: var(--accent);
}

body.light-theme .retry-btn {
  background: #eae7e0;
  color: #18181b;
  border-color: rgba(24, 24, 27, 0.16);
}

/* MOBILE & RESPONSIVE */

.mobile-overlay {
  display: none;
}

@media (max-width: 540px) {
  .settings-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .preferences-grid {
    grid-template-columns: 1fr;
  }

  .plans-grid {
    grid-template-columns: 1fr;
  }

  .image-gen-controls {
    flex-wrap: wrap;
  }
}

@media (max-width: 760px) {
  .sidebar,
  .sidebar.collapsed,
  .app.sidebar-collapsed .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: min(290px, 85vw);
    min-width: 0;
    padding: calc(16px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom));
    transform: translateX(-105%);
    box-shadow: var(--shadow);
  }

  [dir="rtl"] .sidebar,
  [dir="rtl"] .sidebar.collapsed,
  [dir="rtl"] .app.sidebar-collapsed .sidebar {
    transform: translateX(105%);
  }

  .sidebar.open,
  .sidebar.collapsed.open,
  .app.sidebar-collapsed .sidebar.open {
    transform: translateX(0);
  }

  .sidebar.collapsed .brand span,
  .sidebar.collapsed .new-chat-btn .btn-label,
  .sidebar.collapsed .new-chat-btn span:not(.kbd-hint),
  .sidebar.collapsed .kbd-hint,
  .sidebar.collapsed .sidebar-section-title,
  .sidebar.collapsed .history-list,
  .sidebar.collapsed .empty-history,
  .sidebar.collapsed .user-meta,
  .sidebar.collapsed .chevron-icon {
    display: initial;
  }

  .sidebar.collapsed .history-list {
    display: flex;
  }

  .sidebar.collapsed .user-meta {
    display: flex;
  }

  .close-sidebar,
  .menu-btn,
  .mobile-brand {
    display: grid;
  }

  .mobile-brand {
    font-size: 16px;
    font-weight: 700;
  }

  .topbar {
    padding: env(safe-area-inset-top) 12px 0;
    height: calc(56px + env(safe-area-inset-top));
    min-height: calc(56px + env(safe-area-inset-top));
    gap: 8px;
  }

  .topbar-left,
  .topbar-right {
    gap: 6px;
  }

  .welcome-screen {
    width: calc(100% - 24px);
    padding: 20px 0 18px;
  }

  .suggestions {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 18px;
  }

  .suggestion-card {
    padding: 13px 14px;
  }

  .composer-area,
  .messages {
    width: calc(100% - 24px);
  }

  .composer-area {
    padding: 6px 0 calc(12px + env(safe-area-inset-bottom));
  }

  .composer {
    border-radius: 16px;
    padding: 11px 13px 10px;
  }

  .composer textarea,
  .popover-input,
  .popover-select,
  .field-group input,
  .image-gen-input,
  .customization-textarea {
    font-size: 16px;
  }

  .send-btn {
    width: 38px;
    height: 38px;
    border-radius: 11px;
  }

  .attach-btn {
    width: 36px;
    height: 36px;
  }

  .message {
    gap: 8px;
  }

  .message-content {
    max-width: 88%;
    padding: 11px 13px;
    font-size: 14px;
  }

  .msg-action-btn {
    padding: 6px 9px;
    font-size: 11px;
  }

  .settings-modal-card {
    max-height: 90dvh;
    padding: 16px;
    border-radius: 16px;
  }

  .mobile-overlay.show {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 15;
    background: rgba(0, 0, 0, 0.52);
    backdrop-filter: blur(2px);
  }
}

/* CUSTOMIZATION & MEMORIES */

.customization-intro-gate[hidden],
.customization-editor-view[hidden],
#arabicDialectGroup[hidden] {
  display: none;
}

.customization-intro-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.customization-intro-card strong {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}

.customization-intro-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
}

.customization-setup-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.customization-intro-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.customization-region-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 10px;
}

.customization-region-badge {
  font-size: 11.5px;
  font-weight: 600;
  color: #ff8484;
}

.customization-textarea {
  width: 100%;
  min-height: 84px;
  max-height: 180px;
  resize: vertical;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.6;
  outline: none;
  unicode-bidi: plaintext;
}

.customization-textarea:focus {
  border-color: var(--border-strong);
}

.customization-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.customization-clear-btn {
  padding: 6px 12px;
  font-size: 11.5px;
  border-radius: var(--radius-sm);
}

.memories-section {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.memories-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.memories-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.memories-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
}

.memory-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.memory-item-text {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--text);
  line-height: 1.45;
  overflow-wrap: anywhere;
  unicode-bidi: plaintext;
}

/* REDUCED MOTION */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}


/* FIRST-VISIT WELCOME SCREEN */

.fv-overlay {
  z-index: 90;
  background: rgba(10, 10, 14, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.fv-backdrop-glow {
  position: fixed;
  width: 360px;
  height: 360px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(225, 75, 75, 0.22), transparent 70%);
  filter: blur(48px);
  pointer-events: none;
}

.fv-card {
  position: relative;
  width: min(580px, 100%);
  max-height: 92dvh;
  overflow-y: auto;
  padding: 28px 26px 24px;
  border-radius: 22px;
  background: linear-gradient(160deg, var(--sidebar), var(--surface));
  border: 1px solid var(--border-strong);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  animation: modalPopIn 0.28s var(--ease-out) both;
}

.fv-close-btn {
  position: absolute;
  top: 16px;
  inset-inline-end: 16px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-hover);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.fv-close-btn:hover {
  background: var(--accent-soft);
  border-color: rgba(225, 75, 75, 0.35);
  color: var(--text);
  transform: scale(1.04);
}

.fv-close-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.fv-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid rgba(225, 75, 75, 0.25);
  color: #ff8484;
  font-size: 11.5px;
  font-weight: 700;
}

body.light-theme .fv-badge {
  color: var(--accent);
}

.fv-header h2 {
  margin: 12px 0 8px;
  font-size: clamp(20px, 3.2vw, 26px);
  line-height: 1.32;
  font-weight: 700;
  color: var(--text);
  padding-inline-end: 34px;
}

.fv-header p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--muted);
}

.fv-features {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.fv-feature-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 13px;
  border-radius: 14px;
  background: var(--input);
  border: 1px solid var(--border);
}

.fv-feature-item strong {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
}

.fv-feature-item span {
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
}

.fv-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.fv-primary-btn {
  padding: 10px 18px;
  border: 0;
  border-radius: 11px;
  background: var(--accent);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.16s ease;
}

.fv-primary-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.fv-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.fv-secondary-btn {
  padding: 10px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.fv-secondary-btn:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.fv-note {
  font-size: 11.5px;
  color: var(--muted);
}

@media (max-width: 640px) {
  .fv-card {
    padding: 22px 18px 18px;
    border-radius: 18px;
  }

  .fv-features {
    grid-template-columns: 1fr;
  }

  .fv-footer {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
}


/* ==========================================================================
   FLOT MINIMAL CALM LIVE VOICE CALL (MOBILE & DESKTOP)
   ========================================================================== */

.vc-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.voice-call-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.16s var(--ease-out), border-color 0.18s ease, background 0.18s ease;
}

.voice-call-trigger-btn:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  background: var(--surface-hover);
}

.vc-trigger-bars {
  display: inline-flex;
  align-items: center;
  gap: 2.5px;
  height: 12px;
}

.vc-trigger-bars i {
  display: block;
  width: 2px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
  animation: vcMiniWave 1.2s ease-in-out infinite;
}

.vc-trigger-bars i:nth-child(2) {
  animation-delay: 0.18s;
  height: 10px;
}

.vc-trigger-bars i:nth-child(3) {
  animation-delay: 0.36s;
  height: 7px;
}

.vc-trigger-bars i:nth-child(4) {
  animation-delay: 0.54s;
  height: 11px;
}

@keyframes vcMiniWave {
  0%, 100% {
    transform: scaleY(0.6);
    opacity: 0.7;
  }
  50% {
    transform: scaleY(1.15);
    opacity: 1;
  }
}

.vc-studio-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  animation: vcStudioFadeIn 0.2s var(--ease-out) both;
}

.vc-studio-overlay[hidden] {
  display: none;
}

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

.vc-ambient-aurora {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.vc-aurora-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(95px);
  opacity: 0.15;
}

.vc-blob-1 {
  width: 320px;
  height: 320px;
  top: 14%;
  left: 50%;
  transform: translateX(-50%);
  background: radial-gradient(circle, var(--accent), transparent 70%);
}

.vc-blob-2,
.vc-blob-3,
.vc-grid-mesh {
  display: none;
}

.vc-studio-shell {
  position: relative;
  z-index: 2;
  width: min(540px, 100%);
  height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}

.vc-hud-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.vc-hud-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.vc-live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}

.vc-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
}

.vc-timer {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  direction: ltr;
}

.vc-hud-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.vc-lang-pill {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 11.5px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.vc-hud-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}

.vc-hud-icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.vc-hud-icon-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.vc-core-stage {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 8px 0;
}

.vc-orb-arena {
  position: relative;
  width: 180px;
  height: 180px;
  display: grid;
  place-items: center;
  --vc-energy: 0;
}

.vc-hud-rings,
.vc-ripple {
  display: none;
}

.vc-plasma-core {
  position: relative;
  width: 122px;
  height: 122px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  transform: scale(calc(1 + var(--vc-energy, 0) * 0.12));
  transition: transform 0.09s linear;
}

.vc-core-glow {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(225, 75, 75, 0.35), transparent 70%);
  filter: blur(16px);
  opacity: calc(0.45 + var(--vc-energy, 0) * 0.45);
}

.vc-core-sphere {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  overflow: hidden;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.vc-core-logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  object-fit: cover;
}

.vc-studio-shell[data-vc-state="listening"] .vc-core-sphere {
  border-color: rgba(16, 185, 129, 0.65);
}

.vc-studio-shell[data-vc-state="thinking"] .vc-core-sphere {
  border-color: rgba(245, 158, 11, 0.65);
}

.vc-studio-shell[data-vc-state="speaking"] .vc-core-sphere {
  border-color: var(--accent);
}

.vc-studio-shell[data-vc-state="muted"] .vc-core-sphere {
  opacity: 0.65;
}

.vc-spectrum {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 28px;
}

.vc-spectrum span {
  display: block;
  width: 3px;
  height: 6px;
  border-radius: 999px;
  background: var(--muted);
  transition: height 0.08s ease, background 0.2s ease;
}

.vc-studio-shell[data-vc-state="listening"] .vc-spectrum span {
  background: #10b981;
}

.vc-studio-shell[data-vc-state="speaking"] .vc-spectrum span {
  background: var(--accent);
}

.vc-studio-shell[data-vc-state="thinking"] .vc-spectrum span {
  background: #f59e0b;
  animation: vcThinkingWave 0.85s ease-in-out infinite;
}

.vc-studio-shell[data-vc-state="thinking"] .vc-spectrum span:nth-child(even) {
  animation-delay: 0.18s;
}

@keyframes vcThinkingWave {
  0%, 100% {
    height: 6px;
    opacity: 0.45;
  }
  50% {
    height: 20px;
    opacity: 1;
  }
}

.vc-status-stack {
  width: min(480px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.vc-state-chip {
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.vc-caption-glass {
  width: 100%;
  min-height: 70px;
  max-height: 140px;
  overflow-y: auto;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vc-user-caption {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  unicode-bidi: plaintext;
}

.vc-user-caption[hidden] {
  display: none;
}

.vc-ai-caption {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.6;
  unicode-bidi: plaintext;
}

.vc-dock-bar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
}

.vc-dock-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.vc-dock-btn:hover {
  background: var(--surface-hover);
}

.vc-dock-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.vc-dock-btn[aria-pressed="true"] {
  border-color: rgba(245, 158, 11, 0.55);
  color: #f59e0b;
}

.vc-ptt-btn {
  background: var(--surface);
  border-color: var(--border-strong);
}

.vc-end-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.vc-end-btn:hover {
  background: var(--accent-hover);
}

@media (max-width: 540px) {
  .vc-studio-shell {
    padding: max(12px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom));
  }

  .vc-hud-top {
    gap: 6px;
  }

  .vc-lang-pill {
    padding: 5px 8px;
    font-size: 11px;
  }

  .vc-orb-arena {
    width: 156px;
    height: 156px;
  }

  .vc-plasma-core {
    width: 108px;
    height: 108px;
  }

  .vc-core-logo {
    width: 40px;
    height: 40px;
  }

  .vc-caption-glass {
    padding: 10px 12px;
    font-size: 13px;
  }

  .vc-dock-bar {
    width: 100%;
    max-width: 390px;
    gap: 6px;
    padding: 6px 8px;
  }

  .vc-dock-btn {
    flex: 1;
    justify-content: center;
    height: 38px;
    padding: 0 8px;
    font-size: 11.5px;
  }

  .vc-trigger-label {
    display: none;
  }
}


/* ==========================================================================
   TOP-RIGHT SUBSCRIPTIONS DROPDOWN MENU
   ========================================================================== */

.sub-menu-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.sub-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6.5px 11px;
  border-radius: 9px;
  border: 1px solid rgba(225, 75, 75, 0.34);
  background: var(--accent-soft);
  color: #ff8484;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.sub-menu-trigger:hover,
.sub-menu-trigger[aria-expanded="true"] {
  background: rgba(225, 75, 75, 0.22);
  border-color: rgba(225, 75, 75, 0.55);
}

body.light-theme .sub-menu-trigger {
  color: var(--accent);
}

.sub-menu-trigger svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sub-chevron {
  width: 13px;
  height: 13px;
  transition: transform 0.2s var(--ease-out);
}

.sub-menu-trigger[aria-expanded="true"] .sub-chevron {
  transform: rotate(180deg);
}

.sub-trigger-badge {
  padding: 1.5px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.24);
  font-size: 10.5px;
  font-weight: 700;
  direction: ltr;
}

body.light-theme .sub-trigger-badge {
  background: rgba(217, 56, 58, 0.14);
}

.sub-dropdown-panel {
  position: absolute;
  top: calc(100% + 10px);
  inset-inline-end: 0;
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 80px);
  overflow-y: auto;
  padding: 16px;
  border-radius: 18px;
  background: #141418;
  background-color: color-mix(in srgb, var(--sidebar, #141418) 94%, #0b0b0e);
  border: 1px solid var(--border-strong);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.72), 0 0 0 9999px rgba(0, 0, 0, 0.42);
  z-index: 90;
  animation: modalPopIn 0.22s var(--ease-out) both;
}

body.light-theme .sub-dropdown-panel {
  background: #ffffff;
  background-color: color-mix(in srgb, var(--sidebar, #ffffff) 96%, #f8fafc);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24), 0 0 0 9999px rgba(15, 23, 42, 0.22);
}

.sub-dropdown-panel[hidden] {
  display: none;
}

.sub-dropdown-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.sub-dropdown-head strong {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}

.sub-dropdown-head span:not(.current-plan-pill) {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
}

.sub-dropdown-plans .plan-card {
  justify-content: space-between;
  cursor: default;
}

.plan-card-featured {
  border-color: rgba(225, 75, 75, 0.35);
}

.plan-price small {
  font-size: 9.5px;
  font-weight: 500;
  opacity: 0.8;
}

.plan-card-actions {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
}

.plan-checkout-btn {
  flex: 1;
  padding: 6px 8px;
  font-size: 11px;
  text-align: center;
}

.plan-code-btn {
  padding: 6px 8px;
  font-size: 10.5px;
  white-space: nowrap;
}

.plan-select-btn {
  width: 100%;
  margin-top: 6px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.plan-select-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

#checkoutStatusError {
  margin-top: 10px;
}

@media (max-width: 600px) {
  .sub-menu-trigger span[data-i18n="subscriptionTitle"] {
    display: none;
  }

  .sub-dropdown-panel {
    position: fixed;
    top: calc(60px + env(safe-area-inset-top));
    inset-inline: 12px;
    width: auto;
  }

  .sub-dropdown-plans {
    grid-template-columns: 1fr;
  }
}

/* FLOT copy and compact-header polish. Existing app behavior is unchanged. */
.welcome-heading .welcome-access-note {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.6;
}
.fv-features { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.model-name { white-space: nowrap; }
@media (max-width: 760px) {
  .model-release, #topbarPlanTag, #subTriggerBadge { display: none; }
  /* The mobile brand already displays FLOT. Avoid repeating it. */
  .topbar-left .model-selector { display: none; }
  .topbar-left, .topbar-right { min-width: 0; }
  .topbar-right { flex-shrink: 1; }
  .welcome-heading h1 { line-height: 1.3; }
  .fv-features { grid-template-columns: 1fr; }
}
@media (max-width: 380px) {
  .sub-menu-trigger { padding-inline: 8px; gap: 4px; }
  .language-btn { padding-inline: 8px; }
  .sub-menu-trigger .sub-chevron { display: none; }
}

/* Let long welcome content scroll above the fixed composer on short screens. */
.welcome-screen { flex-shrink: 0; }
[dir="rtl"] .welcome-heading h1 { line-height: 1.5; }


/* ===== Review fixes: hidden-state safety, auth UX, language menu, delete account, stop ===== */
.field-group[hidden],
.auth-form[hidden],
.auth-error[hidden],
.auth-success[hidden],
.link-btn[hidden],
.stop-btn[hidden],
.lang-menu[hidden],
.pw-wrap[hidden] {
  display: none !important;
}

.pw-wrap { position: relative; display: flex; align-items: center; }
.pw-wrap input { padding-inline-end: 42px; }
.pw-toggle {
  position: absolute;
  inset-inline-end: 6px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.pw-toggle:hover, .pw-toggle.is-shown { color: var(--text); background: var(--surface-hover); }
.pw-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pw-toggle.is-shown svg { stroke: #ff8484; }

.link-btn {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}
.link-btn:hover { color: var(--text); }

.auth-success a, .delete-account a { color: inherit; text-decoration: underline; }

.auth-form.is-busy input { pointer-events: none; opacity: 0.7; }
.primary-btn.is-loading { position: relative; cursor: progress; opacity: 0.9; }
.primary-btn.is-loading::before {
  content: "";
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-inline-end: 8px;
  vertical-align: -2px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: flot-spin 0.8s linear infinite;
}
@keyframes flot-spin { to { transform: rotate(360deg); } }

.lang-menu-wrap { position: relative; }
.lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-end: 0;
  z-index: 60;
  min-width: 150px;
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #1f1f25;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
}
body.light-theme .lang-menu { background: #ffffff; }
.lang-menu button {
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: start;
  cursor: pointer;
}
.lang-menu button:hover { background: var(--surface-hover); }
.lang-menu button[aria-checked="true"] { color: #ff8484; font-weight: 600; }

.delete-account {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.delete-account h4 { margin: 0; font-size: 14px; }
.delete-account p { margin: 0; font-size: 12.5px; line-height: 1.5; }
.delete-account > .danger-btn { align-self: flex-start; }
.ghost-btn {
  padding: 9px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.ghost-btn:hover { background: var(--surface-hover); }

.stop-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.stop-btn:hover { background: var(--surface-hover); }
.stop-btn svg { width: 16px; height: 16px; fill: currentColor; }

/* Streaming text: plain, direction follows the content, no raw mixed-direction jumps. */
.message.streaming .message-body {
  white-space: pre-wrap;
  unicode-bidi: plaintext;
  text-align: start;
  overflow-wrap: anywhere;
}

/* Guest/account subtitle: allow up to two lines instead of clipping long translations */
.user-info #userSubtitle {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.3;
}
