* { box-sizing: border-box; margin: 0; padding: 0; }
*:focus-visible { outline: 1.5px solid #C9A84C88; outline-offset: 2px; }
button, a, input { outline: none; }

body {
  font-family: 'Inter', sans-serif;
  background: #080E1A;
  color: #E8E8E8;
  height: 100vh;
  overflow: hidden;
}

.shell { display: flex; height: 100vh; }

/* Logo shine */
.side-logo { position: relative; overflow: hidden; }
.side-logo::after {
  content: '';
  position: absolute;
  top: 0;
  left: -60%;
  width: 40%;
  height: 100%;
  background: linear-gradient(120deg, transparent, rgba(201,168,76,0.35), transparent);
  transform: skewX(-20deg);
  animation: shine 1.8s ease-in-out 0.3s 1;
}
@keyframes shine {
  0% { left: -60%; }
  100% { left: 140%; }
}

/* SIDEBAR */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: #0B1628;
  border-right: 0.5px solid #1A2E4A;
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

.side-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  padding: 0.5rem 0.25rem 1.25rem;
}

.side-logo span {
  font-size: 13px;
  font-weight: 600;
  color: #C9A84C;
  letter-spacing: 2px;
}

.new-chat-btn {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #C9A84C;
  background: transparent;
  color: #C9A84C;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 1.5rem;
}

.new-chat-btn:hover { background: #C9A84C18; }

.history-label {
  font-size: 11px;
  color: #4A6A9A;
  letter-spacing: 1.5px;
  padding: 0 0.25rem 0.5rem;
}

.history-list { flex: 1; overflow-y: auto; }

.history-empty {
  font-size: 12px;
  color: #4A6A9A;
  padding: 0.5rem 0.25rem;
  line-height: 1.6;
}

.history-item {
  font-size: 13px;
  color: #C8D0DC;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s;
  position: relative;
}

.history-item:hover { background: #1A2E4A55; }
.history-item.active { background: #1A2E4A; color: #C9A84C; }
.history-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.history-menu-btn {
  display: none;
  background: transparent;
  border: none;
  color: #8A9BB0;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  flex-shrink: 0;
  line-height: 1;
}

.history-item:hover .history-menu-btn { display: block; }
.history-menu-btn:hover { color: #C9A84C; background: #1A2E4A; }

.history-menu {
  display: none;
  position: absolute;
  left: 0;
  top: 100%;
  width: 100%;
  background: #0F1E35;
  border: 0.5px solid #C9A84C33;
  border-radius: 8px;
  z-index: 50;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.history-menu.open { display: block; }

.history-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: #D0D8E8;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}

.history-menu button:hover { background: #1A2E4A; }
.history-menu button.danger { color: #e05555; }
.history-menu button.danger:hover { background: #2A1A1A; }

.tools-section {
  border-top: 0.5px solid #1A2E4A;
  padding-top: 0.75rem;
  margin-top: 0.5rem;
}

.tool-btn,
.side-link {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 6px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: #C9A84C;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  opacity: 0.85;
  margin-bottom: 2px;
}

.tool-btn:hover,
.side-link:hover {
  background: #1A2E4A55;
  opacity: 1;
}

.side-footer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 0.5px solid #1A2E4A;
  padding-top: 0.75rem;
}

.soon {
  font-size: 9px;
  color: #4A6A9A;
  background: #1A2E4A;
  padding: 2px 6px;
  border-radius: 99px;
  margin-left: auto;
  letter-spacing: 0.5px;
}

/* MAIN CHAT */
.chat-main { flex: 1; display: flex; flex-direction: column; height: 100vh; position: relative; }

.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 0.5px solid #1A2E4A;
}

.topbar-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #C9A84C;
  letter-spacing: 1.5px;
}

.dot { width: 7px; height: 7px; border-radius: 50%; background: #4A9A6A; }
.topbar-home { font-size: 12px; color: #C9A84C; text-decoration: none; transition: opacity 0.15s; opacity: 0.85; }
.topbar-home:hover { opacity: 1; }

/* EMPTY STATE */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  transition: opacity 0.25s ease;
}

.empty-state svg { opacity: 0.9; margin-bottom: 18px; }
.empty-state h1 { font-size: 28px; font-weight: 600; color: #F0F0F0; margin-bottom: 8px; }
.empty-state p { font-size: 14px; color: #8A9BB0; max-width: 380px; line-height: 1.6; margin-bottom: 28px; }

.input-row { width: 100%; max-width: 600px; display: flex; gap: 8px; }
.input-row.centered { margin-bottom: 18px; }
.input-row.bottom { margin: 0 auto; padding: 14px 24px 22px; }

.input-row input {
  flex: 1;
  border: 0.5px solid #1A2E4A;
  border-radius: 8px;
  padding: 12px 15px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  background: #0B1628;
  color: #E8E8E8;
  outline: none;
}

.input-row input:focus { border-color: #C9A84C44; }

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: none;
  background: #C9A84C;
  color: #0B1628;
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 600px; }
.chip {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 99px;
  border: 0.5px solid #C9A84C44;
  background: transparent;
  color: #C9A84C;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.chip:hover { background: #C9A84C1c; }

/* CONVERSATION */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.msg {
  display: flex;
  width: 100%;
  gap: 8px;
  align-items: flex-end;
}

.msg.user {
  justify-content: flex-end;
}

.msg.bot {
  justify-content: flex-start;
}

.bubble {
  width: fit-content;
  max-width: 75%;
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.msg.bot .bubble {
  background: #1A2E4A;
  color: #D0D8E8;
  position: relative;
}

.msg.user .bubble {
  background: var(--accent, #C9A84C);
  color: #0B1628;
  font-weight: 500;
}

.pin-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.15s;
  margin: 0;
  padding: 0;
  color: var(--accent, #C9A84C);
}

.msg.bot .bubble:hover .pin-btn {
  opacity: 0.7;
}

.pin-btn:hover {
  opacity: 1 !important;
}

#typing .bubble {
  width: auto;
  min-width: 56px;
  max-width: 56px;
  padding: 10px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.typing {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: auto;
  min-width: 44px;
}

.typing span {
  display: block;
  width: 6px;
  height: 6px;
  min-width: 6px;
  border-radius: 50%;
  background: #8A9BB0;
  margin: 0;
  animation: bounce 1.2s infinite;
}

.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-5px)} }

.hidden { display: none !important; }

/* MODALS */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4,8,16,0.65);
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.open { display: flex; }

.modal {
  width: 100%;
  max-width: 440px;
  max-height: 80vh;
  overflow-y: auto;
  background: #0B1628;
  border: 0.5px solid #C9A84C33;
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-dashboard {
  width: min(1040px, calc(100vw - 36px));
  max-width: 1040px;
  max-height: min(860px, calc(100vh - 36px));
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-dashboard .modal-body {
  overflow-y: auto;
  padding: 18px;
}

.modal-wide { max-width: 720px; }
.modal-sm { max-width: 360px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 0.5px solid #1A2E4A;
  gap: 12px;
}

.modal-header h2 { font-size: 16px; font-weight: 600; color: #C9A84C; }
.modal-title-actions { display:flex; gap:8px; align-items:center; }

.modal-close {
  background: transparent;
  border: none;
  color: #8A9BB0;
  font-size: 16px;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  transition: background 0.15s;
}

.modal-close:hover { background: #1A2E4A; color: #E8E8E8; }
.modal-body { padding: 8px 20px 18px; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 0.5px solid #1A2E4A;
}
.setting-row:last-child { border-bottom: none; }
.setting-row.borderless { border:none; padding-top:0; }

.setting-label { font-size: 13.5px; color: #E8E8E8; font-weight: 500; }
.setting-sub { font-size: 12px; color: #6A7C94; margin-top: 2px; }
.setting-pill { font-size: 11px; color: #6A7C94; background: #1A2E4A; padding: 4px 10px; border-radius: 99px; white-space: nowrap; }

.setting-action,
.modal-save-btn,
.modal-cancel-btn,
.modal-danger-btn {
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.setting-action {
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid #C9A84C44;
  background: transparent;
  color: #C9A84C;
  white-space: nowrap;
}

.setting-action:hover { background: #C9A84C18; }

.modal-confirm-text { font-size: 14px; color: #D0D8E8; line-height: 1.6; margin-bottom: 20px; }
.modal-confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

.modal-cancel-btn {
  padding: 9px 18px;
  border-radius: 8px;
  border: 1px solid #1A2E4A;
  background: transparent;
  color: #8A9BB0;
  font-size: 13px;
}

.modal-cancel-btn:hover { background: #1A2E4A; color: #E8E8E8; }

.modal-danger-btn {
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  background: #8B2020;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.modal-danger-btn:hover { background: #a02525; }

.modal-save-btn {
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  background: #C9A84C;
  color: #0B1628;
  font-size: 13px;
  font-weight: 600;
}

.modal-save-btn:hover { opacity: 0.88; }

.mini-danger-btn {
  border: 1px solid rgba(255, 92, 92, 0.35);
  background: rgba(255, 92, 92, 0.08);
  color: #ffb3b3;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.18s ease;
}

.mini-danger-btn:hover {
  background: rgba(255, 92, 92, 0.16);
  border-color: rgba(255, 92, 92, 0.55);
  color: #ffd0d0;
  transform: translateY(-1px);
}

.confirm-modal {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.confirm-modal h3 {
  margin: 0 0 8px;
  font-size: 18px;
  color: var(--text);
}

.confirm-modal p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.modal-secondary-btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.18s ease;
}

.modal-secondary-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}

.modal-text-input {
  width: 100%;
  border: 0.5px solid #C9A84C44;
  border-radius: 8px;
  padding: 10px 13px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  background: #080E1A;
  color: #E8E8E8;
  outline: none;
  margin-bottom: 16px;
}

.modal-text-input:focus { border-color: #C9A84C; }

/* CHECKLISTS */
.checklist-list-item,
.collection-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 0.5px solid #1A2E4A;
  cursor: pointer;
}

.checklist-list-item:last-child,
.collection-list-item:last-child { border-bottom: none; }

.checklist-list-name,
.collection-list-name { font-size: 13.5px; color: #E8E8E8; font-weight: 600; }

.checklist-list-meta,
.collection-list-meta { font-size: 11px; color: #6A7C94; margin-top: 3px; }

.checklist-list-arrow { color: #C9A84C; font-size: 14px; opacity: 0.7; }

.checklist-empty {
  font-size: 13px;
  color: #4A6A9A;
  padding: 1rem 0;
  text-align: center;
  line-height: 1.6;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 0.5px solid #1A2E4A;
  cursor: pointer;
}

.checklist-item:last-child { border-bottom: none; }
.checklist-item input[type="checkbox"] { width: 16px; height: 16px; accent-color: #C9A84C; cursor: pointer; flex-shrink: 0; }
.checklist-item-name { font-size: 13.5px; color: #E8E8E8; }
.checklist-item-name.done { text-decoration: line-through; color: #4A6A9A; }

/* PORTFOLIOS */

.portfolio-list-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 12px;
}

.portfolio-open-btn {
  width: 100%;
  min-height: 86px;
  border: 1px solid rgba(214, 175, 92, 0.22);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.018));
  color: var(--text);
  border-radius: 18px;
  padding: 14px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 12px;
  align-items: center;
  text-align: left;
  transition: 0.18s ease;
}

.portfolio-open-btn:hover {
  border-color: rgba(214, 175, 92, 0.45);
  background:
    linear-gradient(180deg, rgba(214, 175, 92, 0.09), rgba(255, 255, 255, 0.025));
  transform: translateY(-1px);
}

.portfolio-list-icon {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(214, 175, 92, 0.32);
  background: rgba(214, 175, 92, 0.08);
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 20px;
  font-weight: 800;
}

.portfolio-list-content h3 {
  margin: 0 0 5px;
  font-size: 15px;
  color: var(--text);
}

.portfolio-list-content p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.portfolio-list-content span {
  display: inline-flex;
  width: fit-content;
  border: 1px solid rgba(214, 175, 92, 0.18);
  background: rgba(214, 175, 92, 0.07);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
}

.portfolio-list-arrow {
  color: var(--muted);
  font-size: 28px;
  line-height: 1;
}

.portfolio-delete-btn {
  min-width: 78px;
  align-self: center;
  justify-content: center;
}

@media (max-width: 760px) {
  .portfolio-list-card {
    grid-template-columns: 1fr;
  }

  .portfolio-open-btn {
    grid-template-columns: 38px 1fr auto;
    min-height: 78px;
  }

  .portfolio-delete-btn {
    width: 100%;
  }
}

.portfolio-create-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.portfolio-create-row .modal-text-input {
  width: 100%;
  height: 42px;
}

.portfolio-create-row .modal-save-btn {
  width: 100%;
  height: 42px;
}

.portfolio-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.portfolio-summary-card {
  border: 1px solid rgba(214, 175, 92, 0.18);
  background:
    linear-gradient(180deg, rgba(214, 175, 92, 0.08), rgba(255, 255, 255, 0.025));
  border-radius: 16px;
  padding: 14px;
}

.portfolio-summary-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}

.portfolio-summary-value {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

.portfolio-chart-placeholder {
  min-height: 130px;
  border: 1px dashed rgba(214, 175, 92, 0.28);
  background:
    radial-gradient(circle at top, rgba(214, 175, 92, 0.09), transparent 42%),
    rgba(255, 255, 255, 0.025);
  border-radius: 18px;
  padding: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 18px;
}

.portfolio-add-toggle {
  width: 100%;
  height: 44px;
  border: 1px solid rgba(214, 175, 92, 0.32);
  background: rgba(214, 175, 92, 0.08);
  color: var(--text);
  border-radius: 14px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: 0.18s ease;
}

.portfolio-add-toggle:hover {
  border-color: rgba(214, 175, 92, 0.55);
  background: rgba(214, 175, 92, 0.13);
  transform: translateY(-1px);
}

.portfolio-add-form {
  margin-top: 14px;
}

.portfolio-add-card {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 18px;
}

.portfolio-add-card h3 {
  margin: 0 0 12px;
  font-size: 14px;
  letter-spacing: 0.02em;
}

.portfolio-form-grid {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 0.8fr;
  gap: 10px;
  margin-bottom: 10px;
}

.portfolio-form-grid .modal-text-input {
  min-width: 0;
}

.portfolio-card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.portfolio-card-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02));
  border-radius: 16px;
  padding: 14px 15px;
}

.portfolio-card-row h3 {
  margin: 0 0 5px;
  font-size: 15px;
  color: var(--text);
}

.portfolio-card-row p {
  margin: 3px 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
}

.empty-list-card {
  border: 1px dashed var(--border);
  background: rgba(255, 255, 255, 0.025);
  border-radius: 18px;
  padding: 22px;
  text-align: center;
}

.empty-list-card h3 {
  margin: 0 0 7px;
  font-size: 15px;
}

.empty-list-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 760px) {
  .portfolio-summary {
    grid-template-columns: 1fr;
  }

  .portfolio-form-grid {
    grid-template-columns: 1fr;
  }

  .portfolio-create-row {
    flex-direction: column;
  }

  .portfolio-card-row {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }

  .modal-dashboard {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
  }

  .modal-dashboard .modal-body {
    padding: 14px;
  }

  .modal-dashboard .portfolio-summary {
    grid-template-columns: 1fr;
  }

  .modal-dashboard .portfolio-form-grid {
    grid-template-columns: 1fr;
  }
}

.modal-dashboard .portfolio-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.modal-dashboard .portfolio-summary-card {
  min-height: 78px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.modal-dashboard .portfolio-chart-placeholder {
  min-height: 190px;
  margin-bottom: 22px;
}

.modal-dashboard .portfolio-add-card {
  padding: 18px;
  margin-bottom: 22px;
}

.modal-dashboard .portfolio-form-grid {
  grid-template-columns: 1.2fr 1.2fr 0.8fr;
  gap: 12px;
}

.modal-dashboard .portfolio-card-row {
  min-height: 92px;
  padding: 16px 18px;
}

@media (max-width: 760px) {
  .portfolio-summary {
    grid-template-columns: 1fr;
  }

  .portfolio-form-grid {
    grid-template-columns: 1fr;
  }

  .portfolio-create-row {
    flex-direction: column;
  }

  .portfolio-card-row {
    flex-direction: column;
  }
}

/* COLLECTIONS */
.collection-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 12px;
}

.collection-card-tile {
  background: #111D33;
  border: 0.5px solid #1A2E4A;
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: border 0.15s, transform 0.15s, background 0.15s;
  min-height: 112px;
}

.collection-card-tile:hover {
  border-color: #C9A84C77;
  transform: translateY(-1px);
}

.collection-card-tile.owned {
  border-color: #C9A84C99;
  background: #162746;
}

.collection-check {
  font-size: 20px;
  color: #C9A84C;
  margin-bottom: 8px;
}

.collection-card-name {
  font-size: 13px;
  color: #E8E8E8;
  font-weight: 600;
  line-height: 1.4;
}

.collection-card-set {
  font-size: 11px;
  color: #6A7C94;
  margin-top: 5px;
}

.collection-card-number {
  font-size: 10px;
  color: #4A6A9A;
  margin-top: 3px;
}

.collection-detail-modal { max-width: 820px; }

/* INSIGHTS */
.insight-item { padding: 12px 0; border-bottom: 0.5px solid #1A2E4A; }
.insight-item:last-child { border-bottom: none; }
.insight-text { font-size: 13px; color: #D0D8E8; line-height: 1.6; white-space: pre-wrap; }
.insight-date { font-size: 11px; color: #4A6A9A; margin-top: 4px; }
.insight-delete { float: right; background: transparent; border: none; color: #4A6A9A; cursor: pointer; font-size: 14px; padding: 0 4px; }
.insight-delete:hover { color: #e05555; }

.account-note {
  font-size: 12px;
  color: #4A6A9A;
  margin-top: 12px;
  line-height: 1.6;
}

.menu-toggle {
  display: none;
  background: transparent;
  border: none;
  color: #C9A84C;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.menu-toggle:hover { background: #1A2E4A55; }
.sidebar-backdrop { display: none; }

@media (max-width: 700px) {
  .menu-toggle { display: block; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 30;
    height: 100dvh;
    max-height: 100dvh;
    width: 240px;
    overflow-y: auto;
  }

  .sidebar.open { transform: translateX(0); }
  .side-footer { flex-shrink: 0; margin-top: auto; }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(4,8,16,0.6);
    z-index: 20;
  }

  .sidebar-backdrop.open { display: block; }
  .chat-main { width: 100%; }
  .empty-state h1 { font-size: 22px; }
  .chat-topbar { gap: 10px; }
  .bubble { max-width: 88%; }
  .collection-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

/* ---------- Settings v1 ---------- */

.settings-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-section-title {
  margin-top: 8px;
  padding-top: 10px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent, #d7b56d);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.setting-label {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main, #f6f1e6);
}

.setting-sub {
  margin-top: 4px;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--text-muted, #9aa4b2);
}

.setting-select {
  min-width: 160px;
  border: 1px solid rgba(215, 181, 109, 0.35);
  border-radius: 999px;
  padding: 9px 12px;
  background: rgba(7, 13, 25, 0.92);
  color: var(--text-main, #f6f1e6);
  outline: none;
  font-size: 0.82rem;
}

.setting-select:focus {
  border-color: var(--accent, #d7b56d);
  box-shadow: 0 0 0 3px var(--accent-soft, rgba(215, 181, 109, 0.15));
}

.setting-toggle {
  position: relative;
  width: 48px;
  height: 26px;
  flex: 0 0 auto;
}

.setting-toggle input {
  display: none;
}

.setting-toggle span {
  position: absolute;
  inset: 0;
  cursor: pointer;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: 0.18s ease;
}

.setting-toggle span::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 2px;
  border-radius: 999px;
  background: #ffffff;
  transition: 0.18s ease;
}

.setting-toggle input:checked + span {
  background: var(--accent, #d7b56d);
  border-color: var(--accent, #d7b56d);
}

.setting-toggle input:checked + span::before {
  transform: translateX(22px);
  background: #08101f;
}

.settings-note {
  padding: 12px 14px;
  border: 1px solid rgba(215, 181, 109, 0.18);
  border-radius: 14px;
  background: rgba(215, 181, 109, 0.07);
  color: var(--text-muted, #9aa4b2);
  font-size: 0.8rem;
  line-height: 1.45;
}

.danger-label {
  color: #ff9b9b;
}

.danger-action {
  border-color: rgba(255, 107, 107, 0.45);
  color: #ffd0d0;
}

.danger-action:hover {
  background: rgba(255, 107, 107, 0.12);
}

/* ---------- Theme variables ---------- */

:root {
  --accent: #d7b56d;
  --accent-strong: #f1cc7a;
  --accent-soft: rgba(215, 181, 109, 0.15);
  --bg-main: #070d19;
  --bg-panel: #0c1424;
  --bg-panel-2: #111b2e;
  --text-main: #f6f1e6;
  --text-muted: #9aa4b2;
}

body.theme-navy {
  --bg-main: #070d19;
  --bg-panel: #0c1424;
  --bg-panel-2: #111b2e;
  --text-main: #f6f1e6;
  --text-muted: #9aa4b2;
}

body.theme-midnight {
  --bg-main: #020617;
  --bg-panel: #080f1f;
  --bg-panel-2: #0e1729;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
}

body.theme-royal {
  --bg-main: #11091f;
  --bg-panel: #1a0f2f;
  --bg-panel-2: #251642;
  --text-main: #fbf7ff;
  --text-muted: #b9a9cf;
}

body.theme-light {
  --bg-main: #f7f2e8;
  --bg-panel: #fffaf0;
  --bg-panel-2: #f1e5d2;
  --text-main: #17130c;
  --text-muted: #6f6658;
}

body.accent-gold {
  --accent: #d7b56d;
  --accent-strong: #f1cc7a;
  --accent-soft: rgba(215, 181, 109, 0.16);
}

body.accent-blue {
  --accent: #5ea7ff;
  --accent-strong: #8cc1ff;
  --accent-soft: rgba(94, 167, 255, 0.16);
}

body.accent-purple {
  --accent: #a78bfa;
  --accent-strong: #c4b5fd;
  --accent-soft: rgba(167, 139, 250, 0.16);
}

body.accent-green {
  --accent: #4ade80;
  --accent-strong: #86efac;
  --accent-soft: rgba(74, 222, 128, 0.16);
}

body.accent-red {
  --accent: #fb7185;
  --accent-strong: #fda4af;
  --accent-soft: rgba(251, 113, 133, 0.16);
}

/* Apply theme colors to main surfaces */
body {
  background: var(--bg-main);
  color: var(--text-main);
}

.sidebar,
.chat-main,
.modal,
.collection-card-tile,
.collection-list-item,
.checklist-list-item {
  background-color: var(--bg-panel);
}

.modal-overlay {
  color: var(--text-main);
}

.side-logo span,
.topbar-name,
.history-item.active,
.tool-btn,
.side-link,
.setting-pill,
.checklist-list-arrow,
.collection-check,
.pin-btn {
  color: var(--accent);
}

.new-chat-btn,
.setting-action {
  border-color: var(--accent);
}

.send-btn,
.msg.user .bubble,
.primary-action {
  background: var(--accent);
  color: #08101f;
}

.new-chat-btn:hover,
.setting-action:hover {
  background: var(--accent-soft);
}

/* Chat density */
body.density-compact .messages {
  gap: 8px;
}

body.density-compact .bubble {
  padding: 10px 12px;
  line-height: 1.35;
}

body.density-spacious .messages {
  gap: 18px;
}

body.density-spacious .bubble {
  padding: 16px 18px;
  line-height: 1.65;
}

/* Light theme cleanup */
body.theme-light .sidebar,
body.theme-light .chat-main,
body.theme-light .modal,
body.theme-light .collection-card-tile,
body.theme-light .collection-list-item,
body.theme-light .checklist-list-item {
  border-color: rgba(23, 19, 12, 0.12);
}

body.theme-light .setting-select {
  background: #fffaf0;
  color: #17130c;
}

body.theme-light input,
body.theme-light textarea {
  color: #17130c;
}

/* Prizmantify gold sidebar tool buttons */
.tool-btn {
  width: 100%;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(214, 157, 54, 0.34);
  background:
    radial-gradient(circle at top left, rgba(214, 157, 54, 0.16), transparent 40%),
    linear-gradient(135deg, rgba(31, 24, 13, 0.96), rgba(11, 12, 17, 0.96));
  color: rgba(226, 177, 75, 0.96);
  border-radius: 16px;
  padding: 13px 15px;
  margin: 6px 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.025em;
  text-align: left;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(239, 194, 96, 0.16),
    inset 0 -1px 0 rgba(116, 76, 18, 0.22),
    0 12px 30px rgba(0, 0, 0, 0.24);
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease,
    color 0.2s ease;
}

.tool-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    115deg,
    transparent 0%,
    rgba(181, 121, 30, 0.08) 34%,
    rgba(230, 174, 67, 0.24) 50%,
    rgba(181, 121, 30, 0.08) 66%,
    transparent 100%
  );
  transform: translateX(-130%);
  transition: transform 0.55s ease;
  pointer-events: none;
}

.tool-btn::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(214, 157, 54, 0.62),
    transparent
  );
  opacity: 0.72;
  pointer-events: none;
}

.tool-btn:hover {
  transform: translateY(-2px);
  color: #f0c15d;
  border-color: rgba(224, 166, 56, 0.62);
  background:
    radial-gradient(circle at top left, rgba(214, 157, 54, 0.22), transparent 42%),
    linear-gradient(135deg, rgba(45, 32, 13, 0.98), rgba(13, 14, 19, 0.98));
  box-shadow:
    inset 0 1px 0 rgba(245, 199, 98, 0.2),
    inset 0 -1px 0 rgba(126, 82, 18, 0.26),
    0 15px 38px rgba(0, 0, 0, 0.3),
    0 0 24px rgba(214, 157, 54, 0.12);
}

.tool-btn:hover::before {
  transform: translateX(130%);
}

.tool-btn:active {
  transform: translateY(0);
  color: #d99f35;
  border-color: rgba(214, 157, 54, 0.48);
  box-shadow:
    inset 0 1px 0 rgba(239, 194, 96, 0.14),
    0 8px 22px rgba(0, 0, 0, 0.22);
}

.tool-btn:focus-visible {
  outline: none;
  border-color: rgba(230, 174, 67, 0.78);
  box-shadow:
    0 0 0 3px rgba(214, 157, 54, 0.16),
    0 14px 34px rgba(0, 0, 0, 0.26);
}

/* Mobile tap/zoom stability */
button,
a,
input,
textarea,
select {
  touch-action: manipulation;
}

@media (max-width: 768px) {
  input,
  textarea,
  select,
  .chat-input,
  .chat-textarea,
  #chat-input,
  #input-centered,
  #input-bottom,
  [contenteditable="true"] {
    font-size: 16px !important;
  }

  button,
  a,
  input,
  textarea,
  select {
    touch-action: manipulation;
  }
}



/* Full-screen upgrade plan modal */
.upgrade-overlay {
  background:
    radial-gradient(circle at top, rgba(214, 157, 54, 0.1), transparent 34%),
    rgba(5, 4, 12, 0.94);
  backdrop-filter: blur(18px);
  align-items: flex-start;
  overflow-y: auto;
  padding: 28px 18px;
}

.upgrade-screen {
  width: min(1180px, 100%);
  margin: 0 auto;
  position: relative;
  color: #fff;
}

.upgrade-close {
  position: fixed;
  top: 22px;
  right: 24px;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid rgba(214, 157, 54, 0.24);
  background: rgba(18, 14, 26, 0.86);
  color: rgba(255, 232, 180, 0.86);
  cursor: pointer;
  font-size: 16px;
  z-index: 5;
}

.upgrade-heading {
  text-align: center;
  margin: 8px 0 28px;
}

.upgrade-heading h2 {
  margin: 0 0 18px;
  font-size: clamp(26px, 4vw, 38px);
  font-weight: 780;
  letter-spacing: -0.035em;
  color: #fff8e7;
}

.upgrade-toggle {
  width: 318px;
  max-width: 100%;
  height: 44px;
  margin: 0 auto;
  padding: 4px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.upgrade-toggle button {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.62);
  font-weight: 700;
  cursor: pointer;
}

.upgrade-toggle button.active {
  background:
    linear-gradient(135deg, rgba(214, 157, 54, 0.35), rgba(214, 157, 54, 0.12));
  color: #fff3cf;
  border: 1px solid rgba(255, 224, 151, 0.42);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 10px 24px rgba(0, 0, 0, 0.22);
}

.upgrade-plans {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
  align-items: stretch;
}

.upgrade-plan-card {
  min-height: 610px;
  position: relative;
  padding: 28px 26px;
  border-radius: 22px;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.08), transparent 34%),
    linear-gradient(180deg, rgba(27, 28, 35, 0.96), rgba(17, 17, 23, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 28px 80px rgba(0, 0, 0, 0.32);
}

.upgrade-plan-card.featured {
  background:
    radial-gradient(circle at top left, rgba(214, 157, 54, 0.18), transparent 38%),
    linear-gradient(180deg, rgba(34, 27, 15, 0.98), rgba(18, 17, 23, 0.98));
  border-color: rgba(214, 157, 54, 0.46);
  box-shadow:
    inset 0 1px 0 rgba(255, 226, 157, 0.14),
    0 0 0 1px rgba(214, 157, 54, 0.12),
    0 32px 92px rgba(0, 0, 0, 0.38),
    0 0 42px rgba(214, 157, 54, 0.12);
}

.upgrade-plan-card.pro {
  background:
    radial-gradient(circle at top left, rgba(214, 157, 54, 0.15), transparent 36%),
    linear-gradient(180deg, rgba(35, 29, 18, 0.98), rgba(14, 16, 24, 0.98));
  border-color: rgba(214, 157, 54, 0.34);
}

.upgrade-card-badge {
  position: absolute;
  top: 18px;
  right: 18px;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  color: #1b1408;
  background: linear-gradient(135deg, #f0c15d, #d69d36);
  box-shadow: 0 10px 26px rgba(214, 157, 54, 0.22);
}

.upgrade-plan-card h3 {
  margin: 0 0 22px;
  font-size: 26px;
  line-height: 1;
  font-weight: 800;
  color: #ffffff;
}

.upgrade-price-row {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  margin-bottom: 8px;
}

.upgrade-dollar {
  margin-top: 8px;
  font-size: 18px;
  color: rgba(255, 232, 180, 0.62);
}

.upgrade-price {
  font-size: 46px;
  line-height: 0.95;
  font-weight: 860;
  letter-spacing: -0.06em;
  color: #ffffff;
}

.upgrade-period {
  align-self: flex-end;
  margin-bottom: 6px;
  margin-left: 3px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.68);
}

.upgrade-yearly {
  margin: -2px 0 12px;
  color: #d69d36;
  font-size: 13px;
  font-weight: 800;
}

.upgrade-plan-subtitle {
  min-height: 44px;
  margin: 0 0 24px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 14px;
  line-height: 1.45;
  font-weight: 650;
}

.upgrade-card-button {
  width: 100%;
  height: 44px;
  border-radius: 999px;
  margin: 4px 0 24px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.upgrade-card-button.primary {
  border: 1px solid rgba(214, 157, 54, 0.52);
  background: linear-gradient(135deg, #e4ad45, #b9781d);
  color: #140d05;
  box-shadow:
    inset 0 1px 0 rgba(255, 241, 197, 0.36),
    0 14px 32px rgba(214, 157, 54, 0.16);
}

.upgrade-card-button.muted {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.045);
  color: rgba(255, 255, 255, 0.66);
}

.upgrade-card-button:hover {
  transform: translateY(-1px);
}

.upgrade-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 15px;
}

.upgrade-features li {
  position: relative;
  padding-left: 30px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 14px;
  line-height: 1.35;
}

.upgrade-features li::before {
  content: "✧";
  position: absolute;
  left: 0;
  top: -1px;
  width: 18px;
  height: 18px;
  color: #d69d36;
  font-size: 16px;
  text-align: center;
}

@media (max-width: 980px) {
  .upgrade-plans {
    grid-template-columns: 1fr;
  }

  .upgrade-plan-card {
    min-height: auto;
  }
}

@media (max-width: 620px) {
  .upgrade-overlay {
    padding: 20px 12px;
  }

  .upgrade-plan-card {
    padding: 24px 20px;
    border-radius: 18px;
  }

  .upgrade-price {
    font-size: 40px;
  }

  .upgrade-close {
    top: 14px;
    right: 14px;
  }
}

/* Pro / Pro Maximum toggle */
.pro-multiplier-toggle {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 116px;
  height: 30px;
  padding: 3px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(214, 157, 54, 0.18);
}

.pro-multiplier-toggle button {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.62);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.pro-multiplier-toggle button.active {
  background: linear-gradient(135deg, #e4ad45, #b9781d);
  color: #160f06;
  box-shadow:
    inset 0 1px 0 rgba(255, 242, 198, 0.32),
    0 8px 18px rgba(214, 157, 54, 0.18);
}

.upgrade-plan-card.maximum {
  background:
    radial-gradient(circle at top left, rgba(240, 193, 93, 0.24), transparent 38%),
    radial-gradient(circle at bottom right, rgba(214, 157, 54, 0.14), transparent 34%),
    linear-gradient(180deg, rgba(45, 31, 12, 0.99), rgba(12, 14, 22, 0.99));
  border-color: rgba(240, 193, 93, 0.58);
  box-shadow:
    inset 0 1px 0 rgba(255, 229, 162, 0.18),
    0 0 0 1px rgba(214, 157, 54, 0.16),
    0 34px 96px rgba(0, 0, 0, 0.42),
    0 0 54px rgba(214, 157, 54, 0.18);
}

.upgrade-plan-card.maximum h3 {
  color: #fff1c7;
}

.upgrade-plan-card.maximum .upgrade-price {
  color: #fff7df;
}

.upgrade-plan-card.maximum .upgrade-yearly {
  color: #f0c15d;
}

/* FINAL Account modal layout */
#account-overlay .modal {
  width: min(620px, calc(100vw - 28px));
  max-width: 620px;
  border-radius: 18px;
  border: 1px solid rgba(214, 157, 54, 0.22);
  background:
    radial-gradient(circle at top left, rgba(214, 157, 54, 0.08), transparent 36%),
    linear-gradient(180deg, rgba(8, 15, 31, 0.98), rgba(7, 12, 25, 0.98));
}

#account-overlay .modal-header {
  min-height: 66px;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(214, 157, 54, 0.14);
}

#account-overlay .modal-header h2 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: rgba(226, 177, 75, 0.98);
}

#account-overlay .modal-body {
  padding: 26px 24px 24px;
}

#account-password-recovery.hidden,
#account-recovery-message.hidden,
#account-logged-out.hidden,
#account-logged-in.hidden {
  display: none !important;
}

#account-logged-in:not(.hidden) {
  display: flex;
  flex-direction: column;
}

#account-logged-in .setting-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 18px;
  padding: 15px 0;
  border-bottom: 1px solid rgba(214, 157, 54, 0.08);
}

#account-logged-in .setting-row:first-child {
  padding-top: 0;
}

#account-logged-in .setting-label {
  margin-bottom: 5px;
  font-size: 15px;
  line-height: 1.2;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.94);
}

#account-logged-in .setting-sub {
  max-width: 430px;
  font-size: 13.5px;
  line-height: 1.45;
  color: rgba(184, 198, 224, 0.82);
}

#account-logged-in .setting-pill {
  min-width: 44px;
  justify-self: end;
  margin-top: 2px;
  padding: 6px 11px;
  border-radius: 999px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  color: rgba(226, 177, 75, 0.98);
  background: rgba(50, 88, 139, 0.48);
  border: 1px solid rgba(214, 157, 54, 0.1);
}

#account-logged-in .account-upgrade-actions {
  width: 100%;
  margin: 18px 0 0;
  padding: 18px 0 0;
  border-top: 1px solid rgba(214, 157, 54, 0.14);
  display: flex;
  justify-content: flex-end;
}

#account-logged-in .account-upgrade-actions .modal-save-btn {
  min-width: 150px;
  height: 44px;
  border-radius: 10px;
  font-weight: 800;
}

#account-logged-in .account-upgrade-actions + .modal-confirm-actions {
  width: 100%;
  margin: 14px 0 0;
  padding: 0;
  border-top: 0;
  display: flex;
  justify-content: flex-end;
}

#account-logged-in .modal-danger-btn {
  min-width: 112px;
  height: 42px;
  border-radius: 10px;
  font-weight: 800;
}

#account-logged-in #account-user-message {
  margin: 16px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: rgba(111, 143, 197, 0.92);
}

@media (max-width: 640px) {
  #account-overlay .modal {
    width: calc(100vw - 24px);
  }

  #account-overlay .modal-body {
    padding: 22px 20px 22px;
  }

  #account-logged-in .setting-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  #account-logged-in .setting-pill {
    justify-self: start;
  }

  #account-logged-in .account-upgrade-actions,
  #account-logged-in .account-upgrade-actions + .modal-confirm-actions {
    justify-content: stretch;
  }

  #account-logged-in .account-upgrade-actions .modal-save-btn,
  #account-logged-in .modal-danger-btn {
    width: 100%;
  }
}

/* Full-screen Add Card search */
.portfolio-action-bar {
  display: flex;
  justify-content: flex-end;
  margin: 18px 0;
}

.card-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  padding: 22px;
  background:
    radial-gradient(circle at top left, rgba(214, 157, 54, 0.12), transparent 34%),
    rgba(3, 7, 18, 0.94);
  backdrop-filter: blur(18px);
}

.card-search-overlay.open {
  display: block;
}

.card-search-shell {
  width: min(1420px, 100%);
  height: calc(100vh - 44px);
  margin: 0 auto;
  border: 1px solid rgba(214, 157, 54, 0.24);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(8, 15, 31, 0.98), rgba(5, 10, 22, 0.98));
  box-shadow:
    inset 0 1px 0 rgba(255, 233, 177, 0.08),
    0 34px 120px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-search-header {
  min-height: 86px;
  padding: 22px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(214, 157, 54, 0.16);
}

.card-search-kicker {
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(226, 177, 75, 0.95);
}

.card-search-header h2 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.04em;
  color: rgba(255, 255, 255, 0.96);
}

.card-search-close {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(214, 157, 54, 0.22);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  font-weight: 900;
}

.card-search-main {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
}

.card-search-left {
  min-width: 0;
  min-height: 0;
  padding: 22px;
  overflow-y: auto;
}

.card-search-shell.detail-mode .card-search-left {
  display: none;
}

.card-search-detail {
  display: none;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow-y: auto;
  background:
    radial-gradient(circle at top right, rgba(214, 157, 54, 0.08), transparent 34%),
    rgba(4, 9, 20, 0.52);
}

.card-search-shell.detail-mode .card-search-detail {
  display: block;
}

.card-search-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  padding-bottom: 18px;
  background: linear-gradient(180deg, rgba(8, 15, 31, 0.98), rgba(8, 15, 31, 0));
}

.card-search-input {
  width: 100%;
  height: 52px;
  padding: 0 18px;
  border-radius: 16px;
  border: 1px solid rgba(214, 157, 54, 0.24);
  background: rgba(3, 7, 18, 0.72);
  color: rgba(255, 255, 255, 0.96);
  outline: none;
  font-size: 15px;
}

.card-search-input:focus {
  border-color: rgba(226, 177, 75, 0.55);
  box-shadow: 0 0 0 4px rgba(214, 157, 54, 0.1);
}

.card-search-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: 16px;
}

.card-result-tile {
  min-height: 162px;
  padding: 14px;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  border-radius: 18px;
  border: 1px solid rgba(214, 157, 54, 0.16);
  background:
    radial-gradient(circle at top left, rgba(214, 157, 54, 0.08), transparent 38%),
    rgba(9, 18, 38, 0.86);
  color: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.22);
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.card-result-tile:hover {
  transform: translateY(-2px);
  border-color: rgba(226, 177, 75, 0.5);
  background:
    radial-gradient(circle at top left, rgba(214, 157, 54, 0.16), transparent 42%),
    rgba(12, 24, 49, 0.94);
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.3),
    0 0 34px rgba(214, 157, 54, 0.08);
}

.card-result-image-wrap {
  width: 88px;
  height: 122px;
  border-radius: 13px;
  padding: 7px;
  background:
    linear-gradient(180deg, rgba(226, 177, 75, 0.24), rgba(18, 31, 58, 0.7));
  border: 1px solid rgba(214, 157, 54, 0.16);
}

.card-result-image,
.card-result-image-placeholder {
  width: 100%;
  height: 100%;
  border-radius: 9px;
  object-fit: cover;
}

.card-result-image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at top, rgba(226, 177, 75, 0.28), transparent 42%),
    linear-gradient(180deg, rgba(22, 38, 72, 0.96), rgba(5, 10, 22, 0.96));
  color: rgba(226, 177, 75, 0.96);
  font-size: 34px;
  font-weight: 900;
}

.card-result-info h3 {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.96);
}

.card-result-info p {
  margin: 4px 0;
  font-size: 12.5px;
  line-height: 1.35;
  color: rgba(184, 198, 224, 0.82);
}

.card-result-price {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 900;
  color: rgba(226, 177, 75, 0.98);
}

.card-search-empty {
  border: 1px dashed rgba(214, 157, 54, 0.24);
  border-radius: 18px;
  padding: 22px;
  background: rgba(255, 255, 255, 0.035);
}

.card-search-empty h3 {
  margin: 0 0 8px;
  color: rgba(255, 255, 255, 0.94);
}

.card-search-empty p {
  margin: 0;
  color: rgba(184, 198, 224, 0.78);
  line-height: 1.45;
}

/* Full card detail view after selecting a result */
.card-detail-full {
  min-height: 100%;
  padding: 24px;
}

#card-search-overlay .card-detail-hero {
  margin: 0 0 22px;
  padding: 20px 22px;
  border: 1px solid rgba(var(--card-accent-rgb), 0.22);
  border-radius: 22px;
  background:
    radial-gradient(circle at top left, rgba(var(--card-accent-rgb), 0.14), transparent 42%),
    radial-gradient(circle at bottom right, rgba(var(--card-gold-rgb), 0.08), transparent 42%),
    rgba(var(--card-bg-1-rgb), 0.58);
  box-shadow:
    inset 0 1px 0 rgba(var(--card-gold-rgb), 0.1),
    0 18px 48px rgba(0, 0, 0, 0.22);
}

#card-search-overlay .card-detail-hero h2 {
  margin: 0 0 8px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 0.95;
  letter-spacing: -0.06em;
  color: rgba(255, 255, 255, 0.98);
}

#card-search-overlay .card-detail-hero p {
  margin: 0;
  color: rgba(184, 198, 224, 0.82);
  font-size: 14px;
  line-height: 1.45;
}

#card-search-overlay .card-detail-section-title {
  margin-bottom: 14px;
  color: rgba(var(--card-gold-glow-rgb), 0.98);
  font-size: 13px;
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#card-search-overlay .card-detail-panel-subtitle {
  margin: -8px 0 2px;
  color: rgba(184, 198, 224, 0.72);
  font-size: 13px;
  line-height: 1.4;
}

.card-detail-back {
  margin-bottom: 18px;
  border: 1px solid rgba(214, 157, 54, 0.22);
  border-radius: 12px;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.055);
  color: rgba(226, 177, 75, 0.96);
  font-weight: 900;
  cursor: pointer;
}

.card-detail-layout {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr) minmax(300px, 390px);
  gap: 24px;
  align-items: start;
}

.card-detail-image-panel,
.card-detail-info-panel,
.card-detail-add-panel {
  border: 1px solid rgba(214, 157, 54, 0.16);
  border-radius: 22px;
  background:
    radial-gradient(circle at top left, rgba(214, 157, 54, 0.08), transparent 38%),
    rgba(8, 15, 31, 0.72);
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.24);
}

.card-detail-image-panel {
  padding: 22px;
  display: flex;
  justify-content: center;
}

.card-detail-big-image-wrap {
  width: min(320px, 100%);
  aspect-ratio: 0.72;
  padding: 12px;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(226, 177, 75, 0.24), rgba(18, 31, 58, 0.76));
  border: 1px solid rgba(214, 157, 54, 0.18);
}

.card-detail-big-image,
.card-detail-big-placeholder {
  width: 100%;
  height: 100%;
  border-radius: 14px;
  object-fit: cover;
}

.card-detail-big-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at top, rgba(226, 177, 75, 0.3), transparent 42%),
    linear-gradient(180deg, rgba(22, 38, 72, 0.96), rgba(5, 10, 22, 0.96));
  color: rgba(226, 177, 75, 0.96);
  font-size: 72px;
  font-weight: 900;
}

.card-detail-info-panel {
  padding: 26px;
}

.card-detail-kicker {
  margin-bottom: 8px;
  color: rgba(226, 177, 75, 0.92);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card-detail-info-panel h2 {
  margin: 0 0 22px;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1;
  letter-spacing: -0.055em;
  color: rgba(255, 255, 255, 0.98);
}

.card-detail-info-grid {
  display: grid;
  gap: 14px;
}

.card-detail-info-grid div {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(214, 157, 54, 0.12);
  background: rgba(255, 255, 255, 0.04);
}

.card-detail-info-grid span,
.card-detail-add-panel label span,
.card-detail-market-box span {
  display: block;
  margin-bottom: 5px;
  color: rgba(184, 198, 224, 0.72);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card-detail-info-grid strong {
  color: rgba(255, 255, 255, 0.94);
  font-size: 15px;
}

.card-detail-market-box {
  margin-top: 18px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(214, 157, 54, 0.22);
  background: rgba(214, 157, 54, 0.08);
}

.card-detail-market-box strong {
  display: block;
  color: rgba(226, 177, 75, 0.98);
  font-size: 28px;
  line-height: 1;
}

.card-detail-add-panel {
  padding: 22px;
  display: grid;
  gap: 14px;
}

.card-detail-add-panel h3 {
  margin: 0 0 4px;
  color: rgba(255, 255, 255, 0.96);
  font-size: 20px;
}

.card-detail-add-panel label {
  display: grid;
  gap: 7px;
}

#card-search-overlay .selected-card-add-btn {
  height: 46px;
  margin-top: 8px;
  border: 1px solid rgba(var(--card-gold-glow-rgb), 0.5);
  background:
    linear-gradient(135deg, rgba(var(--card-gold-rgb), 0.98), rgba(var(--card-gold-glow-rgb), 0.92));
  color: rgba(5, 10, 22, 0.96);
  box-shadow:
    0 16px 34px rgba(0, 0, 0, 0.24),
    0 0 24px rgba(var(--card-gold-rgb), 0.14);
}

#card-search-overlay .selected-card-add-btn:hover {
  transform: translateY(-1px);
  box-shadow:
    0 20px 44px rgba(0, 0, 0, 0.3),
    0 0 32px rgba(var(--card-gold-rgb), 0.2);
}

@media (max-width: 1100px) {
  .card-detail-layout {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .card-detail-add-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .card-search-overlay {
    padding: 12px;
  }

  .card-search-shell {
    height: calc(100vh - 24px);
    border-radius: 18px;
  }

  .card-search-header {
    padding: 18px;
  }

  .card-search-left,
  .card-detail-full {
    padding: 16px;
  }

  .card-search-grid {
    grid-template-columns: 1fr;
  }

  .card-detail-layout {
    grid-template-columns: 1fr;
  }
}

/* Add Card theme variable sync */
#card-search-overlay {
  --card-accent-rgb: 214, 157, 54;
  --card-accent-glow-rgb: 226, 177, 75;
  --card-bg-1-rgb: 8, 15, 31;
  --card-bg-2-rgb: 5, 10, 22;
}

#card-search-overlay.card-search-overlay {
  background:
    radial-gradient(circle at top left, rgba(var(--card-accent-rgb), 0.16), transparent 34%),
    rgba(var(--card-bg-2-rgb), 0.94);
}

#card-search-overlay .card-search-shell {
  border-color: rgba(var(--card-accent-rgb), 0.28);
  background:
    radial-gradient(circle at top left, rgba(var(--card-accent-rgb), 0.1), transparent 38%),
    linear-gradient(180deg, rgba(var(--card-bg-1-rgb), 0.98), rgba(var(--card-bg-2-rgb), 0.98));
}

#card-search-overlay .card-search-kicker,
#card-search-overlay .card-result-price,
#card-search-overlay .card-detail-kicker,
#card-search-overlay .card-detail-market-box strong,
#card-search-overlay .card-detail-back,
#card-search-overlay .card-detail-add-panel label span {
  color: rgba(var(--card-accent-glow-rgb), 0.98);
}

#card-search-overlay .card-search-header,
#card-search-overlay .card-search-left,
#card-search-overlay .card-search-input,
#card-search-overlay .card-result-tile,
#card-search-overlay .card-result-image-wrap,
#card-search-overlay .card-search-empty,
#card-search-overlay .card-detail-image-panel,
#card-search-overlay .card-detail-info-panel,
#card-search-overlay .card-detail-add-panel,
#card-search-overlay .card-detail-info-grid div,
#card-search-overlay .card-detail-market-box,
#card-search-overlay .card-detail-big-image-wrap,
#card-search-overlay .card-detail-back,
#card-search-overlay .card-search-close {
  border-color: rgba(var(--card-accent-rgb), 0.22);
}

#card-search-overlay .card-search-input:focus {
  border-color: rgba(var(--card-accent-glow-rgb), 0.62);
  box-shadow: 0 0 0 4px rgba(var(--card-accent-rgb), 0.13);
}

#card-search-overlay .card-result-tile {
  background:
    radial-gradient(circle at top left, rgba(var(--card-accent-rgb), 0.09), transparent 38%),
    rgba(var(--card-bg-1-rgb), 0.86);
}

#card-search-overlay .card-result-tile:hover {
  border-color: rgba(var(--card-accent-glow-rgb), 0.55);
  background:
    radial-gradient(circle at top left, rgba(var(--card-accent-rgb), 0.18), transparent 42%),
    rgba(var(--card-bg-1-rgb), 0.96);
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.3),
    0 0 34px rgba(var(--card-accent-rgb), 0.14);
}

#card-search-overlay .card-result-image-wrap,
#card-search-overlay .card-detail-big-image-wrap {
  background:
    linear-gradient(180deg, rgba(var(--card-accent-rgb), 0.24), rgba(var(--card-bg-1-rgb), 0.72));
}

#card-search-overlay .card-result-image-placeholder,
#card-search-overlay .card-detail-big-placeholder {
  background:
    radial-gradient(circle at top, rgba(var(--card-accent-glow-rgb), 0.28), transparent 42%),
    linear-gradient(180deg, rgba(var(--card-bg-1-rgb), 0.96), rgba(var(--card-bg-2-rgb), 0.96));
  color: rgba(var(--card-accent-glow-rgb), 0.96);
}

#card-search-overlay .card-detail-image-panel,
#card-search-overlay .card-detail-info-panel,
#card-search-overlay .card-detail-add-panel {
  background:
    radial-gradient(circle at top left, rgba(var(--card-accent-rgb), 0.08), transparent 38%),
    rgba(var(--card-bg-1-rgb), 0.72);
}

#card-search-overlay .card-detail-market-box {
  background: rgba(var(--card-accent-rgb), 0.08);
}

/* Add Card premium gold pairing */
#card-search-overlay {
  --card-gold-rgb: 214, 157, 54;
  --card-gold-glow-rgb: 226, 177, 75;
}

/* Keep these brand moments gold */
#card-search-overlay .card-search-kicker,
#card-search-overlay .card-result-price,
#card-search-overlay .card-detail-market-box strong,
  color: rgba(var(--card-gold-glow-rgb), 0.98);
}

/* Search bar gets purple structure with gold inner shine */
#card-search-overlay .card-search-input {
  border-color: rgba(var(--card-accent-rgb), 0.42);
  box-shadow:
    inset 0 0 0 1px rgba(var(--card-gold-rgb), 0.14),
    0 0 22px rgba(var(--card-accent-rgb), 0.12);
}

#card-search-overlay .card-search-input:focus {
  border-color: rgba(var(--card-gold-glow-rgb), 0.72);
  box-shadow:
    0 0 0 4px rgba(var(--card-accent-rgb), 0.13),
    0 0 28px rgba(var(--card-gold-rgb), 0.14);
}

/* Card tiles: purple body, gold premium edge */
#card-search-overlay .card-result-tile {
  border-color: rgba(var(--card-accent-rgb), 0.28);
  box-shadow:
    inset 0 1px 0 rgba(var(--card-gold-rgb), 0.08),
    0 16px 38px rgba(0, 0, 0, 0.22);
}

#card-search-overlay .card-result-tile:hover {
  border-color: rgba(var(--card-gold-glow-rgb), 0.5);
  box-shadow:
    inset 0 1px 0 rgba(var(--card-gold-rgb), 0.14),
    0 20px 50px rgba(0, 0, 0, 0.3),
    0 0 34px rgba(var(--card-accent-rgb), 0.16),
    0 0 20px rgba(var(--card-gold-rgb), 0.08);
}

/* Placeholder card frames: purple outside, gold inside */
#card-search-overlay .card-result-image-wrap,
#card-search-overlay .card-detail-big-image-wrap {
  border-color: rgba(var(--card-accent-rgb), 0.34);
  background:
    linear-gradient(180deg, rgba(var(--card-accent-rgb), 0.32), rgba(var(--card-bg-1-rgb), 0.72));
  box-shadow:
    inset 0 0 0 1px rgba(var(--card-gold-rgb), 0.12),
    0 0 22px rgba(var(--card-accent-rgb), 0.14);
}

/* Make the placeholder letters gold again for Prizmantify contrast */
#card-search-overlay .card-result-image-placeholder,
#card-search-overlay .card-detail-big-placeholder {
  color: rgba(var(--card-gold-glow-rgb), 0.98);
  background:
    radial-gradient(circle at top, rgba(var(--card-accent-rgb), 0.36), transparent 42%),
    radial-gradient(circle at bottom, rgba(var(--card-gold-rgb), 0.12), transparent 44%),
    linear-gradient(180deg, rgba(var(--card-bg-1-rgb), 0.96), rgba(var(--card-bg-2-rgb), 0.96));
}

/* Detail/add panels get subtle gold premium trim */
#card-search-overlay .card-detail-image-panel,
#card-search-overlay .card-detail-info-panel,
#card-search-overlay .card-detail-add-panel,
#card-search-overlay .card-detail-info-grid div,
#card-search-overlay .card-detail-market-box {
  box-shadow:
    inset 0 1px 0 rgba(var(--card-gold-rgb), 0.08),
    0 20px 54px rgba(0, 0, 0, 0.24);
}

/* Close/back buttons: purple base, gold hover */
#card-search-overlay .card-search-close,
#card-search-overlay .card-detail-back {
  border-color: rgba(var(--card-accent-rgb), 0.34);
  box-shadow: inset 0 1px 0 rgba(var(--card-gold-rgb), 0.08);
}

#card-search-overlay .card-search-close:hover,
#card-search-overlay .card-detail-back:hover {
  border-color: rgba(var(--card-gold-glow-rgb), 0.48);
  color: rgba(var(--card-gold-glow-rgb), 0.98);
}

/* Add Card compact result count */
.card-search-status.compact {
  margin: 0 0 16px;
  padding: 10px 13px;
  width: fit-content;
  border: 1px solid rgba(var(--card-accent-rgb), 0.22);
  border-radius: 999px;
  background: rgba(var(--card-bg-1-rgb), 0.58);
  box-shadow:
    inset 0 1px 0 rgba(var(--card-gold-rgb), 0.08),
    0 12px 28px rgba(0, 0, 0, 0.16);
}

.card-search-status.compact strong {
  color: rgba(var(--card-gold-glow-rgb), 0.98);
  font-size: 13px;
  font-weight: 900;
}

/* Portfolio dashboard redesign - Step 1 full screen */
#portfolio-detail-overlay {
  padding: 0;
}

#portfolio-detail-overlay .modal-dashboard {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: none;
  background:
    radial-gradient(circle at top left, rgba(var(--card-accent-rgb, 214, 157, 54), 0.14), transparent 34%),
    radial-gradient(circle at bottom right, rgba(var(--card-gold-rgb, 214, 157, 54), 0.08), transparent 38%),
    rgba(8, 10, 24, 0.98);
  box-shadow: none;
}

#portfolio-detail-overlay .modal-dashboard .modal-header {
  flex: 0 0 auto;
  padding: 24px 32px;
  border-bottom: 1px solid rgba(var(--card-accent-rgb, 214, 157, 54), 0.2);
  background:
    linear-gradient(135deg, rgba(var(--card-accent-rgb, 214, 157, 54), 0.12), transparent 44%),
    rgba(18, 13, 42, 0.76);
}

#portfolio-detail-overlay .modal-dashboard .modal-body {
  flex: 1;
  min-height: 0;
  padding: 28px 32px 34px;
  overflow-y: auto;
}

#portfolio-detail-overlay .modal-dashboard .modal-close {
  border: 1px solid rgba(var(--card-accent-rgb, 214, 157, 54), 0.24);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(238, 242, 255, 0.84);
}

#portfolio-detail-overlay .modal-dashboard .modal-close:hover {
  border-color: rgba(var(--card-gold-rgb, 214, 157, 54), 0.55);
  color: rgba(255, 255, 255, 0.96);
  transform: translateY(-1px);
}

@media (max-width: 900px) {
  #portfolio-detail-overlay {
    padding: 0;
    min-height: 100dvh;
    height: 100dvh;
    overflow: hidden;
    background: rgba(8, 10, 24, 0.98);
  }

  #portfolio-detail-overlay .modal-dashboard {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    overflow: hidden;
  }

  #portfolio-detail-overlay .modal-dashboard .modal-header {
    padding:
      calc(10px + env(safe-area-inset-top))
      22px
      18px;
  }

  #portfolio-detail-overlay .modal-dashboard .modal-body {
    padding:
      22px
      22px
      calc(96px + env(safe-area-inset-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #portfolio-detail-overlay #portfolio-detail-title {
    font-size: clamp(2.35rem, 11vw, 3.65rem);
    line-height: 1;
    letter-spacing: -0.06em;
  }

  #portfolio-detail-overlay #portfolio-detail-meta {
    font-size: 1rem;
  }

  #portfolio-detail-overlay .modal-dashboard .modal-close {
    width: 46px;
    height: 46px;
    flex: 0 0 auto;
  }
}

/* Portfolio dashboard redesign - Step 2 header + summary */
#portfolio-detail-overlay #portfolio-detail-title {
  margin: 0;
  font-size: clamp(2rem, 3vw, 3.35rem);
  line-height: 1;
  letter-spacing: -0.055em;
  color: rgba(255, 255, 255, 0.96);
  text-shadow: 0 0 34px rgba(var(--card-accent-rgb, 214, 157, 54), 0.18);
}

#portfolio-detail-overlay #portfolio-detail-meta {
  margin-top: 10px;
  max-width: 720px;
  font-size: 0.98rem;
  line-height: 1.6;
  color: rgba(226, 232, 240, 0.68);
}

#portfolio-detail-overlay .portfolio-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 16px;
  margin: 0 0 22px;
}

#portfolio-detail-overlay .portfolio-summary-card {
  position: relative;
  min-height: 128px;
  padding: 20px;
  overflow: hidden;
  border: 1px solid rgba(var(--card-accent-rgb, 214, 157, 54), 0.22);
  border-radius: 22px;
  background:
    radial-gradient(circle at top right, rgba(var(--card-accent-rgb, 214, 157, 54), 0.16), transparent 42%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.025)),
    rgba(7, 10, 24, 0.72);
  box-shadow:
    0 20px 54px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

#portfolio-detail-overlay .portfolio-summary-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), transparent 30%),
    radial-gradient(circle at bottom left, rgba(var(--card-gold-rgb, 214, 157, 54), 0.1), transparent 42%);
  opacity: 0.85;
}

#portfolio-detail-overlay .portfolio-summary-label {
  position: relative;
  z-index: 1;
  margin-bottom: 14px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(var(--card-gold-rgb, 214, 157, 54), 0.88);
}

#portfolio-detail-overlay .portfolio-summary-value {
  position: relative;
  z-index: 1;
  font-size: clamp(1.65rem, 2.5vw, 2.55rem);
  font-weight: 900;
  letter-spacing: -0.055em;
  color: rgba(255, 255, 255, 0.96);
}

#portfolio-detail-overlay .portfolio-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 20px 0 22px;
  padding: 16px;
  border: 1px solid rgba(var(--card-accent-rgb, 214, 157, 54), 0.18);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.035);
}

#portfolio-detail-overlay .portfolio-action-bar h3 {
  margin: 0;
  font-size: 1.05rem;
  color: rgba(255, 255, 255, 0.92);
}

#portfolio-detail-overlay .portfolio-action-bar p {
  margin: 6px 0 0;
  color: rgba(226, 232, 240, 0.62);
}

@media (max-width: 900px) {
  #portfolio-detail-overlay .portfolio-summary {
    grid-template-columns: 1fr;
  }

  #portfolio-detail-overlay .portfolio-action-bar {
    align-items: stretch;
    flex-direction: column;
  }
}

/* Portfolio dashboard redesign - Step 3 chart shell */
#portfolio-detail-overlay .portfolio-chart-panel {
  margin: 0 0 22px;
  padding: 20px;
  border: 1px solid rgba(var(--card-accent-rgb, 214, 157, 54), 0.2);
  border-radius: 24px;
  background:
    radial-gradient(circle at top left, rgba(var(--card-accent-rgb, 214, 157, 54), 0.13), transparent 38%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.025)),
    rgba(6, 9, 22, 0.74);
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

#portfolio-detail-overlay .portfolio-chart-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

#portfolio-detail-overlay .portfolio-section-kicker {
  display: inline-flex;
  margin-bottom: 8px;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: rgba(var(--card-gold-rgb, 214, 157, 54), 0.9);
}

#portfolio-detail-overlay .portfolio-chart-top h3 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: -0.035em;
  color: rgba(255, 255, 255, 0.94);
}

#portfolio-detail-overlay .portfolio-chart-top p {
  margin: 7px 0 0;
  max-width: 620px;
  line-height: 1.55;
  color: rgba(226, 232, 240, 0.62);
}

#portfolio-detail-overlay .portfolio-chart-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

#portfolio-detail-overlay .portfolio-chart-btn {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(var(--card-accent-rgb, 214, 157, 54), 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  color: rgba(235, 240, 255, 0.76);
  font-size: 0.83rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

#portfolio-detail-overlay .portfolio-chart-btn:hover:not(:disabled),
#portfolio-detail-overlay .portfolio-chart-btn.active {
  transform: translateY(-1px);
  border-color: rgba(var(--card-gold-rgb, 214, 157, 54), 0.58);
  background: rgba(var(--card-accent-rgb, 214, 157, 54), 0.16);
  color: rgba(255, 255, 255, 0.96);
}

#portfolio-detail-overlay .portfolio-chart-btn.locked {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  opacity: 0.72;
  cursor: not-allowed;
}

#portfolio-detail-overlay .portfolio-chart-btn.locked span {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(var(--card-gold-rgb, 214, 157, 54), 0.18);
  color: rgba(var(--card-gold-rgb, 214, 157, 54), 0.95);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#portfolio-detail-overlay .portfolio-chart-shell {
  position: relative;
  min-height: 260px;
  overflow: hidden;
  border: 1px solid rgba(var(--card-accent-rgb, 214, 157, 54), 0.14);
  border-radius: 22px;
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018)),
    rgba(3, 6, 16, 0.64);
}

#portfolio-detail-overlay .portfolio-chart-grid-lines {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 100% 25%, 12.5% 100%;
  mask-image: linear-gradient(to bottom, transparent, black 18%, black 82%, transparent);
  opacity: 0.7;
}

#portfolio-detail-overlay .portfolio-chart-shell::after {
  content: "";
  position: absolute;
  left: 7%;
  right: 7%;
  bottom: 28%;
  height: 42%;
  border-bottom: 3px solid rgba(var(--card-gold-rgb, 214, 157, 54), 0.72);
  border-radius: 50%;
  transform: skewX(-12deg);
  filter: drop-shadow(0 0 18px rgba(var(--card-gold-rgb, 214, 157, 54), 0.26));
  opacity: 0.7;
}

#portfolio-detail-overlay .portfolio-chart-placeholder {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
}

#portfolio-detail-overlay .portfolio-chart-placeholder strong {
  color: rgba(255, 255, 255, 0.92);
  font-size: 1rem;
}

#portfolio-detail-overlay .portfolio-chart-placeholder span {
  max-width: 520px;
  color: rgba(226, 232, 240, 0.58);
  line-height: 1.55;
}

@media (max-width: 900px) {
  #portfolio-detail-overlay .portfolio-chart-top {
    flex-direction: column;
  }

  #portfolio-detail-overlay .portfolio-chart-tabs {
    justify-content: flex-start;
  }

  #portfolio-detail-overlay .portfolio-chart-shell {
    min-height: 220px;
  }
}

/* Portfolio dashboard redesign - Step 4 info panel */
#portfolio-detail-overlay .portfolio-info-panel {
  margin: 0 0 22px;
  padding: 20px;
  border: 1px solid rgba(var(--card-accent-rgb, 214, 157, 54), 0.18);
  border-radius: 24px;
  background:
    radial-gradient(circle at top right, rgba(var(--card-accent-rgb, 214, 157, 54), 0.11), transparent 42%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.022)),
    rgba(6, 9, 22, 0.66);
  box-shadow:
    0 22px 62px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

#portfolio-detail-overlay .portfolio-info-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

#portfolio-detail-overlay .portfolio-info-header h3 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.035em;
  color: rgba(255, 255, 255, 0.94);
}

#portfolio-detail-overlay .portfolio-info-header p {
  margin: 7px 0 0;
  color: rgba(226, 232, 240, 0.62);
}

#portfolio-detail-overlay .portfolio-info-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

#portfolio-detail-overlay .portfolio-info-card {
  min-height: 104px;
  padding: 16px;
  border: 1px solid rgba(var(--card-accent-rgb, 214, 157, 54), 0.15);
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.02)),
    rgba(255, 255, 255, 0.025);
}

#portfolio-detail-overlay .portfolio-info-card span {
  display: block;
  margin-bottom: 16px;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(226, 232, 240, 0.58);
}

#portfolio-detail-overlay .portfolio-info-card strong {
  display: block;
  font-size: clamp(1.35rem, 2vw, 2rem);
  font-weight: 900;
  letter-spacing: -0.045em;
  color: rgba(255, 255, 255, 0.94);
}

@media (max-width: 1100px) {
  #portfolio-detail-overlay .portfolio-info-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }
}

@media (max-width: 620px) {
  #portfolio-detail-overlay .portfolio-info-grid {
    grid-template-columns: 1fr;
  }
}

/* Portfolio dashboard redesign - Step 5 complete compact card tiles */
#portfolio-detail-overlay .portfolio-card-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
  padding-bottom: 34px;
}

#portfolio-detail-overlay .portfolio-card-tile {
  position: relative;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  min-height: 230px;
  padding: 12px;
  overflow: hidden;
  border: 1px solid rgba(var(--card-accent-rgb, 214, 157, 54), 0.2);
  border-radius: 22px;
  background:
    radial-gradient(circle at top left, rgba(var(--card-accent-rgb, 214, 157, 54), 0.13), transparent 42%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.024)),
    rgba(7, 10, 24, 0.78);
  box-shadow:
    0 18px 46px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.065);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease, filter 0.18s ease;
}

#portfolio-detail-overlay .portfolio-card-tile:hover {
  transform: translateY(-3px);
  border-color: rgba(var(--card-gold-rgb, 214, 157, 54), 0.44);
  box-shadow:
    0 24px 62px rgba(0, 0, 0, 0.32),
    0 0 28px rgba(var(--card-accent-rgb, 214, 157, 54), 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

#portfolio-detail-overlay .portfolio-card-tile.portfolio-card-not-owned {
  opacity: 0.46;
  filter: grayscale(0.45) saturate(0.75);
}

#portfolio-detail-overlay .portfolio-card-tile.portfolio-card-not-owned:hover {
  opacity: 0.72;
}

#portfolio-detail-overlay .portfolio-card-image-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 206px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(var(--card-accent-rgb, 214, 157, 54), 0.16);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 15%, rgba(var(--card-gold-rgb, 214, 157, 54), 0.18), transparent 48%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018)),
    rgba(255, 255, 255, 0.035);
}

#portfolio-detail-overlay .portfolio-card-image-wrap img {
  width: 100%;
  height: 100%;
  max-height: 188px;
  object-fit: contain;
  padding: 7px;
}

#portfolio-detail-overlay .portfolio-card-placeholder {
  display: grid;
  place-items: center;
  width: 76px;
  height: 112px;
  border: 1px solid rgba(var(--card-gold-rgb, 214, 157, 54), 0.42);
  border-radius: 14px;
  background:
    linear-gradient(145deg, rgba(var(--card-accent-rgb, 214, 157, 54), 0.24), rgba(255, 255, 255, 0.045)),
    rgba(0, 0, 0, 0.18);
  color: rgba(255, 255, 255, 0.9);
  font-size: 2.2rem;
  font-weight: 900;
  text-transform: uppercase;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.26);
}

#portfolio-detail-overlay .portfolio-card-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 1px 0;
}

#portfolio-detail-overlay .portfolio-owned-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 9px;
}

#portfolio-detail-overlay .portfolio-owned-label {
  min-width: 0;
  color: rgba(226, 232, 240, 0.56);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1.15;
  text-transform: uppercase;
}

#portfolio-detail-overlay .portfolio-owned-switch {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  min-width: 92px;
  min-height: 28px;
  padding: 4px 7px 4px 4px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  color: rgba(226, 232, 240, 0.74);
  font-size: 0.68rem;
  font-weight: 900;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

#portfolio-detail-overlay .portfolio-owned-switch:hover {
  transform: translateY(-1px);
}

#portfolio-detail-overlay .portfolio-owned-switch.is-on {
  border-color: rgba(var(--card-gold-rgb, 214, 157, 54), 0.56);
  background: rgba(var(--card-accent-rgb, 214, 157, 54), 0.14);
  color: rgba(255, 255, 255, 0.94);
}

#portfolio-detail-overlay .portfolio-owned-switch strong {
  display: block;
  min-width: 38px;
  font-size: 0.68rem;
  line-height: 1;
}

#portfolio-detail-overlay .portfolio-owned-switch-track {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.24);
  flex-shrink: 0;
}

#portfolio-detail-overlay .portfolio-owned-switch-track i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.94);
  transition: transform 0.18s ease, background 0.18s ease;
}

#portfolio-detail-overlay .portfolio-owned-switch.is-on .portfolio-owned-switch-track i {
  transform: translateX(14px);
  background: rgba(var(--card-gold-rgb, 214, 157, 54), 0.96);
}

#portfolio-detail-overlay .portfolio-card-content h3 {
  margin: 0 0 5px;
  color: rgba(255, 255, 255, 0.96);
  font-size: 0.98rem;
  line-height: 1.12;
  letter-spacing: -0.025em;
  word-break: break-word;
}

#portfolio-detail-overlay .portfolio-card-meta {
  margin: 0 0 9px;
  min-height: 0;
  color: rgba(226, 232, 240, 0.62);
  font-size: 0.74rem;
  line-height: 1.35;
}

#portfolio-detail-overlay .portfolio-card-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 9px;
}

#portfolio-detail-overlay .portfolio-card-stat {
  padding: 8px;
  border: 1px solid rgba(var(--card-accent-rgb, 214, 157, 54), 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

#portfolio-detail-overlay .portfolio-card-stat span {
  display: block;
  margin-bottom: 3px;
  color: rgba(226, 232, 240, 0.52);
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#portfolio-detail-overlay .portfolio-card-stat strong {
  display: block;
  color: rgba(255, 255, 255, 0.94);
  font-size: 0.85rem;
  font-weight: 900;
}

#portfolio-detail-overlay .portfolio-card-value {
  margin: 0 0 6px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.74rem;
  line-height: 1.38;
}

#portfolio-detail-overlay .portfolio-card-source {
  margin: 0 0 7px;
  color: rgba(var(--card-gold-rgb, 214, 157, 54), 0.9);
  font-size: 0.7rem;
  font-weight: 850;
}

#portfolio-detail-overlay .portfolio-card-not-owned-note,
#portfolio-detail-overlay .portfolio-card-notes {
  margin: 0 0 7px;
  color: rgba(226, 232, 240, 0.58);
  font-size: 0.7rem;
  line-height: 1.35;
}

#portfolio-detail-overlay .portfolio-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 7px;
}

#portfolio-detail-overlay .portfolio-card-condition {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 27px;
  padding: 0 9px;
  border: 1px solid rgba(var(--card-accent-rgb, 214, 157, 54), 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(226, 232, 240, 0.68);
  font-size: 0.68rem;
  font-weight: 850;
}

#portfolio-detail-overlay .portfolio-card-delete {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(248, 113, 113, 0.42);
  border-radius: 999px;
  background: rgba(248, 113, 113, 0.09);
  color: rgba(254, 202, 202, 0.95);
  font-size: 0.68rem;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

#portfolio-detail-overlay .portfolio-card-delete:hover {
  transform: translateY(-1px);
  border-color: rgba(248, 113, 113, 0.68);
  background: rgba(248, 113, 113, 0.16);
}

@media (max-width: 1600px) {
  #portfolio-detail-overlay .portfolio-card-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 1350px) {
  #portfolio-detail-overlay .portfolio-card-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 1050px) {
  #portfolio-detail-overlay .portfolio-card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  #portfolio-detail-overlay .portfolio-card-grid {
    grid-template-columns: 1fr;
  }

  #portfolio-detail-overlay .portfolio-card-tile {
    grid-template-columns: 112px minmax(0, 1fr);
    min-height: 230px;
  }

  #portfolio-detail-overlay .portfolio-card-image-wrap {
    min-height: 206px;
  }

  #portfolio-detail-overlay .portfolio-card-placeholder {
    width: 82px;
    height: 120px;
    font-size: 2.2rem;
  }
}

/* Portfolio dashboard redesign - Step 7 dynamic theme sync */
#portfolio-detail-overlay {
  --portfolio-theme-rgb: var(--card-accent-rgb, 214, 157, 54);
  --portfolio-gold-rgb: var(--card-gold-rgb, 214, 157, 54);
}

#portfolio-detail-overlay .modal-dashboard {
  background:
    radial-gradient(circle at top left, rgba(var(--portfolio-theme-rgb), 0.16), transparent 34%),
    radial-gradient(circle at bottom right, rgba(var(--portfolio-gold-rgb), 0.1), transparent 38%),
    rgba(8, 10, 24, 0.98);
}

#portfolio-detail-overlay .modal-dashboard .modal-header {
  border-bottom-color: rgba(var(--portfolio-theme-rgb), 0.22);
  background:
    linear-gradient(135deg, rgba(var(--portfolio-theme-rgb), 0.14), transparent 44%),
    rgba(18, 13, 42, 0.8);
}

#portfolio-detail-overlay .portfolio-chart-panel,
#portfolio-detail-overlay .portfolio-info-panel,
#portfolio-detail-overlay .portfolio-action-bar,
#portfolio-detail-overlay .portfolio-card-tile,
#portfolio-detail-overlay .portfolio-summary-card,
#portfolio-detail-overlay .portfolio-info-card,
#portfolio-detail-overlay .portfolio-card-stat,
#portfolio-detail-overlay .portfolio-card-image-wrap {
  border-color: rgba(var(--portfolio-theme-rgb), 0.22);
}

#portfolio-detail-overlay .portfolio-summary-card,
#portfolio-detail-overlay .portfolio-chart-panel,
#portfolio-detail-overlay .portfolio-info-panel,
#portfolio-detail-overlay .portfolio-card-tile {
  background:
    radial-gradient(circle at top left, rgba(var(--portfolio-theme-rgb), 0.12), transparent 40%),
    radial-gradient(circle at bottom right, rgba(var(--portfolio-gold-rgb), 0.08), transparent 42%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.024)),
    rgba(7, 10, 24, 0.78);
}

#portfolio-detail-overlay .portfolio-section-kicker,
#portfolio-detail-overlay .portfolio-summary-label {
  color: rgba(var(--portfolio-theme-rgb), 0.94);
}

#portfolio-detail-overlay .portfolio-card-source,
#portfolio-detail-overlay .portfolio-chart-btn.locked span {
  color: rgba(var(--portfolio-gold-rgb), 0.95);
}

#portfolio-detail-overlay .portfolio-summary-value,
#portfolio-detail-overlay #portfolio-detail-title {
  text-shadow:
    0 0 30px rgba(var(--portfolio-theme-rgb), 0.16),
    0 0 18px rgba(var(--portfolio-gold-rgb), 0.08);
}

#portfolio-detail-overlay .portfolio-add-toggle {
  border-color: rgba(var(--portfolio-theme-rgb), 0.32);
  background:
    linear-gradient(135deg, rgba(var(--portfolio-theme-rgb), 0.16), rgba(var(--portfolio-gold-rgb), 0.08)),
    rgba(255, 255, 255, 0.035);
  color: rgba(255, 255, 255, 0.94);
}

#portfolio-detail-overlay .portfolio-add-toggle:hover {
  border-color: rgba(var(--portfolio-gold-rgb), 0.6);
  background:
    linear-gradient(135deg, rgba(var(--portfolio-theme-rgb), 0.22), rgba(var(--portfolio-gold-rgb), 0.12)),
    rgba(255, 255, 255, 0.045);
  transform: translateY(-1px);
}

#portfolio-detail-overlay .portfolio-chart-btn {
  border-color: rgba(var(--portfolio-theme-rgb), 0.24);
}

#portfolio-detail-overlay .portfolio-chart-btn:hover:not(:disabled),
#portfolio-detail-overlay .portfolio-chart-btn.active,
#portfolio-detail-overlay .portfolio-owned-switch.is-on {
  border-color: rgba(var(--portfolio-gold-rgb), 0.58);
  background:
    linear-gradient(135deg, rgba(var(--portfolio-theme-rgb), 0.16), rgba(var(--portfolio-gold-rgb), 0.08));
}

#portfolio-detail-overlay .portfolio-chart-btn.locked span {
  background: rgba(var(--portfolio-gold-rgb), 0.16);
}

#portfolio-detail-overlay .portfolio-owned-switch.is-on .portfolio-owned-switch-track i {
  background: rgba(var(--portfolio-gold-rgb), 0.96);
}

#portfolio-detail-overlay .portfolio-card-placeholder {
  border-color: rgba(var(--portfolio-gold-rgb), 0.42);
  background:
    linear-gradient(145deg, rgba(var(--portfolio-theme-rgb), 0.22), rgba(var(--portfolio-gold-rgb), 0.1)),
    rgba(0, 0, 0, 0.18);
}

#portfolio-detail-overlay .portfolio-chart-shell::after {
  border-bottom-color: rgba(var(--portfolio-gold-rgb), 0.7);
  filter: drop-shadow(0 0 18px rgba(var(--portfolio-theme-rgb), 0.28));
}

/* iPhone Safari input zoom fix */
@media (max-width: 900px) {
  html {
    -webkit-text-size-adjust: 100%;
  }

  input,
  textarea,
  select,
  [contenteditable="true"],
  .chat-input,
  .chatbox-input,
  .chat-textarea,
  .message-input,
  .composer-input,
  .input-centered,
  .input-bottom,
  .modal-text-input,
  .portfolio-name-input,
  #input-centered,
  #input-bottom,
  #chat-input,
  #chat-textarea,
  #portfolio-name,
  #portfolio-name-input,
  #new-portfolio-name,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  input[type="number"] {
    font-size: 16px !important;
    line-height: 1.35 !important;
  }

  button,
  a,
  input,
  textarea,
  select {
    touch-action: manipulation;
  }
}

/* Chat spam prevention */
.send-btn.is-disabled,
.chat-send-btn.is-disabled,
button.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.account-center-modal {
  width: min(720px, calc(100vw - 28px));
  max-height: min(860px, calc(100dvh - 28px));
  border: 1px solid rgba(214, 157, 54, 0.22);
  background:
    radial-gradient(circle at top left, rgba(214, 157, 54, 0.16), transparent 34%),
    radial-gradient(circle at bottom right, rgba(155, 92, 255, 0.13), transparent 36%),
    rgba(9, 13, 28, 0.96);
  box-shadow:
    0 34px 90px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.account-center-header {
  align-items: flex-start;
  padding: 26px 28px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(135deg, rgba(214, 157, 54, 0.12), transparent 45%),
    rgba(255, 255, 255, 0.025);
}

.account-center-header h2 {
  margin: 5px 0 6px;
  font-size: clamp(2rem, 4vw, 3.15rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
}

.account-center-header p {
  margin: 0;
  max-width: 480px;
  color: rgba(235, 236, 245, 0.64);
  font-size: 0.95rem;
  line-height: 1.45;
}

.account-center-kicker,
.account-hero-label {
  color: rgba(214, 157, 54, 0.92);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.account-center-body {
  padding: 22px;
}

.account-hero-card,
.account-form-card,
.account-dashboard-card,
.account-mini-card {
  border: 1px solid rgba(255, 255, 255, 0.09);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.025)),
    rgba(255, 255, 255, 0.025);
  border-radius: 24px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 18px 50px rgba(0, 0, 0, 0.22);
}

.account-hero-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 20px;
  overflow: hidden;
}

.account-hero-card::before {
  content: "";
  position: absolute;
  inset: -80px auto auto -70px;
  width: 190px;
  height: 190px;
  border-radius: 999px;
  background: rgba(214, 157, 54, 0.14);
  filter: blur(10px);
  pointer-events: none;
}

.account-orb {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 19px;
  border: 1px solid rgba(214, 157, 54, 0.4);
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.18), transparent 28%),
    linear-gradient(145deg, rgba(214, 157, 54, 0.2), rgba(155, 92, 255, 0.11)),
    rgba(255, 255, 255, 0.04);
  color: rgba(255, 245, 214, 0.96);
  font-size: 1.45rem;
  font-weight: 950;
  box-shadow: 0 0 34px rgba(214, 157, 54, 0.16);
}

.account-hero-card h3 {
  margin: 5px 0 6px;
  color: rgba(255, 255, 255, 0.94);
  font-size: 1.18rem;
  letter-spacing: -0.035em;
}

.account-hero-card p {
  margin: 0;
  color: rgba(235, 236, 245, 0.62);
  line-height: 1.45;
  font-size: 0.92rem;
}

.account-status-pill {
  position: relative;
  padding: 8px 11px;
  border-radius: 999px;
  border: 1px solid rgba(214, 157, 54, 0.34);
  background: rgba(214, 157, 54, 0.1);
  color: rgba(255, 231, 166, 0.96);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.account-status-pill.active {
  border-color: rgba(52, 211, 153, 0.38);
  background: rgba(52, 211, 153, 0.1);
  color: rgba(167, 255, 219, 0.95);
}

.account-form-card {
  margin-top: 16px;
  padding: 18px;
}

.account-input-label {
  display: block;
  margin: 0 0 8px;
  color: rgba(235, 236, 245, 0.7);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.account-input {
  margin-bottom: 13px;
  border-radius: 16px !important;
  border-color: rgba(255, 255, 255, 0.11) !important;
  background: rgba(3, 7, 18, 0.44) !important;
}

.account-input:focus {
  border-color: rgba(214, 157, 54, 0.58) !important;
  box-shadow: 0 0 0 4px rgba(214, 157, 54, 0.12) !important;
}

.account-action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.15fr;
  gap: 10px;
  margin-top: 4px;
}

.account-action-grid.single {
  grid-template-columns: 1fr;
}

.account-primary-btn,
.account-secondary-btn,
.account-danger-btn {
  min-height: 44px;
  border-radius: 15px;
  font-weight: 900;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease,
    opacity 0.18s ease;
}

.account-primary-btn {
  border: 1px solid rgba(214, 157, 54, 0.54);
  background:
    linear-gradient(135deg, rgba(214, 157, 54, 0.95), rgba(169, 115, 34, 0.95));
  color: rgba(10, 12, 20, 0.96);
  box-shadow: 0 12px 30px rgba(214, 157, 54, 0.16);
}

.account-primary-btn.full {
  width: 100%;
  margin-top: 16px;
}

.account-secondary-btn {
  border: 1px solid rgba(255, 255, 255, 0.11);
  background: rgba(255, 255, 255, 0.055);
  color: rgba(255, 255, 255, 0.84);
}

.account-danger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 98px;
  height: 46px;
  padding: 0 20px;
  border-radius: 16px;
  border: 1px solid rgba(248, 113, 113, 0.7);
  background:
    linear-gradient(135deg, rgba(239, 68, 68, 0.98), rgba(127, 29, 29, 0.98));
  color: rgba(255, 245, 245, 0.98);
  font-weight: 900;
  line-height: 1;
  text-align: center;
  cursor: pointer;
  box-shadow:
    0 14px 30px rgba(239, 68, 68, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.account-primary-btn:hover,
.account-secondary-btn:hover,
.account-danger-btn:hover {
  transform: translateY(-1px);
}

.account-danger-btn:hover {
  border-color: rgba(252, 165, 165, 0.85);
  background:
    linear-gradient(135deg, rgba(248, 113, 113, 0.98), rgba(153, 27, 27, 0.98));
  box-shadow:
    0 16px 34px rgba(239, 68, 68, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.account-mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.account-mini-card {
  padding: 15px;
}

.account-mini-card span,
.account-card-topline span {
  display: block;
  color: rgba(235, 236, 245, 0.48);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.account-mini-card strong {
  display: block;
  margin-top: 7px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 1rem;
}

.account-dashboard-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}

.account-dashboard-card {
  padding: 18px;
}

.account-dashboard-card.plan-card {
  border-color: rgba(214, 157, 54, 0.22);
  background:
    radial-gradient(circle at top left, rgba(214, 157, 54, 0.16), transparent 42%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.025));
}

.account-card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.account-dashboard-card h3 {
  margin: 13px 0 7px;
  color: rgba(255, 255, 255, 0.94);
  font-size: 1.08rem;
  letter-spacing: -0.035em;
}

.account-dashboard-card p {
  margin: 0;
  color: rgba(235, 236, 245, 0.58);
  line-height: 1.48;
  font-size: 0.91rem;
}

.account-bottom-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.account-note {
  margin: 14px 2px 0;
  color: rgba(235, 236, 245, 0.58);
  font-size: 0.86rem;
  line-height: 1.45;
}

@media (max-width: 760px) {
  .account-center-modal {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .account-center-header {
    padding:
      calc(18px + env(safe-area-inset-top))
      20px
      18px;
  }

  .account-center-body {
    padding:
      18px
      18px
      calc(28px + env(safe-area-inset-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .account-hero-card {
    grid-template-columns: auto 1fr;
  }

  .account-status-pill {
    grid-column: 1 / -1;
    width: fit-content;
  }

  .account-action-grid,
  .account-mini-grid,
  .account-dashboard-grid {
    grid-template-columns: 1fr;
  }

  .account-bottom-actions {
    justify-content: stretch;
  }

  .account-danger-btn {
    width: 100%;
  }
}

.account-usage-track {
  position: relative;
  width: 100%;
  height: 9px;
  margin-top: 15px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.account-usage-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background:
    linear-gradient(90deg, rgba(214, 157, 54, 0.95), rgba(255, 214, 118, 0.95));
  box-shadow: 0 0 18px rgba(214, 157, 54, 0.28);
  transition: width 0.25s ease;
}

.account-security-card {
  gap: 14px;
}

.account-security-list {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.account-security-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.62);
  font-size: 13px;
}

.account-security-row strong {
  color: rgba(255, 255, 255, 0.88);
  font-size: 12px;
  font-weight: 800;
}

.account-small-action {
  width: 100%;
  margin-top: 14px;
  padding: 11px 14px;
  border-radius: 14px;
  border: 1px solid rgba(214, 157, 54, 0.35);
  background: rgba(214, 157, 54, 0.12);
  color: #f4c96a;
  font-weight: 800;
  cursor: pointer;
}

.account-small-action:hover {
  border-color: rgba(244, 201, 106, 0.7);
  background: rgba(214, 157, 54, 0.18);
}

.account-security-wide {
  margin-top: 16px;
}

#account-overlay {
  overflow-y: auto;
  align-items: flex-start;
  padding-top: 28px;
  padding-bottom: 28px;
}

#account-overlay > div {
  max-height: none;
}

.account-security-wide {
  margin-top: 16px;
  margin-bottom: 18px;
}

.account-bottom-actions {
  margin-top: 18px;
}

@media (max-width: 720px) {
  #account-overlay {
    padding: 18px 12px;
  }

  .account-security-wide {
    margin-bottom: 22px;
  }
}

#account-overlay {
  overflow-y: auto;
  align-items: center;
  justify-content: center;
  padding: 28px 18px;
}

#account-overlay > div {
  max-height: calc(100vh - 56px);
  overflow-y: auto;
}

.account-security-wide {
  margin-top: 16px;
  margin-bottom: 18px;
}

.account-bottom-actions {
  margin-top: 18px;
}

@media (max-height: 760px) {
  #account-overlay {
    align-items: flex-start;
  }
}

@media (max-width: 720px) {
  #account-overlay {
    padding: 18px 12px;
  }

  #account-overlay > div {
    max-height: calc(100vh - 36px);
  }

  .account-security-wide {
    margin-bottom: 22px;
  }
}

.chart-range-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chart-range-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.045);
  color: rgba(255, 255, 255, 0.74);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.chart-range-button.active {
  border-color: rgba(214, 157, 54, 0.75);
  background: rgba(214, 157, 54, 0.16);
  color: #f4c96a;
}

.chart-range-button.locked {
  opacity: 0.62;
}

.chart-range-button small {
  color: rgba(244, 201, 106, 0.8);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

#upgrade-overlay {
  position: fixed !important;
  inset: 0 !important;
  z-index: 999999 !important;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px 18px;
  background: rgba(2, 4, 12, 0.78);
  backdrop-filter: blur(14px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#upgrade-overlay.open {
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

/* =========================
   PREMIUM UPGRADE MODAL
   Paste at very bottom
   ========================= */

.upgrade-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
  box-sizing: border-box;
  background:
    radial-gradient(circle at top center, rgba(214, 157, 54, 0.08), transparent 24%),
    radial-gradient(circle at bottom center, rgba(155, 92, 255, 0.06), transparent 28%),
    rgba(2, 4, 13, 0.96);
  backdrop-filter: blur(10px);
  z-index: 999999;
  overflow-y: auto;
}

.upgrade-overlay.open {
  display: flex;
  animation: upgradeOverlayFade 0.28s ease;
}

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

.upgrade-screen {
  position: relative;
  width: min(1260px, 100%);
  max-width: 1260px;
  margin: auto;
  padding: 44px 34px 34px;
  border-radius: 30px;
  border: 1px solid rgba(214, 157, 54, 0.16);
  background:
    radial-gradient(circle at top center, rgba(214, 157, 54, 0.12), transparent 26%),
    radial-gradient(circle at bottom right, rgba(93, 63, 211, 0.08), transparent 32%),
    linear-gradient(180deg, rgba(10, 13, 28, 0.98), rgba(4, 7, 18, 0.985));
  box-shadow:
    0 40px 120px rgba(0, 0, 0, 0.58),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 -1px 0 rgba(214, 157, 54, 0.08);
  overflow: hidden;
  animation: upgradeScreenPop 0.36s cubic-bezier(0.2, 0.9, 0.2, 1);
}

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

.upgrade-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(
      115deg,
      transparent 0%,
      transparent 42%,
      rgba(255, 255, 255, 0.045) 49%,
      rgba(255, 255, 255, 0.085) 50%,
      rgba(255, 255, 255, 0.045) 51%,
      transparent 58%,
      transparent 100%
    );
  transform: translateX(-130%);
  animation: upgradeMasterShine 1.35s ease 0.18s 1;
}

@keyframes upgradeMasterShine {
  0% {
    transform: translateX(-130%);
  }
  100% {
    transform: translateX(130%);
  }
}

.upgrade-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid rgba(214, 157, 54, 0.22);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 227, 163, 0.9);
  font-size: 1rem;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
  z-index: 3;
}

.upgrade-close:hover {
  transform: translateY(-1px);
  border-color: rgba(214, 157, 54, 0.42);
  background: rgba(214, 157, 54, 0.08);
  box-shadow: 0 8px 22px rgba(214, 157, 54, 0.12);
}

.upgrade-heading {
  position: relative;
  z-index: 1;
  text-align: center;
  margin-bottom: 28px;
}

.upgrade-heading h2 {
  margin: 0 0 16px;
  color: rgba(255, 249, 235, 0.98);
  font-size: clamp(2.3rem, 4vw, 3.7rem);
  line-height: 0.96;
  letter-spacing: -0.065em;
  font-weight: 950;
  text-shadow: 0 10px 35px rgba(214, 157, 54, 0.08);
}

/* Better monthly/yearly toggle */
.upgrade-toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 auto;
  padding: 5px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    rgba(10, 13, 25, 0.92);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 10px 30px rgba(0, 0, 0, 0.22);
  width: 250px;
}

.upgrade-toggle button {
  appearance: none;
  border: 0;
  min-height: 42px;
  padding: 0 20px;
  border-radius: 999px;
  background: transparent;
  color: rgba(214, 218, 233, 0.72);
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.upgrade-toggle button:hover {
  color: rgba(255, 255, 255, 0.92);
}

.upgrade-toggle button.active {
  color: rgba(17, 12, 5, 0.96);
  background:
    linear-gradient(135deg, rgba(232, 188, 83, 0.98), rgba(193, 133, 36, 0.96));
  box-shadow:
    0 10px 24px rgba(214, 157, 54, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

/* Cards layout */
.upgrade-cards,
.upgrade-grid,
.upgrade-plan-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
  position: relative;
  z-index: 1;
}

/* Generic card styles */
.upgrade-card,
#free-plan-card,
#plus-plan-card,
#pro-plan-card {
  position: relative;
  overflow: hidden;
  border-radius: 26px;
  padding: 22px 20px 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.018)),
    rgba(11, 15, 32, 0.96);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.055),
    0 18px 46px rgba(0, 0, 0, 0.26);
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    border-color 0.22s ease;
}

.upgrade-card:hover,
#free-plan-card:hover,
#plus-plan-card:hover,
#pro-plan-card:hover {
  transform: translateY(-4px);
}

/* Individual plan color treatments */
#free-plan-card {
  border-color: rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.06), transparent 34%),
    linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.018)),
    rgba(11, 15, 32, 0.96);
}

#plus-plan-card {
  border-color: rgba(214, 157, 54, 0.34);
  background:
    radial-gradient(circle at top left, rgba(214, 157, 54, 0.18), transparent 38%),
    linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.018)),
    rgba(18, 14, 8, 0.97);
  box-shadow:
    0 22px 52px rgba(214, 157, 54, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.055);
}

#pro-plan-card {
  border-color: rgba(214, 157, 54, 0.34);
  background:
    radial-gradient(circle at top left, rgba(214, 157, 54, 0.16), transparent 38%),
    linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.018)),
    rgba(22, 17, 10, 0.97);
  box-shadow:
    0 22px 52px rgba(214, 157, 54, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.055);
}

/* Shine effect on open for each card */
#free-plan-card::before,
#plus-plan-card::before,
#pro-plan-card::before {
  content: "";
  position: absolute;
  inset: -20% -40%;
  pointer-events: none;
  background:
    linear-gradient(
      115deg,
      transparent 0%,
      transparent 43%,
      rgba(255, 255, 255, 0.02) 47%,
      rgba(255, 255, 255, 0.12) 50%,
      rgba(255, 255, 255, 0.02) 53%,
      transparent 57%,
      transparent 100%
    );
  transform: translateX(-135%) skewX(-8deg);
}

.upgrade-overlay.open #free-plan-card::before {
  animation: upgradeCardShine 1.1s ease 0.12s 1;
}

.upgrade-overlay.open #plus-plan-card::before {
  animation: upgradeCardShine 1.1s ease 0.26s 1;
}

.upgrade-overlay.open #pro-plan-card::before {
  animation: upgradeCardShine 1.1s ease 0.4s 1;
}

@keyframes upgradeCardShine {
  0% {
    transform: translateX(-135%) skewX(-8deg);
  }
  100% {
    transform: translateX(135%) skewX(-8deg);
  }
}

/* Typography inside cards */
.upgrade-card h3,
#free-plan-card h3,
#plus-plan-card h3,
#pro-plan-card h3 {
  margin: 0 0 10px;
  color: rgba(255, 251, 240, 0.98);
  font-size: 2rem;
  letter-spacing: -0.045em;
  line-height: 1;
  font-weight: 900;
}

.upgrade-price-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin: 4px 0 10px;
}

.upgrade-dollar {
  color: rgba(228, 199, 123, 0.78);
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1;
  transform: translateY(-6px);
}

.upgrade-price {
  color: rgba(255, 249, 235, 0.98);
  font-size: clamp(2.5rem, 3vw, 3.4rem);
  font-weight: 950;
  line-height: 0.9;
  letter-spacing: -0.06em;
}

.upgrade-period {
  color: rgba(232, 236, 245, 0.72);
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.upgrade-yearly {
  margin: 0 0 10px;
  color: rgba(232, 188, 83, 0.92);
  font-size: 0.95rem;
  font-weight: 800;
}

.upgrade-plan-subtitle {
  margin: 0 0 18px;
  color: rgba(233, 236, 247, 0.74);
  font-size: 0.98rem;
  line-height: 1.42;
}

/* Card badges */
.upgrade-badge,
.upgrade-top-badge,
.upgrade-pro-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.upgrade-pill,
.upgrade-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.upgrade-pill.gold,
.upgrade-tag.gold {
  color: rgba(28, 19, 5, 0.96);
  background: linear-gradient(135deg, #f2c454, #d9a131);
}

.upgrade-pill.dark,
.upgrade-tag.dark {
  color: rgba(255, 247, 226, 0.92);
  background: rgba(255, 255, 255, 0.08);
}

/* Buttons in cards */
.upgrade-card-button {
  width: 100%;
  min-height: 48px;
  border-radius: 16px;
  border: 1px solid rgba(214, 157, 54, 0.38);
  background:
    linear-gradient(135deg, rgba(232, 188, 83, 0.98), rgba(200, 140, 35, 0.96));
  color: rgba(17, 12, 5, 0.96);
  font-size: 0.98rem;
  font-weight: 900;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    filter 0.18s ease;
  box-shadow: 0 14px 30px rgba(214, 157, 54, 0.16);
}

.upgrade-card-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.03);
  box-shadow: 0 18px 38px rgba(214, 157, 54, 0.22);
}

.upgrade-card-button.current-plan {
  background: rgba(255, 255, 255, 0.04);
  color: rgba(226, 231, 244, 0.76);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

/* Feature list */
.upgrade-features {
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
}

.upgrade-features li {
  position: relative;
  padding-left: 18px;
  margin-bottom: 12px;
  color: rgba(235, 238, 247, 0.82);
  font-size: 0.95rem;
  line-height: 1.42;
}

.upgrade-features li::before {
  content: "✦";
  position: absolute;
  left: 0;
  top: 0;
  color: rgba(232, 188, 83, 0.92);
  font-size: 0.78rem;
}

/* Pro mode pills */
#pro-normal-btn,
#pro-max-btn {
  border-radius: 999px;
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(234, 238, 248, 0.74);
  font-weight: 800;
  cursor: pointer;
  transition: all 0.18s ease;
}

#pro-normal-btn.active,
#pro-max-btn.active {
  background: linear-gradient(135deg, rgba(232, 188, 83, 0.98), rgba(200, 140, 35, 0.96));
  color: rgba(17, 12, 5, 0.96);
  border-color: rgba(214, 157, 54, 0.44);
}

/* Better spacing on plan top row */
.upgrade-card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

/* Responsive */
@media (max-width: 1100px) {
  .upgrade-cards,
  .upgrade-grid,
  .upgrade-plan-grid {
    grid-template-columns: 1fr;
  }

  .upgrade-screen {
    max-height: none;
    padding: 38px 24px 28px;
  }
}

@media (max-width: 700px) {
  .upgrade-overlay {
    padding: 14px;
    align-items: flex-start;
  }

  .upgrade-screen {
    width: 100%;
    padding: 30px 16px 22px;
    border-radius: 24px;
  }

  .upgrade-heading h2 {
    font-size: 2rem;
  }

  .upgrade-toggle {
    width: 100%;
    max-width: 240px;
  }
}

/* =========================
   CLEAN UPGRADE TOGGLES
   Monthly/Yearly + Pro/Maximum
   ========================= */

.upgrade-toggle {
  display: inline-grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 5px !important;
  width: 270px !important;
  min-height: 48px !important;
  padding: 5px !important;
  border-radius: 999px !important;
  border: 1px solid rgba(255, 255, 255, 0.09) !important;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.022)),
    rgba(12, 15, 28, 0.94) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.055),
    0 12px 32px rgba(0, 0, 0, 0.25) !important;
}

.upgrade-toggle button {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: 0 !important;
  outline: 0 !important;
  min-height: 38px !important;
  padding: 0 16px !important;
  border-radius: 999px !important;
  background: transparent !important;
  color: rgba(224, 228, 239, 0.68) !important;
  font-size: 0.9rem !important;
  font-weight: 850 !important;
  line-height: 1 !important;
  text-align: center !important;
  white-space: nowrap !important;
  cursor: pointer !important;
  box-shadow: none !important;
}

.upgrade-toggle button.active {
  color: rgba(18, 12, 4, 0.96) !important;
  background:
    linear-gradient(135deg, rgba(244, 198, 86, 0.98), rgba(203, 143, 37, 0.97)) !important;
  box-shadow:
    0 8px 18px rgba(214, 157, 54, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.18) !important;
}

/* Pro / Maximum toggle - fixed HTML version */
#pro-plan-card .pro-plan-header {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 12px !important;
  margin-bottom: 12px !important;
}

#pro-plan-card #pro-plan-title {
  display: block !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  color: rgba(255, 251, 240, 0.98) !important;
  font-size: 2rem !important;
  line-height: 1 !important;
  letter-spacing: -0.045em !important;
  font-weight: 900 !important;
}

#pro-plan-card.maximum #pro-plan-title {
  font-size: 1.85rem !important;
  letter-spacing: -0.055em !important;
}

#pro-plan-card .upgrade-pro-toggle {
  display: grid !important;
  grid-template-columns: 70px 118px !important;
  gap: 5px !important;
  width: 198px !important;
  height: 40px !important;
  padding: 5px !important;
  box-sizing: border-box !important;
  border-radius: 999px !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.022)),
    rgba(12, 15, 28, 0.82) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.055) !important;
  overflow: hidden !important;
}

#pro-plan-card #pro-normal-btn,
#pro-plan-card #pro-max-btn {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 30px !important;
  min-height: 30px !important;
  width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  border: 0 !important;
  outline: 0 !important;
  border-radius: 999px !important;
  background: transparent !important;
  color: rgba(230, 234, 245, 0.68) !important;
  font-size: 0.76rem !important;
  font-weight: 900 !important;
  line-height: 1 !important;
  text-align: center !important;
  white-space: nowrap !important;
  cursor: pointer !important;
  transform: none !important;
  box-shadow: none !important;
}

#pro-plan-card #pro-normal-btn.active,
#pro-plan-card #pro-max-btn.active {
  color: rgba(18, 12, 4, 0.96) !important;
  background:
    linear-gradient(135deg, rgba(244, 198, 86, 0.98), rgba(203, 143, 37, 0.97)) !important;
  box-shadow:
    0 6px 14px rgba(214, 157, 54, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.18) !important;
  transform: none !important;
}
