/* Modal */

  @keyframes modalIn {

    from { opacity: 0; transform: scale(0.92) translateY(12px); }

    to { opacity: 1; transform: scale(1) translateY(0); }

  }

  @keyframes modalOverlayIn {

    from { opacity: 0; }

    to { opacity: 1; }

  }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.show, .modal-overlay.active {

  opacity: 1;

  pointer-events: auto;

}

  .modal {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    width: 400px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.25s ease both;
  }

  .modal h2 {

    font-size: 18px;

    font-weight: 600;

    margin-bottom: 20px;

    display: flex;

    align-items: center;

    gap: 8px;

  }

  .modal-close {

    margin-left: auto;

    cursor: pointer;

    color: var(--text-muted);

    width: 28px;

    height: 28px;

    display: flex;

    align-items: center;

    justify-content: center;

    border-radius: 6px;

    transition: background 0.12s;

  }

  .modal-close:hover { background: var(--hover); color: var(--text); }

  .modal-section {

    margin-bottom: 16px;

    padding-bottom: 16px;

    border-bottom: 1px solid var(--border);

  }

  .modal-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

  .modal-section label {

    display: block;

    font-size: 13px;

    font-weight: 500;

    color: var(--text);

    margin-bottom: 8px;

  }

  .modal-section select,

  .modal-section input[type="text"] {

    width: 100%;

    padding: 9px 12px;

    background: var(--bg-soft);

    border: 1px solid var(--border);

    border-radius: 8px;

    color: var(--text);

    font-size: 13px;

    outline: none;

    font-family: inherit;

  }

  .modal-section select:focus,

  .modal-section input[type="text"]:focus { border-color: var(--accent); }

  .toggle-row {

    display: flex;

    align-items: center;

    justify-content: space-between;

    padding: 6px 0;

  }

  .toggle-row span { font-size: 14px; color: var(--text); }

/* SETTINGS */

  .settings-section {

    padding: 18px 20px;

    border-bottom: 1px solid rgba(255,255,255,0.04);

  }

  .settings-section:last-child { border-bottom: none; }

  .settings-section-title {

    font-size: 12px;

    font-weight: 700;

    color: var(--text2);

    margin-bottom: 14px;

    text-transform: uppercase;

    letter-spacing: .5px;

    opacity: .8;

    display: flex;

    align-items: center;

    gap: 8px;

  }

  .settings-toggle-row {

    display: flex;

    align-items: center;

    justify-content: space-between;

    padding: 13px 0;

    font-size: 14px;

  }

  .toggle-switch {

    width: 46px;

    height: 26px;

    background: var(--surface3);

    border-radius: 13px;

    position: relative;

    cursor: pointer;

    transition: 0.3s ease;

    flex-shrink: 0;

    border: 1px solid var(--border);

  }

  .toggle-switch.active {

    background: var(--primary);

    border-color: var(--primary);

    box-shadow: 0 0 12px var(--primary-glow);

  }

  .toggle-switch::before {

    content: "";

    width: 20px;

    height: 20px;

    background: white;

    border-radius: 50%;

    position: absolute;

    top: 2px;

    left: 3px;

    transition: 0.3s cubic-bezier(.4,0,.2,1);

    box-shadow: 0 2px 4px rgba(0,0,0,0.2);

  }

  .toggle-switch.active::before {

    left: 22px;

  }

  .settings-info-row {

    display: flex;

    justify-content: space-between;

    padding: 11px 0;

    font-size: 14px;

    color: var(--text2);

    border-bottom: 1px solid rgba(255,255,255,0.03);

  }

  .settings-info-row:last-child {

    border-bottom: none;

  }

  .settings-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; gap: 12px; }

  .settings-item label { font-size: 13px; color: var(--text); white-space: nowrap; }

  .custom-select {
    position: relative;
    min-width: 140px;
  }

  .custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    user-select: none;
  }

  .custom-select-trigger:hover {
    border-color: var(--accent);
  }

  .custom-select.open .custom-select-trigger {
    border-color: var(--accent);
    background: var(--surface2);
  }

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

  .custom-select-trigger svg {
    transition: transform 0.2s;
    color: var(--text-muted);
    flex-shrink: 0;
  }

  .custom-select-options {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
    transition: opacity 0.15s, transform 0.15s;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  }

  .custom-select.open .custom-select-options {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .custom-select-option {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    transition: background 0.1s;
  }

  .custom-select-option:hover {
    background: var(--hover);
  }

  .custom-select-option.active {
    background: var(--accent);
    color: var(--accent-text);
  }

/* THEME GRID */

  .theme-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .theme-grid-main {
    grid-template-columns: repeat(2, 1fr);
  }

  .theme-grid-extra {
    grid-template-columns: repeat(2, 1fr);
  }

  .theme-card {
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    overflow: hidden;
    background: var(--bg-soft);
  }

  .theme-card:hover { transform: scale(1.02); }

  .theme-card.active { border-color: var(--accent); box-shadow: 0 0 16px var(--primary-glow); }

  .theme-card-preview {
    width: 100%;
    height: 100px;
    border-radius: 12px 12px 0 0;
    display: flex;
    overflow: hidden;
  }

  .theme-card-sidebar {
    width: 35%;
    display: flex;
    flex-direction: column;
    padding: 12px 8px;
    gap: 6px;
    border-right: 1px solid rgba(255,255,255,0.08);
  }

  .theme-card-sidebar .sidebar-item {
    height: 8px;
    border-radius: 4px;
  }

  .theme-card-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 12px;
    gap: 6px;
  }

  .theme-card-name {
    display: block;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    padding: 10px 0;
    color: var(--text);
  }

  .more-themes-btn {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 10px;
    background: var(--hover);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s, color 0.2s;
  }

  .more-themes-btn:hover {
    background: var(--surface2);
    color: var(--text);
  }

  .theme-extra-wrap {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, margin-top 0.35s ease;
    margin-top: 0;
  }

  .theme-extra-wrap.open {
    max-height: 500px;
    margin-top: 12px;
  }

/* Hide scrollbar */
.modal::-webkit-scrollbar { width: 0; height: 0; }
.modal { scrollbar-width: none; -ms-overflow-style: none; }
