/* ============================================================
   AI Scenario — extracted styles
   Auto-generated: do not edit the HTML file's <style> tags
   ============================================================ */

/* ── Block 1 ──────────────────────────────────────────────── */
    /* ===================== CSS VARIABLES ===================== */
    :root {
      --bg-base: #080402;
      --bg-panel: #0c0806;
      --bg-card: #0e0a08;
      --bg-input: #16110e;
      --bg-hover: #1e1510;
      --bg-user-msg: #0a0705;
      --bg-bot-msg: #080503;

    --accent: #f97316;
    --accent-dim: #d45b0e00;
    --accent-glow: rgba(249, 115, 22, 0.45);
    --accent2: #2ebdd9;

      --border: #2e2e2e;
      --border-light: #383838;

      --text-primary: #ffffff;
      --text-secondary: #ffffff;
      --text-dim: #ffffff;
      --text-dialogue: #ffffff;
      --text-bot: #2ebdd9;
      --text-user: #29bad6;
      --text-narration-bot: #2ebdd9;
      --text-narration-user: #29bad6;

      --sidebar-w: 320px;
      --topbar-h: 52px;

      --font-display: 'Inter', sans-serif;
      --font-body: 'Inter', sans-serif;
      --chat-bubble-bg-alpha: 0.10;

      --radius: 6px;
      --radius-lg: 10px;
      --transition: 0.18s ease;
    }

    /* ===================== RESET ===================== */
    *,
    *::before,
    *::after {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    html,
    body {
      height: 100%;
      overflow: hidden;
      background: var(--bg-base);
      color: var(--text-primary);
      font-family: var(--font-body);
      font-size: 14px;
      -webkit-text-size-adjust: 100%;
      text-size-adjust: 100%;
    }

    button {
      cursor: pointer;
      border: none;
      background: none;
      font-family: inherit;
      color: inherit;
    }

    input,
    textarea,
    select {
      font-family: inherit;
      font-size: 14px;
      color: inherit;
      background: var(--bg-input);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 8px 12px;
      outline: none;
      width: 100%;
      transition: all 0.2s ease;
    }

    select {
      appearance: none;
      -webkit-appearance: none;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 12px center;
      padding-right: 36px;
      cursor: pointer;
      opacity: 0.9;
    }

    select:hover {
      opacity: 1;
      border-color: rgba(255, 255, 255, 0.2);
    }

    select:focus {
      border-color: var(--accent);
      opacity: 1;
    }

    input:focus,
    textarea:focus,
    select:focus {
      border-color: var(--accent);
      box-shadow: 0 0 0 2px rgba(232, 98, 26, 0.1);
    }

    select option {
      background: var(--bg-panel);
    }

    textarea {
      resize: vertical;
    }

    a {
      color: inherit;
      text-decoration: none;
    }

    #charModal input,
    #charModal textarea,
    #charModal select {
      background: #1a1a1a;
      border: 1px solid #333333;
      border-radius: 8px;
      padding: 12px 14px;
      color: #ffffff;
      font-size: 14px;
      transition: border-color 0.2s;
    }

    #charModal select {
      padding-right: 36px;
      background-position: right 14px center;
      opacity: 0.9;
    }

    #charModal select:hover {
      opacity: 1;
      border-color: #444;
    }

    #charModal input::placeholder,
    #charModal textarea::placeholder {
      color: #666666;
    }

    #charModal input:focus,
    #charModal textarea:focus,
    #charModal select:focus {
      border-color: var(--accent);
      box-shadow: 0 0 0 2px rgba(232, 98, 26, 0.15);
    }

    /* ===================== CACHE INDICATOR STYLES ===================== */
    .cache-badge {
      display: none !important;
    }

    .cache-badge .material-symbols-outlined {
      font-size: 14px;
      line-height: 1;
      font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 20;
    }

    .cache-badge.active .material-symbols-outlined {
      color: rgba(232, 98, 26, 0.7);
    }

    .cache-badge.cached {
      display: none;
    }

    /* User messages are row-reversed; badge after name = visually left of name, so reset order */
    .user-msg .cache-badge {
      order: 0;
    }


    .msg-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-size: 12px;
      color: var(--text-dim);
      margin-bottom: 4px;
    }

    ::-webkit-scrollbar {
      width: 5px;
      height: 5px;
    }

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

    ::-webkit-scrollbar-thumb {
      background: #333;
      border-radius: 3px;
    }

    /* ===================== AUTH & COMMUNITY STYLES ===================== */
    .auth-overlay {
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, 0.85);
      backdrop-filter: blur(8px);
      z-index: 2000;
      display: none;
      align-items: center;
      justify-content: center;
    }

    .auth-modal {
      background: var(--bg-panel);
      width: 100%;
      max-width: 400px;
      padding: 32px;
      border-radius: var(--radius-lg);
      border: 1px solid var(--border);
      box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    }

    .auth-modal h2 {
      font-family: var(--font-display);
      margin-bottom: 24px;
      text-align: center;
      color: var(--accent);
    }

    .auth-tabs {
      display: flex;
      gap: 16px;
      margin-bottom: 24px;
      border-bottom: 1px solid var(--border);
    }

    .auth-tab {
      padding: 8px 0;
      flex: 1;
      text-align: center;
      font-weight: 600;
      color: var(--text-dim);
      border-bottom: 2px solid transparent;
    }

    .auth-tab.active {
      color: var(--text-primary);
      border-bottom-color: var(--accent);
    }

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

    /* ── Home carousels ─────────────────────────────────────────── */
    .home-carousel-section {
      padding: 0 32px;
      margin-bottom: 32px;
    }
    .home-carousel-header {
      display: flex;
      align-items: flex-end;
      justify-content: space-between;
      margin-bottom: 14px;
    }
    .home-carousel-title {
      font-size: 28px;
      font-weight: 800;
      font-family: var(--font-display);
      background: linear-gradient(90deg, #fff 0%, #f97316 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
      text-transform: uppercase;
      letter-spacing: 2px;
      text-shadow: 0 4px 15px rgba(249, 115, 22, 0.2);
    }
    .home-carousel-sub {
      font-size: 12px;
      color: var(--text-dim);
      margin-top: 2px;
    }
    .home-carousel-arrows { display: flex; gap: 6px; }
    .home-carousel-arrow {
      background: rgba(255,255,255,0.07);
      border: 1px solid rgba(255,255,255,0.1);
      color: var(--text-primary);
      width: 32px; height: 32px;
      border-radius: 50%;
      cursor: pointer;
      font-size: 18px;
      line-height: 1;
      display: flex; align-items: center; justify-content: center;
      transition: background 0.15s;
    }
    .home-carousel-arrow:hover { background: rgba(255,255,255,0.14); }
    .home-carousel-track {
      display: flex;
      gap: 14px;
      overflow-x: auto;
      scroll-behavior: smooth;
      padding-bottom: 10px;
      scrollbar-width: none;
    }
    .home-carousel-track::-webkit-scrollbar { display: none; }
    .home-carousel-2row {
      display: grid;
      grid-template-rows: 1fr 1fr;
      grid-auto-flow: column;
      grid-auto-columns: 364px;
      gap: 14px;
      overflow-x: auto;
      scroll-behavior: smooth;
    }
    .home-carousel-card {
      flex: 0 0 364px;
      width: 364px;
      height: 259px;
      border-radius: 14px;
      overflow: hidden;
      position: relative;
      cursor: pointer;
      background: linear-gradient(135deg,#1a1a2e,#16213e);
      transition: transform 0.18s, box-shadow 0.18s;
      flex-shrink: 0;
    }
    .home-carousel-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.5); }
    .home-carousel-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
    .home-carousel-card-overlay {
      position: absolute; inset: 0;
      background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.2) 55%, transparent 100%);
      display: flex; flex-direction: column; justify-content: flex-end;
      padding: 10px;
    }
    .home-carousel-card-title {
      font-size: 16px; font-weight: 700; color: #fff;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
      line-height: 1.3;
    }
    .home-carousel-card-meta {
      font-size: 12px; color: rgba(255,255,255,0.65);
      margin-top: 4px;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .home-carousel-card-desc {
      font-size: 11px; color: rgba(255,255,255,0.5);
      margin-top: 3px;
      display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
      overflow: hidden; line-height: 1.4;
    }
    .home-carousel-like-btn {
      position: absolute; top: 7px; right: 7px;
      background: rgba(0,0,0,0.5); border: none; border-radius: 50%;
      width: 26px; height: 26px; cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      color: #fff; backdrop-filter: blur(4px);
      transition: background 0.15s;
    }
    .home-carousel-like-btn:hover, .home-carousel-like-btn.liked { background: rgba(229,62,62,0.75); }
    .home-carousel-placeholder {
      color: var(--text-dim); font-size: 13px; padding: 40px 0; text-align: center; width: 100%;
    }

    /* ── Floating Discord button ────────────────────────────────── */
    #discordFab {
      position: fixed;
      bottom: 24px;
      right: 24px;
      z-index: 9000;
      display: flex;
      align-items: center;
      gap: 0;
    }
    .discord-fab-main {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 10px 16px;
      background: var(--accent);
      border: none;
      border-radius: 50px 0 0 50px;
      color: #fff;
      font-size: 13px;
      font-weight: 700;
      cursor: pointer;
      box-shadow: 0 4px 20px rgba(232,98,26,0.45);
      transition: transform 0.18s, box-shadow 0.18s, background 0.18s;
      text-decoration: none;
    }
    .discord-fab-main:hover {
      transform: translateY(-2px);
      box-shadow: 0 8px 28px rgba(232,98,26,0.6);
      background: #f07030;
    }
    .discord-fab-dismiss {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 26px;
      height: 38px;
      background: rgba(232,98,26,0.75);
      border: none;
      border-radius: 0 50px 50px 0;
      border-left: 1px solid rgba(255,255,255,0.2);
      color: #fff;
      font-size: 16px;
      cursor: pointer;
      transition: background 0.15s;
      line-height: 1;
      padding: 0;
    }
    .discord-fab-dismiss:hover { background: rgba(180,60,10,0.9); }
    .discord-fab-label { letter-spacing: 0.01em; }
    .reddit-fab-main {
      border-radius: 0;
      border-left: 1px solid rgba(255,255,255,0.22);
      background: #ff4500;
      box-shadow: 0 4px 20px rgba(255,69,0,0.32);
    }
    .reddit-fab-main:hover {
      background: #ff5b1f;
      box-shadow: 0 8px 28px rgba(255,69,0,0.48);
    }
    @media (max-width: 600px) {
      #discordFab { bottom: 72px; right: 16px; }
      .discord-fab-main { padding: 10px 13px; border-radius: 50px 0 0 50px; }
      .reddit-fab-main { border-radius: 0; }
      .discord-fab-label { display: none; }
    }

    /* ── Discord popup ───────────────────────────────────────────── */
    #discordPopup {
      position: fixed;
      inset: 0;
      z-index: 10050;
      background: rgba(0,0,0,0.65);
      backdrop-filter: blur(4px);
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .discord-popup-card {
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 18px;
      padding: 36px 28px 28px;
      max-width: 360px;
      width: 90%;
      text-align: center;
      position: relative;
    }
    .discord-popup-close {
      position: absolute; top: 12px; right: 14px;
      background: none; border: none; color: var(--text-dim);
      font-size: 22px; cursor: pointer; line-height: 1;
    }
    .discord-popup-close:hover { color: var(--text-primary); }
    .discord-popup-icon {
      width: 58px; height: 58px;
      background: var(--accent);
      border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      margin: 0 auto 16px;
      box-shadow: 0 4px 18px rgba(232,98,26,0.4);
    }
    .discord-popup-title {
      font-size: 20px; font-weight: 800;
      color: var(--text-primary); margin-bottom: 8px;
      font-family: var(--font-display);
    }
    .discord-popup-desc {
      font-size: 13px; color: var(--text-dim);
      line-height: 1.65; margin-bottom: 24px;
    }
    .discord-popup-btn {
      display: inline-flex; align-items: center; gap: 8px;
      background: var(--accent); color: #fff;
      border-radius: 10px; padding: 12px 26px;
      font-size: 14px; font-weight: 700;
      text-decoration: none; cursor: pointer;
      transition: background 0.15s, transform 0.15s;
    }
    .discord-popup-btn:hover { background: #f07030; transform: translateY(-1px); }
    @media (max-width: 600px) {
      .home-carousel-section { padding: 0 14px; }
      .home-carousel-title { font-size: 20px; }
      .home-carousel-card { flex: 0 0 220px; width: 220px; height: 156px; }
      .home-carousel-2row { grid-auto-columns: 220px; }
      .home-carousel-card-title { font-size: 12px; }
      .home-carousel-card-meta { font-size: 10px; }
    }

    .community-section {
      margin-top: 32px;
    }

    .community-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
      gap: 16px;
      margin-top: 16px;
    }

    .scenario-card.community {
      border-color: var(--accent2);
    }

    .user-tier-badge {
      font-size: 10px;
      padding: 2px 6px;
      border-radius: 4px;
      background: var(--bg-card);
      border: 1px solid var(--border);
      color: var(--text-dim);
      text-transform: uppercase;
      font-weight: 800;
      margin-left: 8px;
    }

    .user-tier-badge.pro {
      background: linear-gradient(135deg, var(--accent) 0%, #ff8c00 100%);
      color: white;
      border: none;
    }

    /* ===================== LAYOUT ===================== */
    #app {
      display: flex;
      flex-direction: row;
      height: 100vh;
      width: 100vw;
      overflow: hidden;
      background: linear-gradient(to bottom, #000 60%, rgba(232, 98, 26, 0.2) 100%);
    }

    /* ===================== SIDEBAR ===================== */
    #sidebar {
      width: var(--sidebar-w);
      min-width: var(--sidebar-w);
      background: transparent;
      display: flex;
      flex-direction: column;
      transition: width var(--transition);
      overflow: hidden;
      position: relative;
      z-index: 10;
      border-right: none;
    }

    #sidebar.collapsed {
      width: 52px;
      min-width: 52px;
    }

    /* Collapsed sidebar — hide everything except icons */
    #sidebar.collapsed .nav-label {
      display: none;
    }

    #sidebar.collapsed .sidebar-logo-text {
      display: none;
    }

    #sidebar.collapsed .sidebar-logo img {
      display: none;
    }

    #sidebar.collapsed .sidebar-section-label {
      display: none;
    }

    #sidebar.collapsed .chat-history-list {
      display: none;
    }

    #sidebar.collapsed .music-player {
      display: none;
    }

    #sidebar.collapsed .user-info {
      display: none;
    }

    #sidebar.collapsed .sidebar-legal {
      display: none;
    }

    #sidebar.collapsed .sidebar-user-area {
      display: none !important;
    }

    #sidebar.collapsed .nav-item {
      padding: 12px 0;
      justify-content: center;
      gap: 0;
    }

    #sidebar.collapsed .sidebar-nav {
      padding: 12px 0;
    }

    .sidebar-logo {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 0 14px;
      height: var(--topbar-h);
      flex-shrink: 0;
    }

    .sidebar-logo svg {
      flex-shrink: 0;
    }

    .sidebar-logo-text {
      font-family: var(--font-display);
      font-size: 20px;
      font-weight: 700;
      color: var(--text-primary);
      white-space: nowrap;
      overflow: hidden;
      padding-bottom: 2px;
    }

    .sidebar-logo-text span {
      color: var(--accent);
    }

    .sidebar-collapse-btn {
      position: absolute;
      top: 14px;
      right: 10px;
      width: 24px;
      height: 24px;
      display: flex;
      align-items: center;
      justify-content: center;
      color: rgba(255, 255, 255, 0.92);
      border-radius: 4px;
      transition: background var(--transition);
    }

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

    #sidebar.collapsed .sidebar-collapse-btn {
      right: 14px;
    }

    .sidebar-nav {
      padding: 0 0 8px;
      flex-shrink: 0;
    }

    .nav-item {
      display: flex;
      align-items: center;
      gap: 14px;
      padding: 16px 20px;
      color: var(--text-secondary);
      cursor: pointer;
      border-radius: 0;
      transition: background var(--transition), color var(--transition);
      white-space: nowrap;
      overflow: hidden;
      font-size: 17px;
      font-weight: 500;
      letter-spacing: 0.1px;
    }

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

    .nav-item.active {
      background: linear-gradient(90deg, rgba(232, 98, 26, 0.18) 0%, rgba(232, 98, 26, 0.08) 78%, rgba(232, 98, 26, 0) 100%);
      color: var(--accent);
      border-left: 3px solid var(--accent);
    }

    .nav-item svg {
      flex-shrink: 0;
    }

    .nav-label {
      overflow: hidden;
      white-space: nowrap;
    }

    .sidebar-section-label {
      padding: 16px 18px 6px;
      font-size: 11px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 1.2px;
      color: var(--text-dim);
      white-space: nowrap;
      overflow: hidden;
    }

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

    .chat-history-item {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 10px 12px;
      cursor: pointer;
      color: var(--text-secondary);
      transition: background var(--transition);
      overflow: hidden;
    }

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

    .chat-history-item:hover .chat-menu-btn {
      opacity: 1 !important;
    }

    .chat-menu-btn {
      cursor: pointer;
      transition: all var(--transition);
    }

    .chat-menu-btn:hover {
      color: var(--accent) !important;
      background: var(--bg-card);
    }

    .chat-del-btn:hover {
      color: #e05252 !important;
      background: rgba(224, 82, 82, 0.1);
    }

    .chat-history-avatar {
      width: 34px;
      height: 34px;
      border-radius: 50%;
      background: var(--bg-card);
      flex-shrink: 0;
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 10px;
      color: var(--text-dim);
      border: 1px solid var(--border);
    }

    .chat-history-avatar img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .chat-history-info {
      overflow: hidden;
      flex: 1;
    }

    .chat-history-name {
      font-size: 13px;
      font-weight: 600;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .chat-history-time {
      font-size: 11px;
      color: var(--text-dim);
      margin-top: 1px;
    }

    .sidebar-user-area {
      border-top: none;
      padding: 10px 14px 24px;
      display: flex;
      flex-direction: row;
      align-items: center;
      gap: 12px;
      flex-shrink: 0;
      cursor: pointer;
      transition: background var(--transition);
      margin-top: 0;
    }

    .sidebar-user-area:hover {
      background: transparent;
    }

    .sidebar-avatar-wrap {
      position: relative;
      width: 96px;
      height: 96px;
      flex-shrink: 0;
    }

    .user-avatar {
      width: 96px;
      height: 96px;
      border-radius: 50%;
      background: var(--accent);
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: 700;
      font-size: 32px;
      border: 2px solid rgba(255,255,255,0.1);
      transition: box-shadow 0.3s ease;
      flex-shrink: 0;
    }

    .sidebar-user-area:hover .user-avatar {
      box-shadow: inset 0 0 20px rgba(0,0,0,0.6), 0 0 32px var(--tier-glow, rgba(232, 98, 26, 0.55)) !important;
    }

    .sidebar-avatar-edit {
      position: absolute;
      bottom: 2px;
      right: 2px;
      width: 26px;
      height: 26px;
      border-radius: 50%;
      background: rgba(20,20,20,0.9);
      border: 1.5px solid rgba(255,255,255,0.18);
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      opacity: 0;
      transition: opacity 0.2s;
    }
    .sidebar-avatar-wrap:hover .sidebar-avatar-edit { opacity: 1; }

    .user-avatar img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .user-info {
      overflow: hidden;
      width: 100%;
      text-align: left;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      gap: 5px;
      flex-shrink: 1;
    }

    .user-name-script {
      font-family: 'Comfortaa', 'Nothing You Could Do', cursive;
      font-size: 22px;
      font-weight: 700;
      color: #ffffff;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      line-height: 1.2;
      letter-spacing: 0.5px;
    }

    /* ===================== MAIN CONTENT ===================== */
    #main {
      flex: 1;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      position: relative;
      min-width: 0;
    }

    /* ===================== TOP BAR ===================== */
    #topbar {
      height: var(--topbar-h);
      background: rgba(10, 5, 10, 0.45);
      backdrop-filter: blur(15px);
      -webkit-backdrop-filter: blur(15px);
      display: flex;
      align-items: center;
      padding: 0 20px;
      gap: 14px;
      flex-shrink: 0;
      position: relative;
      z-index: 5;
      justify-content: flex-end;
      border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .topbar-search {
      flex: 1;
      max-width: 480px;
      position: relative;
    }

    .topbar-search input {
      background: var(--bg-input);
      border: 1px solid var(--border);
      padding: 7px 12px 7px 34px;
      border-radius: 20px;
      font-size: 13px;
      color: var(--text-secondary);
    }

    .topbar-search input::placeholder {
      color: var(--text-dim);
    }

    .topbar-search-icon {
      position: absolute;
      left: 10px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--text-dim);
    }

    .topbar-actions {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-left: auto;
      padding-right: 20px;
    }

    .get-premium-btn {
      display: flex;
      align-items: center;
      gap: 7px;
      background: linear-gradient(135deg, #fa8211, #e05a00);
      border: none;
      border-radius: 20px;
      color: #fff;
      font-size: 13px;
      font-weight: 700;
      padding: 7px 16px;
      cursor: pointer;
      white-space: nowrap;
      transition: opacity 0.2s, transform 0.1s;
      letter-spacing: 0.2px;
    }
    .get-premium-btn:hover { opacity: 0.88; transform: translateY(-1px); }
    .get-premium-btn:active { transform: translateY(0); }

    .topbar-btn {
      width: 32px;
      height: 32px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-secondary);
      transition: background var(--transition);
    }

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

    .topbar-avatar {
      width: 34px;
      height: 34px;
      flex-shrink: 0;
      border-radius: 50%;
      background: var(--accent);
      overflow: hidden;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: 700;
      font-size: 13px;
    }

    .topbar-avatar img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    /* Chat topbar */
    #chat-topbar {
      height: var(--topbar-h);
      background: transparent;
      border-bottom: none;
      display: none;
      align-items: center;
      padding: 0 16px;
      gap: 12px;
      flex-shrink: 0;
    }

    .chat-topbar-scenario-img {
      width: 36px;
      height: 36px;
      border-radius: 50%;
      background: var(--bg-card);
      overflow: hidden;
      flex-shrink: 0;
      border: 2px solid var(--border);
    }

    .chat-topbar-scenario-img img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .chat-topbar-info {
      flex: 1;
      overflow: hidden;
      min-width: 80px;
      flex-shrink: 1;
    }

    .chat-topbar-info:hover .chat-topbar-name {
      color: var(--accent);
    }

    .chat-topbar-name {
      font-size: 13px;
      font-weight: 700;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .chat-topbar-sub {
      font-size: 11px;
      color: var(--text-dim);
    }

    .chat-topbar-badge {
      font-size: 10px;
      background: var(--accent);
      color: white;
      padding: 1px 6px;
      border-radius: 10px;
      font-weight: 700;
      font-family: var(--font-display);
    }

    .chat-topbar-actions {
      display: flex;
      gap: 6px;
      margin-left: auto;
      align-items: center;
      flex-shrink: 1;
      overflow: hidden;
      min-width: 0;
    }

    .persona-picker-btn {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 4px 10px 4px 6px;
      border-radius: 20px;
      border: 1px solid var(--border);
      background: var(--bg-card);
      color: var(--text-secondary);
      font-size: 11px;
      font-weight: 600;
      cursor: pointer;
      transition: border-color var(--transition), color var(--transition);
      max-width: 140px;
    }

    .persona-picker-btn:hover {
      border-color: var(--accent);
      color: var(--text-primary);
    }

    .persona-picker-btn.active {
      border-color: var(--accent);
      color: var(--accent);
    }

    .persona-picker-avatar {
      width: 22px;
      height: 22px;
      border-radius: 50%;
      background: var(--bg-input);
      flex-shrink: 0;
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
      border: 1px solid var(--border);
    }

    .persona-picker-avatar img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .persona-picker-name {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    /* Persona picker dropdown */
    #personaPickerMenu {
      position: fixed;
      z-index: 300;
      background: var(--bg-panel);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
      display: none;
      max-height: 480px;
    }

    #personaPickerMenu.open {
      display: flex;
      flex-direction: row;
      padding: 0;
      overflow: hidden;
      border-radius: var(--radius-lg);
    }

    /* Left list — scrollable */
    .picker-list-col {
      display: flex;
      flex-direction: column;
      width: 210px;
      flex-shrink: 0;
      border-right: 1px solid var(--border);
      overflow: hidden;
    }

    .picker-list-scroll {
      flex: 1;
      overflow-y: auto;
      padding: 6px;
    }

    .picker-list-scroll::-webkit-scrollbar {
      width: 4px;
    }

    .picker-list-footer {
      padding: 6px;
      border-top: 1px solid var(--border);
      flex-shrink: 0;
    }

    /* Right preview */
    .picker-preview-col {
      width: 200px;
      flex-shrink: 0;
      display: flex;
      flex-direction: column;
      background: var(--bg-card);
    }

    .picker-preview-col.empty {
      align-items: center;
      justify-content: center;
      padding: 20px;
      color: var(--text-dim);
      font-size: 11px;
      text-align: center;
      gap: 8px;
    }

    .picker-preview-hero {
      width: 100%;
      height: 130px;
      background: linear-gradient(135deg, #1a0e2e, #2d1b4e);
      flex-shrink: 0;
      overflow: hidden;
    }

    .picker-preview-hero img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      object-position: top center;
    }

    .picker-preview-hero-placeholder {
      width: 100%;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      color: rgba(167, 139, 250, 0.25);
    }

    .picker-preview-body {
      padding: 10px 12px;
      flex: 1;
      overflow-y: auto;
      min-height: 0;
    }

    .picker-preview-body::-webkit-scrollbar {
      width: 3px;
    }

    .picker-preview-name {
      font-size: 13px;
      font-weight: 700;
      color: var(--text-primary);
      margin-bottom: 6px;
      line-height: 1.3;
    }

    .picker-preview-desc {
      font-size: 11px;
      color: var(--text-secondary);
      line-height: 1.6;
      white-space: pre-wrap;
      word-break: break-word;
    }

    .picker-preview-actions {
      padding: 8px 10px;
      border-top: 1px solid var(--border);
      display: flex;
      gap: 6px;
      flex-shrink: 0;
    }

    .persona-picker-item {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 8px 10px;
      border-radius: var(--radius);
      cursor: pointer;
      font-size: 13px;
      color: var(--text-secondary);
      transition: background var(--transition), color var(--transition);
    }

    .persona-picker-item:hover {
      background: var(--bg-hover);
      color: var(--text-primary);
    }

    .persona-picker-item.selected {
      color: var(--accent);
    }

    .persona-picker-item-avatar {
      width: 28px;
      height: 28px;
      border-radius: 50%;
      background: var(--bg-card);
      flex-shrink: 0;
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
      border: 1px solid var(--border);
      font-size: 10px;
      color: var(--text-dim);
    }

    .persona-picker-item-avatar img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .persona-picker-item-info {
      flex: 1;
      overflow: hidden;
    }

    .persona-picker-item-name {
      font-weight: 600;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .persona-picker-item-subtext {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 5px;
      margin-top: 3px;
      line-height: 1;
    }

    .persona-picker-item-tag {
      background: rgba(168, 85, 247, 0.12);
      color: #b172f3;
      padding: 2px 5px;
      border-radius: 4px;
      font-size: 8px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.4px;
      border: 1px solid rgba(168, 85, 247, 0.25);
      white-space: nowrap;
    }

    .persona-picker-item-default {
      font-size: 9px;
      color: var(--text-dim);
      white-space: nowrap;
    }

    .persona-picker-divider {
      height: 1px;
      background: var(--border);
      margin: 4px 0;
    }

    .chat-topbar-btn {
      width: 30px;
      height: 30px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-secondary);
      transition: background var(--transition);
    }

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

    .chat-topbar-icon-btn {
      width: 30px;
      height: 30px;
      border-radius: 6px;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-dim);
      transition: background var(--transition), color var(--transition);
      flex-shrink: 0;
      position: relative;
    }

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

    /* Chat quick settings drawer */
    .chat-quick-settings-overlay {
      position: fixed;
      inset: 0;
      z-index: 640;
      background: rgba(0, 0, 0, 0.58);
      backdrop-filter: blur(2px);
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.2s ease;
    }

    .chat-quick-settings-overlay.open {
      opacity: 1;
      pointer-events: auto;
    }

    .chat-quick-settings-drawer {
      position: fixed;
      top: 0;
      right: 0;
      z-index: 641;
      width: min(430px, 100vw);
      height: 100dvh;
      background: linear-gradient(180deg, rgba(18, 18, 18, 0.98), rgba(7, 7, 7, 0.98));
      border-left: 1px solid rgba(255, 255, 255, 0.1);
      box-shadow: -24px 0 70px rgba(0, 0, 0, 0.72);
      transform: translateX(104%);
      transition: transform 0.24s ease;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }

    .chat-quick-settings-drawer.open {
      transform: translateX(0);
    }

    .cqs-scroll {
      flex: 1;
      overflow-y: auto;
      padding: 18px;
    }

    .cqs-hero {
      position: relative;
      min-height: 190px;
      border-radius: 0 0 18px 18px;
      overflow: hidden;
      background: radial-gradient(circle at 20% 0%, rgba(232, 98, 26, 0.3), transparent 55%), #121212;
      flex-shrink: 0;
    }

    .cqs-hero-bg {
      position: absolute;
      inset: 0;
      background-size: cover;
      background-position: center;
      opacity: 0.78;
    }

    .cqs-hero::after {
      content: "";
      position: absolute;
      inset: 0;
      background: linear-gradient(180deg, rgba(0,0,0,0.15), rgba(0,0,0,0.82));
    }

    .cqs-close {
      position: absolute;
      top: 14px;
      right: 14px;
      z-index: 2;
      width: 42px;
      height: 42px;
      border-radius: 12px;
      border: 1px solid rgba(255, 255, 255, 0.16);
      background: rgba(0, 0, 0, 0.38);
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
    }

    .cqs-hero-copy {
      position: absolute;
      left: 18px;
      right: 66px;
      bottom: 18px;
      z-index: 2;
    }

    .cqs-eyebrow {
      color: var(--accent);
      font-size: 11px;
      font-weight: 900;
      letter-spacing: 2px;
      text-transform: uppercase;
      margin-bottom: 6px;
    }

    .cqs-title {
      color: #fff;
      font-size: 25px;
      line-height: 1.05;
      font-family: var(--font-display);
      font-weight: 900;
      letter-spacing: 0;
      text-shadow: 0 2px 14px rgba(0, 0, 0, 0.75);
    }

    .cqs-desc {
      color: rgba(255,255,255,0.82);
      font-size: 13px;
      line-height: 1.45;
      margin-top: 8px;
      max-height: 58px;
      overflow: hidden;
    }

    .cqs-section-label {
      margin: 18px 0 9px;
      color: #fff;
      font-size: 12px;
      font-weight: 900;
      letter-spacing: 1.7px;
      text-transform: uppercase;
    }

    .cqs-length-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 8px;
      padding: 5px;
      background: rgba(255, 255, 255, 0.035);
      border: 1px solid rgba(255, 255, 255, 0.08);
      border-radius: 14px;
    }

    .cqs-length-btn {
      border: 0;
      border-radius: 10px;
      background: transparent;
      color: rgba(255,255,255,0.74);
      padding: 12px 8px;
      font-size: 14px;
      font-weight: 800;
      cursor: pointer;
    }

    .cqs-length-btn.active {
      background: linear-gradient(135deg, #f97316, #e8621a);
      color: #fff;
      box-shadow: 0 8px 24px rgba(232, 98, 26, 0.26);
    }

    .cqs-slider-wrap {
      padding: 14px 14px 10px;
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 14px;
      background: rgba(255,255,255,0.035);
    }

    .cqs-card {
      position: relative;
      min-height: 84px;
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 14px;
      background: rgba(255,255,255,0.035);
      overflow: hidden;
      cursor: pointer;
      display: flex;
      align-items: center;
      padding: 18px;
      margin-bottom: 12px;
      transition: transform 0.16s ease, border-color 0.16s ease;
    }

    .cqs-card:hover {
      transform: translateY(-1px);
      border-color: rgba(232, 98, 26, 0.55);
    }

    .cqs-card-bg {
      position: absolute;
      inset: 0;
      background-size: cover;
      background-position: center;
      opacity: 0.72;
    }

    .cqs-model-card .cqs-card-bg {
      opacity: 1;
    }

    .cqs-card::after {
      content: "";
      position: absolute;
      inset: 0;
      background: linear-gradient(90deg, rgba(0,0,0,0.84), rgba(0,0,0,0.42), rgba(0,0,0,0.76));
    }

    .cqs-model-card::after {
      background: linear-gradient(90deg, rgba(0,0,0,0.16), rgba(0,0,0,0.02), rgba(0,0,0,0.12));
    }

    .cqs-card-content {
      position: relative;
      z-index: 1;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 14px;
      width: 100%;
    }

    .cqs-card-kicker {
      color: var(--accent);
      font-size: 11px;
      font-weight: 900;
      letter-spacing: 1.5px;
      text-transform: uppercase;
      margin-bottom: 4px;
    }

    .cqs-card-title {
      color: #fff;
      font-size: 20px;
      line-height: 1.1;
      font-family: var(--font-display);
      font-weight: 900;
    }

    .cqs-card-sub {
      color: rgba(255,255,255,0.72);
      font-size: 12px;
      line-height: 1.35;
      margin-top: 5px;
    }

    .cqs-card-arrow {
      color: rgba(255,255,255,0.78);
      font-size: 30px;
      flex-shrink: 0;
    }

    .cqs-bg-panel {
      display: none;
      padding: 12px;
      border-radius: 14px;
      border: 1px solid rgba(255,255,255,0.08);
      background: rgba(255,255,255,0.03);
      margin: -2px 0 14px;
      max-height: min(390px, 44vh);
      overflow-y: auto;
      overscroll-behavior: contain;
    }

    .cqs-bg-panel.open {
      display: block;
    }

    .cqs-bg-grid {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 9px;
      padding-right: 2px;
    }

    .cqs-bg-chip {
      position: relative;
      aspect-ratio: 1.45;
      border-radius: 9px;
      border: 2px solid rgba(255,255,255,0.13);
      background: #111;
      background-size: cover;
      background-position: center;
      cursor: pointer;
      overflow: hidden;
    }

    .cqs-bg-chip.active {
      border-color: var(--accent);
      box-shadow: 0 0 0 1px rgba(232,98,26,0.25), 0 8px 22px rgba(232,98,26,0.2);
    }

    .cqs-bg-chip.locked::after {
      content: "LOCK";
      position: absolute;
      inset: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      background: rgba(0,0,0,0.62);
      color: rgba(255,255,255,0.78);
      font-size: 9px;
      font-weight: 900;
      letter-spacing: 1px;
    }

    .cqs-action-list {
      display: grid;
      gap: 9px;
    }

    .cqs-action-row {
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 13px;
      background: rgba(255,255,255,0.04);
      color: #fff;
      padding: 14px;
      display: flex;
      align-items: center;
      gap: 12px;
      font-weight: 800;
      cursor: pointer;
      text-align: left;
    }

    .cqs-action-row:hover {
      border-color: rgba(232,98,26,0.45);
      background: rgba(232,98,26,0.08);
    }

    @media (max-width: 640px) {
      .chat-quick-settings-drawer {
        width: 100vw;
      }

      .cqs-scroll {
        padding: 14px;
      }

      .cqs-hero {
        min-height: 168px;
      }
    }

    .chat-topbar-icon-btn .material-symbols-outlined {
      font-size: 18px;
    }

    .chat-topbar-icon-btn::after {
      content: attr(data-tooltip);
      position: absolute;
      bottom: calc(100% + 6px);
      left: 50%;
      transform: translateX(-50%) translateY(4px);
      background: #2a2a2a;
      color: var(--text-secondary);
      font-size: 11px;
      font-weight: 500;
      white-space: nowrap;
      padding: 4px 8px;
      border-radius: 5px;
      border: 1px solid var(--border-light);
      pointer-events: none;
      opacity: 0;
      transition: opacity 0.15s ease, transform 0.15s ease;
      z-index: 500;
    }

    .chat-topbar-icon-btn:hover::after {
      opacity: 1;
      transform: translateX(-50%) translateY(0);
    }

    .chat-overflow-item {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 8px 14px;
      font-size: 13px;
      color: var(--text-secondary);
      width: 100%;
      text-align: left;
      transition: background var(--transition), color var(--transition);
    }

    .chat-overflow-item:hover {
      background: var(--bg-hover);
      color: var(--text-primary);
    }

    /* ===================== VIEWS ===================== */
    .view {
      display: none;
      flex: 1 1 auto;
      overflow: hidden;
      width: 100%;
      min-width: 0;
    }

    .view.active {
      display: flex;
      flex-direction: column;
    }

    /* Subtle warm gradient on all views except chat */
    .view.active:not(#view-chat) {
      background: transparent;
    }

    /* ===================== HOME VIEW ===================== */
    #view-home {
      overflow-y: auto;
    }

    .home-content {
      padding: 36px 40px 24px;
      max-width: 1600px;
      margin: 0 auto;
      width: 100%;
    }

    .home-discord-banner {
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 16px;
      padding: 16px 24px;
    }

    .home-discord-banner-inner {
      display: flex;
      align-items: center;
      gap: 16px;
    }

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

    .featured-header h2 {
      font-family: var(--font-display);
      font-size: 16px;
      font-weight: 600;
    }

    .featured-header .add-btn {
      width: 22px;
      height: 22px;
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 4px;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-secondary);
      font-size: 16px;
      transition: background var(--transition);
    }

    .featured-header .add-btn:hover {
      background: var(--accent);
      color: white;
    }

    .featured-banner {
      width: 100%;
      height: 520px;
      flex-shrink: 0;
      background: transparent;
      overflow: hidden;
      position: relative;
      border: none;
      border-radius: 0;
      display: flex;
      align-items: stretch;
      cursor: default;
      isolation: isolate;
    }

    .featured-banner-img {
      position: absolute;
      top: 0; bottom: 0;
      right: 0;
      width: 70%;
      background: linear-gradient(135deg, #1a0a0a 0%, #2a1a0a 50%, #1a0a1a 100%);
      transition: opacity 0.4s ease, transform 10s linear, filter 0.9s ease;
      z-index: 0;
      -webkit-mask-image: linear-gradient(to left, rgba(0,0,0,1) 50%, rgba(0,0,0,0) 100%);
      mask-image: linear-gradient(to left, rgba(0,0,0,1) 50%, rgba(0,0,0,0) 100%);
    }

    .featured-banner:hover .featured-banner-img {
      transform: scale(1.03);
      filter: saturate(1.1) brightness(1.04);
    }

    .featured-banner-img img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      object-position: center 25%;
      display: block;
    }

    .featured-banner-overlay {
      position: absolute;
      inset: 0;
      z-index: 1;
      pointer-events: none;
      background: linear-gradient(to right, rgba(15,10,15,1) 0%, rgba(15,10,15,1) 30%, transparent 100%);
    }

    .featured-banner-content {
      position: absolute;
      bottom: 0;
      left: 0;
      z-index: 3;
      padding: 0 60px 52px;
      width: 44%;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      text-align: left;
      transition: opacity 0.4s ease, transform 0.35s ease;
    }

    .featured-banner:hover .featured-banner-content {
      transform: translateY(-3px);
    }

    .featured-banner-eyebrow {
      font-size: 11px;
      font-weight: 700;
      letter-spacing: 3px;
      text-transform: uppercase;
      color: var(--accent);
      margin-bottom: 10px;
      text-shadow: 0 1px 8px rgba(0,0,0,0.9);
    }

    .featured-banner-title {
      font-family: 'Cinzel', serif;
      font-size: clamp(36px, 4vw, 58px);
      font-weight: 800;
      text-transform: uppercase;
      letter-spacing: 4px;
      color: #ffffff;
      text-shadow: 0 2px 32px rgba(0,0,0,0.95), 0 0 80px rgba(0,0,0,0.7);
      margin-bottom: 14px;
      line-height: 1.08;
      max-width: 700px;
    }

    .featured-banner-desc {
      font-size: 15px;
      color: rgba(255,255,255,0.88);
      max-width: 520px;
      line-height: 1.65;
      margin-bottom: 28px;
      text-shadow: 0 1px 12px rgba(0,0,0,0.95);
      font-weight: 400;
    }

    .featured-btn-start {
      font-size: 15px !important;
      padding: 13px 28px !important;
      font-weight: 700 !important;
      border-radius: 8px !important;
    }

    .featured-btn-details {
      font-size: 15px !important;
      padding: 13px 24px !important;
      font-weight: 600 !important;
      border-radius: 8px !important;
      background: rgba(255,255,255,0.12) !important;
      border-color: rgba(255,255,255,0.25) !important;
      backdrop-filter: blur(6px) !important;
    }

    .featured-btn-details:hover {
      background: rgba(255,255,255,0.2) !important;
      border-color: rgba(255,255,255,0.45) !important;
    }

    .featured-nav-btn {
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      width: 36px;
      height: 36px;
      background: rgba(0, 0, 0, 0.45);
      border: 1px solid rgba(255, 255, 255, 0.15);
      border-radius: 50%;
      color: white;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      z-index: 10;
      transition: background 0.2s;
      opacity: 0;
      transition: opacity 0.2s, background 0.2s;
    }

    .featured-banner:hover .featured-nav-btn {
      opacity: 1;
    }

    .featured-nav-btn:hover {
      background: rgba(232, 98, 26, 0.7);
    }

    .featured-nav-prev {
      left: 12px;
    }

    .featured-nav-next {
      right: 12px;
    }

    .featured-dots {
      position: absolute;
      bottom: 14px;
      left: 50%;
      transform: translateX(-50%);
      display: flex;
      gap: 7px;
      z-index: 10;
    }

    .featured-dot {
      width: 7px;
      height: 7px;
      border-radius: 50%;
      background: rgba(255, 255, 255, 0.35);
      cursor: pointer;
      transition: background 0.3s, transform 0.3s;
    }

    .featured-dot.active {
      background: #ffffff;
      transform: scale(1.25);
    }

    .featured-banner-actions {
      display: flex;
      gap: 12px;
    }

    .featured-banner-actions .btn-primary,
    .featured-banner-actions .btn-secondary {
      font-size: 14px;
      padding: 10px 22px;
      font-weight: 600;
    }

    .btn-primary {
      background: var(--accent);
      color: white;
      padding: 7px 16px;
      border-radius: var(--radius);
      font-size: 12px;
      font-weight: 700;
      display: flex;
      align-items: center;
      gap: 6px;
      transition: background var(--transition), transform var(--transition);
    }

    .btn-primary:hover {
      background: #d0561a;
      transform: translateY(-1px);
    }

    .btn-secondary {
      background: rgba(255, 255, 255, 0.08);
      color: var(--text-primary);
      padding: 7px 16px;
      border-radius: var(--radius);
      font-size: 12px;
      font-weight: 700;
      display: flex;
      align-items: center;
      gap: 6px;
      border: 1px solid rgba(255, 255, 255, 0.12);
      transition: background var(--transition);
    }

    .btn-secondary:hover {
      background: rgba(255, 255, 255, 0.14);
    }

    .btn-danger {
      background: rgba(224, 82, 82, 0.15);
      color: #e05252;
      padding: 7px 16px;
      border-radius: var(--radius);
      font-size: 12px;
      font-weight: 700;
      display: flex;
      align-items: center;
      gap: 6px;
      border: 1px solid rgba(224, 82, 82, 0.3);
      transition: background var(--transition);
    }

    .btn-danger:hover {
      background: rgba(224, 82, 82, 0.28);
    }

    .creator-bottom-actions {
      position: sticky;
      bottom: 0;
      z-index: 4;
      display: flex;
      justify-content: flex-end;
      gap: 12px;
      padding: 16px 0 16px;
      margin-top: 8px;
      background: linear-gradient(to bottom, transparent, var(--bg-main) 40%);
    }
    .creator-bottom-actions .btn-primary,
    .creator-bottom-actions .btn-secondary {
      padding: 13px 28px;
      font-size: 15px;
      border-radius: 10px;
    }

    /* ── Publishing Panel ── */
    .publish-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
      padding: 14px 0;
      border-bottom: 1px solid rgba(255,255,255,0.07);
    }
    .publish-row:last-child { border-bottom: none; }
    .publish-row-label { font-size: 15px; font-weight: 600; color: var(--text-primary); }
    .publish-row-sub { font-size: 13px; color: rgba(255,255,255,0.7); margin-top: 3px; }

    /* Big pill toggle */
    .pub-toggle-pill {
      display: flex;
      align-items: center;
      gap: 10px;
      flex-shrink: 0;
    }
    .pub-toggle-word {
      font-size: 14px;
      font-weight: 600;
      color: var(--text-dim);
      transition: color 0.2s;
      min-width: 44px;
    }
    .pub-toggle-word.active { color: var(--accent); }
    .pub-toggle-track {
      position: relative;
      width: 48px;
      height: 26px;
      border-radius: 13px;
      background: rgba(255,255,255,0.12);
      cursor: pointer;
      transition: background 0.2s;
      flex-shrink: 0;
    }
    .pub-toggle-track.on { background: var(--accent); }
    .pub-toggle-track input {
      opacity: 0; position: absolute; width: 0; height: 0;
    }
    .pub-toggle-thumb {
      position: absolute;
      top: 3px; left: 3px;
      width: 20px; height: 20px;
      background: #fff;
      border-radius: 50%;
      transition: transform 0.2s;
      pointer-events: none;
    }
    .pub-toggle-track.on .pub-toggle-thumb { transform: translateX(22px); }

    /* Playable character toggle in char modal */
    .char-playable-row { display: flex; align-items: center; gap: 14px; padding: 12px 0 4px; border-top: 1px solid rgba(255,255,255,0.07); margin-top: 10px; }
    .char-playable-info { flex: 1; }
    .char-playable-info strong { font-size: 13px; font-weight: 600; color: #e0e0e0; display: block; }
    .char-playable-info span { font-size: 11px; color: #888; }
    .char-card-playable-badge { display: inline-block; font-size: 10px; font-weight: 700; color: #e8621a; background: rgba(232,98,26,0.15); border: 1px solid rgba(232,98,26,0.35); border-radius: 4px; padding: 2px 6px; margin-left: 6px; vertical-align: middle; text-transform: uppercase; letter-spacing: 0.04em; }

    /* Playable character selection modal */
    #playableCharModal { display:none; position:fixed; inset:0; z-index:11000; background:rgba(0,0,0,0.85); align-items:center; justify-content:center; }
    #playableCharModal.open { display:flex; }
    .playable-char-box { background:#181818; border:1px solid #2e2e2e; border-radius:16px; padding:32px; max-width:520px; width:90%; max-height:80vh; overflow-y:auto; }
    .playable-char-box h2 { font-size:20px; font-weight:800; color:#fff; margin:0 0 6px; }
    .playable-char-box .playable-sub { font-size:13px; color:#888; margin-bottom:24px; }
    .playable-char-list { display:flex; flex-direction:column; gap:10px; }
    .playable-char-option { display:flex; align-items:center; gap:14px; padding:14px 16px; border:2px solid #2e2e2e; border-radius:10px; cursor:pointer; background:#111; transition:border-color 0.15s, background 0.15s; }
    .playable-char-option:hover { border-color:#444; background:#1a1a1a; }
    .playable-char-option.selected { border-color:#e8621a; background:rgba(232,98,26,0.08); }
    .playable-char-avatar { width:44px; height:44px; border-radius:50%; background:#2e2e2e; flex-shrink:0; overflow:hidden; display:flex; align-items:center; justify-content:center; }
    .playable-char-avatar img { width:100%; height:100%; object-fit:cover; }
    .playable-char-name { font-size:15px; font-weight:700; color:#fff; }
    .playable-char-traits { font-size:12px; color:#888; margin-top:2px; }
    .playable-char-persona-tag { font-size:10px; font-weight:700; color:#6366f1; background:rgba(99,102,241,0.15); border:1px solid rgba(99,102,241,0.3); border-radius:4px; padding:2px 7px; margin-left:8px; text-transform:uppercase; }
    .playable-char-tag { font-size:10px; font-weight:700; color:#e8621a; background:rgba(232,98,26,0.15); border:1px solid rgba(232,98,26,0.3); border-radius:4px; padding:2px 7px; margin-left:8px; text-transform:uppercase; }
    .playable-char-actions { display:flex; justify-content:flex-end; gap:12px; margin-top:24px; }

    /* Content warning chips */
    .warn-chips { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 14px; }
    .warn-chip {
      display: inline-flex; align-items: center; gap: 5px;
      padding: 8px 16px;
      border-radius: 20px;
      font-size: 13px; font-weight: 600;
      border: 1.5px solid rgba(255,255,255,0.12);
      background: rgba(255,255,255,0.05);
      color: var(--text-dim);
      cursor: pointer;
      transition: all 0.15s;
      user-select: none;
    }
    .warn-chip:hover { border-color: rgba(255,255,255,0.25); color: #fff; }
    .warn-chip.active[data-warn="violence"]  { background: rgba(232,123,53,0.18); border-color: #e87b35; color: #e87b35; }
    .warn-chip.active[data-warn="gore"]      { background: rgba(204,34,34,0.18);  border-color: #cc2222; color: #e06060; }
    .warn-chip.active[data-warn="sexual"]    { background: rgba(155,89,182,0.18); border-color: #9b59b6; color: #c39bd3; }
    .warn-chip.active[data-warn="substance"] { background: rgba(41,128,185,0.18); border-color: #2980b9; color: #7fc4f0; }
    .warn-chip.active[data-warn="language"]  { background: rgba(127,140,141,0.18);border-color: #7f8c8d; color: #aab7b8; }
    .warn-chip.active[data-warn="dark"]      { background: rgba(80,60,120,0.22);  border-color: #7d6aaa; color: #b2a4d4; }
    .warn-chip.active[data-warn="dead-dove"] { background: rgba(160,160,180,0.15); border-color: #9090a8; color: #c0c0d0; }
    .warn-chip.active[data-warn="noncon"]    { background: rgba(200,30,30,0.18);   border-color: #cc2222; color: #e08080; }
    .warn-chip.active[data-warn="dubcon"]    { background: rgba(200,100,30,0.18);  border-color: #d06020; color: #e0a070; }
    .warn-chip.active[data-warn="trauma"]    { background: rgba(100,60,160,0.18);  border-color: #8060b0; color: #c0a0e0; }

    /* Warning badge on scenario cards */
    .sc-warn-badges {
      position: absolute;
      top: 6px; left: 6px;
      display: flex; flex-wrap: wrap; gap: 3px;
      max-width: calc(100% - 12px);
    }
    .sc-warn-badge {
      font-size: 9px; font-weight: 700;
      padding: 2px 6px;
      border-radius: 3px;
      letter-spacing: 0.3px;
      text-transform: uppercase;
    }
    .sc-warn-badge.violence  { background: #e87b35; color: #fff; }
    .sc-warn-badge.gore      { background: #b41e1e; color: #fff; }
    .sc-warn-badge.sexual    { background: #783caa; color: #fff; }
    .sc-warn-badge.substance { background: #1e64a0; color: #fff; }
    .sc-warn-badge.language  { background: #505a5a; color: #ccc; }
    .sc-warn-badge.dark      { background: #322350; color: #bbb; }

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

    .section-header h3 {
      font-family: var(--font-display);
      font-size: 14px;
      font-weight: 600;
    }

    .scenario-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
      gap: 24px;
      margin-bottom: 28px;
    }

    .scenario-card {
      background: rgba(255, 255, 255, 0.02);
      border: 1px solid rgba(255,255,255,0.05);
      border-radius: 12px;
      overflow: hidden;
      cursor: pointer;
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      position: relative;
      aspect-ratio: auto;
      display: flex;
      flex-direction: column;
      gap: 12px;
      padding-bottom: 12px;
    }

    .scenario-card:hover {
      transform: translateY(-4px);
      border-color: rgba(249, 115, 22, 0.5);
      box-shadow: 0 10px 30px rgba(249, 115, 22, 0.15);
      background: rgba(255, 255, 255, 0.05);
    }

    .scenario-card-img {
      position: relative;
      inset: auto;
      width: 100%;
      aspect-ratio: 16/9;
      background: #1a1a1a;
      border-radius: 12px 12px 0 0;
      overflow: hidden;
      transition: border-color 0.2s ease;
    }

    .scenario-card:hover .scenario-card-img {
      border-color: rgba(232, 98, 26, 0.5);
    }

    .scenario-card-img img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .scenario-card-overlay {
      position: absolute;
      inset: 0;
      background: linear-gradient(to top, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.4) 50%, rgba(0, 0, 0, 0) 100%);
      display: none;
    }

    .scenario-card-age {
      position: absolute;
      top: 8px;
      left: 8px;
      font-size: 9px;
      font-weight: 700;
      background: rgba(0, 0, 0, 0.7);
      border: 1px solid var(--border);
      padding: 2px 6px;
      border-radius: 4px;
      color: var(--text-secondary);
      display: none;
    }

    .scenario-card-menu-btn {
      position: absolute;
      top: 8px;
      right: 8px;
      width: 28px;
      height: 28px;
      background: rgba(0, 0, 0, 0.6);
      border-radius: 6px;
      display: none;
      align-items: center;
      justify-content: center;
      color: var(--text-secondary);
      font-size: 16px;
      z-index: 2;
    }

    .scenario-card:hover .scenario-card-menu-btn {
      display: flex;
    }

    /* ── Bulk-select overlays ── */
    .sc-select-cb {
      position: absolute;
      top: 8px;
      left: 8px;
      width: 24px;
      height: 24px;
      border-radius: 6px;
      background: rgba(15,15,20,0.75);
      border: 2px solid rgba(255,255,255,0.35);
      display: flex;
      align-items: center;
      justify-content: center;
      color: #fff;
      z-index: 10;
      pointer-events: none;
      transition: border-color 0.15s, background 0.15s;
    }
    .scenario-card.sc-selected .sc-select-cb {
      background: #fa8211;
      border-color: #fa8211;
    }
    .scenario-card.sc-selected {
      outline: 2px solid #fa8211;
      outline-offset: 2px;
    }

    .ch-select-cb {
      position: absolute;
      top: 8px;
      right: 8px;
      width: 22px;
      height: 22px;
      border-radius: 5px;
      background: rgba(15,15,20,0.75);
      border: 2px solid rgba(255,255,255,0.35);
      display: flex;
      align-items: center;
      justify-content: center;
      color: #fff;
      z-index: 10;
      pointer-events: none;
      transition: border-color 0.15s, background 0.15s;
    }
    .ch-selected .ch-select-cb {
      background: #fa8211;
      border-color: #fa8211;
    }
    .ch-selected {
      outline: 2px solid #fa8211 !important;
      outline-offset: 2px;
    }

    .prof-sc-menu-popup {
      background: #1e1e1e;
      border: 1px solid rgba(255,255,255,0.1);
      border-radius: 10px;
      box-shadow: 0 8px 32px rgba(0,0,0,0.6);
      overflow: hidden;
      min-width: 200px;
    }
    .prof-sc-menu-popup button {
      display: flex;
      align-items: center;
      gap: 10px;
      width: 100%;
      padding: 12px 16px;
      background: none;
      border: none;
      color: var(--text-primary);
      font-size: 14px;
      text-align: left;
      cursor: pointer;
      transition: background 0.15s;
    }
    .prof-sc-menu-popup button:hover { background: rgba(255,255,255,0.07); }
    .prof-sc-menu-popup button.danger { color: #e05555; }
    .prof-sc-menu-popup button.danger:hover { background: rgba(224,85,85,0.1); }
    .prof-sc-menu-popup button + button { border-top: 1px solid rgba(255,255,255,0.06); }

    .scenario-card-body {
      position: static;
      padding: 0;
      z-index: 1;
    }

    .scenario-card-title {
      font-size: 14px;
      font-weight: 700;
      color: #ffffff;
      margin-bottom: 6px;
      line-height: 1.3;
      display: -webkit-box;
      -webkit-line-clamp: 1;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }

    .scenario-card-desc {
      font-size: 12px;
      color: #a7b0bd;
      line-height: 1.5;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }

    /* ===================== CREATE CONTENT HUB ===================== */
    #view-create-hub {
      overflow-y: auto;
    }

    .create-hub-content {
      padding: 48px 60px;
      max-width: 900px;
      margin: 0 auto;
      width: 100%;
      display: flex;
      flex-direction: column;
      gap: 20px;
    }

    .create-hub-title {
      font-family: var(--font-display);
      font-size: 22px;
      font-weight: 700;
      text-align: center;
      margin-bottom: 10px;
      color: var(--text-primary);
    }

    .create-hub-card {
      width: 100%;
      height: 220px;
      border-radius: var(--radius-lg);
      overflow: hidden;
      position: relative;
      cursor: pointer;
      border: 1px solid var(--border);
      transition: transform var(--transition), border-color var(--transition);
    }

    .create-hub-card:hover {
      transform: translateY(-3px);
      border-color: var(--border-light);
    }

    .create-hub-card-bg {
      position: absolute;
      inset: 0;
      background-size: cover;
      background-position: center;
      transition: transform 0.4s ease;
    }

    .create-hub-card:hover .create-hub-card-bg {
      transform: scale(1.03);
    }

    .hub-card-scenarios .create-hub-card-bg {
      background-image: url("assets/create.jpg");
      background-size: cover;
      background-position: center;
    }

    .create-hub-card-overlay {
      position: absolute;
      inset: 0;
      background: linear-gradient(to right, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0.1) 100%);
    }

    .create-hub-card-label {
      position: absolute;
      bottom: 18px;
      left: 22px;
      font-family: var(--font-display);
      font-size: 26px;
      font-weight: 700;
      color: white;
      text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
      letter-spacing: 0.5px;
    }

    .create-hub-card-tag {
      position: absolute;
      top: 16px;
      right: 18px;
      font-size: 12px;
      font-weight: 700;
      color: #f5c842;
      font-family: var(--font-display);
      text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
    }

    .create-hub-lock-panel {
      display: none;
      position: absolute;
      top: 18px;
      left: 22px;
      right: 22px;
      max-width: 430px;
      padding: 14px 16px;
      border-radius: 8px;
      border: 1px solid rgba(246, 215, 111, 0.25);
      background: rgba(10, 10, 10, 0.72);
      box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
      backdrop-filter: blur(8px);
    }

    .create-hub-lock-title {
      color: #f6d76f;
      font-size: 13px;
      font-weight: 800;
      letter-spacing: 0;
      margin-bottom: 5px;
    }

    .create-hub-lock-copy {
      color: rgba(255, 255, 255, 0.72);
      font-size: 12px;
      line-height: 1.45;
      max-width: 360px;
    }

    .create-hub-lock-btn {
      margin-top: 10px;
      border: 1px solid rgba(246, 215, 111, 0.35);
      border-radius: 7px;
      background: rgba(246, 215, 111, 0.12);
      color: #f6d76f;
      padding: 7px 11px;
      font-size: 12px;
      font-weight: 800;
      cursor: pointer;
    }

    .create-hub-card.is-locked {
      cursor: default;
      border-color: rgba(246, 215, 111, 0.24);
    }

    .create-hub-card.is-locked:hover {
      transform: none;
    }

    .create-hub-card.is-locked .create-hub-card-bg {
      filter: grayscale(0.4) brightness(0.68);
    }

    .create-hub-card.is-locked:hover .create-hub-card-bg {
      transform: none;
    }

    .create-hub-card.is-locked .create-hub-lock-panel {
      display: block;
    }

    /* ===================== MEMORY CARD ===================== */
    .memory-card {
      background: linear-gradient(135deg, rgba(232, 98, 26, 0.08), rgba(46, 189, 217, 0.06));
      border: 1px solid rgba(232, 98, 26, 0.3);
      border-radius: var(--radius-lg);
      margin: 12px 40px;
      overflow: hidden;
      transition: all 0.15s ease;
    }

    .memory-card:hover {
      border-color: rgba(232, 98, 26, 0.5);
      box-shadow: 0 4px 12px rgba(232, 98, 26, 0.1);
    }

    .memory-card-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 14px 16px;
      cursor: pointer;
      user-select: none;
      background: rgba(255, 255, 255, 0.01);
      transition: background 0.15s ease;
    }

    .memory-card-header:hover {
      background: rgba(255, 255, 255, 0.04);
    }

    .memory-card-title {
      font-size: 12px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      color: var(--accent);
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .memory-card-header-right {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .memory-card-edit-btn {
      font-size: 11px;
      font-weight: 600;
      color: var(--text-dim) !important;
      padding: 6px 12px;
      border-radius: 6px;
      background: rgba(232, 98, 26, 0.08);
      border: 1px solid rgba(232, 98, 26, 0.2);
      cursor: pointer;
      transition: all var(--transition);
      display: inline-block !important;
      visibility: visible !important;
    }

    .memory-card-edit-btn:hover {
      color: var(--accent) !important;
      border-color: var(--accent);
      background: rgba(232, 98, 26, 0.15);
    }

    .memory-card-delete-btn {
      font-size: 11px;
      font-weight: 600;
      color: #ffb4b4 !important;
      padding: 6px 12px;
      border-radius: 6px;
      background: rgba(224, 82, 82, 0.08);
      border: 1px solid rgba(224, 82, 82, 0.2);
      cursor: pointer;
      transition: all var(--transition);
      display: inline-block !important;
      visibility: visible !important;
    }

    .memory-card-delete-btn:hover {
      color: #ff6b6b !important;
      border-color: rgba(224, 82, 82, 0.4);
      background: rgba(224, 82, 82, 0.15);
    }

    .memory-card-toggle {
      color: var(--text-dim);
      font-size: 12px;
      transition: transform 0.2s;
    }

    .memory-card.open .memory-card-toggle {
      transform: rotate(180deg);
    }

    .memory-card-body {
      display: none;
      padding: 0 16px 14px;
    }

    .memory-card.open .memory-card-body {
      display: block;
    }

    .memory-card-content {
      font-size: 13px;
      color: var(--text-secondary);
      line-height: 1.6;
      white-space: pre-wrap;
      margin-bottom: 12px;
    }

    .memory-card-summary {
      font-size: 13px;
      font-weight: 600;
      color: var(--text-primary);
      line-height: 1.5;
      margin-bottom: 10px;
      padding: 8px 12px;
      background: rgba(255, 255, 255, 0.03);
      border-radius: 8px;
      border-left: 3px solid #a78bfa;
    }

    .memory-card-chars {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
    }

    .memory-card-char-tag {
      font-size: 11px;
      font-weight: 600;
      background: rgba(232, 98, 26, 0.12);
      color: var(--accent);
      border: 1px solid rgba(232, 98, 26, 0.25);
      padding: 3px 10px;
      border-radius: 12px;
      transition: all 0.15s ease;
    }

    .memory-card-char-tag:hover {
      background: rgba(232, 98, 26, 0.18);
      border-color: rgba(232, 98, 26, 0.4);
    }

    .memory-card.story-arc {
      background: linear-gradient(135deg, rgba(46, 189, 217, 0.08), rgba(46, 189, 217, 0.04));
      border-color: rgba(46, 189, 217, 0.35);
    }

    .memory-card.story-arc:hover {
      border-color: rgba(46, 189, 217, 0.6);
      box-shadow: 0 4px 12px rgba(46, 189, 217, 0.1);
    }

    .memory-card.story-arc .memory-card-title {
      color: var(--accent2);
    }

    .memory-card.archived-memory-card {
      opacity: 0.72;
      border-left-color: #6b7280;
    }

    .memory-card.archived-memory-card:hover {
      opacity: 0.95;
    }

    /* ===== MODERNIZED MEMORY TAB ===== */

    /* Side panel glassmorphism */
    .side-panel.glass-panel {
      background: rgba(12, 14, 20, 0.92);
      backdrop-filter: blur(32px) saturate(1.4);
      -webkit-backdrop-filter: blur(32px) saturate(1.4);
      border-left: 1px solid rgba(255, 255, 255, 0.08);
      box-shadow: -16px 0 64px rgba(0, 0, 0, 0.7), inset 1px 0 0 rgba(255, 255, 255, 0.06);
    }

    .side-panel-overlay.glass-overlay {
      background: rgba(0, 0, 0, 0.55);
      backdrop-filter: blur(6px);
      -webkit-backdrop-filter: blur(6px);
    }

    /* Memory tab header */
    .mem-tab-title-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 20px 20px 14px;
    }

    .mem-tab-title-group {
      display: flex;
      align-items: center;
      gap: 12px;
    }

    .mem-tab-icon {
      width: 40px;
      height: 40px;
      border-radius: 12px;
      background: linear-gradient(135deg, rgba(46, 189, 217, 0.2), rgba(168, 85, 247, 0.15));
      border: 1px solid rgba(46, 189, 217, 0.35);
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      box-shadow: 0 2px 12px rgba(46, 189, 217, 0.2);
    }

    .mem-tab-title {
      font-size: 17px;
      font-weight: 700;
      font-family: var(--font-display);
      letter-spacing: -0.3px;
      color: var(--text-primary);
    }

    .mem-tab-subtitle {
      font-size: 11px;
      color: rgba(255, 255, 255, 0.45);
      margin-top: 2px;
      letter-spacing: 0.3px;
    }

    /* Description box */
    .mem-tab-desc {
      margin: 0 16px 14px;
      padding: 12px 14px;
      background: linear-gradient(135deg, rgba(46, 189, 217, 0.1), rgba(168, 85, 247, 0.06));
      border: 1px solid rgba(46, 189, 217, 0.2);
      border-radius: 10px;
      font-size: 11.5px;
      color: rgba(255, 255, 255, 0.65);
      line-height: 1.6;
    }

    /* Stats bar glass effect */
    .mem-tab-stats {
      margin: 0 16px 14px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      background: linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
      border: 1px solid rgba(255, 255, 255, 0.1);
      border-radius: 14px;
      padding: 16px 18px;
      gap: 10px;
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    }

    .mem-stat-item {
      display: flex;
      flex-direction: column;
      gap: 5px;
      flex: 1;
    }

    .mem-stat-label {
      font-size: 9px;
      font-weight: 800;
      color: rgba(255, 255, 255, 0.4);
      text-transform: uppercase;
      letter-spacing: 1px;
    }

    .mem-stat-value {
      font-size: 20px;
      font-weight: 700;
      color: var(--text-primary);
      font-family: var(--font-display);
      line-height: 1;
    }

    .mem-stat-value.accent {
      color: var(--accent);
      text-shadow: 0 0 20px rgba(232, 98, 26, 0.3);
    }

    .mem-stat-divider {
      width: 1px;
      background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.12), transparent);
      margin: 2px 0;
      align-self: stretch;
    }

    .mem-stat-action {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      flex: 1.2;
      padding-left: 12px;
    }

    /* Summarise button */
    .mem-btn-summarise {
      display: flex;
      align-items: center;
      gap: 8px;
      background: linear-gradient(135deg, rgba(6, 182, 212, 0.18), rgba(6, 182, 212, 0.08));
      border: 1px solid rgba(6, 182, 212, 0.4);
      color: #22d3ee;
      padding: 9px 16px;
      border-radius: 10px;
      font-size: 11.5px;
      font-weight: 700;
      cursor: pointer;
      transition: all 0.2s ease;
      font-family: inherit;
      white-space: nowrap;
      box-shadow: 0 2px 12px rgba(6, 182, 212, 0.1);
    }

    .mem-btn-summarise:hover {
      background: linear-gradient(135deg, rgba(6, 182, 212, 0.28), rgba(6, 182, 212, 0.14));
      border-color: rgba(6, 182, 212, 0.6);
      box-shadow: 0 4px 20px rgba(6, 182, 212, 0.2);
      transform: translateY(-1px);
    }

    /* Action buttons row */
    .mem-tab-actions {
      display: flex;
      gap: 8px;
      padding: 0 16px 16px;
    }

    .mem-tab-btn {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      font-size: 11.5px;
      padding: 10px 8px;
      flex: 1;
      font-weight: 600;
      border-radius: 10px;
      cursor: pointer;
      transition: all 0.2s ease;
      font-family: inherit;
      border: 1.5px solid;
    }

    .mem-tab-btn.purple {
      background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(168, 85, 247, 0.05));
      color: #c084fc;
      border-color: rgba(168, 85, 247, 0.4);
      box-shadow: 0 2px 8px rgba(168, 85, 247, 0.08);
    }

    .mem-tab-btn.purple:hover {
      background: linear-gradient(135deg, rgba(168, 85, 247, 0.25), rgba(168, 85, 247, 0.1));
      border-color: rgba(168, 85, 247, 0.65);
      box-shadow: 0 4px 16px rgba(168, 85, 247, 0.18);
      transform: translateY(-1px);
    }

    .mem-tab-btn.orange {
      background: linear-gradient(135deg, rgba(232, 98, 26, 0.15), rgba(232, 98, 26, 0.05));
      color: #f97316;
      border-color: rgba(232, 98, 26, 0.4);
      box-shadow: 0 2px 8px rgba(232, 98, 26, 0.08);
    }

    .mem-tab-btn.orange:hover {
      background: linear-gradient(135deg, rgba(232, 98, 26, 0.25), rgba(232, 98, 26, 0.1));
      border-color: rgba(232, 98, 26, 0.65);
      box-shadow: 0 4px 16px rgba(232, 98, 26, 0.18);
      transform: translateY(-1px);
    }

    .mem-tab-btn.cyan {
      background: linear-gradient(135deg, rgba(46, 189, 217, 0.15), rgba(46, 189, 217, 0.05));
      color: #67e8f9;
      border-color: rgba(46, 189, 217, 0.4);
      box-shadow: 0 2px 8px rgba(46, 189, 217, 0.08);
    }

    .mem-tab-btn.cyan:hover {
      background: linear-gradient(135deg, rgba(46, 189, 217, 0.25), rgba(46, 189, 217, 0.1));
      border-color: rgba(46, 189, 217, 0.65);
      box-shadow: 0 4px 16px rgba(46, 189, 217, 0.18);
      transform: translateY(-1px);
    }

    /* Memory tab cards (inside the side panel) */
    .mem-tab-card {
      margin: 8px 14px;
      padding: 18px;
      background: linear-gradient(145deg, rgba(232, 98, 26, 0.1), rgba(46, 189, 217, 0.05));
      border: 1px solid rgba(232, 98, 26, 0.3);
      border-radius: 14px;
      transition: all 0.2s ease;
      position: relative;
      overflow: hidden;
      box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    }

    .mem-tab-card::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      height: 2px;
      background: linear-gradient(90deg, transparent, rgba(232, 98, 26, 0.6), rgba(46, 189, 217, 0.4), transparent);
      opacity: 0;
      transition: opacity 0.2s ease;
    }

    .mem-tab-card:hover {
      border-color: rgba(232, 98, 26, 0.5);
      box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(232, 98, 26, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.06);
      transform: translateY(-2px);
    }

    .mem-tab-card:hover::before {
      opacity: 1;
    }

    .mem-tab-card-title {
      font-size: 14px;
      font-weight: 700;
      color: var(--accent);
      line-height: 1.4;
      margin-bottom: 6px;
      text-shadow: 0 0 16px rgba(232, 98, 26, 0.2);
    }

    .mem-tab-card-date {
      font-size: 10px;
      color: rgba(255, 255, 255, 0.4);
      white-space: nowrap;
      background: rgba(255, 255, 255, 0.06);
      padding: 3px 9px;
      border-radius: 6px;
      border: 1px solid rgba(255, 255, 255, 0.06);
    }

    .mem-tab-card-content {
      font-size: 12.5px;
      color: rgba(255, 255, 255, 0.7);
      line-height: 1.7;
      word-break: break-word;
      max-height: 100px;
      overflow: hidden;
      position: relative;
      white-space: pre-wrap;
      padding-right: 8px;
      margin: 10px 0 10px;
    }

    .mem-tab-card-gradient {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      height: 36px;
      background: linear-gradient(transparent, rgba(18, 20, 28, 0.95));
      pointer-events: none;
    }

    .mem-tab-card-footer {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      padding-top: 6px;
    }

    .mem-tab-show-more {
      font-size: 11px;
      font-weight: 600;
      color: rgba(255, 255, 255, 0.45);
      background: none;
      border: none;
      cursor: pointer;
      padding: 0;
      transition: color 0.15s ease;
      display: flex;
      align-items: center;
      gap: 4px;
    }

    .mem-tab-show-more:hover {
      color: var(--accent);
    }

    .mem-tab-show-more .arrow {
      transition: transform 0.2s ease;
      font-size: 10px;
    }

    .mem-tab-card.expanded .mem-tab-show-more .arrow {
      transform: rotate(180deg);
    }

    .mem-tab-edit-btn {
      font-size: 11px;
      font-weight: 600;
      color: rgba(255, 255, 255, 0.5);
      padding: 6px 14px;
      border-radius: 8px;
      background: rgba(232, 98, 26, 0.12);
      border: 1px solid rgba(232, 98, 26, 0.25);
      cursor: pointer;
      transition: all 0.2s ease;
      font-family: inherit;
    }

    .mem-tab-edit-btn:hover {
      color: #fb923c;
      border-color: rgba(232, 98, 26, 0.5);
      background: rgba(232, 98, 26, 0.2);
      box-shadow: 0 2px 12px rgba(232, 98, 26, 0.12);
    }

    /* Staggered entrance animation */
    @keyframes memCardIn {
      from {
        opacity: 0;
        transform: translateY(8px);
      }
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    /* Custom scrollbar for memory tab */
    #memoryTabBody::-webkit-scrollbar {
      width: 5px;
    }

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

    #memoryTabBody::-webkit-scrollbar-thumb {
      background: rgba(255, 255, 255, 0.1);
      border-radius: 10px;
    }

    #memoryTabBody::-webkit-scrollbar-thumb:hover {
      background: rgba(255, 255, 255, 0.14);
    }

    /* Separator line */
    .mem-tab-separator {
      height: 1px;
      background: linear-gradient(90deg, transparent, var(--border), transparent);
      margin: 0;
    }

    /* Memory Edit Modal */
    #memEditModal-overlay {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 10120;
      background:
        radial-gradient(circle at 78% 18%, rgba(46, 189, 217, 0.08), transparent 22%),
        radial-gradient(circle at 22% 82%, rgba(232, 98, 26, 0.08), transparent 26%),
        rgba(4, 6, 12, 0.76);
      backdrop-filter: blur(12px) saturate(1.05);
      -webkit-backdrop-filter: blur(12px) saturate(1.05);
      align-items: center;
      justify-content: center;
      padding: 22px;
    }

    #memEditModal-overlay.open {
      display: flex;
    }

    #memEditModal {
      background: linear-gradient(180deg, rgba(20, 22, 30, 0.96), rgba(14, 16, 24, 0.98));
      border: 1px solid rgba(255, 255, 255, 0.09);
      border-radius: 18px;
      width: 760px;
      max-width: 94vw;
      max-height: 88vh;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      box-shadow:
        0 32px 90px rgba(0, 0, 0, 0.62),
        0 0 0 1px rgba(46, 189, 217, 0.04);
    }

    .memEditModal-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 24px 28px;
      border-bottom: 1px solid #2d2d2d;
      flex-shrink: 0;
    }

    .memEditModal-header h3 {
      font-family: var(--font-display);
      font-size: 20px;
      font-weight: 800;
      margin: 0;
      text-transform: uppercase;
      letter-spacing: 2px;
      color: #d8d8d8;
    }

    .memEditModal-body {
      flex: 1;
      overflow-y: auto;
      padding: 26px 32px 28px;
      display: flex;
      flex-direction: column;
      gap: 22px;
    }

    .memEditModal-field {
      display: flex;
      flex-direction: column;
      gap: 10px;
    }

    .memEditModal-label {
      font-size: 12px;
      font-weight: 800;
      text-transform: uppercase;
      letter-spacing: 1.8px;
      color: #a7adba;
    }

    .memEditModal-subtle {
      color: #777;
      font-size: 12px;
      font-weight: 500;
      text-transform: none;
      letter-spacing: 0;
      margin-left: 6px;
    }

    .memEditModal-body input,
    .memEditModal-body textarea {
      width: 100%;
      background: #1d1d1d;
      border: 1px solid #282828;
      border-radius: 12px;
      padding: 14px 16px;
      color: #f4f4f4;
      font-family: inherit;
      font-size: 15px;
      line-height: 1.65;
      transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    }

    .memEditModal-body input:focus,
    .memEditModal-body textarea:focus {
      border-color: rgba(255, 156, 0, 0.55);
      outline: none;
      box-shadow: 0 0 0 2px rgba(255, 156, 0, 0.08);
      background: #202020;
    }

    #memEditTitle {
      font-size: 18px;
      font-weight: 700;
    }

    #memEditContent {
      min-height: 360px;
      resize: vertical;
      white-space: pre-wrap;
    }

    .memEditModal-footer {
      padding: 18px 28px 22px;
      border-top: 1px solid #2d2d2d;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 14px;
      flex-shrink: 0;
    }

    .memEditModal-footer-actions {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .memEditModal-footer .btn-primary,
    .memEditModal-footer .btn-secondary,
    .memEditModal-footer .btn-danger {
      border-radius: 10px;
      font-size: 14px;
      padding: 10px 18px;
    }

    @media (max-width: 640px) {
      #memEditModal {
        width: 96vw;
        max-height: 92vh;
        border-radius: 14px;
      }

      .memEditModal-header {
        padding: 20px;
      }

      .memEditModal-body {
        padding: 20px;
      }

      .memEditModal-footer {
        padding: 16px 20px;
        flex-direction: column-reverse;
        align-items: stretch;
      }

      .memEditModal-footer-actions {
        width: 100%;
      }

      .memEditModal-footer-actions button,
      .memEditModal-footer>button {
        flex: 1;
        justify-content: center;
      }
    }

    /* ===================== CROP MODAL ===================== */
    #cropModal-overlay {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 10100;
      background: rgba(0, 0, 0, 0.75);
      backdrop-filter: blur(4px);
      align-items: center;
      justify-content: center;
    }

    #cropModal-overlay.open {
      display: flex;
    }

    #cropModal {
      background: var(--bg-panel);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      width: 520px;
      max-width: 95vw;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8);
    }

    .cropModal-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 14px 18px;
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
    }

    .cropModal-header h3 {
      font-family: var(--font-display);
      font-size: 13px;
      font-weight: 700;
      letter-spacing: 1px;
      text-transform: uppercase;
    }

    .cropModal-body {
      padding: 16px;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 12px;
      background: #0d0d0d;
    }

    #cropCanvas {
      border: 1px solid var(--border);
      border-radius: var(--radius);
      cursor: crosshair;
      max-width: 100%;
      display: block;
    }

    .cropModal-hint {
      font-size: 11px;
      color: var(--text-dim);
      text-align: center;
    }

    .cropModal-footer {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 10px;
      padding: 12px 18px;
      border-top: 1px solid var(--border);
      flex-shrink: 0;
    }

    .cropModal-footer-actions {
      display: flex;
      gap: 8px;
    }

    #cropAspectBtns {
      display: flex;
      gap: 6px;
    }

    .crop-aspect-btn {
      font-size: 11px;
      font-weight: 600;
      padding: 4px 10px;
      border-radius: 4px;
      border: 1px solid var(--border);
      background: var(--bg-card);
      color: var(--text-secondary);
      transition: background var(--transition), border-color var(--transition);
    }

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

    .crop-aspect-btn.active {
      border-color: var(--accent);
      color: var(--accent);
      background: rgba(232, 98, 26, 0.1);
    }

    /* ===================== PERSONA MODAL ===================== */
    #personaModal-overlay {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 400;
      background: rgba(0, 0, 0, 0.7);
      backdrop-filter: blur(3px);
      align-items: center;
      justify-content: center;
    }

    #personaModal-overlay.open {
      display: flex;
    }

    #personaModal {
      background: var(--bg-base);
      border: 1px solid var(--border);
      border-radius: 18px;
      width: 500px;
      max-width: 96vw;
      max-height: 92vh;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      box-shadow: 0 24px 64px rgba(0, 0, 0, 0.85);
    }

    .personaModal-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 22px 24px 0;
      flex-shrink: 0;
    }

    .personaModal-header h3 {
      font-size: 22px;
      font-weight: 700;
      color: var(--text-primary);
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .personaModal-header-help {
      width: 20px;
      height: 20px;
      border-radius: 50%;
      border: 1.5px solid var(--border-light);
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-dim);
      font-size: 11px;
      font-weight: 700;
      cursor: default;
      flex-shrink: 0;
    }

    .personaModal-close {
      width: 32px;
      height: 32px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-secondary);
      font-size: 20px;
      font-weight: 300;
      transition: background var(--transition);
      background: none;
      border: none;
      cursor: pointer;
    }

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

    .personaModal-body {
      flex: 1;
      overflow-y: auto;
      padding: 16px 24px 24px;
      display: flex;
      flex-direction: column;
      gap: 14px;
      align-items: center;
    }

    .persona-avatar-upload {
      width: 200px;
      height: 200px;
      border-radius: 12px;
      background: var(--bg-card);
      border: 2px solid var(--border-light);
      margin: 4px auto 0;
      overflow: hidden;
      cursor: pointer;
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-dim);
      transition: border-color var(--transition);
      flex-shrink: 0;
    }

    .persona-avatar-upload:hover {
      border-color: var(--accent);
    }

    .persona-avatar-upload img {
      width: 100%;
      height: 100%;
      object-fit: contain;
      background: transparent;
      border-radius: 12px;
    }

    .persona-avatar-overlay {
      position: absolute;
      inset: 0;
      border-radius: 12px;
      background: rgba(0, 0, 0, 0.5);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      opacity: 0;
      transition: opacity var(--transition);
      color: white;
      font-size: 11px;
      font-weight: 600;
      gap: 4px;
    }

    .persona-avatar-upload:hover .persona-avatar-overlay {
      opacity: 1;
    }

    .personaModal-fields {
      width: 100%;
      display: flex;
      flex-direction: column;
      gap: 12px;
    }

    .personaModal-fields input {
      background: var(--bg-input);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 12px 16px;
      font-size: 15px;
      color: var(--text-primary);
      width: 100%;
    }

    .personaModal-fields input:focus {
      border-color: var(--border-light);
      outline: none;
    }

    .personaModal-textarea-wrap {
      position: relative;
      width: 100%;
    }

    .personaModal-fields textarea {
      background: var(--bg-input);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 12px 16px;
      font-size: 13px;
      line-height: 1.7;
      resize: vertical;
      min-height: 160px;
      width: 100%;
      color: var(--text-primary);
    }

    .personaModal-fields textarea:focus {
      border-color: var(--border-light);
      outline: none;
    }

    .personaModal-charcount {
      position: absolute;
      bottom: 10px;
      right: 14px;
      font-size: 11px;
      color: var(--text-dim);
      pointer-events: none;
    }

    .personaModal-footer {
      display: flex;
      justify-content: flex-end;
      gap: 10px;
      padding: 14px 24px 18px;
      flex-shrink: 0;
    }

    .personaModal-footer .btn-secondary {
      padding: 10px 24px;
      border-radius: 20px;
      font-size: 14px;
    }

    .personaModal-footer .btn-primary {
      padding: 10px 28px;
      border-radius: 20px;
      font-size: 14px;
    }

    #charModal-overlay {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 350;
      background: rgba(0, 0, 0, 0.88);
      align-items: center;
      justify-content: center;
    }

    #charModal-overlay.open {
      display: flex;
    }

    #charModal {
      background: #111111;
      border: 1px solid rgba(255, 255, 255, 0.08);
      border-radius: 12px;
      width: 600px;
      max-width: 96vw;
      max-height: 85vh;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      outline: none;
      box-shadow: 0 24px 80px rgba(0, 0, 0, 0.9);
    }

    .charModal-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 24px 32px;
      border-bottom: 1px solid #2e2e2e;
      flex-shrink: 0;
      background: rgba(30, 30, 30, 0.3);
    }

    .charModal-header h3 {
      font-family: var(--font-display);
      font-size: 18px;
      font-weight: 700;
      color: #f0ece6;
      margin: 0;
    }

    .charModal-body {
      flex: 1;
      overflow-y: auto;
      padding: 32px;
      display: flex;
      flex-direction: column;
      gap: 24px;
    }

    .charModal-field label {
      display: block;
      font-size: 12px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 1.2px;
      color: #888888;
      margin-bottom: 10px;
    }

    .char-traits-tag-ui {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      align-items: center;
      min-height: 42px;
      background: var(--bg-input, #1a1a1a);
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 8px;
      padding: 7px 10px;
      cursor: text;
    }
    .char-trait-chip {
      display: flex;
      align-items: center;
      gap: 5px;
      background: rgba(46,189,217,0.12);
      border: 1px solid rgba(46,189,217,0.3);
      border-radius: 20px;
      padding: 3px 10px 3px 12px;
      font-size: 12px;
      font-weight: 600;
      color: var(--accent, #2ebdd9);
      white-space: nowrap;
    }
    .char-trait-chip button {
      background: none;
      border: none;
      color: inherit;
      opacity: 0.6;
      cursor: pointer;
      padding: 0;
      font-size: 14px;
      line-height: 1;
    }
    .char-trait-chip button:hover { opacity: 1; }
    #charTraitsTagInput {
      background: none;
      border: none;
      outline: none;
      color: var(--text-primary, #fff);
      font-size: 12px;
      min-width: 120px;
      flex: 1;
      padding: 3px 2px;
    }
    #charTraitsTagInput::placeholder { color: #555; }

    .charModal-footer {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 16px;
      padding: 20px 32px;
      border-top: 1px solid #2e2e2e;
      flex-shrink: 0;
    }

    /* Character card grid layout */
    #storyCharactersList {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
      gap: 16px;
    }

    .char-card {
      background: #1a1a1a;
      border: 1px solid #333333;
      border-left: 4px solid #2ebdd9;
      border-radius: 8px;
      padding: 0;
      display: flex;
      flex-direction: row;
      overflow: hidden;
      transition: all var(--transition);
      cursor: pointer;
      align-items: stretch;
    }

    .char-card:hover {
      border-color: #555555;
      background: #242424;
    }

    /* Character card type variants */
    .char-card.protagonist {
      border-left-color: #e8621a;
    }

    .char-card.antagonist {
      border-left-color: #d946a6;
    }

    .char-card.ally {
      border-left-color: #2ebdd9;
    }

    .char-card.neutral {
      border-left-color: #8b5cf6;
    }

    .char-card.mentor {
      border-left-color: #10b981;
    }

    .char-card.comic {
      border-left-color: #f59e0b;
    }

    .char-card-image {
      width: 120px;
      height: 140px;
      background: #242424;
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
    }

    .char-card-image img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .char-card-content {
      padding: 12px;
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 6px;
      justify-content: flex-start;
    }

    .char-card-badge {
      display: inline-block;
      padding: 2px 8px;
      background: rgba(46, 189, 217, 0.1);
      border: 1px solid rgba(46, 189, 217, 0.3);
      border-radius: 4px;
      font-size: 11px;
      font-weight: 600;
      color: var(--accent2);
      text-transform: uppercase;
      letter-spacing: 0.05em;
      width: fit-content;
      flex-shrink: 0;
    }

    .char-card-name {
      font-family: var(--font-display);
      font-size: 14px;
      font-weight: 700;
      color: var(--text-primary);
      line-height: 1.3;
    }

    .char-card-desc {
      font-size: 12px;
      color: var(--text-secondary);
      line-height: 1.4;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }

    /* ===================== STORY CARDS ===================== */
    .story-card {
      display: flex;
      border: 1px solid var(--border);
      border-left: 4px solid var(--accent2);
      border-radius: var(--radius-lg);
      background: #1a1a1d;
      padding: 10px 14px;
      overflow: hidden;
      transition: all var(--transition);
      position: relative;
      cursor: pointer;
    }

    .story-card[style*="row"] {
      gap: 16px;
      align-items: flex-start;
    }

    .story-card[style*="column"] {
      flex-direction: column;
      gap: 10px;
    }

    .story-card:hover {
      background: #1f1f23;
      border-color: var(--accent2);
      box-shadow: 0 2px 8px rgba(46, 189, 217, 0.1);
    }

    .story-card-image {
      width: 110px;
      height: 110px;
      min-width: 110px;
      background: rgba(46, 189, 217, 0.1);
      border-radius: 6px;
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 28px;
    }

    .story-card-image img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .story-card-content {
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 10px;
      min-width: 0;
      padding-top: 4px;
    }

    .story-card-header {
      display: flex;
      align-items: flex-start;
      flex-direction: column;
      gap: 12px;
    }

    .story-card-header-inline {
      display: flex;
      align-items: center;
      gap: 2px;
      margin-bottom: 8px;
      margin-top: 4px;
    }

    .story-card-title-section {
      flex: 1;
    }

    .story-card-type {
      font-size: 10px;
      font-weight: 600;
      padding: 2px 8px;
      border-radius: 3px;
      width: fit-content;
      border: 1px solid;
      margin-bottom: 2px;
    }

    .story-card-type.character {
      background: rgba(46, 189, 217, 0.15);
      color: #6ac9e0;
      border-color: rgba(46, 189, 217, 0.4);
    }

    .story-card-type.location {
      background: rgba(76, 175, 80, 0.15);
      color: #66bb6a;
      border-color: rgba(76, 175, 80, 0.4);
    }

    .story-card-type.faction {
      background: rgba(156, 39, 176, 0.15);
      color: #ba68c8;
      border-color: rgba(156, 39, 176, 0.4);
    }

    .story-card-type.item {
      background: rgba(233, 30, 99, 0.15);
      color: #ec407a;
      border-color: rgba(233, 30, 99, 0.4);
    }

    .story-card-type.event {
      background: rgba(255, 152, 0, 0.15);
      color: #ffb74d;
      border-color: rgba(255, 152, 0, 0.4);
    }

    .story-card-type.custom {
      background: rgba(158, 158, 158, 0.15);
      color: #bdbdbd;
      border-color: rgba(158, 158, 158, 0.4);
    }

    /* Type-based left border colors and soft gradients */
    .story-card.character {
      border-left-color: #6ac9e0;
      background: radial-gradient(circle at top left, rgba(106, 201, 224, 0.12), transparent 70%), #1a1a1d;
    }

    .story-card.location {
      border-left-color: #66bb6a;
      background: radial-gradient(circle at top left, rgba(102, 187, 106, 0.12), transparent 70%), #1a1a1d;
    }

    .story-card.faction {
      border-left-color: #ba68c8;
      background: radial-gradient(circle at top left, rgba(186, 104, 200, 0.12), transparent 70%), #1a1a1d;
    }

    .story-card.item {
      border-left-color: #ec407a;
      background: radial-gradient(circle at top left, rgba(236, 64, 122, 0.12), transparent 70%), #1a1a1d;
    }

    .story-card.event {
      border-left-color: #ffb74d;
      background: radial-gradient(circle at top left, rgba(255, 183, 77, 0.12), transparent 70%), #1a1a1d;
    }

    .story-card.custom {
      border-left-color: #bdbdbd;
      background: radial-gradient(circle at top left, rgba(189, 189, 189, 0.12), transparent 70%), #1a1a1d;
    }

    /* Section headers for type-based grouping */
    .story-card-section-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 12px 0;
      margin-bottom: 12px;
      margin-top: 24px;
      border-bottom: 1px solid var(--border);
      cursor: pointer;
      user-select: none;
    }

    .story-card-section-header:first-of-type {
      margin-top: 0;
    }

    .story-card-section-header svg {
      color: var(--text-dim);
    }

    .story-card-section-header.collapsed svg {
      transform: rotate(-90deg);
    }

    .story-card-section-title {
      font-size: 12px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.1em;
      margin: 0;
      color: var(--text-primary);
    }

    .story-card-section-count {
      font-size: 13px;
      color: var(--text-dim);
      font-weight: 500;
    }

    .story-card-section-icon {
      font-size: 16px;
      opacity: 0.6;
    }

    .story-card-section-grid {
      display: grid;
      grid-template-columns: 1fr;
      gap: 12px;
      margin-bottom: 16px;
    }

    @media (min-width: 768px) {
      .story-card-section-grid {
        grid-template-columns: repeat(2, 1fr);
      }
    }

    @media (min-width: 1024px) {
      .story-card-section-grid {
        grid-template-columns: repeat(3, 1fr);
      }
    }

    .story-card-name {
      font-size: 15px;
      font-weight: 600;
      color: var(--text-primary);
      margin: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .story-card-triggers {
      display: flex;
      flex-wrap: wrap;
      gap: 4px;
      margin-top: 4px;
    }

    .story-card-trigger-pill {
      font-size: 10px;
      font-weight: 600;
      padding: 2px 8px;
      border-radius: 10px;
      background: rgba(46, 189, 217, 0.2);
      color: var(--accent2);
      border: 1px solid rgba(46, 189, 217, 0.3);
    }

    .story-card-entry {
      font-size: 13px;
      color: #999;
      line-height: 1.4;
      overflow: hidden;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
    }

    .story-card-members {
      display: flex;
      flex-wrap: wrap;
      gap: 5px;
      margin: 0 0 8px;
    }

    .story-card-member-pill {
      font-size: 10px;
      color: rgba(255,255,255,0.7);
      border: 1px solid rgba(186,104,200,0.28);
      background: rgba(186,104,200,0.08);
      border-radius: 999px;
      padding: 2px 7px;
      line-height: 1.2;
    }

    .linked-character-picker {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
      gap: 10px;
      margin-top: 12px;
    }

    .linked-character-field > label {
      color: #ffffff;
    }

    .linked-character-field > label span {
      color: rgba(255,255,255,0.88);
      font-weight: 500;
    }

    .linked-character-option {
      display: flex;
      align-items: center;
      gap: 11px;
      min-height: 62px;
      border: 1px solid rgba(255,255,255,0.12);
      border-radius: 10px;
      background:
        linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.025));
      padding: 10px 12px;
      color: #ffffff;
      font-size: 13px;
      font-weight: 700;
      cursor: pointer;
      user-select: none;
      transition: border-color .16s ease, background .16s ease, transform .16s ease, box-shadow .16s ease;
    }

    .linked-character-option:hover {
      border-color: rgba(46,189,217,0.42);
      background:
        radial-gradient(circle at top left, rgba(46,189,217,0.12), transparent 58%),
        linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.035));
      transform: translateY(-1px);
    }

    .linked-character-option:has(input:checked) {
      border-color: rgba(232,98,26,0.74);
      background:
        radial-gradient(circle at top left, rgba(232,98,26,0.2), transparent 58%),
        linear-gradient(180deg, rgba(232,98,26,0.14), rgba(46,189,217,0.055));
      box-shadow: 0 0 0 1px rgba(232,98,26,0.22), 0 10px 28px rgba(232,98,26,0.08);
    }

    .linked-character-option input {
      appearance: none;
      width: 22px;
      height: 22px;
      border-radius: 7px;
      border: 1.5px solid rgba(255,255,255,0.55);
      background: rgba(0,0,0,0.28);
      display: grid;
      place-items: center;
      align-self: center;
      margin: 0 0 0 auto;
      flex-shrink: 0;
      transition: background .16s ease, border-color .16s ease, box-shadow .16s ease;
    }

    .linked-character-option input::before {
      content: "";
      width: 10px;
      height: 6px;
      border-left: 2px solid #ffffff;
      border-bottom: 2px solid #ffffff;
      transform: rotate(-45deg) scale(0);
      transform-origin: center;
      transition: transform .16s ease;
    }

    .linked-character-option input:checked {
      border-color: var(--accent);
      background: linear-gradient(135deg, var(--accent), #fa8211);
      box-shadow: 0 0 16px rgba(232,98,26,0.28);
    }

    .linked-character-option input:checked::before {
      transform: rotate(-45deg) scale(1);
    }

    .linked-character-avatar {
      width: 38px;
      height: 38px;
      border-radius: 10px;
      border: 1px solid rgba(255,255,255,0.12);
      background:
        radial-gradient(circle at 35% 25%, rgba(46,189,217,0.22), transparent 62%),
        rgba(255,255,255,0.055);
      color: #ffffff;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      overflow: hidden;
      font-size: 11px;
      font-weight: 900;
      letter-spacing: 0.2px;
    }

    .linked-character-avatar img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block;
    }

    .linked-character-option:has(input:checked) .linked-character-avatar {
      border-color: rgba(232,98,26,0.42);
      box-shadow: 0 0 18px rgba(232,98,26,0.18);
    }

    .linked-character-name {
      flex: 1;
      min-width: 0;
      color: #ffffff;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      line-height: 1.25;
    }

    .story-card-actions {
      display: flex;
      gap: 12px;
      margin-top: 8px;
    }

    .story-card-actions button {
      background: none;
      border: none;
      color: #999;
      cursor: pointer;
      font-size: 12px;
      padding: 0;
      font-weight: 500;
      transition: color var(--transition);
    }

    .story-card-actions button:hover {
      color: var(--accent2);
    }

    /* Active indicator in chat — shows which cards are currently injected */
    .story-card-active-badge {
      position: absolute;
      top: 8px;
      right: 8px;
      font-size: 9px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      padding: 2px 6px;
      border-radius: 3px;
      background: rgba(46, 189, 217, 0.15);
      color: var(--accent2);
      border: 1px solid rgba(46, 189, 217, 0.3);
    }

    /* Event Card styling — IF/THEN mechanics cards */
    .story-card.event-card {
      border-style: dashed;
      border-left-color: #ffb74d;
      opacity: 0.95;
    }

    .story-card.event-card:hover {
      background: rgba(255, 152, 0, 0.05);
    }

    .story-card.event-card .story-card-type.event {
      background: rgba(255, 152, 0, 0.25);
      border-color: rgba(255, 152, 0, 0.6);
    }

    /* Story card modal */
    #scModal-overlay {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 500;
      background: rgba(0, 0, 0, 0.8);
      backdrop-filter: blur(4px);
      align-items: center;
      justify-content: center;
    }

    #scModal-overlay.open {
      display: flex;
    }

    #scModal {
      background: rgba(14, 16, 20, 0.95);
      backdrop-filter: blur(24px);
      -webkit-backdrop-filter: blur(24px);
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 16px;
      width: 760px;
      max-width: 96vw;
      max-height: 88vh;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      box-shadow: 0 24px 64px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255,255,255,0.02) inset;
    }

    .scModal-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 20px 28px;
      border-bottom: 1px solid rgba(255,255,255,0.06);
      flex-shrink: 0;
      background: transparent;
    }

    .scModal-header h3 {
      font-family: var(--font-display);
      font-size: 16px;
      font-weight: 700;
      color: #f0ece6;
      margin: 0;
    }

    .scModal-body {
      flex: 1;
      overflow-y: auto;
      padding: 24px 28px;
      display: flex;
      flex-direction: column;
      gap: 20px;
    }

    .scModal-field label {
      display: block;
      font-size: 13px;
      font-weight: 600;
      color: #e2e8f0;
      margin-bottom: 8px;
    }

    .scModal-field label span {
      font-weight: 400;
      color: var(--text-dim);
      font-size: 12px;
    }

    /* Lore card entry footer */
    .sc-lore-entry-wrap textarea {
      border-bottom-left-radius: 8px;
      border-bottom-right-radius: 8px;
      margin-bottom: 0;
      background: rgba(0,0,0,0.2);
    }
    .sc-lore-entry-footer {
      display: flex;
      justify-content: flex-end;
      align-items: center;
      padding: 6px 4px 0 0;
      background: transparent;
      border: none;
      font-size: 11px;
      color: var(--text-dim);
    }

    /* Recall section */
    .sc-recall-section {
      margin-bottom: 12px;
    }
    .sc-recall-label {
      font-size: 13px;
      font-weight: 600;
      color: #e2e8f0;
      margin-bottom: 8px;
    }
    .sc-recall-pills {
      display: flex;
      flex-wrap: wrap;
      gap: 5px;
    }
    .sc-recall-pill {
      display: inline-flex;
      align-items: center;
      padding: 5px 12px;
      border-radius: 8px;
      border: 1px solid rgba(255,255,255,0.06);
      background: rgba(255,255,255,0.03);
      color: rgba(220,228,242,0.6);
      font-size: 11px;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.14s ease;
      font-family: inherit;
    }
    .sc-recall-pill:hover {
      background: rgba(249,115,22,0.08);
      border-color: rgba(249,115,22,0.24);
      color: #ffd8ba;
      transform: translateY(-1px);
    }
    .sc-recall-pill.active {
      background: rgba(249,115,22,0.16);
      border-color: rgba(249,115,22,0.42);
      color: #ffd4b0;
      font-weight: 700;
    }
    .sc-recall-pill.sc-recall-toggle {
      width: 100%;
      justify-content: center;
      padding: 7px 12px;
      font-size: 12px;
    }
    .sc-recall-pill.sc-recall-toggle::before {
      content: 'link_off';
      font-family: 'Material Symbols Outlined';
      font-size: 16px;
      margin-right: 6px;
      font-weight: 400;
      opacity: 0.5;
      transition: opacity 0.16s ease;
    }
    .sc-recall-pill.sc-recall-toggle.active::before {
      content: 'link';
      opacity: 1;
    }

    .sc-modal-menu button:hover {
      background-color: rgba(224, 82, 82, 0.1);
    }

    .sc-modal-menu button:active {
      background-color: rgba(224, 82, 82, 0.2);
    }

    .scModal-footer {
      padding: 16px 28px;
      border-top: 1px solid rgba(255,255,255,0.06);
      display: flex;
      justify-content: flex-end;
      align-items: center;
      flex-shrink: 0;
      gap: 12px;
      background: transparent;
    }

    #scModal input,
    #scModal textarea,
    #scModal select {
      background: rgba(0,0,0,0.2);
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 8px;
      padding: 10px 12px;
      color: #ffffff;
      font-size: 13px;
      transition: border-color 0.2s;
    }

    #scModal select {
      padding-right: 36px;
      background-position: right 14px center;
      opacity: 0.9;
    }

    #scModal select:hover {
      opacity: 1;
      border-color: #444;
    }

    #scModal input::placeholder,
    #scModal textarea::placeholder {
      color: #666666;
    }

    #scModal input:focus,
    #scModal textarea:focus,
    #scModal select:focus {
      border-color: var(--accent);
      box-shadow: 0 0 0 2px rgba(232, 98, 26, 0.15);
    }

    .scenario-detail-content {
      max-width: 1000px;
      margin: 0 auto;
      width: 100%;
      padding-bottom: 40px;
    }

    .scenario-detail-hero {
      width: 100%;
      height: 480px;
      position: relative;
      overflow: hidden;
      background: transparent;
      flex-shrink: 0;
      isolation: isolate;
      display: flex;
      align-items: stretch;
    }

    .scenario-detail-hero-img {
      position: absolute;
      top: 0; bottom: 0;
      right: 0;
      left: 38%;
      width: auto;
      background: linear-gradient(135deg, #1a0a0a 0%, #2a1a0a 50%, #1a0a1a 100%);
      transition: transform 1.4s ease, filter 0.9s ease;
      z-index: 0;
      -webkit-mask-image: linear-gradient(to right, transparent 0%, black 18%);
      mask-image: linear-gradient(to right, transparent 0%, black 18%);
    }

    .scenario-detail-hero-img img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      object-position: center 25%;
      display: block;
    }

    .scenario-detail-hero-overlay {
      position: absolute;
      inset: 0;
      z-index: 1;
      pointer-events: none;
      background:
        linear-gradient(to top,
          rgba(0,0,0,0.45) 0%,
          transparent 35%);
    }

    .scenario-detail-header {
      position: absolute;
      bottom: 0;
      left: 0;
      z-index: 3;
      padding: 0 60px 48px;
      width: 48%;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
    }

    .scenario-detail-title {
      font-family: var(--font-display);
      font-size: 34px;
      font-weight: 700;
      color: var(--text-primary);
      margin-bottom: 8px;
      text-shadow: 0 2px 16px rgba(0, 0, 0, 0.8);
      line-height: 1.1;
    }

    .scenario-detail-desc {
      font-size: 13px;
      color: var(--text-secondary);
      max-width: 580px;
      line-height: 1.6;
      margin-bottom: 14px;
    }

    .scenario-detail-creator {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-bottom: 10px;
    }

    .scenario-detail-creator-avatar {
      width: 24px;
      height: 24px;
      border-radius: 50%;
      background: var(--accent);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 11px;
      font-weight: 700;
      color: #fff;
      overflow: hidden;
      flex-shrink: 0;
    }

    .scenario-detail-creator-avatar img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .scenario-detail-creator-name {
      font-size: 12px;
      color: rgba(255,255,255,0.55);
      font-weight: 500;
      letter-spacing: 0.2px;
      transition: color 0.15s;
    }
    .scenario-detail-creator:hover .scenario-detail-creator-name {
      color: var(--accent);
    }

    .scenario-detail-tags {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-bottom: 18px;
    }

    .scenario-detail-tag {
      font-size: 11px;
      font-weight: 600;
      background: rgba(255, 255, 255, 0.08);
      border: 1px solid rgba(255, 255, 255, 0.14);
      color: var(--text-secondary);
      padding: 3px 10px;
      border-radius: 20px;
    }

    .scenario-detail-actions {
      display: flex;
      gap: 10px;
      align-items: center;
    }

    .btn-start-scenario {
      background: var(--accent);
      color: white;
      padding: 10px 24px;
      border-radius: var(--radius);
      font-size: 13px;
      font-weight: 700;
      display: flex;
      align-items: center;
      gap: 8px;
      transition: background var(--transition), transform var(--transition);
    }

    .btn-start-scenario:hover {
      background: #d0561a;
      transform: translateY(-1px);
    }

    .btn-customise {
      background: rgba(255, 255, 255, 0.08);
      color: var(--text-primary);
      padding: 10px 20px;
      border-radius: var(--radius);
      font-size: 13px;
      font-weight: 700;
      border: 1px solid rgba(255, 255, 255, 0.15);
      display: flex;
      align-items: center;
      gap: 8px;
      transition: background var(--transition);
    }

    .btn-customise:hover {
      background: rgba(255, 255, 255, 0.14);
    }

    .btn-cancel-detail {
      color: var(--text-dim);
      padding: 10px 12px;
      font-size: 13px;
      transition: color var(--transition);
    }

    .btn-cancel-detail:hover {
      color: var(--text-secondary);
    }

    /* Scenario detail top-right icon strip */
    .detail-corner-strip {
      position: absolute;
      top: 14px;
      right: 16px;
      z-index: 20;
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .detail-corner-btn {
      display: flex;
      align-items: center;
      gap: 5px;
      padding: 7px 10px;
      border-radius: 8px;
      background: rgba(0,0,0,0.55);
      backdrop-filter: blur(8px);
      border: 1px solid rgba(255,255,255,0.12);
      color: rgba(255,255,255,0.8);
      font-size: 11px;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.15s, color 0.15s;
    }

    .detail-corner-btn:hover {
      background: rgba(0,0,0,0.75);
      color: #fff;
    }

    .detail-corner-btn.liked {
      color: #f87171;
      border-color: rgba(248,113,113,0.4);
      background: rgba(0,0,0,0.6);
    }

    .detail-corner-btn.liked svg {
      fill: #f87171;
      stroke: #f87171;
    }

    .detail-corner-close {
      color: rgba(255,255,255,0.6);
    }

    .detail-corner-close:hover {
      color: #fff;
    }

    /* Folder manager modal */
    .folder-mgr-overlay {
      position: fixed; inset: 0; z-index: 10500;
      background: rgba(0,0,0,0.6);
      display: flex; align-items: center; justify-content: center;
    }

    .folder-mgr-modal {
      background: var(--bg-panel);
      border: 1px solid var(--border-light);
      border-radius: 16px;
      width: min(640px, 95vw);
      max-height: 80vh;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      box-shadow: 0 24px 60px rgba(0,0,0,0.6);
    }

    .folder-mgr-head {
      padding: 20px 24px 16px;
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
      flex-shrink: 0;
    }

    .folder-mgr-title { font-size: 18px; font-weight: 800; color: var(--text-primary); }
    .folder-mgr-sub  { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
    .folder-mgr-count { font-size: 12px; color: var(--text-dim); white-space: nowrap; margin-top: 4px; }

    .folder-mgr-status {
      min-height: 0;
      max-height: 0;
      overflow: hidden;
      padding: 0 24px;
      font-size: 12px;
      font-weight: 650;
      color: var(--text-dim);
      border-bottom: 1px solid transparent;
      transition: max-height 0.18s ease, padding 0.18s ease, border-color 0.18s ease;
    }

    .folder-mgr-status.show {
      max-height: 48px;
      padding: 10px 24px 12px;
      border-bottom-color: rgba(255,255,255,0.05);
    }

    .folder-mgr-status.success {
      color: #34d399;
    }

    .folder-mgr-status.info {
      color: #fbbf24;
    }

    .folder-mgr-body {
      flex: 1; overflow-y: auto; padding: 12px 16px;
    }

    .folder-mgr-row {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 12px 14px;
      border-radius: 10px;
      border: 1px solid var(--border);
      margin-bottom: 8px;
      background: var(--bg-card);
      cursor: default;
      transition: border-color 0.15s;
    }

    .folder-mgr-row:hover { border-color: var(--border-light); }
    .folder-mgr-row.dragging { opacity: 0.4; }

    .folder-mgr-drag {
      color: var(--text-dim);
      cursor: grab;
      flex-shrink: 0;
      padding: 2px;
    }

    .folder-mgr-badge {
      width: 28px; height: 28px;
      background: #c07d10;
      border-radius: 6px;
      display: flex; align-items: center; justify-content: center;
      font-size: 11px; font-weight: 800; color: #fff;
      flex-shrink: 0;
    }

    .folder-mgr-badge.auto { background: rgba(232,98,26,0.25); color: var(--accent); }

    .folder-mgr-info { flex: 1; min-width: 0; }
    .folder-mgr-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
    .folder-mgr-meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

    .folder-mgr-vis {
      background: none; border: none;
      color: #34d399; cursor: pointer; padding: 4px;
      transition: opacity 0.15s;
    }
    .folder-mgr-vis.hidden { color: var(--text-dim); }
    .folder-mgr-del {
      background: none; border: none;
      color: var(--text-dim); cursor: pointer; padding: 4px;
      transition: color 0.15s;
    }
    .folder-mgr-del:hover { color: #f87171; }

    .folder-mgr-foot {
      padding: 12px 16px;
      border-top: 1px solid var(--border);
      flex-shrink: 0;
    }

    .folder-mgr-create-btn {
      width: 100%;
      padding: 13px;
      border-radius: 10px;
      border: 1px dashed var(--border-light);
      background: rgba(232,98,26,0.05);
      color: var(--accent);
      font-size: 13px;
      font-weight: 700;
      cursor: pointer;
      display: flex; align-items: center; justify-content: center; gap: 8px;
      transition: background 0.15s;
    }
    .folder-mgr-create-btn:hover { background: rgba(232,98,26,0.12); }

    /* Add to folder modal */
    .add-folder-modal {
      background: var(--bg-panel);
      border: 1px solid var(--border-light);
      border-radius: 16px;
      width: min(560px, 95vw);
      max-height: 75vh;
      display: flex; flex-direction: column;
      overflow: hidden;
      box-shadow: 0 24px 60px rgba(0,0,0,0.6);
    }

    .add-folder-row {
      display: flex; align-items: center; gap: 12px;
      padding: 13px 16px;
      border-radius: 10px;
      border: 1px solid var(--border);
      margin-bottom: 8px;
      background: var(--bg-card);
      cursor: pointer;
      transition: all 0.15s;
    }
    .add-folder-row:hover, .add-folder-row.in-folder {
      border-color: var(--accent);
      background: rgba(232,98,26,0.06);
    }

    /* Settings folder card */
    .sm-folder-card {
      display: flex; align-items: center; gap: 14px;
      padding: 14px 16px;
      border-radius: 10px;
      border: 1px solid var(--border);
      background: var(--bg-card);
      cursor: pointer;
      transition: border-color 0.15s, background 0.15s;
      margin-top: 8px;
    }
    .sm-folder-card:hover { border-color: var(--border-light); background: rgba(255,255,255,0.04); }
    .sm-folder-card-icon { font-size: 28px; flex-shrink: 0; }
    .sm-folder-card-info { flex: 1; min-width: 0; }
    .sm-folder-card-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }
    .sm-folder-card-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

    .scenario-detail-body {
      padding: 28px 32px;
      display: flex;
      flex-direction: column;
      gap: 28px;
    }

    .scenario-detail-section-title {
      font-family: var(--font-display);
      font-size: 11px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 2px;
      color: var(--accent);
      margin-bottom: 14px;
    }

    .scenario-detail-intro {
      font-size: 13px;
      color: var(--text-secondary);
      line-height: 1.8;
    }
    .scenario-detail-intro img {
      max-width: 100% !important;
      height: auto !important;
      border-radius: 6px;
      display: block !important;
      margin: 8px auto !important;
    }

    .scenario-detail-chars {
      display: flex;
      flex-wrap: wrap;
      gap: 18px;
      justify-content: flex-start;
    }

    .detail-char-card {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 8px;
      width: 90px;
      cursor: default;
    }

    .detail-char-avatar {
      width: 80px;
      height: 80px;
      border-radius: 50%;
      overflow: hidden;
      flex-shrink: 0;
      background: var(--bg-input);
      border: 2px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-dim);
      transition: border-color var(--transition);
    }

    .detail-char-card:hover .detail-char-avatar {
      border-color: var(--accent);
    }

    .detail-char-avatar img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      object-position: center top;
    }

    .detail-char-name {
      font-family: var(--font-display);
      font-size: 10px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.8px;
      color: var(--text-primary);
      text-align: center;
      line-height: 1.3;
      word-break: break-word;
    }

    .detail-char-role {
      display: none;
    }

    .scenario-card[draggable="true"] {
      cursor: grab;
    }

    .scenario-card[draggable="true"]:active {
      cursor: grabbing;
    }

    .scenario-card.drag-over {
      outline: 2px dashed var(--accent);
      outline-offset: 2px;
      opacity: 0.7;
    }

    .scenario-card.dragging {
      opacity: 0.35;
    }

    #slashMenu {
      display: none;
      position: absolute;
      bottom: 100%;
      left: 0;
      right: 0;
      background: var(--bg-panel);
      border: 1px solid var(--border);
      border-radius: 12px;
      margin-bottom: 6px;
      box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
      overflow: hidden;
      z-index: 50;
    }

    #slashMenu.open {
      display: block;
    }

    .slash-cmd {
      padding: 12px 16px;
      cursor: pointer;
      border-bottom: 1px solid var(--border);
      transition: background var(--transition);
      display: flex;
      flex-direction: column;
      gap: 3px;
    }

    .slash-cmd:last-child {
      border-bottom: none;
    }

    .slash-cmd:hover,
    .slash-cmd.active {
      background: var(--bg-hover);
    }

    .slash-cmd-name {
      font-size: 13px;
      font-weight: 700;
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .slash-cmd-name span {
      font-family: var(--font-body);
      color: var(--text-primary);
    }

    .slash-cmd-arg {
      font-size: 11px;
      font-weight: 600;
      color: var(--accent);
      background: rgba(232, 98, 26, 0.12);
      border: 1px solid rgba(232, 98, 26, 0.25);
      padding: 1px 7px;
      border-radius: 6px;
    }

    .slash-cmd-desc {
      font-size: 12px;
      color: var(--text-dim);
    }

    /* ===================== MUSIC PLAYER ===================== */
    .floating-music-player {
      position: fixed;
      bottom: 20px;
      right: 20px;
      width: 280px;
      background: var(--bg-panel);
      border: 1px solid var(--border);
      border-radius: 12px;
      box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
      padding: 0 14px 14px;
      z-index: 9999;
      resize: both;
      overflow: hidden;
      min-width: 220px;
      min-height: 120px;
      max-width: 90vw;
      display: flex;
      flex-direction: column;
    }

    .music-drag-handle {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 8px 0;
      margin-bottom: 6px;
      cursor: grab;
      border-bottom: 1px solid rgba(255,255,255,0.05);
    }
    
    .music-drag-handle:active {
      cursor: grabbing;
    }

    .music-drag-title {
      font-size: 10px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 1.5px;
      color: var(--text-dim);
      pointer-events: none;
    }

    .music-close-btn {
      background: none;
      border: none;
      color: var(--text-dim);
      cursor: pointer;
      padding: 4px;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: color 0.2s;
    }

    .music-close-btn:hover {
      color: var(--text-main);
    }

    .music-player-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 6px;
    }

    .music-player-label {
      font-size: 8px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 1.5px;
      color: var(--text-dim);
      display: flex;
      align-items: center;
      gap: 4px;
    }

    .music-manage-btn {
      font-size: 9px;
      color: var(--text-dim);
      background: none;
      border: none;
      cursor: pointer;
      padding: 2px 5px;
      border-radius: 4px;
      transition: color var(--transition);
    }

    .music-manage-btn:hover { color: var(--text-primary); }

    .music-now-playing {
      font-size: 12px;
      font-weight: 600;
      color: var(--text-primary);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      margin-bottom: 10px;
      min-height: 16px;
    }

    .music-now-playing:not(.active) { color: var(--text-dim); font-weight: 400; }

    /* Seek bar */
    .music-seek-wrap {
      margin-bottom: 8px;
    }
    .music-seek-track {
      width: 100%;
      height: 3px;
      background: rgba(255,255,255,0.1);
      border-radius: 2px;
      position: relative;
      cursor: pointer;
    }
    .music-seek-fill {
      height: 100%;
      background: var(--accent);
      border-radius: 2px;
      width: 0%;
      pointer-events: none;
      transition: width 0.25s linear;
    }
    .music-seek-input {
      position: absolute;
      inset: -6px 0;
      opacity: 0;
      cursor: pointer;
      width: 100%;
    }
    .music-time-row {
      display: flex;
      justify-content: space-between;
      margin-top: 4px;
    }
    .music-time-row span {
      font-size: 9px;
      color: var(--text-dim);
    }

    /* Controls row */
    .music-controls {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0;
    }

    .music-btn {
      flex-shrink: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      background: none;
      border: none;
      color: rgba(255,255,255,0.45);
      cursor: pointer;
      padding: 6px;
      border-radius: 8px;
      transition: color 0.18s;
    }

    .music-btn:hover { color: #fff; }

    .music-btn.shuffle-btn.active {
      color: var(--accent);
      background: rgba(232,98,26,0.12);
    }

    .music-btn.play-btn {
      color: #fff;
      background: var(--accent);
      border-radius: 50%;
      width: 34px;
      height: 34px;
      padding: 0;
    }

    .music-btn.play-btn:hover { opacity: 0.88; }

    .music-vol-slider {
      width: 52px;
      height: 3px;
      accent-color: rgba(255,255,255,0.4);
      cursor: pointer;
      opacity: 0.6;
    }
    .music-vol-slider:hover { opacity: 1; }

    .error-bubble {
      padding: 14px 16px;
      background: linear-gradient(135deg, rgba(8,16,28,0.92), rgba(16,26,24,0.88));
      border: 1px solid rgba(46,189,217,0.24);
      border-left: 3px solid var(--accent2);
      border-radius: 12px;
      color: var(--text-primary);
      box-shadow: 0 16px 40px rgba(0,0,0,0.18);
    }

    #musicModal-overlay {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 400;
      background: rgba(0, 0, 0, 0.7);
      backdrop-filter: blur(3px);
      align-items: center;
      justify-content: center;
    }

    #musicModal-overlay.open {
      display: flex;
    }

    #musicModal {
      background: var(--bg-panel);
      border: 1px solid var(--border);
      border-radius: 16px;
      width: 480px;
      max-width: 95vw;
      max-height: 88vh;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      box-shadow: 0 24px 64px rgba(0, 0, 0, 0.85);
    }

    .musicModal-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 16px 20px 12px;
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
    }

    .musicModal-header h3 {
      font-family: var(--font-display);
      font-size: 14px;
      font-weight: 700;
    }

    .musicModal-body {
      flex: 1;
      overflow-y: auto;
      padding: 16px 20px;
      display: flex;
      flex-direction: column;
      gap: 10px;
    }

    .music-track-item {
      display: flex;
      align-items: center;
      gap: 10px;
      background: var(--bg-input);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 10px 12px;
    }

    .music-track-item.playing {
      border-color: var(--accent2);
      background: rgba(46, 189, 217, 0.06);
    }

    .music-track-name {
      flex: 1;
      font-size: 12px;
      font-weight: 600;
      color: var(--text-primary);
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .musicModal-footer {
      padding: 12px 20px;
      border-top: 1px solid var(--border);
      flex-shrink: 0;
    }

    .music-add-row {
      display: flex;
      gap: 8px;
      margin-top: 6px;
    }

    .music-add-row input {
      flex: 1;
      font-size: 12px;
    }

    .music-add-row button {
      flex-shrink: 0;
      font-size: 12px;
      padding: 7px 14px;
      border-radius: 8px;
    }

    /* ===================== SLIDE-IN RIGHT PANEL ===================== */
    .side-panel-overlay {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 850;
      background: rgba(0, 0, 0, 0.4);
    }

    .side-panel-overlay.open {
      display: block;
    }

    .side-panel {
      position: fixed;
      top: 0;
      right: 0;
      bottom: 0;
      z-index: 851;
      width: 380px;
      max-width: 95vw;
      background: var(--bg-panel);
      border-left: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      box-shadow: -8px 0 32px rgba(0, 0, 0, 0.5);
      transform: translateX(100%);
      transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
      overflow: hidden;
    }

    .side-panel.open {
      transform: translateX(0);
    }

    .side-panel-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 16px 20px;
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
    }

    .side-panel-header h3 {
      font-family: var(--font-display);
      font-size: 15px;
      font-weight: 700;
    }

    .side-panel-close {
      width: 30px;
      height: 30px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-secondary);
      font-size: 18px;
      background: none;
      border: none;
      cursor: pointer;
      transition: background var(--transition);
    }

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

    .side-panel-body {
      flex: 1;
      overflow-y: auto;
      overflow-x: hidden;
      -webkit-overflow-scrolling: touch;
    }

    /* Memory bank panel cards */
    .mem-bank-card {
      padding: 14px 20px;
      border-bottom: 1px solid var(--border);
      cursor: pointer;
      transition: background var(--transition);
    }

    .mem-bank-card:hover {
      background: var(--bg-hover);
    }

    .mem-bank-card-title {
      font-size: 13px;
      font-weight: 700;
      color: var(--accent);
      margin-bottom: 4px;
    }

    .mem-bank-card-content {
      font-size: 12px;
      color: var(--text-secondary);
      line-height: 1.5;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }

    .mem-bank-card-chars {
      display: flex;
      flex-wrap: wrap;
      gap: 4px;
      margin-top: 6px;
    }

    .mem-bank-card-char {
      font-size: 10px;
      font-weight: 600;
      background: rgba(232, 98, 26, 0.1);
      color: var(--accent);
      border: 1px solid rgba(232, 98, 26, 0.2);
      padding: 1px 7px;
      border-radius: 10px;
    }

    .mem-bank-empty {
      padding: 40px 20px;
      text-align: center;
      font-size: 13px;
      color: var(--text-dim);
      line-height: 1.7;
    }

    #memoryPanel-overlay {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 1200;
      background: rgba(0, 0, 0, 0.7);
      backdrop-filter: blur(3px);
      align-items: center;
      justify-content: center;
    }

    #memoryPanel-overlay.open {
      display: flex;
    }

    #memoryPanel {
      background: var(--bg-panel);
      border: 1px solid var(--border);
      border-radius: 16px;
      width: 520px;
      max-width: 95vw;
      max-height: 88vh;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      box-shadow: 0 24px 64px rgba(0, 0, 0, 0.85);
    }

    .memoryPanel-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 18px 20px 14px;
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
    }

    .memoryPanel-header h3 {
      font-family: var(--font-display);
      font-size: 15px;
      font-weight: 700;
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .memoryPanel-header h3 svg {
      color: #a78bfa;
    }

    .memoryPanel-body {
      flex: 1;
      overflow-y: auto;
      padding: 16px 20px;
      display: flex;
      flex-direction: column;
      gap: 18px;
    }

    .memoryPanel-chronicle {
      background: rgba(167, 139, 250, 0.05);
      border: 1px solid rgba(167, 139, 250, 0.15);
      border-radius: 12px;
      padding: 16px;
      margin-bottom: 4px;
    }

    .chronicle-title {
      font-size: 11px;
      font-weight: 700;
      color: #a78bfa;
      text-transform: uppercase;
      letter-spacing: 1px;
      margin-bottom: 8px;
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .chronicle-content {
      font-size: 13px;
      color: var(--text-primary);
      line-height: 1.6;
      white-space: pre-wrap;
      font-style: italic;
    }

    .memoryPanel-section-label {
      font-size: 10px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 1px;
      color: var(--text-dim);
      margin-bottom: 8px;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    .memory-fact-list {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .memory-fact-item {
      display: flex;
      align-items: center;
      gap: 8px;
      background: var(--bg-input);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 7px 10px;
      font-size: 12px;
      color: var(--text-secondary);
    }

    .memory-fact-item.pinned {
      border-color: #a78bfa44;
      background: rgba(167, 139, 250, 0.07);
    }

    .memory-fact-item input[type="text"] {
      flex: 1;
      background: transparent;
      border: none;
      padding: 0;
      font-size: 12px;
      color: var(--text-primary);
      outline: none;
    }

    .memory-fact-pin-btn {
      width: 22px;
      height: 22px;
      border-radius: 4px;
      flex-shrink: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-dim);
      background: none;
      border: none;
      cursor: pointer;
      transition: color var(--transition);
    }

    .memory-fact-pin-btn.active {
      color: #a78bfa;
    }

    .memory-fact-pin-btn:hover {
      color: #a78bfa;
    }

    .memory-fact-del-btn {
      width: 22px;
      height: 22px;
      border-radius: 4px;
      flex-shrink: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-dim);
      background: none;
      border: none;
      cursor: pointer;
      transition: color var(--transition);
    }

    .memory-fact-del-btn:hover {
      color: #e05252;
    }

    .memory-add-row {
      display: flex;
      gap: 8px;
      margin-top: 4px;
    }

    .memory-add-row input {
      flex: 1;
      font-size: 12px;
      padding: 7px 10px;
      border-radius: 8px;
    }

    .memory-add-row button {
      padding: 7px 14px;
      border-radius: 8px;
      font-size: 12px;
      flex-shrink: 0;
    }

    .memory-extract-btn {
      width: 100%;
      padding: 9px;
      border-radius: 8px;
      font-size: 12px;
      font-weight: 600;
      background: rgba(167, 139, 250, 0.12);
      border: 1px solid rgba(167, 139, 250, 0.3);
      color: #a78bfa;
      cursor: pointer;
      transition: background var(--transition);
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
    }

    .memory-extract-btn:hover {
      background: rgba(167, 139, 250, 0.22);
    }

    .memory-extract-btn:disabled {
      opacity: 0.5;
      cursor: default;
    }

    .memoryPanel-footer {
      padding: 12px 20px;
      border-top: 1px solid var(--border);
      display: flex;
      justify-content: flex-end;
      gap: 8px;
      flex-shrink: 0;
    }

    .memory-facts-badge {
      display: none;
      position: absolute;
      top: -4px;
      right: -4px;
      width: 16px;
      height: 16px;
      border-radius: 50%;
      background: #a78bfa;
      color: white;
      font-size: 9px;
      font-weight: 700;
      align-items: center;
      justify-content: center;
    }

    #charProfileModal-overlay {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 400;
      background: rgba(0, 0, 0, 0.75);
      backdrop-filter: blur(4px);
      align-items: center;
      justify-content: center;
    }

    #charProfileModal-overlay.open {
      display: flex;
    }

    #charProfileModal {
      background: var(--bg-panel);
      border: 1px solid var(--border);
      border-radius: 18px;
      width: 420px;
      max-width: 95vw;
      max-height: 88vh;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      box-shadow: 0 24px 64px rgba(0, 0, 0, 0.85);
    }

    .charProfile-hero {
      width: 100%;
      height: 180px;
      background: linear-gradient(135deg, #1a0a2e, #2d1b4e);
      position: relative;
      flex-shrink: 0;
      display: flex;
      align-items: flex-end;
      padding: 0 24px 16px;
      gap: 18px;
    }

    .charProfile-hero-img {
      width: 90px;
      height: 90px;
      border-radius: 50%;
      border: 3px solid var(--accent);
      overflow: hidden;
      flex-shrink: 0;
      background: var(--bg-card);
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-dim);
      margin-bottom: -30px;
      box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    }

    .charProfile-hero-img img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .charProfile-hero-info {
      padding-bottom: 4px;
    }

    .charProfile-name {
      font-family: var(--font-display);
      font-size: 17px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 1.5px;
      color: var(--text-primary);
      text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
    }

    .charProfile-role {
      font-size: 12px;
      color: var(--accent);
      font-weight: 600;
      margin-top: 3px;
    }

    .charProfile-close {
      position: absolute;
      top: 12px;
      right: 14px;
      width: 30px;
      height: 30px;
      border-radius: 50%;
      background: rgba(0, 0, 0, 0.4);
      border: none;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-secondary);
      font-size: 16px;
      transition: background var(--transition);
    }

    .charProfile-close:hover {
      background: rgba(0, 0, 0, 0.7);
      color: white;
    }

    .charProfile-body {
      flex: 1;
      overflow-y: auto;
      padding: 40px 24px 24px;
      display: flex;
      flex-direction: column;
      gap: 14px;
    }

    .charProfile-section-label {
      font-size: 10px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 1px;
      color: var(--text-dim);
      margin-bottom: 5px;
    }

    .charProfile-text {
      font-size: 13px;
      color: var(--text-secondary);
      line-height: 1.7;
    }

    .charProfile-traits {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
    }

    .charProfile-trait {
      font-size: 11px;
      font-weight: 600;
      background: rgba(232, 98, 26, 0.12);
      color: var(--accent);
      border: 1px solid rgba(232, 98, 26, 0.3);
      padding: 3px 10px;
      border-radius: 20px;
    }

    #view-create {
      overflow-y: auto;
    }

    .creator-content {
      padding: 32px 60px;
      max-width: 1400px;
      margin: 0 auto;
      width: 100%;
    }

    .creator-title {
      font-family: var(--font-display);
      font-size: 22px;
      font-weight: 700;
      margin-bottom: 40px;
      text-align: center;
      display: flex;
      align-items: center;
      gap: 16px;
      color: var(--text-primary);
    }

    .creator-title::before,
    .creator-title::after {
      content: '';
      flex: 1;
      height: 1px;
      background: var(--border);
    }

    .form-section {
      background: none;
      border: none;
      border-radius: 0;
      padding: 0;
      margin-bottom: 40px;
    }

    .form-section-title {
      font-family: var(--font-display);
      font-size: 14px;
      font-weight: 700;
      color: var(--text-primary);
      text-transform: uppercase;
      letter-spacing: 1.5px;
      margin-bottom: 24px;
      text-align: left;
      display: flex;
      align-items: center;
      gap: 12px;
      background: linear-gradient(90deg, rgba(232,98,26,0.12) 0%, rgba(232,98,26,0.04) 35%, transparent 70%);
      border-left: 4px solid #e8621a;
      box-shadow: inset 3px 0 16px rgba(232,98,26,0.06);
      padding: 18px 24px;
      margin-left: -60px;
      margin-right: -60px;
      padding-left: 60px;
      padding-right: 60px;
    }

    .form-section-title.blue {
      border-left-color: #3b82f6;
      background: linear-gradient(90deg, rgba(59,130,246,0.12) 0%, rgba(59,130,246,0.04) 35%, transparent 70%);
      box-shadow: inset 3px 0 16px rgba(59,130,246,0.06);
    }

    .form-section-title.green {
      border-left-color: #10b981;
      background: linear-gradient(90deg, rgba(16,185,129,0.12) 0%, rgba(16,185,129,0.04) 35%, transparent 70%);
      box-shadow: inset 3px 0 16px rgba(16,185,129,0.06);
    }

    .form-section-title.purple {
      border-left-color: #8b5cf6;
      background: linear-gradient(90deg, rgba(139,92,246,0.12) 0%, rgba(139,92,246,0.04) 35%, transparent 70%);
      box-shadow: inset 3px 0 16px rgba(139,92,246,0.06);
    }

    .form-section-title.amber {
      border-left-color: #f59e0b;
      background: linear-gradient(90deg, rgba(245,158,11,0.12) 0%, rgba(245,158,11,0.04) 35%, transparent 70%);
      box-shadow: inset 3px 0 16px rgba(245,158,11,0.06);
    }

    .form-section-title.teal {
      border-left-color: #14b8a6;
      background: linear-gradient(90deg, rgba(20,184,166,0.12) 0%, rgba(20,184,166,0.04) 35%, transparent 70%);
      box-shadow: inset 3px 0 16px rgba(20,184,166,0.06);
    }

    .form-section-title::before,
    .form-section-title::after {
      display: none;
    }

    .inline-doc-link {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 5px;
      margin-left: auto;
      padding: 5px 10px;
      border-radius: 999px;
      border: 1px solid rgba(232, 98, 26, 0.34);
      background: rgba(232, 98, 26, 0.1);
      color: #ff8a3d;
      font-family: var(--font-body);
      font-size: 10px;
      font-weight: 800;
      line-height: 1;
      letter-spacing: 0.7px;
      text-transform: uppercase;
      text-decoration: none;
      white-space: nowrap;
      transition: border-color 0.16s, background 0.16s, color 0.16s, transform 0.16s;
    }

    .inline-doc-link::before {
      content: "?";
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 13px;
      height: 13px;
      border-radius: 50%;
      background: rgba(255, 255, 255, 0.1);
      color: currentColor;
      font-size: 9px;
      font-weight: 900;
      line-height: 1;
    }

    .inline-doc-link:hover {
      border-color: rgba(255, 138, 61, 0.62);
      background: rgba(232, 98, 26, 0.18);
      color: #fff;
      transform: translateY(-1px);
    }

    .modal-doc-link {
      margin: 7px 0 0;
    }

    .settings-title-row {
      display: flex;
      align-items: center;
      gap: 12px;
      margin: 0 0 24px;
    }

    .settings-title-row .sm-section-title {
      margin: 0;
    }

    .form-row {
      display: flex;
      gap: 16px;
      margin-bottom: 14px;
    }

    .form-col {
      flex: 1;
    }

    .form-group {
      margin-bottom: 20px;
    }

    .form-label {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 13px;
      font-weight: 700;
      color: var(--text-secondary);
      margin-bottom: 8px;
    }

    .form-label .info-icon,
    .info-icon {
      width: 15px;
      height: 15px;
      border-radius: 50%;
      background: var(--bg-input);
      border: 1px solid var(--border);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 9px;
      color: var(--text-dim);
      cursor: help;
      flex-shrink: 0;
      font-style: normal;
      font-weight: 700;
      line-height: 1;
      vertical-align: middle;
    }

    .info-icon::after {
      content: 'i';
    }

    /* Info-icon tooltip (data-tip attribute) */
    .info-icon[data-tip] {
      position: relative;
    }
    .info-icon[data-tip]::before {
      content: attr(data-tip);
      position: absolute;
      bottom: calc(100% + 7px);
      left: 50%;
      transform: translateX(-50%);
      background: #222428;
      color: var(--text-secondary);
      font-size: 11px;
      font-weight: 400;
      font-style: normal;
      line-height: 1.5;
      white-space: normal;
      width: 210px;
      padding: 7px 10px;
      border-radius: 7px;
      border: 1px solid var(--border-light);
      pointer-events: none;
      opacity: 0;
      transition: opacity 0.15s;
      z-index: 600;
      box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    }
    .info-icon[data-tip]:hover::before { opacity: 1; }
    .info-icon[data-tip]:hover::after  { content: 'i'; } /* keep the i */

    /* Comment section */
    .scenario-comments { padding: 0 24px 32px; max-width: 760px; margin: 0 auto; }
    .scenario-comments-title { font-size: 14px; font-weight: 700; color: var(--text-primary); margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
    .comment-input-row { display: flex; gap: 10px; margin-bottom: 20px; }
    .comment-input-row textarea { flex: 1; resize: none; height: 68px; font-size: 13px; border-radius: 10px; padding: 10px 13px; }
    .comment-input-row .btn-primary { align-self: flex-end; padding: 10px 18px; font-size: 13px; white-space: nowrap; }
    .comment-list { display: flex; flex-direction: column; gap: 12px; }
    .comment-card { background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
    .comment-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
    .comment-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--bg-input); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--text-dim); overflow: hidden; flex-shrink: 0; }
    .comment-avatar img { width: 100%; height: 100%; object-fit: cover; }
    .comment-author { font-size: 13px; font-weight: 600; color: var(--text-primary); }
    .comment-date { font-size: 11px; color: var(--text-dim); margin-left: auto; }
    .comment-body { font-size: 13px; color: var(--text-secondary); line-height: 1.6; word-break: break-word; }
    .comment-report-btn { background: none; border: none; color: var(--text-dim); font-size: 11px; cursor: pointer; padding: 4px 0; margin-top: 6px; opacity: 0.6; transition: opacity 0.15s; }
    .comment-report-btn:hover { opacity: 1; color: #e05252; }
    .comment-delete-btn { background: none; border: none; color: #e05252; font-size: 11px; cursor: pointer; padding: 4px 0; margin-top: 6px; margin-left: 10px; opacity: 0.6; transition: opacity 0.15s; }
    .comment-delete-btn:hover { opacity: 1; }
    .sc-like-btn { position:absolute; bottom:10px; right:10px; background:rgba(0,0,0,0.55); border:1px solid rgba(255,255,255,0.15); border-radius:20px; color:#fff; font-size:12px; cursor:pointer; padding:4px 9px; display:flex; align-items:center; gap:5px; backdrop-filter:blur(4px); transition:background 0.15s,color 0.15s; z-index:3; }
    .sc-like-btn:hover,.sc-like-btn.liked { background:rgba(229,62,62,0.7); border-color:rgba(229,62,62,0.5); color:#fff; }
    .sc-like-btn.liked svg { fill:#fff; }
    .comments-empty { color: var(--text-dim); font-size: 13px; text-align: center; padding: 24px 0; }

    .char-count {
      font-size: 10px;
      color: var(--text-dim);
      text-align: right;
      margin-top: 3px;
    }

    .image-upload-area {
      width: 100%;
      aspect-ratio: 16 / 9;
      height: auto;
      background: var(--bg-input);
      border: 2px dashed var(--border);
      border-radius: var(--radius-lg);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: border-color var(--transition);
      gap: 8px;
      color: var(--text-dim);
      font-size: 12px;
      text-align: center;
      overflow: hidden;
      position: relative;
      flex-shrink: 0;
    }

    .image-upload-area:hover {
      border-color: var(--accent);
      color: var(--text-secondary);
    }

    #scenarioImgUpload:has(#scenarioImgPreview[style*="block"]) {
      border-style: solid;
      border-color: rgba(255,255,255,0.14);
    }

    #scenarioImgUpload:has(#scenarioImgPreview[style*="block"]) > svg,
    #scenarioImgUpload:has(#scenarioImgPreview[style*="block"]) > span {
      display: none;
    }

    .image-upload-area img {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .image-upload-area input[type=file] {
      position: absolute;
      inset: 0;
      opacity: 0;
      cursor: pointer;
    }

    #scenarioImgUpload {
      aspect-ratio: 16 / 9;
      height: auto;
    }

    .image-upload-actions {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .btn-upload-action {
      background: var(--bg-input);
      border: 1px solid var(--border);
      color: var(--text-secondary);
      padding: 8px 14px;
      border-radius: var(--radius);
      font-size: 12px;
      font-weight: 600;
      display: flex;
      align-items: center;
      gap: 8px;
      transition: background var(--transition), border-color var(--transition);
      cursor: pointer;
    }

    .btn-upload-action:hover {
      background: var(--bg-hover);
      border-color: var(--border-light);
      color: var(--text-primary);
    }

    .rich-toolbar {
      display: flex;
      align-items: center;
      gap: 2px;
      background: var(--bg-input);
      border: 1px solid var(--border);
      border-bottom: none;
      border-radius: var(--radius) var(--radius) 0 0;
      padding: 4px 8px;
      flex-wrap: wrap;
    }

    .rich-toolbar button {
      width: 24px;
      height: 24px;
      border-radius: 3px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 12px;
      font-weight: 700;
      color: var(--text-secondary);
      transition: background var(--transition);
    }

    .rich-toolbar button:hover {
      background: var(--bg-hover);
      color: var(--text-primary);
    }

    .rich-toolbar .divider {
      width: 1px;
      height: 16px;
      background: var(--border);
      margin: 0 4px;
    }

    .rich-textarea h3 {
      font-size: 15px;
      font-weight: 700;
      margin: 6px 0 4px;
      color: var(--text-primary);
    }

    .rich-textarea blockquote {
      border-left: 3px solid var(--accent);
      padding-left: 10px;
      margin: 4px 0;
      color: var(--text-secondary);
      font-style: italic;
    }

    .rich-textarea ul {
      padding-left: 18px;
      margin: 4px 0;
    }

    .rich-textarea ul li {
      margin: 2px 0;
    }

    .rich-textarea a {
      color: var(--accent2);
      text-decoration: underline;
    }

    .tag-btn-group {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 4px;
    }

    .tag-btn {
      padding: 6px 14px;
      border-radius: 20px;
      font-size: 12px;
      font-weight: 600;
      background: var(--bg-input);
      border: 1px solid var(--border);
      color: var(--text-secondary);
      cursor: pointer;
      transition: background var(--transition), border-color var(--transition), color var(--transition);
      user-select: none;
    }

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

    .tag-btn.selected {
      background: rgba(232, 98, 26, 0.15);
      border-color: var(--accent);
      color: var(--accent);
    }

    .creator-bottom-actions {
      display: flex;
      justify-content: flex-end;
      gap: 10px;
      padding: 14px 0 2px;
    }

    /* ── Tag Picker ──────────────────────────────────────── */
    .tag-picker-wrap { position: relative; }

    .tag-selected-pills {
      display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; min-height: 0;
    }

    .tag-selected-pill {
      display: inline-flex; align-items: center; gap: 5px;
      padding: 4px 10px 4px 12px;
      background: rgba(232,98,26,0.14); border: 1px solid var(--accent);
      border-radius: 20px; font-size: 12px; font-weight: 600; color: var(--accent);
      cursor: default;
    }

    .tag-selected-pill-x {
      display: flex; align-items: center; justify-content: center;
      width: 14px; height: 14px; border-radius: 50%;
      background: rgba(232,98,26,0.25); font-size: 11px; cursor: pointer;
      line-height: 1; color: var(--accent);
    }
    .tag-selected-pill-x:hover { background: var(--accent); color: #fff; }

    .tag-picker-trigger {
      display: inline-flex; align-items: center; gap: 6px;
      padding: 7px 14px; border-radius: 8px;
      background: var(--bg-input); border: 1px dashed var(--border);
      color: var(--text-dim); font-size: 12px; cursor: pointer;
      transition: border-color 0.15s, color 0.15s;
    }
    .tag-picker-trigger:hover, .tag-picker-trigger.open {
      border-color: var(--accent); color: var(--accent);
    }

    .tag-picker-popup {
      position: absolute; top: calc(100% + 6px); left: 0;
      width: 480px; max-width: 95vw;
      background: var(--bg-secondary, #1a1a2e); border: 1px solid var(--border);
      border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,0.6);
      z-index: 300; display: none;
      flex-direction: column; overflow: hidden;
    }
    .tag-picker-popup.open { display: flex; }

    .tag-picker-search-row {
      padding: 10px 12px; border-bottom: 1px solid var(--border);
      display: flex; align-items: center; gap: 8px;
    }

    .tag-picker-search {
      flex: 1; background: none; border: none; outline: none;
      color: var(--text-primary); font-size: 13px;
    }
    .tag-picker-search::placeholder { color: var(--text-dim); }

    .tag-picker-body {
      display: flex; height: 300px; overflow: hidden;
    }

    .tag-picker-cats {
      width: 130px; flex-shrink: 0;
      border-right: 1px solid var(--border);
      overflow-y: auto; padding: 6px 0;
    }

    .tag-picker-cat-btn {
      display: block; width: 100%;
      padding: 8px 12px; text-align: left;
      font-size: 11px; font-weight: 600; color: var(--text-dim);
      background: none; border: none; cursor: pointer;
      transition: background 0.1s, color 0.1s;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .tag-picker-cat-btn:hover { background: rgba(255,255,255,0.04); color: var(--text-primary); }
    .tag-picker-cat-btn.active { color: var(--accent); background: rgba(232,98,26,0.08); }

    .tag-picker-list {
      flex: 1; overflow-y: auto; padding: 8px;
      display: flex; flex-direction: column; gap: 2px;
    }

    .tag-picker-item {
      display: flex; align-items: center; gap: 8px;
      padding: 7px 10px; border-radius: 6px;
      cursor: pointer; font-size: 12px; color: var(--text-secondary);
      transition: background 0.1s;
    }
    .tag-picker-item:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
    .tag-picker-item.selected { background: rgba(232,98,26,0.1); color: var(--accent); }
    .tag-picker-item.disabled { opacity: 0.35; cursor: not-allowed; }

    .tag-picker-item-emoji { font-size: 14px; width: 20px; text-align: center; flex-shrink: 0; }

    .tag-picker-footer {
      padding: 8px 12px; border-top: 1px solid var(--border);
      font-size: 11px; color: var(--text-dim);
    }

    /* ===================== CHAT VIEW ===================== */
    #view-chat {
      flex-direction: column;
    }

    #view-chat.active {
      display: flex;
    }

    .chat-messages {
      flex: 1;
      overflow-y: auto;
      padding: 20px 56px;
      display: flex;
      flex-direction: column;
      gap: 0;
    }

    .chat-date-divider {
      display: flex;
      align-items: center;
      gap: 12px;
      margin: 16px 0;
      color: var(--text-dim);
      font-size: 11px;
      font-weight: 600;
    }

    .chat-date-divider::before,
    .chat-date-divider::after {
      content: '';
      flex: 1;
      height: 1px;
      background: var(--border);
    }

    .chat-msg {
      display: flex;
      gap: 14px;
      padding: 10px 0;
      position: relative;
      align-items: flex-start;
    }

    .chat-msg.user-msg {
      flex-direction: row-reverse;
    }

    /* Archived messages: visible to you, invisible to the AI (in memory card) */
    .chat-msg.archived-msg {
      opacity: 0.35;
      filter: saturate(0.4);
      transition: opacity 0.15s ease, filter 0.15s ease;
    }

    .chat-msg.archived-msg:hover {
      opacity: 0.7;
      filter: saturate(0.7);
    }

    .chat-msg.archived-msg .msg-bubble::after {
      content: 'archived — AI reads summary';
      display: block;
      font-size: 10px;
      color: var(--text-dim);
      margin-top: 6px;
      font-style: italic;
      letter-spacing: 0.02em;
    }

    .chat-msg.reroll-alt-msg .msg-bubble::after {
      content: 'reroll alternative — not sent to AI';
    }

    /* Reroll navigation pill */
    .reroll-nav {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 4px;
      margin-top: 6px;
      padding: 0;
    }

    .reroll-nav-btn {
      background: none;
      border: none;
      color: rgba(255, 255, 255, 0.3);
      font-size: 18px;
      cursor: pointer;
      padding: 0 4px;
      line-height: 1;
      transition: color 0.15s ease;
      font-family: inherit;
    }

    .reroll-nav-btn:hover:not(:disabled) {
      color: var(--accent2);
    }

    .reroll-nav-btn:disabled {
      opacity: 0.2;
      cursor: default;
    }

    .reroll-nav-label {
      font-size: 11px;
      font-weight: 700;
      color: rgba(255, 255, 255, 0.35);
      min-width: 30px;
      text-align: center;
      font-family: var(--font-display);
      letter-spacing: 0.5px;
    }

    .reroll-nav-action {
      background: none;
      border: 1px solid rgba(255, 255, 255, 0.1);
      border-radius: 6px;
      color: rgba(255, 255, 255, 0.35);
      cursor: pointer;
      padding: 3px 6px;
      margin-left: 6px;
      display: flex;
      align-items: center;
      transition: all 0.15s ease;
    }

    .reroll-nav-action:hover {
      color: var(--accent);
      border-color: rgba(232, 98, 26, 0.4);
      background: rgba(232, 98, 26, 0.08);
    }

    .msg-avatar {
      width: 136px;
      height: 136px;
      border-radius: 50%;
      background: var(--bg-card);
      flex-shrink: 0;
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 11px;
      color: var(--text-dim);
      border: 1px solid var(--border);
      margin-top: 0;
    }

    .msg-avatar img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .msg-body {
      flex: 1;
      min-width: 0;
      max-width: 78%;
      display: flex;
      flex-direction: column;
      gap: 4px;
      /* removed overflow:hidden to allow menu to sit outside */
    }

    .user-msg .msg-body {
      align-items: flex-end;
      margin-left: auto;
      margin-right: 0;
    }

    .chat-msg:not(.user-msg) .msg-body {
      margin-right: auto;
      margin-left: 0;
    }

    .msg-name {
      font-size: 11px;
      font-weight: 700;
      color: var(--text-dim);
      padding: 0 4px;
      letter-spacing: 0.5px;
      text-transform: uppercase;
    }

    .msg-header {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 11px;
      color: var(--text-dim);
    }

    .msg-sender {
      font-weight: 700;
      font-size: 12px;
      color: var(--text-secondary);
    }

    .user-msg .msg-header {
      flex-direction: row-reverse;
    }

    .msg-bubble {
      padding: 12px 16px;
      border-radius: 10px;
      line-height: 1.7;
      font-size: var(--chat-font-size, 14px);
      position: relative;
      font-family: var(--font-body);
      text-align: left;
    }

    .bot-bubble {
      background: var(--bg-bot-msg);
      color: var(--text-bot);
      border: 1px solid var(--border);
      border-top-left-radius: 2px;
    }

    .user-bubble {
      background: var(--bg-user-msg);
      color: var(--text-user);
      border: 1px solid var(--border);
      border-top-right-radius: 2px;
    }

    /* ── Chat background mode ── */
    #view-chat.has-chat-bg {
      background-size: cover;
      background-position: center;
      background-attachment: scroll;
    }
    #view-chat.has-chat-bg .chat-messages {
      background: transparent !important;
    }
    #view-chat.has-chat-bg .bot-bubble {
      background: rgba(20, 20, 26, var(--chat-bubble-bg-alpha, 0.10)) !important;
      backdrop-filter: blur(20px) saturate(200%);
      -webkit-backdrop-filter: blur(20px) saturate(200%);
      border: 1px solid rgba(255,255,255,0.18) !important;
      border-top-left-radius: 10px !important;
      box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.35),
        inset 0 -1px 0 rgba(0,0,0,0.2),
        0 4px 24px rgba(0,0,0,0.35);
    }
    #view-chat.has-chat-bg .user-bubble {
      background: rgba(20, 20, 26, var(--chat-bubble-bg-alpha, 0.10)) !important;
      backdrop-filter: blur(20px) saturate(200%);
      -webkit-backdrop-filter: blur(20px) saturate(200%);
      border: 1px solid rgba(255,255,255,0.18) !important;
      border-top-right-radius: 10px !important;
      box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.25),
        inset 0 -1px 0 rgba(0,0,0,0.2),
        0 4px 24px rgba(0,0,0,0.35);
    }
    #view-chat.has-chat-bg.chat-bubbles-no-glass .bot-bubble,
    #view-chat.has-chat-bg.chat-bubbles-no-glass .user-bubble {
      backdrop-filter: none !important;
      -webkit-backdrop-filter: none !important;
      box-shadow: 0 8px 24px rgba(0,0,0,0.26);
    }
    #view-chat.has-chat-bg .chat-input-area {
      background: transparent !important;
      backdrop-filter: none !important;
      -webkit-backdrop-filter: none !important;
      border-top: 1px solid rgba(255,255,255,0.08) !important;
    }
    #view-chat.has-chat-bg .chat-input-row {
      background: rgba(20, 20, 26, 0.18) !important;
      backdrop-filter: blur(20px) saturate(200%);
      -webkit-backdrop-filter: blur(20px) saturate(200%);
      border-color: rgba(255,255,255,0.18) !important;
      box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.25),
        inset 0 -1px 0 rgba(0,0,0,0.15),
        0 4px 24px rgba(0,0,0,0.3);
    }
    #view-chat.has-chat-bg #chat-topbar {
      background: rgba(20, 20, 24, 0.65) !important;
      backdrop-filter: blur(20px) saturate(160%);
      -webkit-backdrop-filter: blur(20px) saturate(160%);
      border-bottom-color: rgba(255,255,255,0.08) !important;
    }
    #view-chat.has-chat-bg #mobileLogoBar {
      background: rgba(20, 20, 24, 0.65) !important;
      backdrop-filter: blur(20px) saturate(160%);
      -webkit-backdrop-filter: blur(20px) saturate(160%);
    }
    .chat-bg-presets {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      margin-top: 10px;
    }
    .chat-bg-preset {
      width: 52px;
      height: 52px;
      border-radius: 8px;
      border: 2px solid transparent;
      cursor: pointer;
      transition: border-color 0.15s, transform 0.15s;
      flex-shrink: 0;
    }
    .chat-bg-preset:hover { transform: scale(1.08); }
    .chat-bg-preset.active { border-color: var(--accent); }
    .chat-bg-upload-btn {
      width: 52px;
      height: 52px;
      border-radius: 8px;
      border: 2px dashed var(--border-light);
      background: var(--bg-card);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-dim);
      font-size: 22px;
      transition: border-color 0.15s;
      flex-shrink: 0;
    }
    .chat-bg-upload-btn:hover { border-color: var(--accent); color: var(--accent); }

    .bot-bubble em {
      font-style: italic;
      color: var(--text-bot);
      opacity: 0.85;
    }

    .user-bubble em {
      font-style: italic;
      color: var(--text-user);
      opacity: 0.85;
    }

    .bot-bubble strong,
    .user-bubble strong {
      font-weight: 700;
      font-style: normal;
    }

    .bot-bubble strong {
      color: var(--text-dialogue);
    }

    .user-bubble strong {
      color: var(--text-dialogue);
    }

    /* dialogue = quoted speech — normal weight so **bold** and *italic* can work inside it */
    .bot-bubble .dialogue,
    .user-bubble .dialogue {
      color: var(--text-dialogue);
      font-weight: normal;
    }

    .bot-bubble .dialogue em,
    .user-bubble .dialogue em {
      color: var(--text-dialogue);
      font-style: italic;
      opacity: 0.9;
    }

    .bot-bubble .dialogue strong,
    .user-bubble .dialogue strong {
      color: var(--text-dialogue);
      font-weight: 700;
    }

    /* backtick code spans */
    .bot-bubble .backtick,
    .user-bubble .backtick {

      /* Protective CSS: Prevent color bleed from parent spans */
      .msg-bubble span:not(.dialogue):not(.backtick) {
        color: inherit;
      }

      font-family: 'Courier New',
      monospace;
      font-size: 0.9em;
      background: rgba(255, 255, 255, 0.08);
      border-radius: 3px;
      padding: 1px 5px;
      color: #f5c842;
    }

    /* Hover menu - now sits to the side of bubble */
    .msg-hover-controls {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 6px;
      flex-shrink: 0;
      align-self: center;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.08s ease;
    }

    .chat-msg:hover .msg-hover-controls {
      opacity: 1;
      pointer-events: auto;
    }

    .response-menu {
      position: absolute !important;
      bottom: 0 !important;
      flex-direction: column !important;
      background: none !important;
      backdrop-filter: none !important;
      border-radius: 0 !important;
      padding: 0 !important;
      align-self: flex-end !important;
      margin-bottom: 0 !important;
      justify-content: flex-end !important;
      z-index: 10;
      box-shadow: none !important;
      gap: 4px !important;
    }

    .bot-bubble .response-menu {
      right: -38px !important;
      left: auto !important;
    }

    .user-bubble .response-menu {
      left: -38px !important;
      right: auto !important;
    }

    .hover-btn {
      width: 30px;
      height: 30px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-secondary);
      font-size: 13px;
      background: var(--bg-panel);
      border: 1px solid var(--border);
      transition: background var(--transition), color var(--transition);
      flex-shrink: 0;
    }

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

    .hover-btn.listen-btn.playing {
      color: var(--accent);
      border-color: var(--accent);
    }

    /* Inline message edit */
    .msg-edit-wrap {
      display: flex;
      flex-direction: column;
      gap: 10px;
      width: 100%;
    }

    .msg-edit-textarea {
      width: 100%;
      background: var(--bg-input);
      border: 1px solid var(--border-light);
      border-radius: 10px;
      padding: 12px 16px;
      font-size: var(--chat-font-size, 14px);
      font-family: var(--font-body);
      color: var(--text-primary);
      line-height: 1.7;
      resize: vertical;
      min-height: 80px;
      outline: none;
    }

    .msg-edit-textarea:focus {
      border-color: var(--accent);
    }

    .msg-edit-actions {
      display: flex;
      gap: 8px;
    }

    .msg-edit-save {
      background: var(--text-primary);
      color: var(--bg-base);
      border: none;
      border-radius: 20px;
      padding: 8px 22px;
      font-size: 13px;
      font-weight: 700;
      cursor: pointer;
      font-family: var(--font-body);
      transition: opacity var(--transition);
    }

    .msg-edit-save:hover {
      opacity: 0.85;
    }

    .msg-edit-cancel {
      background: var(--bg-card);
      color: var(--text-secondary);
      border: 1px solid var(--border);
      border-radius: 20px;
      padding: 8px 22px;
      font-size: 13px;
      font-weight: 600;
      cursor: pointer;
      font-family: var(--font-body);
      transition: background var(--transition);
    }

    .msg-edit-cancel:hover {
      background: var(--bg-hover);
      color: var(--text-primary);
    }

    /* Three dots context menu - sized to content */
    .ctx-menu {
      display: none;
      position: fixed;
      background: var(--bg-panel);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      min-width: 190px;
      box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
      z-index: 1000;
      overflow: hidden;
      width: auto;
    }

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

    .ctx-menu-item {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 10px 16px;
      font-size: 13px;
      color: var(--text-secondary);
      transition: background var(--transition);
      cursor: pointer;
      white-space: nowrap;
    }

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

    .ctx-menu-item.danger {
      color: #e05252;
    }

    .ctx-menu-item.danger:hover {
      background: rgba(224, 82, 82, 0.1);
    }

    /* Chat input */
    .chat-input-area {
      padding: 12px 20px 10px;
      border-top: none;
      background: transparent;
      flex-shrink: 0;
    }

    .chat-input-row {
      display: flex;
      align-items: center;
      gap: 10px;
      background: transparent;
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      padding: 10px 12px;
      transition: border-color var(--transition);
    }

    .chat-input-row:focus-within {
      border-color: var(--border-light);
    }

    .chat-textarea {
      flex: 1;
      background: transparent;
      border: none;
      outline: none;
      resize: none;
      min-height: 22px;
      max-height: 140px;
      font-size: 13.5px;
      line-height: 1.5;
      color: var(--text-primary);
      padding: 0;
    }

    .chat-textarea::placeholder {
      color: var(--text-dim);
    }

    .chat-image-btn {
      height: 30px;
      min-width: 30px;
      border-radius: 999px;
      background: rgba(255, 214, 138, 0.12);
      color: #ffd68a;
      border: 1px solid rgba(255, 214, 138, 0.35);
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      flex-shrink: 0;
      padding: 0 10px;
      font-size: 11px;
      font-weight: 700;
      transition: background var(--transition), transform var(--transition), border-color var(--transition);
    }

    .chat-image-btn:hover {
      background: rgba(255, 214, 138, 0.2);
      border-color: rgba(255, 214, 138, 0.55);
      transform: scale(1.03);
    }

    .chat-image-btn svg {
      flex-shrink: 0;
    }

    .chat-send-btn {
      width: 30px;
      height: 30px;
      border-radius: 50%;
      background: var(--accent);
      color: white;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      transition: background var(--transition), transform var(--transition);
    }

    .chat-send-btn:hover {
      background: #d0561a;
      transform: scale(1.05);
    }

    .chat-input-footer {
      text-align: center;
      font-size: 10px;
      color: var(--text-dim);
      margin-top: 6px;
    }

    /* ===================== MY SCENARIOS VIEW ===================== */
    #view-scenarios {
      overflow-y: auto;
    }

    .scenarios-content {
      padding: 40px;
      max-width: 1400px;
      margin: 0 auto;
      width: 100%;
    }

    .scenarios-content .section-header {
      margin-bottom: 32px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      border: none;
      padding: 0;
    }

    .scenarios-content .section-header h3 {
      font-size: 20px;
      font-weight: 700;
      color: #ffffff;
    }

    /* ===================== PERSONAS VIEW ===================== */
    #view-personas {
      overflow-y: auto;
    }

    .personas-content {
      padding: 24px;
      max-width: 900px;
      margin: 0 auto;
      width: 100%;
    }

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

    .personas-header h2 {
      font-family: var(--font-display);
      font-size: 16px;
      font-weight: 600;
    }

    .personas-search {
      margin-bottom: 16px;
      position: relative;
    }

    .personas-search input {
      padding-left: 34px;
    }

    .personas-search-icon {
      position: absolute;
      left: 10px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--text-dim);
    }

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

    .persona-card {
      background: linear-gradient(135deg, rgba(107, 114, 128, 0.08), rgba(107, 114, 128, 0.04));
      border: 1px solid rgba(107, 114, 128, 0.25);
      border-radius: var(--radius-lg);
      overflow: hidden;
      cursor: pointer;
      transition: all var(--transition);
      position: relative;
      display: flex;
      flex-direction: row;
    }

    .persona-card:hover {
      transform: translateY(-2px);
      border-color: rgba(107, 114, 128, 0.5);
      box-shadow: 0 4px 12px rgba(107, 114, 128, 0.1);
    }

    .persona-card-img {
      width: 140px;
      height: 140px;
      flex-shrink: 0;
      background: var(--bg-input);
      overflow: hidden;
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .persona-card-img img {
      max-width: 100%;
      max-height: 100%;
      object-fit: scale-down;
      object-position: center;
      background: transparent;
    }

    .persona-card-menu {
      position: absolute;
      top: 6px;
      right: 6px;
      width: 26px;
      height: 26px;
      background: rgba(0, 0, 0, 0.65);
      border-radius: 4px;
      display: none;
      align-items: center;
      justify-content: center;
      color: var(--text-secondary);
      font-size: 16px;
    }

    .persona-card:hover .persona-card-menu {
      display: flex;
    }

    .persona-card-body {
      padding: 12px 14px;
      flex: 1;
      display: flex;
      flex-direction: column;
    }

    .persona-card-badge {
      display: inline-block;
      font-size: 9px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      background: rgba(236, 72, 153, 0.15);
      color: #ec4899;
      border: 1px solid rgba(236, 72, 153, 0.3);
      padding: 3px 10px;
      border-radius: 12px;
      width: fit-content;
      margin-bottom: 6px;
    }

    .persona-card-name {
      font-size: 13px;
      font-weight: 700;
      margin-bottom: 4px;
    }

    .persona-card-desc {
      font-size: 11px;
      color: var(--text-secondary);
      line-height: 1.4;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }

    /* ===================== ORIGINAL CHARACTERS ===================== */
    .hub-card-characters-original .create-hub-card-bg {
      background-image: url('assets/characters.jpg');
      background-size: cover;
      background-position: center center;
    }

    .characters-content {
      padding: 24px;
      max-width: 1100px;
      margin: 0 auto;
      width: 100%;
    }

    .characters-header {
      display: none; /* Replaced by the hero banner */
    }

    .personas-header {
      display: none; /* Replaced by the hero banner */
    }

    .persona-hub-hero {
      position: relative;
      border-radius: 16px;
      overflow: hidden;
      margin-bottom: 24px;
      border: 1px solid var(--border-light);
      background-image: linear-gradient(135deg, rgba(15, 23, 42, 0.7) 0%, rgba(15, 23, 42, 0.3) 50%, rgba(15, 23, 42, 0) 100%), url('assets/personas.jpg');
      background-size: cover;
      background-position: center;
      box-shadow: inset 0 0 100px rgba(0,0,0,0.4), 0 16px 40px rgba(0, 0, 0, 0.4);
      padding: 40px;
      display: flex;
      flex-direction: column;
      gap: 16px;
      min-height: 240px;
      justify-content: center;
      transition: border-color var(--transition);
    }
    .persona-hub-hero:hover {
      border-color: rgba(168, 85, 247, 0.3);
    }
    
    .persona-hub-hero-back {
      position: absolute;
      top: 16px;
      left: 16px;
      background: rgba(15, 23, 42, 0.7);
      border: 1px solid rgba(255, 255, 255, 0.1);
      border-radius: 50%;
      width: 32px;
      height: 32px;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-secondary);
      cursor: pointer;
      transition: all 0.2s ease;
      z-index: 10;
      padding: 0;
    }
    .persona-hub-hero-back:hover {
      background: var(--bg-card);
      color: var(--text-primary);
      transform: translateX(-2px);
      border-color: rgba(255, 255, 255, 0.25);
    }
    
    .persona-hub-hero-content {
      max-width: 650px;
      z-index: 2;
    }
    
    .persona-hub-hero-title {
      font-family: var(--font-display);
      font-size: 38px;
      font-weight: 600;
      letter-spacing: -0.5px;
      margin-bottom: 12px;
      text-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
      display: flex;
      align-items: center;
      gap: 12px;
      line-height: 1.2;
    }
    
    .persona-hub-hero-desc {
      font-size: 13px;
      line-height: 1.6;
      color: var(--text-secondary);
      text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
      margin: 0;
    }
    
    .persona-hub-controls {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      align-items: center;
      z-index: 2;
    }

    .character-hub-hero {
      position: relative;
      border-radius: 16px;
      overflow: hidden;
      margin-bottom: 24px;
      border: 1px solid var(--border-light);
      background-image: linear-gradient(135deg, rgba(15, 23, 42, 0.7) 0%, rgba(15, 23, 42, 0.3) 50%, rgba(15, 23, 42, 0) 100%), url('assets/characters.jpg');
      background-size: cover;
      background-position: center;
      box-shadow: inset 0 0 100px rgba(0,0,0,0.4), 0 16px 40px rgba(0, 0, 0, 0.4);
      padding: 40px;
      display: flex;
      flex-direction: column;
      gap: 16px;
      min-height: 240px;
      justify-content: center;
      transition: border-color var(--transition);
    }
    .character-hub-hero:hover {
      border-color: rgba(245, 158, 11, 0.3);
    }
    
    .character-hub-hero-back {
      position: absolute;
      top: 16px;
      left: 16px;
      background: rgba(15, 23, 42, 0.7);
      border: 1px solid rgba(255, 255, 255, 0.1);
      border-radius: 50%;
      width: 32px;
      height: 32px;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-secondary);
      cursor: pointer;
      transition: all 0.2s ease;
      z-index: 10;
      padding: 0;
    }
    .character-hub-hero-back:hover {
      background: var(--bg-card);
      color: var(--text-primary);
      transform: translateX(-2px);
      border-color: rgba(255, 255, 255, 0.25);
    }
    
    .character-hub-hero-content {
      max-width: 650px;
      z-index: 2;
    }
    
    .character-hub-hero-title {
      font-family: var(--font-display);
      font-size: 38px;
      font-weight: 600;
      letter-spacing: -0.5px;
      margin-bottom: 12px;
      text-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
      display: flex;
      align-items: center;
      gap: 12px;
      line-height: 1.2;
    }
    
    .character-hub-hero-desc {
      font-size: 13px;
      line-height: 1.6;
      color: var(--text-secondary);
      text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
      margin: 0;
    }
    
    .character-hub-controls {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      align-items: center;
      z-index: 2;
    }

    .characters-search {
      position: relative;
      margin-bottom: 18px;
    }

    .characters-search-icon {
      position: absolute;
      left: 12px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--text-dim);
    }

    .characters-search input {
      padding-left: 36px;
      height: 42px;
      border-radius: 10px;
    }

    .characters-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 16px;
    }

    .character-sections-wrap {
      display: flex;
      flex-direction: column;
      gap: 24px;
    }

    .character-section-block {
      margin-top: 24px;
    }

    .character-section-dropzone {
      min-height: 110px;
      border: 2px dashed rgba(255, 255, 255, 0.08);
      border-radius: 16px;
      padding: 14px;
      transition: all 0.15s ease;
      background: transparent;
      grid-column: 1 / -1;
    }

    .character-section-dropzone.drag-over,
    .characters-grid.drag-over {
      border-color: rgba(232, 98, 26, 0.8);
      background: rgba(232, 98, 26, 0.08);
      box-shadow: inset 0 0 20px rgba(232, 98, 26, 0.1);
    }

    .character-section-title {
      display: flex;
      align-items: center;
      gap: 12px;
      margin: 0 0 12px;
      padding: 12px 16px;
      background: linear-gradient(90deg, rgba(232, 98, 26, 0.3), rgba(232, 98, 26, 0.05));
      border-left: 4px solid var(--accent);
      border-radius: 6px;
      color: #fff;
      font-family: var(--font-display);
      font-size: 16px;
      font-weight: 700;
      letter-spacing: 0.2px;
      position: relative;
      overflow: visible;
    }

    .character-section-title-text {
      white-space: nowrap;
      flex: 1;
    }

    .character-section-title::before,
    .character-section-title::after {
      display: none;
    }

    .character-section-title-actions {
      display: flex !important;
      align-items: center;
      gap: 6px;
      margin-left: auto;
    }

    .character-section-title-btn:hover {
      color: #fff;
      border-color: rgba(232, 98, 26, 0.35);
      background: rgba(232, 98, 26, 0.10);
    }

    .character-section-title-btn.delete:hover {
      color: #ffb4b4;
      border-color: rgba(224, 82, 82, 0.35);
      background: rgba(224, 82, 82, 0.10);
    }

    .character-card {
      transition: transform 0.12s cubic-bezier(0.23, 1, 0.320, 1),
        box-shadow 0.12s ease,
        opacity 0.12s ease,
        filter 0.12s ease;
    }

    .character-card[draggable="true"] {
      cursor: grab;
    }

    .character-card[draggable="true"]:active {
      cursor: grabbing;
    }

    .character-card.dragging {
      opacity: 0.45;
      transform: scale(0.98) translateY(-2px);
      cursor: grabbing;
      filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.3));
    }

    .character-card.drop-before {
      box-shadow: inset 0 3px 0 0 var(--accent);
    }

    .character-card.drop-after {
      box-shadow: inset 0 -3px 0 0 var(--accent);
    }

    .character-card.drop-target {
      border: 2px solid var(--accent);
      background: rgba(232, 98, 26, 0.08);
      transform: scale(1.02);
    }

    .character-card:hover:not(.dragging) {
      transform: translateY(-1px);
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    .character-section-block.is-empty .character-section-dropzone {
      min-height: 72px;
    }

    .simple-overlay {
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, 0.72);
      display: none;
      align-items: center;
      justify-content: center;
      z-index: 4000;
      padding: 20px;
    }

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

    .simple-modal {
      width: 100%;
      max-width: 420px;
      background: var(--bg-panel);
      border: 1px solid var(--border);
      border-radius: 16px;
      overflow: hidden;
      box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
    }

    .simple-modal-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 18px 20px;
      border-bottom: 1px solid var(--border);
    }

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

    .simple-modal-body {
      padding: 18px 20px 6px;
    }

    .simple-modal-label {
      display: block;
      margin-bottom: 8px;
      font-size: 12px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.8px;
      color: var(--text-dim);
    }

    .simple-modal-footer {
      display: flex;
      justify-content: flex-end;
      gap: 10px;
      padding: 16px 20px 20px;
    }

    .character-card {
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 12px;
      overflow: hidden;
      cursor: pointer;
      transition: transform 0.2s cubic-bezier(0.23, 1, 0.32, 1), border-color 0.2s, box-shadow 0.2s, filter 0.2s;
      position: relative;
    }

    .character-card:hover {
      transform: translateY(-3px) scale(1.02);
      border-color: rgba(46, 189, 217, 0.5);
      box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4), inset 0 0 1px rgba(46, 189, 217, 0.1);
    }

    .character-card-img {
      width: 100%;
      height: 180px;
      background: linear-gradient(135deg, #151922 0%, #1e2234 60%, #20172f 100%);
      overflow: hidden;
      position: relative;
    }

    .character-card-img img {
      width: 100%;
      height: 100%;
      max-width: 100%;
      max-height: 180px;
      object-fit: contain;
      object-position: center center;
      display: block;
      transition: transform 0.3s ease;
    }

    .character-card:hover .character-card-img img {
      transform: scale(1.05);
    }

    .character-card-img::after {
      content: '';
      position: absolute;
      inset: 0;
      background: linear-gradient(to top, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.1) 48%, rgba(0, 0, 0, 0.02) 100%);
      pointer-events: none;
    }

    .character-card-body {
      padding: 14px;
      background: linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, rgba(255, 255, 255, 0) 100%);
    }

    .character-card-name {
      font-size: 14px;
      font-weight: 700;
      color: #fff;
      margin-bottom: 4px;
      letter-spacing: 0.2px;
    }

    .character-card-role {
      font-size: 11px;
      color: var(--accent2);
      margin-bottom: 6px;
      font-weight: 500;
    }

    .character-card-desc {
      font-size: 11px;
      color: var(--text-secondary);
      line-height: 1.55;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }

    .character-card-menu {
      position: absolute;
      top: 8px;
      right: 8px;
      z-index: 2;
      width: 28px;
      height: 28px;
      border-radius: 8px;
      display: none;
      align-items: center;
      justify-content: center;
      background: rgba(0, 0, 0, 0.55);
      color: #fff;
    }

    .character-card:hover .character-card-menu {
      display: flex;
    }

    .characters-action-buttons {
      display: flex;
      gap: 10px;
      margin-bottom: 16px;
      flex-wrap: wrap;
      align-items: center;
    }

    .characters-action-buttons button {
      padding: 9px 18px;
      background: var(--accent);
      border: none;
      border-radius: 6px;
      color: #fff;
      cursor: pointer;
      font-weight: 600;
      font-size: 13px;
      transition: background var(--transition);
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .characters-action-buttons button:hover {
      background: #d4561c;
    }

    .characters-action-buttons button svg {
      width: 16px;
      height: 16px;
    }

    .char-menu-popover {
      position: absolute;
      top: 100%;
      right: 0;
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 8px;
      min-width: 140px;
      box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
      z-index: 50;
      margin-top: 4px;
    }

    .char-menu-popover button {
      width: 100%;
      text-align: left;
      padding: 10px 14px;
      background: none;
      border: none;
      color: var(--text-secondary);
      cursor: pointer;
      font-size: 13px;
      font-weight: 400;
      border-bottom: 1px solid var(--border);
    }

    .char-menu-popover button:last-child {
      border-bottom: none;
    }

    .char-menu-popover button:hover {
      background: var(--bg-hover);
      color: var(--text-primary);
    }

    #characterSheetOverlay,
    #characterEditorOverlay {
      position: fixed;
      inset: 0;
      background: rgba(8, 9, 11, 0.65);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      display: none;
      align-items: center;
      justify-content: center;
      z-index: 410;
      padding: 20px;
    }

    #characterSheetOverlay.open,
    #characterEditorOverlay.open {
      display: flex;
    }

    .character-sheet-modal,
    .character-editor-modal {
      width: min(100%, 1100px);
      max-height: min(92vh, 980px);
      background: rgba(17, 20, 24, 0.75);
      backdrop-filter: blur(25px) saturate(180%);
      -webkit-backdrop-filter: blur(25px) saturate(180%);
      border: 1px solid rgba(255, 255, 255, 0.08);
      border-radius: 20px;
      overflow: hidden;
      box-shadow: 0 32px 80px rgba(0, 0, 0, 0.65),
                  inset 0 1px 0 rgba(255, 255, 255, 0.1);
      display: flex;
      flex-direction: column;
    }

    .character-editor-modal {
      width: min(100%, 980px);
    }

    .character-sheet-topbar,
    .character-editor-topbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 18px 22px;
      border-bottom: 1px solid var(--border);
      background: rgba(255, 255, 255, 0.02);
      position: relative;
    }

    .character-sheet-topbar h3,
    .character-editor-topbar h3 {
      font-size: 22px;
      font-weight: 800;
      color: #fff;
      flex: 1;
    }

    .character-sheet-header-badge {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      font-size: 14px;
      text-transform: uppercase;
      letter-spacing: 1px;
      font-weight: 700;
      color: var(--accent2);
      border: 1px solid rgba(46, 189, 217, 0.3);
      padding: 8px 14px;
      border-radius: 4px;
      background: rgba(46, 189, 217, 0.08);
      margin-bottom: 32px;
      width: fit-content;
    }

    .character-sheet-header-badge::before {
      content: '';
      display: inline-block;
      width: 8px;
      height: 8px;
      background: var(--accent2);
      border-radius: 50%;
    }

    .character-sheet-body {
      overflow-y: auto;
      display: grid;
      grid-template-columns: 420px minmax(0, 1fr);
      min-height: 0;
    }
    @media (max-width: 700px) {
      .character-sheet-body { grid-template-columns: 1fr; }
      .character-sheet-visual { border-right: none; border-bottom: 1px solid var(--border); }
      .character-sheet-mainimg { aspect-ratio: 16/9; max-height: 280px; }
      .character-sheet-album { grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 10px; }
      .character-sheet-thumb { border-radius: 8px; }
      .character-sheet-details { padding: 16px; }
    }

    .character-sheet-visual {
      border-right: 1px solid var(--border);
      background: linear-gradient(180deg, rgba(46, 189, 217, 0.08) 0%, rgba(255, 255, 255, 0.01) 100%);
      display: flex;
      flex-direction: column;
    }

    .character-sheet-mainimg {
      width: 100%;
      aspect-ratio: 4/5;
      background: #181b22;
      overflow: hidden;
    }

    .character-sheet-mainimg img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .character-sheet-album {
      padding: 14px;
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 10px;
      perspective: 1000px;
    }

    .character-sheet-thumb {
      aspect-ratio: 1/1;
      border-radius: 12px;
      overflow: hidden;
      border: 1px solid rgba(255, 255, 255, 0.12);
      background: rgba(255, 255, 255, 0.03);
      backdrop-filter: blur(8px) saturate(145%);
      -webkit-backdrop-filter: blur(8px) saturate(145%);
      cursor: pointer;
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
      transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), 
                  box-shadow 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), 
                  border-color 0.4s ease;
      transform-style: preserve-3d;
    }

    .character-sheet-thumb:hover {
      transform: translateY(-8px) scale(1.05) rotateX(4deg) rotateY(2deg);
      border-color: rgba(184, 124, 255, 0.5);
      box-shadow: 0 16px 36px rgba(184, 124, 255, 0.35), 
                  0 4px 12px rgba(0, 0, 0, 0.5), 
                  inset 0 1px 0 rgba(255, 255, 255, 0.2);
    }

    .character-sheet-thumb img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block;
      transition: transform 0.4s ease;
    }
    
    .character-sheet-thumb:hover img {
      transform: scale(1.03);
    }

    .character-sheet-details {
      padding: 80px 24px 24px;
      overflow-y: auto;
      display: flex;
      flex-direction: column;
    }

    .character-sheet-header {
      color: var(--accent);
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 2px;
      font-weight: 700;
      margin-bottom: 16px;
      min-height: 18px;
    }

    .character-sheet-name {
      font-size: 56px;
      font-weight: 900;
      color: #ffffff;
      margin-bottom: 16px;
      line-height: 1.0;
      letter-spacing: -1px;
      text-transform: uppercase;
    }

    .character-sheet-role {
      color: var(--accent2);
      font-size: 16px;
      font-weight: 600;
      margin-bottom: 8px;
      display: none;
    }

    .character-sheet-tagline {
      color: #fff;
      font-size: 14px;
      line-height: 1.65;
      margin-bottom: 24px;
      padding-bottom: 24px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .character-sheet-textblock {
      margin: 0 0 18px;
      padding: 0 0 2px;
    }

    .character-sheet-textblock:last-child {
      margin-bottom: 0;
    }

    .character-sheet-textheading {
      display: inline-flex;
      align-items: center;
      gap: 7px;
      margin: 0 0 7px;
      color: var(--accent);
      font-size: 11px;
      line-height: 1.1;
      letter-spacing: 1.5px;
      text-transform: uppercase;
      font-weight: 900;
    }

    .character-sheet-textheading::before {
      content: '';
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: var(--accent);
      box-shadow: 0 0 10px rgba(250, 130, 17, 0.45);
    }

    .character-sheet-tagline p {
      margin: 0 0 8px;
      color: #fff;
      overflow-wrap: anywhere;
    }

    .character-sheet-tagline p:last-child {
      margin-bottom: 0;
    }

    .character-sheet-bullet {
      position: relative;
      padding-left: 16px;
    }

    .character-sheet-bullet::before {
      content: '';
      position: absolute;
      left: 1px;
      top: 0.78em;
      width: 5px;
      height: 5px;
      border-radius: 50%;
      background: var(--accent2);
    }

    .character-sheet-attributes-label {
      color: var(--text-dim);
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 1.5px;
      font-weight: 700;
      margin-bottom: 16px;
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .character-sheet-chiprow {
      display: flex;
      flex-wrap: wrap;
      gap: 12px;
    }

    .character-sheet-chip {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 6px 12px;
      border-radius: 4px;
      border: 1px solid rgba(61, 189, 218, 0.3);
      background: #111217;
      color: var(--text-secondary);
      font-size: 11px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      position: relative;
    }

    .character-sheet-chip::before {
      content: '';
      display: inline-block;
      width: 6px;
      height: 6px;
      background: var(--accent);
      border-radius: 50%;
      flex-shrink: 0;
    }

    .character-sheet-actions {
      display: flex;
      gap: 10px;
      margin-top: auto;
      padding-top: 16px;
    }

    #characterSheetOverlay.view-only .character-sheet-topbar .btn-secondary,
    #characterSheetOverlay.view-only .character-sheet-topbar .btn-danger {
      display: none !important;
    }

    /* Intro rich-text editor */
    .intro-editor-toolbar {
      display: flex;
      flex-wrap: wrap;
      gap: 2px;
      align-items: center;
      padding: 6px 10px;
      background: #1a1a1a;
      border: 1px solid var(--border);
      border-bottom: none;
      border-radius: 8px 8px 0 0;
      position: sticky;
      top: 0;
      z-index: 50;
    }
    .intro-editor-toolbar button {
      background: none;
      border: 1px solid transparent;
      color: var(--text-dim);
      border-radius: 4px;
      padding: 3px 7px;
      font-size: 13px;
      cursor: pointer;
      transition: all 0.12s;
      font-weight: 600;
      line-height: 1.4;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 26px;
    }
    .intro-editor-toolbar button:hover { color: var(--text-primary); background: rgba(255,255,255,0.08); }
    .intro-editor-toolbar button.tb-active { color: var(--accent2); background: rgba(46,189,217,0.1); }
    .intro-editor-toolbar .tb-sep { width: 1px; height: 16px; background: var(--border); margin: 0 4px; flex-shrink: 0; }
    .intro-editor-toolbar select {
      width: auto;
      background: #1a1a1a !important;
      background-image: none !important;
      border: 1px solid var(--border);
      color: var(--text-secondary);
      border-radius: 4px;
      padding: 3px 6px !important;
      font-size: 12px;
      cursor: pointer;
      font-family: inherit;
      outline: none;
      transition: all 0.12s;
      height: 26px;
      appearance: auto !important;
      -webkit-appearance: auto !important;
    }
    .intro-editor-toolbar select:hover { border-color: var(--border-light); }
    @media (max-width: 700px) {
      .intro-editor-toolbar {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 6px 8px;
      }
      .intro-editor-toolbar::-webkit-scrollbar { display: none; }
      .intro-editor-toolbar button,
      .intro-editor-toolbar select { flex-shrink: 0; }
    }
    /* Custom font picker popup */
    .intro-font-picker-wrap { position: relative; display: inline-block; }
    .intro-font-btn {
      background: rgba(255,255,255,0.06); border: 1px solid var(--border); color: var(--text-primary);
      border-radius: 5px; padding: 3px 11px; cursor: pointer; font-size: 14px; height: 30px;
      font-family: 'Cinzel',serif; letter-spacing: 0.05em;
    }
    .intro-font-btn:hover { background: rgba(255,255,255,0.12); }
    .intro-font-picker {
      display: none; position: absolute; z-index: 700; top: 110%; left: 0; min-width: 220px;
      background: var(--bg-panel); border: 1px solid var(--border); border-radius: 8px;
      padding: 6px; box-shadow: 0 8px 32px rgba(0,0,0,0.5); max-height: 320px; overflow-y: auto;
    }
    .intro-font-opt {
      padding: 9px 12px; cursor: pointer; border-radius: 6px; font-size: 17px;
      color: var(--text-primary); transition: background 0.1s; white-space: nowrap;
    }
    .intro-font-opt:hover { background: rgba(255,255,255,0.1); }

    /* Color picker popup */
    .tb-color-popup {
      position: absolute;
      z-index: 700;
      background: var(--bg-panel);
      border: 1px solid var(--border-light);
      border-radius: 10px;
      padding: 10px;
      display: flex;
      flex-wrap: wrap;
      gap: 5px;
      width: 168px;
      box-shadow: 0 8px 32px rgba(0,0,0,0.65);
      backdrop-filter: blur(8px);
    }
    .tb-color-popup.has-gradients {
      width: 218px;
    }
    .tb-color-swatch {
      width: 20px; height: 20px;
      border-radius: 4px;
      cursor: pointer;
      border: 2px solid transparent;
      transition: transform 0.1s;
    }
    .tb-color-swatch:hover { transform: scale(1.2); border-color: #fff4; }
    .tb-color-btn-wrap { position: relative; display: inline-flex; }
    .intro-link-modal {
      position: fixed; inset: 0; z-index: 9100;
      display: flex; align-items: center; justify-content: center;
      background: rgba(0,0,0,0.55);
    }
    .intro-link-modal-box {
      background: var(--bg-panel);
      border: 1px solid var(--border-light);
      border-radius: 12px;
      padding: 22px 24px;
      width: 380px;
      max-width: 90vw;
    }
    .intro-link-modal-title { font-weight: 700; font-size: 14px; margin-bottom: 14px; }
    .intro-link-modal input {
      width: 100%; background: var(--bg-input); border: 1px solid var(--border);
      border-radius: 6px; padding: 9px 12px; font-size: 13px; outline: none; color: var(--text-primary);
    }
    .intro-link-modal input:focus { border-color: var(--accent); }
    .intro-link-modal-hint { font-size: 11px; color: var(--text-dim); margin-top: 6px; margin-bottom: 14px; }
    .intro-link-modal-row { display: flex; gap: 8px; justify-content: flex-end; }
    .intro-editor-body {
      min-height: 220px;
      overflow-y: auto;
      padding: 12px 14px;
      font-size: 14px;
      line-height: 1.7;
      border: 1px solid var(--border);
      border-radius: 0 0 8px 8px;
      background: var(--bg-input);
      color: var(--text-primary);
      outline: none;
      resize: vertical;
    }
    .intro-editor-body:focus { border-color: rgba(46,189,217,0.35); }
    .intro-editor-body img { max-width: min(480px, 100%); border-radius: 6px; margin: 6px auto; display: block; cursor: pointer; }
    .intro-editor-body img.intro-img-selected { outline: 2px solid var(--accent2); outline-offset: 2px; }
    .intro-yt-wrap { display:block; width:100%; margin:14px 0; border-radius:10px; overflow:hidden; aspect-ratio:16/9; background:#000; }
    .intro-yt-wrap iframe { width:100%; height:100%; border:0; display:block; }
    .scenario-detail-intro .intro-yt-wrap { border-radius:10px; overflow:hidden; }
    .scenario-detail-intro .intro-yt-wrap iframe { width:100%; height:100%; border:0; aspect-ratio:16/9; display:block; }
    #introImgToolbar {
      position: fixed;
      background: var(--bg-card, #1e1e2e);
      border: 1px solid rgba(255,255,255,0.15);
      border-radius: 8px;
      padding: 5px 7px;
      display: none;
      gap: 4px;
      align-items: center;
      z-index: 9999;
      box-shadow: 0 4px 16px rgba(0,0,0,0.5);
      font-size: 11px;
    }
    #introImgToolbar button {
      background: rgba(255,255,255,0.06);
      border: 1px solid rgba(255,255,255,0.1);
      color: var(--text-primary);
      border-radius: 5px;
      padding: 3px 7px;
      cursor: pointer;
      font-size: 11px;
      white-space: nowrap;
    }
    #introImgToolbar button:hover { background: rgba(255,255,255,0.12); }
    #introImgToolbar button.active { background: rgba(46,189,217,0.15); border-color: var(--accent2); color: var(--accent2); }
    #introImgToolbar .itb-sep { width: 1px; height: 16px; background: rgba(255,255,255,0.12); margin: 0 2px; }

    .intro-editor-body h1 { font-size: 28px; font-weight: 700; margin: 16px 0 8px; line-height: 1.2; }
    .intro-editor-body h2 { font-size: 22px; font-weight: 600; margin: 14px 0 6px; line-height: 1.25; }
    .intro-editor-body h3 { font-size: 18px; font-weight: 600; margin: 12px 0 4px; line-height: 1.3; }
    .intro-editor-body p { margin: 0 0 8px; }
    .intro-editor-body:empty:before {
      content: attr(data-placeholder);
      color: var(--text-dim);
      pointer-events: none;
    }

    /* Backstory subsections */
    .backstory-subsections { display: flex; flex-direction: column; gap: 18px; }
    .backstory-sub { }
    .backstory-sub-label {
      font-size: 12px;
      font-weight: 700;
      color: var(--text-secondary);
      text-transform: uppercase;
      letter-spacing: 0.07em;
      margin-bottom: 6px;
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .backstory-sub-label .sub-limit {
      font-weight: 400;
      font-size: 11px;
      text-transform: none;
      letter-spacing: 0;
      color: var(--text-dim);
    }
    .backstory-sub textarea {
      width: 100%;
      resize: vertical;
    }

    .character-editor-body {
      overflow-y: auto;
      padding: 22px 24px 28px;
      display: grid;
      grid-template-columns: 240px minmax(0, 1fr);
      gap: 20px;
    }

    .character-editor-media {
      display: flex;
      flex-direction: column;
      gap: 12px;
    }

    .character-editor-mainupload {
      width: 100%;
      aspect-ratio: 4/5;
      border-radius: 8px;
      border: 1px dashed rgba(46, 189, 217, 0.35);
      background: rgba(46, 189, 217, 0.06);
      overflow: hidden;
      position: relative;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-secondary);
      text-align: center;
      padding: 16px;
    }

    .character-editor-mainupload img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block;
    }

    .character-editor-albumgrid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 8px;
      perspective: 1000px;
    }

    .character-editor-albumslot {
      aspect-ratio: 1/1;
      border-radius: 12px;
      border: 1px dashed rgba(184, 124, 255, 0.35);
      background: rgba(184, 124, 255, 0.05);
      backdrop-filter: blur(6px);
      -webkit-backdrop-filter: blur(6px);
      overflow: hidden;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-secondary);
      font-size: 11px;
      text-align: center;
      padding: 8px;
      box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.05);
      transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), 
                  box-shadow 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), 
                  border-color 0.4s ease, 
                  background-color 0.4s ease;
      transform-style: preserve-3d;
    }

    .character-editor-albumslot:hover {
      transform: translateY(-6px) scale(1.05) rotateX(3deg) rotateY(1deg);
      border-color: rgba(184, 124, 255, 0.7);
      background: rgba(184, 124, 255, 0.1);
      box-shadow: 0 14px 28px rgba(184, 124, 255, 0.25), 
                  0 4px 10px rgba(0, 0, 0, 0.35), 
                  inset 0 1px 0 rgba(255, 255, 255, 0.15);
    }

    .character-editor-albumslot img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block;
    }

    .character-editor-fields {
      display: flex;
      flex-direction: column;
      gap: 10px;
      min-width: 0;
    }

    .character-editor-grid2 {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 12px;
    }

    .character-editor-field label {
      display: block;
      margin-bottom: 6px;
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 1px;
      color: var(--text-dim);
      font-weight: 700;
    }

    .character-editor-field small {
      color: var(--text-dim);
      font-size: 11px;
      line-height: 1.5;
      display: block;
      margin-top: 6px;
    }

    .character-editor-footer {
      display: flex;
      justify-content: flex-end;
      gap: 10px;
      padding: 16px 24px 22px;
      border-top: 1px solid var(--border);
    }

    @media (max-width: 920px) {

      .character-sheet-body,
      .character-editor-body {
        grid-template-columns: 1fr;
      }

      .character-sheet-visual {
        border-right: none;
        border-bottom: 1px solid var(--border);
      }
    }

    /* ===================== SETTINGS PANEL ===================== */
    #settings-overlay {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 200;
      background: rgba(0, 0, 0, 0.5);
      backdrop-filter: blur(2px);
    }

    #settings-overlay.open {
      display: block;
    }

    .scenario-card-content {
      position: relative;
      background: transparent;
      padding: 0 16px;
      display: flex;
      flex-direction: column;
      flex: 1;
    }

    #settings-panel {
      position: absolute;
      top: 0;
      right: 0;
      width: 380px;
      height: 100vh;
      background: var(--bg-panel);
      border-left: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      overflow: hidden;
      transform: translateX(100%);
      transition: transform 0.25s ease;
    }

    #settings-overlay.open #settings-panel {
      transform: translateX(0);
    }

    #settings-main-view {
      display: flex;
      flex-direction: column;
      flex: 1;
      min-height: 0;
    }

    #edit-char-panel {
      display: none;
      flex-direction: column;
      flex: 1;
      min-height: 0;
    }

    #edit-char-panel.open {
      display: flex;
    }

    .settings-body {
      flex: 1;
      overflow-y: scroll;
      padding: 0 0 40px;
      min-height: 0;
    }

    .settings-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 16px 20px;
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
    }

    .settings-header h2 {
      font-family: var(--font-display);
      font-size: 14px;
      font-weight: 700;
    }

    .settings-close {
      width: 28px;
      height: 28px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-secondary);
      transition: background var(--transition);
    }

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

    .settings-section {
      border-bottom: 1px solid var(--border);
      padding: 24px 20px;
    }

    .settings-section-label {
      font-size: 10px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 1px;
      color: var(--text-dim);
      margin-bottom: 12px;
    }

    .settings-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 10px 0;
      border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    }

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

    .settings-row-label {
      font-size: 14px;
      font-weight: 600;
    }

    .settings-row-sub {
      font-size: 11px;
      color: var(--text-dim);
      margin-top: 2px;
    }

    /* Toggle */
    .toggle {
      width: 44px;
      height: 24px;
      background: var(--bg-input);
      border-radius: 12px;
      position: relative;
      cursor: pointer;
      border: 1px solid var(--border);
      transition: background var(--transition);
      flex-shrink: 0;
    }

    .toggle.on {
      background: var(--accent);
      border-color: var(--accent);
    }

    .toggle::after {
      content: '';
      position: absolute;
      top: 3px;
      left: 3px;
      width: 16px;
      height: 16px;
      border-radius: 50%;
      background: var(--text-secondary);
      transition: left var(--transition), background var(--transition);
    }

    .toggle.on::after {
      left: 23px;
      background: white;
    }

    /* Select */
    .settings-select {
      background: var(--bg-input);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 10px 30px 10px 12px;
      font-size: 13px;
      color: var(--text-primary);
      width: 100%;
      appearance: none;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a544c' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 10px center;
      margin-top: 8px;
    }

    /* Slider */
    .slider-row {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .slider-spinbox {
      width: 60px;
      background: var(--bg-input);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 4px 8px;
      font-size: 12px;
      text-align: center;
    }

    input[type=range] {
      flex: 1;
      -webkit-appearance: none;
      height: 4px;
      background: var(--border);
      border-radius: 2px;
      border: none;
      padding: 0;
    }

    input[type=range]::-webkit-slider-thumb {
      -webkit-appearance: none;
      width: 14px;
      height: 14px;
      border-radius: 50%;
      background: var(--accent);
      cursor: pointer;
    }

    /* Segment control */
    .segment-control {
      display: flex;
      background: var(--bg-input);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      overflow: hidden;
      width: 100%;
      margin-top: 8px;
    }

    .segment-btn {
      flex: 1;
      padding: 8px;
      font-size: 13px;
      font-weight: 600;
      color: var(--text-secondary);
      transition: background var(--transition), color var(--transition);
      text-align: center;
    }

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

    /* Color row */
    .color-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 8px 0;
      border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    }

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

    .color-row-label {
      font-size: 13px;
      font-weight: 600;
    }

    .color-row-right {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .color-row-hex {
      font-size: 12px;
      color: var(--text-dim);
      font-family: monospace;
    }

    .color-swatch {
      width: 22px;
      height: 22px;
      border-radius: 3px;
      border: 1px solid var(--border);
      cursor: pointer;
      flex-shrink: 0;
      position: relative;
      overflow: hidden;
    }

    .color-swatch input[type=color] {
      position: absolute;
      inset: -4px;
      opacity: 0;
      cursor: pointer;
      width: 200%;
      height: 200%;
    }

    .btn-reset {
      width: 100%;
      padding: 10px;
      background: var(--bg-hover);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      color: var(--text-secondary);
      font-size: 13px;
      font-weight: 600;
      margin-top: 12px;
      transition: background var(--transition);
    }

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

    /* LLM Model row */
    .model-banner {
      width: 100%;
      height: 54px;
      background: linear-gradient(135deg, #1a0e2e, #2d1b4e);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 14px;
      cursor: pointer;
      margin-top: 8px;
      overflow: hidden;
      position: relative;
    }

    .model-banner-bg {
      position: absolute;
      inset: 0;
      background: linear-gradient(135deg, #1a0e2e 0%, #3a1e5e 50%, #1a0e2e 100%);
      opacity: 0.8;
    }

    .model-banner-label {
      font-size: 15px;
      font-weight: 700;
      color: var(--accent);
      font-family: var(--font-display);
      position: relative;
    }

    .model-banner-size {
      font-size: 10px;
      color: var(--text-dim);
      margin-left: 4px;
    }

    .model-banner-arrow {
      position: relative;
      color: var(--text-secondary);
    }

    .settings-nav-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 13px 0;
      border-bottom: 1px solid rgba(255, 255, 255, 0.04);
      cursor: pointer;
      transition: color var(--transition);
    }

    .settings-nav-row:hover {
      color: var(--text-primary);
    }

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

    .settings-nav-label {
      font-size: 14px;
      font-weight: 600;
    }

    .settings-nav-arrow {
      color: var(--text-dim);
    }

    /* ===================== EDIT CHARACTER SUBPANEL ===================== */
    #settings-main-view {
      display: flex;
      flex-direction: column;
      height: 100%;
      overflow: hidden;
    }

    #edit-char-panel {
      display: none;
      flex-direction: column;
      height: 100%;
      overflow: hidden;
    }

    #edit-char-panel.open {
      display: flex;
    }

    .settings-back-btn {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 14px 20px;
      border-bottom: 1px solid var(--border);
      color: var(--text-secondary);
      cursor: pointer;
      font-size: 13px;
      font-weight: 600;
      transition: color var(--transition);
    }

    .settings-back-btn:hover {
      color: var(--text-primary);
    }

    /* Temperature sliders subpanel */
    .param-group {
      padding: 18px 20px;
      border-bottom: 1px solid var(--border);
    }

    .param-title {
      font-size: 16px;
      font-weight: 700;
      margin-bottom: 4px;
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .param-desc {
      font-size: 12px;
      color: var(--text-secondary);
      line-height: 1.5;
      margin-bottom: 14px;
    }

    .param-value {
      font-size: 16px;
      font-weight: 700;
      color: var(--text-secondary);
      text-align: right;
    }

    .param-slider-row {
      display: flex;
      align-items: center;
      gap: 12px;
    }

    .param-slider {
      flex: 1;
    }

    /* Number input styling for LLM settings */
    .llm-param-input {
      background: var(--bg-secondary) !important;
      border: 1px solid var(--border-color) !important;
      border-radius: 6px !important;
      color: var(--text-primary) !important;
      padding: 8px 10px !important;
      font-size: 14px !important;
      font-weight: 600 !important;
      width: auto !important;
      max-width: 120px !important;
      min-width: 80px !important;
      box-sizing: border-box;
      text-align: center;
    }

    .llm-param-input:focus {
      outline: none !important;
      border-color: var(--accent2) !important;
      background: var(--bg-secondary) !important;
    }

    /* Spinner buttons */
    .llm-param-input::-webkit-outer-spin-button,
    .llm-param-input::-webkit-inner-spin-button {
      -webkit-appearance: inner-spin-button !important;
      opacity: 1;
    }

    /* ===================== MISC ===================== */
    .empty-state {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      flex: 1;
      gap: 12px;
      color: var(--text-dim);
      font-size: 13px;
      padding: 40px;
      text-align: center;
    }

    .empty-state svg {
      opacity: 0.3;
    }

    .badge-plus {
      font-size: 9px;
      background: var(--accent);
      color: white;
      padding: 1px 5px;
      border-radius: 8px;
      font-weight: 700;
      font-family: var(--font-display);
      vertical-align: middle;
    }

    /* ===================== HD TOGGLE ===================== */

    /* ===================== SETTINGS VIEW ===================== */
    #view-settings {
      overflow-y: auto;
    }

    #view-edit-char {
      overflow-y: auto;
    }

    #view-profile,
    #view-scenario-detail {
      overflow-y: auto;
    }

    #view-ai-rules {
      overflow-y: auto;
    }

    #view-cloud-sync {
      overflow-y: auto;
    }

    .settings-content {
      padding: 0;
      max-width: 750px;
      margin: 0 auto;
      width: 100%;
      padding-bottom: 40px;
    }

    .subpage-view .settings-content {
      padding-top: 18px;
    }

    .model-settings-picker-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 12px;
      margin-bottom: 16px;
    }

    .model-settings-picker-card {
      padding: 16px 18px;
      border: 1.5px solid var(--border);
      border-radius: 12px;
      background: var(--bg-card);
    }

    .model-settings-picker-label {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 11px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 1px;
      color: var(--text-dim);
      margin-bottom: 8px;
    }

    .model-settings-picker-label .material-symbols-outlined {
      font-size: 16px;
      color: var(--accent);
    }

    .model-settings-picker-card .settings-select {
      margin-top: 0;
    }

    @media (max-width: 700px) {
      .model-settings-picker-grid {
        grid-template-columns: 1fr;
      }
    }

    .settings-view-header {
      display: flex;
      align-items: center;
      gap: 14px;
      padding: 20px 24px 0;
      margin-bottom: 4px;
    }

    .settings-view-header h2 {
      font-family: var(--font-display);
      font-size: 16px;
      font-weight: 700;
    }

    .settings-back-btn {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 20px 24px 0;
      color: var(--text-secondary);
      cursor: pointer;
      font-size: 13px;
      font-weight: 600;
      transition: color var(--transition);
      margin-bottom: 8px;
    }

    .settings-back-btn:hover {
      color: var(--text-primary);
    }

    .settings-section {
      border-bottom: 1px solid var(--border);
      padding: 24px 24px;
    }

    .settings-section-label {
      font-size: 10px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 1px;
      color: var(--text-dim);
      margin-bottom: 12px;
    }

    .settings-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 10px 0;
      border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    }

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

    .settings-row-label {
      font-size: 14px;
      font-weight: 600;
    }

    .settings-row-sub {
      font-size: 11px;
      color: var(--text-dim);
      margin-top: 2px;
    }

    .settings-nav-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 13px 0;
      border-bottom: 1px solid rgba(255, 255, 255, 0.04);
      cursor: pointer;
      transition: color var(--transition);
    }

    .settings-nav-row:hover {
      color: var(--text-primary);
    }

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

    .settings-nav-label {
      font-size: 14px;
      font-weight: 600;
    }

    .settings-nav-arrow {
      color: var(--text-dim);
      font-size: 18px;
    }

    .profile-avatar-wrap {
      position: relative;
      width: 72px;
      height: 72px;
      flex-shrink: 0;
    }

    .profile-avatar-display {
      width: 72px;
      height: 72px;
      border-radius: 50%;
      background: var(--accent);
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: 700;
      font-size: 24px;
      color: white;
      border: 2px solid var(--border-light);
    }

    .profile-avatar-display img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .profile-avatar-edit-btn {
      position: absolute;
      bottom: 0;
      right: 0;
      width: 22px;
      height: 22px;
      border-radius: 50%;
      background: var(--accent);
      color: white;
      display: flex;
      align-items: center;
      justify-content: center;
      border: 2px solid var(--bg-panel);
      cursor: pointer;
    }

    .profile-avatar-edit-btn:hover {
      background: #d0561a;
    }

    /* ===================== NOTIFICATION ===================== */
    .toast-container {
      position: fixed;
      bottom: 24px;
      right: 20px;
      display: flex;
      flex-direction: column;
      gap: 10px;
      z-index: 99999;
      pointer-events: none;
      align-items: flex-end;
    }

    .toast-item {
      --toast-accent: var(--accent);
      background:
        radial-gradient(circle at 12% 0%, color-mix(in srgb, var(--toast-accent) 26%, transparent), transparent 46%),
        linear-gradient(135deg, rgba(24, 24, 27, 0.96), rgba(9, 10, 13, 0.96));
      border: 1px solid color-mix(in srgb, var(--toast-accent) 42%, rgba(255,255,255,0.14));
      border-radius: 14px;
      padding: 12px;
      font-size: 13px;
      color: #fff;
      pointer-events: auto;
      opacity: 0;
      transform: translateY(10px) scale(0.98);
      transition: opacity 0.22s ease, transform 0.22s ease;
      width: min(390px, calc(100vw - 32px));
      display: grid;
      grid-template-columns: 34px minmax(0, 1fr) auto;
      align-items: center;
      gap: 10px;
      box-shadow: 0 18px 48px rgba(0,0,0,0.48), 0 0 28px color-mix(in srgb, var(--toast-accent) 18%, transparent);
      overflow: hidden;
      backdrop-filter: blur(16px);
    }

    .toast-item.show {
      opacity: 1;
      transform: translateY(0) scale(1);
    }

    .toast-item.success { --toast-accent: #22c55e; }
    .toast-item.warning { --toast-accent: #f59e0b; }
    .toast-item.error {
      --toast-accent: #ef4444;
    }

    .toast-icon {
      width: 34px;
      height: 34px;
      border-radius: 12px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      background: color-mix(in srgb, var(--toast-accent) 20%, rgba(255,255,255,0.06));
      border: 1px solid color-mix(in srgb, var(--toast-accent) 48%, transparent);
      color: var(--toast-accent);
      box-shadow: inset 0 0 18px color-mix(in srgb, var(--toast-accent) 12%, transparent);
    }

    .toast-icon .material-symbols-outlined {
      font-size: 18px;
    }

    .toast-copy,
    .toast-close {
      width: 30px;
      height: 30px;
      border-radius: 10px;
      border: 1px solid rgba(255,255,255,0.12);
      background: rgba(255,255,255,0.06);
      color: rgba(255,255,255,0.82);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
    }

    .toast-copy:hover,
    .toast-close:hover {
      background: rgba(255,255,255,0.12);
      border-color: color-mix(in srgb, var(--toast-accent) 44%, rgba(255,255,255,0.16));
      color: #fff;
    }

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

    .toast-text {
      min-width: 0;
      line-height: 1.38;
      font-weight: 650;
      overflow-wrap: anywhere;
    }

    @media (max-width: 640px) {
      .toast-container {
        left: 14px;
        right: 14px;
        bottom: calc(14px + env(safe-area-inset-bottom));
        align-items: stretch;
      }

      .toast-item {
        width: 100%;
      }
    }

    /* ===================== COMPRESS PROGRESS BAR ===================== */
    #compressProgress {
      position: fixed;
      bottom: 24px;
      left: 50%;
      transform: translateX(-50%);
      background: var(--bg-panel);
      border: 1px solid var(--accent);
      border-radius: var(--radius-lg);
      padding: 12px 20px 10px;
      min-width: 260px;
      z-index: 10000;
      pointer-events: none;
      opacity: 0;
      transition: opacity 0.2s;
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    #compressProgress.show {
      opacity: 1;
    }

    #compressProgressLabel {
      font-size: 12px;
      font-weight: 600;
      color: var(--text-primary);
      display: flex;
      align-items: center;
      gap: 8px;
    }

    #compressProgressLabel .cp-spinner {
      width: 12px;
      height: 12px;
      border: 2px solid rgba(232, 98, 26, 0.3);
      border-top-color: var(--accent);
      border-radius: 50%;
      animation: cpSpin 0.7s linear infinite;
      flex-shrink: 0;
    }

    #compressProgressLabel .cp-tick {
      width: 12px;
      height: 12px;
      color: #4caf50;
      font-size: 13px;
      line-height: 1;
      flex-shrink: 0;
    }

    .cp-track {
      height: 4px;
      background: var(--bg-input);
      border-radius: 2px;
      overflow: hidden;
    }

    #compressProgressBar {
      height: 100%;
      width: 0%;
      background: var(--accent);
      border-radius: 2px;
      transition: width 0.4s ease;
    }

    #compressProgressSub {
      font-size: 10px;
      color: var(--text-dim);
      letter-spacing: 0.2px;
    }

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

    @keyframes typingDot {

      0%,
      60%,
      100% {
        opacity: 0.2;
        transform: scale(0.8);
      }

      30% {
        opacity: 1;
        transform: scale(1.2);
      }
    }

    /* ===================== MOBILE OPTIMIZATIONS ===================== */
    @media (max-width: 768px) {

      html,
      body {
        font-size: 14px !important;
        overflow: hidden;
      }

      #sidebar {
        display: none !important;
      }

      #main {
        flex: 1;
        width: 100vw;
        padding-bottom: 64px;
      }

      #view-chat.active {
        display: flex !important;
        flex-direction: column !important;
      }

      #view-chat:not(.active) {
        display: none !important;
      }

      #topbar {
        display: none !important;
      }

      /* Mobile logo topbar */
      #mobileLogoBar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: 54px;
        padding: 0 10px;
        background: var(--bg-panel);
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
        position: sticky;
        top: 0;
        z-index: 50;
      }

      #mobileLogoBarBtn {
        width: 38px;
        height: 38px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: var(--text-dim);
        border-radius: 50%;
        flex-shrink: 0;
        cursor: pointer;
      }

      #mobileLogoBarBtn:active {
        background: var(--bg-hover);
      }

      #mobileLogoBarCenter {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        align-items: center;
        gap: 8px;
        pointer-events: none;
      }

      #mobileLogoImg {
        width: 32px;
        height: 32px;
        object-fit: contain;
        mix-blend-mode: lighten;
        filter: drop-shadow(0 0 5px rgba(232, 98, 26, 0.6));
      }

      #mobileLogoText {
        font-family: var(--font-display);
        font-size: 18px;
        font-weight: 700;
        color: var(--text-primary);
        white-space: nowrap;
      }

      #mobileLogoText span {
        color: var(--accent);
      }

      #mobileLogoBarSpacer {
        width: 38px;
        flex-shrink: 0;
      }

      /* chat-topbar: let JS control display */
      #chat-topbar {
        align-items: center;
        height: 56px !important;
        padding: 0 12px !important;
        gap: 10px !important;
        background: var(--bg-panel) !important;
        border-bottom: 1px solid var(--border) !important;
        position: sticky;
        top: 0;
        z-index: 50;
        flex-shrink: 0;
        overflow: visible !important;
      }

      #chat-topbar>button:first-child {
        flex-shrink: 0;
        width: 36px !important;
        height: 36px !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
        color: var(--text-secondary) !important;
        background: none;
        border: none;
        padding: 0 !important;
        margin-right: 0 !important;
      }

      .chat-topbar-scenario-img {
        width: 36px !important;
        height: 36px !important;
        border-radius: 50% !important;
        flex-shrink: 0;
      }

      .chat-topbar-info {
        flex: 1;
        min-width: 0;
        overflow: hidden;
      }

      .chat-topbar-name {
        font-size: 15px !important;
        font-weight: 700;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .chat-topbar-sub {
        font-size: 11px !important;
      }

      .chat-topbar-actions {
        display: flex !important;
        gap: 2px !important;
        align-items: center;
        flex-shrink: 0;
        margin-left: auto;
        overflow: visible !important;
      }

      .chat-topbar-icon-btn {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
        border-radius: 50% !important;
        flex-shrink: 0;
      }

      #topbarMemoryMapBtn,
      #topbarCompressBtn {
        display: none !important;
      }

      .chat-topbar-icon-btn .material-symbols-outlined {
        font-size: 20px !important;
      }

      .persona-picker-btn {
        display: flex !important;
        padding: 4px !important;
        border-radius: 50% !important;
        min-width: 32px !important;
        width: 32px !important;
        height: 32px !important;
        justify-content: center !important;
        align-items: center !important;
        background: rgba(255,255,255,0.06) !important;
        border: 1px solid rgba(255,255,255,0.1) !important;
        flex-shrink: 0 !important;
        margin-right: 4px !important;
      }
      .persona-picker-name {
        display: none !important;
      }
      .persona-picker-avatar {
        margin: 0 !important;
        width: 24px !important;
        height: 24px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
      }
      .persona-picker-avatar img {
        width: 100% !important;
        height: 100% !important;
        border-radius: 50% !important;
        object-fit: cover !important;
      }

      .chat-messages {
        padding: 12px 4px !important;
        flex: 1;
        overflow-y: auto !important;
        min-height: 0;
      }

      #mobileBottomNav {
        display: flex !important;
      }
    }

    #mobileBottomNav {
      display: none;
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      height: 64px;
      background: var(--bg-panel);
      border-top: 1px solid var(--border);
      z-index: 200;
      align-items: stretch;
      justify-content: space-around;
      padding: 0 4px;
      padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .mob-tab {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 3px;
      background: none;
      border: none;
      color: var(--text-dim);
      font-size: 10px;
      font-family: var(--font-body);
      font-weight: 500;
      padding: 6px 4px 4px;
      cursor: pointer;
      transition: color 0.15s ease;
    }

    .mob-tab svg {
      transition: transform 0.15s ease;
    }

    .mob-tab:active svg {
      transform: scale(0.88);
    }

    .mob-tab.active {
      color: var(--accent);
    }

    .mob-tab.active svg {
      stroke: var(--accent);
    }

    .mob-tab span {
      line-height: 1;
      letter-spacing: 0.1px;
    }

    .mob-tab-create {
      width: 48px;
      height: 48px;
      border-radius: 50%;
      background: var(--accent);
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: 0 4px 14px rgba(232, 98, 26, 0.45);
      margin-bottom: 2px;
    }

    .mob-tab-create svg {
      stroke: #fff;
    }

    .mob-tab[data-view="create-hub"] {
      padding-top: 4px;
    }


    /* ===== MOBILE LORE CARD READABILITY PATCH ===== */
    @media (max-width: 768px) {

      .story-card,
      .story-card[style*="row"],
      .story-card[style*="column"] {
        flex-direction: column !important;
        gap: 10px !important;
        padding: 10px !important;
      }

      .story-card-image {
        width: 100% !important;
        min-width: 0 !important;
        height: auto !important;
        aspect-ratio: 1 / 1 !important;
        border-radius: 8px !important;
      }

      .story-card-content {
        width: 100% !important;
        padding-top: 0 !important;
        gap: 8px !important;
      }

      .story-card-header {
        gap: 6px !important;
        margin-top: 0 !important;
      }

      .story-card-name {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        line-height: 1.25 !important;
        font-size: 14px !important;
      }

      .story-card-type {
        margin-bottom: 0 !important;
      }
    }


    /* ===== MOBILE CHAT BUBBLE PATCH ===== */
    @media (max-width: 768px) {

      /* ── 1. Avatar at TOP of bubble, not bottom ── */
      .chat-msg {
        gap: 8px !important;
        padding: 4px 12px !important;
        align-items: flex-start !important;
      }

      .msg-avatar {
        width: 34px !important;
        height: 34px !important;
        border-radius: 7px !important;
        flex-shrink: 0;
        margin-top: 2px;
      }

      /* ── 2. Bubble body width ── */
      .msg-body {
        max-width: 80% !important;
        flex: none !important;
        min-width: 0;
      }

      .user-msg .msg-body {
        align-items: flex-end !important;
        margin-left: auto !important;
        margin-right: 0 !important;
      }

      .chat-msg:not(.user-msg) .msg-body {
        margin-right: auto !important;
        margin-left: 0 !important;
      }

      .msg-name {
        font-size: 10px !important;
        margin-bottom: 2px !important;
      }

      .bot-bubble, .user-bubble {
        padding: 12px 14px !important;
        line-height: 1.55 !important;
        font-size: 14px !important;
      }

      .response-menu {
        position: absolute !important;
        bottom: 0 !important;
        flex-direction: column !important;
        margin-bottom: 0 !important;
        background: none !important;
        backdrop-filter: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        gap: 4px !important;
      }

      .bot-bubble .response-menu {
        right: -32px !important;
        left: auto !important;
      }

      .user-bubble .response-menu {
        left: -32px !important;
        right: auto !important;
      }

      .hover-btn {
        width: 30px !important;
        height: 30px !important;
        background: rgba(255, 255, 255, 0.07) !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        flex-shrink: 0;
      }

      /* ── 4. Input bar pill style ── */
      .chat-input-area {
        padding: 8px 12px 10px !important;
        background: transparent !important;
        border-top: none !important;
        flex-shrink: 0 !important;
        min-height: 60px;
        margin-bottom: 64px !important;
      }

      #view-personas .chat-input-area,
      #view-home .chat-input-area,
      #view-create .chat-input-area,
      #view-scenarios .chat-input-area,
      #view-create-hub .chat-input-area,
      #view-profile .chat-input-area,
      #view-browse .chat-input-area {
        display: none !important;
      }

      .chat-input-row {
        background: rgba(255, 255, 255, 0.06) !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        border-radius: 28px !important;
        padding: 6px 6px 6px 16px !important;
        gap: 6px !important;
        align-items: center !important;
      }

      #chatInput {
        background: transparent !important;
        border: none !important;
        outline: none !important;
        border-radius: 0 !important;
        padding: 8px 0 !important;
        font-size: 14px !important;
        min-height: 36px !important;
        box-shadow: none !important;
      }

      #chatInput:focus {
        outline: none !important;
        box-shadow: none !important;
      }

      .chat-send-btn {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        border-radius: 50% !important;
        flex-shrink: 0;
      }

      .chat-input-footer {
        font-size: 10px !important;
        text-align: center !important;
        margin-top: 6px !important;
        color: var(--text-dim) !important;
        padding: 0 !important;
      }

      /* ── 5. Featured banner: mobile card stack ── */
      .featured-banner {
        height: 320px !important;
        min-height: 320px !important;
      }

      .featured-banner-img {
        left: 0 !important;
        width: 100% !important;
        mask-image: none !important;
        -webkit-mask-image: none !important;
      }

      .featured-banner-overlay {
        background: linear-gradient(to top, rgba(10,10,10,0.95) 0%, rgba(10,10,10,0.7) 50%, rgba(10,10,10,0.2) 100%) !important;
      }

      .featured-banner-content {
        padding: 0 16px 20px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        bottom: 0 !important;
      }

      .featured-banner-eyebrow {
        font-size: 9px !important;
        margin-bottom: 4px !important;
      }

      .featured-banner-title {
        font-size: 22px !important;
        letter-spacing: 1px !important;
        margin-bottom: 6px !important;
        line-height: 1.2 !important;
      }

      .featured-banner-desc {
        font-size: 12px !important;
        margin-bottom: 12px !important;
        max-width: 100% !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
      }

      .featured-banner-actions { gap: 8px !important; }

      .featured-banner-actions .btn-primary,
      .featured-banner-actions .btn-secondary {
        font-size: 11px !important;
        padding: 8px 14px !important;
        height: auto !important;
      }

      .featured-nav-btn { display: none !important; }

      /* ── Home ── */
      .home-content {
        padding: 12px 14px !important;
      }

      .featured-header {
        margin-bottom: 12px !important;
      }

      /* ── Scenarios grid ── */
      .scenario-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
      }

      .scenarios-content {
        padding: 12px 14px !important;
      }

      .scenarios-content .section-header {
        flex-wrap: wrap !important;
        gap: 8px !important;
        padding: 12px 0 8px !important;
      }

      .scenarios-content .section-header>div {
        flex-wrap: wrap !important;
        gap: 6px !important;
      }

      /* ── Create hub cards ── */
      .create-hub-content {
        padding: 16px 14px !important;
        gap: 12px !important;
      }

      .create-hub-title {
        font-size: 17px !important;
        margin-bottom: 4px !important;
      }

      .create-hub-card {
        height: 130px !important;
        border-radius: 12px !important;
      }

      .create-hub-card-label {
        font-size: 20px !important;
        bottom: 14px !important;
        left: 16px !important;
      }

      .create-hub-card-tag {
        font-size: 11px !important;
        top: 12px !important;
        right: 14px !important;
      }
    }


    /* ===== SETTINGS POLISH CLEANUP ===== */
    .model-settings-current-card {
      padding: 16px 18px;
      border: 1px solid var(--border);
      border-radius: 16px;
      background: linear-gradient(135deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.015));
      margin-bottom: 18px;
    }

    .model-settings-picker-grid {
      gap: 18px;
      margin-bottom: 18px;
    }

    .model-settings-picker-card {
      border-radius: 16px;
    }

    #view-model-settings .settings-section {
      border-radius: 16px;
      border-bottom: none !important;
      padding: 28px 24px !important;
      display: flex;
      flex-direction: column;
      justify-content: center;
    }

    #view-model-settings .settings-section:last-of-type {
      border-bottom: none !important;
    }

    #view-settings .settings-section {
      border-radius: 14px;
    }

    #sceneImageGenerationSection textarea {
      min-height: 112px !important;
    }

    @media (max-width: 720px) {
      .model-settings-picker-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
      }

      .model-settings-current-card {
        margin: 0 0 14px;
        padding: 14px;
      }

      #view-settings .settings-section,
      #view-model-settings .settings-section {
        margin-left: 0;
        margin-right: 0;
      }
    }



    /* ===================== POLISHED SETTINGS SUBPAGES ===================== */
    .provider-banner-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 12px;
      margin-bottom: 14px;
    }

    .provider-banner {
      position: relative;
      min-height: 110px;
      border-radius: 16px;
      border: 1px solid rgba(255, 255, 255, 0.08);
      overflow: hidden;
      padding: 0;
      display: flex;
      align-items: stretch;
      justify-content: stretch;
      cursor: pointer;
      background: var(--bg-card);
      color: var(--text-primary);
      transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease, filter .22s ease;
      isolation: isolate;
    }

    .provider-banner::before {
      content: "";
      position: absolute;
      inset: 0;
      opacity: .94;
      transition: opacity .22s ease, transform .45s ease, filter .22s ease;
      z-index: 0;
    }

    .provider-banner::after {
      content: "";
      position: absolute;
      inset: 0;
      z-index: 1;
      background:
        linear-gradient(to top, rgba(0, 0, 0, .84) 0%, rgba(0, 0, 0, .44) 48%, rgba(0, 0, 0, .18) 100%),
        radial-gradient(circle at 50% 100%, rgba(232, 98, 26, .18), transparent 42%);
      transition: opacity .22s ease;
    }

    .provider-banner:hover {
      transform: translateY(-2px) scale(1.01);
      border-color: rgba(232, 98, 26, .55);
      box-shadow: 0 14px 34px rgba(0, 0, 0, .42), 0 0 26px rgba(232, 98, 26, .12);
    }

    .provider-banner:hover::before {
      transform: scale(1.055);
      opacity: 1;
      filter: saturate(1.12) brightness(1.06);
    }

    .provider-banner:active {
      transform: translateY(0) scale(.985);
    }

    .provider-banner.active {
      border-color: var(--accent);
      box-shadow: 0 0 0 1px rgba(232, 98, 26, .44), 0 14px 34px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(255, 255, 255, .08);
    }

    .provider-banner.active::after {
      background:
        linear-gradient(to top, rgba(0, 0, 0, .78) 0%, rgba(0, 0, 0, .38) 48%, rgba(0, 0, 0, .12) 100%),
        radial-gradient(circle at 50% 100%, rgba(232, 98, 26, .32), transparent 46%);
    }

    .provider-banner-title {
      position: relative;
      z-index: 2;
      width: 100%;
      align-self: flex-end;
      padding: 0 18px 16px;
      text-align: left;
      font-size: 22px;
      font-weight: 900;
      letter-spacing: .3px;
      color: #fff;
      text-shadow: 0 2px 14px rgba(0, 0, 0, .85);
    }

    .provider-banner-sub {
      display: none !important;
    }


    .provider-banner.deepseek::before {
      background: radial-gradient(circle at 76% 20%, rgba(46, 189, 217, .8), transparent 32%), radial-gradient(circle at 18% 80%, rgba(20, 75, 112, .55), transparent 36%), linear-gradient(135deg, #06151e, #142735 48%, #07090b);
    }

    .provider-banner.xai::before {
      background: radial-gradient(circle at 74% 18%, rgba(255, 255, 255, .38), transparent 30%), radial-gradient(circle at 20% 72%, rgba(110, 110, 110, .45), transparent 38%), linear-gradient(135deg, #060606, #232323 48%, #030303);
    }

    .provider-banner.nanogpt::before {
      background: radial-gradient(circle at 20% 20%, rgba(0, 200, 120, .75), transparent 35%), radial-gradient(circle at 80% 80%, rgba(0, 120, 200, .45), transparent 38%), linear-gradient(135deg, #041a0e, #062818 48%, #050f0a);
    }

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

    .settings-action-card {
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 14px;
      padding: 14px;
      display: flex;
      flex-direction: column;
      gap: 8px;
      min-height: 112px;
    }

    .settings-action-card-title {
      font-size: 14px;
      font-weight: 800;
      color: var(--text-primary);
    }

    .settings-action-card-sub {
      font-size: 12px;
      line-height: 1.45;
      color: var(--text-dim);
      flex: 1;
    }

    .settings-action-row {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 2px;
    }

    #smAutoBackupsToggle:checked + span {
      background: rgba(250, 91, 12, 0.9) !important;
      border-color: rgba(250, 91, 12, 0.95) !important;
    }

    #smAutoBackupsToggle:checked + span + span {
      transform: translateX(20px);
    }

    .api-key-grid {
      display: grid;
      grid-template-columns: 1fr;
      gap: 14px;
    }

    .api-key-card {
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 14px;
      padding: 14px;
    }

    .api-key-card-title {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 13px;
      font-weight: 800;
      color: var(--text-primary);
      margin-bottom: 8px;
    }

    .api-key-card-sub {
      font-size: 11px;
      color: var(--text-dim);
      margin-top: 6px;
      line-height: 1.45;
    }

    @media (max-width: 700px) {

      .provider-banner-grid,
      .settings-card-grid {
        grid-template-columns: 1fr;
      }

      .provider-banner {
        min-height: 92px;
      }

      .provider-banner-title {
        font-size: 20px;
        padding: 0 16px 14px;
      }
    }



    /* ===================== SETTINGS SPACING POLISH PATCH ===================== */
    #settings-panel .subpage-view .settings-content {
      padding: 0 20px 42px !important;
      max-width: none;
    }

    #settings-panel .subpage-view .settings-back-btn {
      margin: 0 -20px 18px !important;
      padding: 16px 20px !important;
      border-bottom: 1px solid rgba(255, 255, 255, 0.075) !important;
      color: var(--text-secondary);
      background: rgba(255, 255, 255, 0.01);
    }

    #settings-panel .subpage-view .settings-view-header {
      padding: 4px 0 18px !important;
      margin: 0 0 16px !important;
      border-bottom: 0 !important;
    }

    #settings-panel .subpage-view .settings-view-header h2 {
      margin: 0 !important;
      line-height: 1.15;
    }

    #settings-panel .subpage-view .settings-section {
      padding: 18px 0 !important;
      border-bottom: 1px solid rgba(255, 255, 255, 0.07) !important;
    }

    #settings-panel .subpage-view .settings-section:first-of-type {
      padding-top: 4px !important;
    }

    #settings-panel .subpage-view .settings-card-grid,
    #settings-panel .subpage-view .api-key-grid {
      gap: 14px !important;
    }

    @media (max-width: 720px) {
      #settings-panel .subpage-view .settings-content {
        padding-left: 18px !important;
        padding-right: 18px !important;
      }

      #settings-panel .subpage-view .settings-back-btn {
        margin-left: -18px !important;
        margin-right: -18px !important;
        padding-left: 18px !important;
        padding-right: 18px !important;
      }
    }



    /* ===================== IN-SITE CONFIRM / PROMPT MODAL ===================== */
    .app-dialog-backdrop {
      position: fixed;
      inset: 0;
      z-index: 5000;
      display: none;
      align-items: center;
      justify-content: center;
      background: rgba(0, 0, 0, 0.62);
      backdrop-filter: blur(8px);
      padding: 18px;
    }

    .app-dialog-backdrop.open {
      display: flex;
    }

    .app-dialog {
      width: min(420px, 100%);
      background: var(--bg-panel);
      border: 1px solid var(--border-light);
      border-radius: 16px;
      box-shadow: 0 24px 80px rgba(0, 0, 0, 0.65);
      overflow: hidden;
    }

    .app-dialog-head {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 16px 18px 10px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }

    .app-dialog-icon {
      width: 30px;
      height: 30px;
      border-radius: 10px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: rgba(232, 98, 26, 0.14);
      color: var(--accent);
      flex-shrink: 0;
    }

    .app-dialog-title {
      font-size: 15px;
      font-weight: 800;
      color: var(--text-primary);
    }

    .app-dialog-body {
      padding: 14px 18px 4px;
      color: var(--text-secondary);
      font-size: 13px;
      line-height: 1.55;
      white-space: pre-wrap;
    }

    .app-dialog-input {
      width: calc(100% - 36px);
      margin: 8px 18px 0;
      display: none;
    }

    .app-dialog-input.open {
      display: block;
    }

    .app-dialog-actions {
      display: flex;
      justify-content: flex-end;
      gap: 10px;
      padding: 18px;
    }

    .app-dialog .btn-secondary,
    .app-dialog .btn-danger,
    .app-dialog .btn-primary {
      min-width: 88px;
      justify-content: center;
    }

    .image-cleanup-status {
      margin-top: 8px;
      font-size: 11px;
      line-height: 1.45;
      color: var(--text-dim);
    }

/* ── Block 2 ──────────────────────────────────────────────── */
    /* ===================== SETTINGS SIDEBAR ALIGNMENT PATCH ===================== */
    #settings-panel {
      --settings-x-pad: 24px;
      --settings-row-h: 58px;
      --settings-soft-line: rgba(255, 255, 255, 0.075);
    }

    #settings-panel .settings-header {
      min-height: 72px !important;
      padding: 0 var(--settings-x-pad) !important;
      display: flex !important;
      align-items: center !important;
      justify-content: space-between !important;
      border-bottom: 1px solid var(--settings-soft-line) !important;
    }

    #settings-panel .settings-header h2 {
      margin: 0 !important;
      line-height: 1 !important;
      font-size: 22px !important;
      letter-spacing: -0.02em;
    }

    #settings-panel .settings-close {
      width: 40px !important;
      height: 40px !important;
      display: flex !important;
      align-items: center !important;
      justify-content: center !important;
      flex: 0 0 40px !important;
    }

    #settings-panel .settings-body {
      padding: 0 0 44px !important;
    }

    #settings-panel .settings-section {
      padding: 18px var(--settings-x-pad) !important;
      border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
    }

    #settings-panel .settings-section-label {
      margin: 0 0 14px !important;
      line-height: 1.15 !important;
    }

    #settings-panel .settings-row,
    #settings-panel .settings-nav-row,
    #settings-panel .color-row {
      min-height: 48px !important;
      padding-top: 10px !important;
      padding-bottom: 10px !important;
      display: flex !important;
      align-items: center !important;
    }

    #settings-panel .settings-row>div:first-child,
    #settings-panel .settings-nav-row>div:first-child {
      min-width: 0;
    }

    #settings-panel .settings-row-label,
    #settings-panel .settings-nav-label,
    #settings-panel .color-row-label {
      line-height: 1.2 !important;
    }

    #settings-panel .settings-row-sub {
      line-height: 1.35 !important;
      margin-top: 4px !important;
    }

    #settings-panel .settings-select,
    #settings-panel .segment-control,
    #settings-panel .model-banner {
      margin-top: 10px !important;
    }

    #settings-panel .subpage-view .settings-content {
      padding: 0 var(--settings-x-pad) 46px !important;
      max-width: none !important;
    }

    #settings-panel .subpage-view .settings-back-btn {
      height: var(--settings-row-h) !important;
      min-height: var(--settings-row-h) !important;
      margin: 0 calc(var(--settings-x-pad) * -1) !important;
      padding: 0 var(--settings-x-pad) !important;
      display: flex !important;
      align-items: center !important;
      gap: 12px !important;
      border-top: 0 !important;
      border-bottom: 1px solid var(--settings-soft-line) !important;
      background: rgba(255, 255, 255, 0.012) !important;
      color: var(--text-secondary) !important;
      line-height: 1 !important;
    }

    #settings-panel .subpage-view .settings-back-btn svg,
    #settings-panel .subpage-view .settings-back-btn .material-symbols-outlined {
      flex: 0 0 auto !important;
      display: block !important;
    }

    #settings-panel .subpage-view .settings-view-header {
      min-height: 68px !important;
      margin: 0 !important;
      padding: 0 !important;
      display: flex !important;
      align-items: center !important;
      gap: 14px !important;
      border-bottom: 0 !important;
    }

    #settings-panel .subpage-view .settings-view-header h2 {
      margin: 0 !important;
      line-height: 1.05 !important;
      font-size: 22px !important;
      letter-spacing: -0.025em;
    }

    #settings-panel .subpage-view .settings-view-header .material-symbols-outlined,
    #settings-panel .subpage-view .settings-view-header svg {
      flex: 0 0 auto !important;
      color: var(--accent) !important;
    }

    #settings-panel .subpage-view .settings-section:first-of-type {
      padding-top: 10px !important;
    }

    #settings-panel .subpage-view .settings-section {
      padding-left: 0 !important;
      padding-right: 0 !important;
    }

    #settings-panel .settings-nav-row:hover,
    #settings-panel .settings-back-btn:hover {
      background: rgba(255, 255, 255, 0.025) !important;
    }

    @media (max-width: 720px) {
      #settings-panel {
        --settings-x-pad: 20px;
        --settings-row-h: 56px;
      }

      #settings-panel .settings-header {
        min-height: 68px !important;
      }

      #settings-panel .settings-header h2,
      #settings-panel .subpage-view .settings-view-header h2 {
        font-size: 21px !important;
      }
    }

    /* === SETTINGS SUBPAGE ALIGNMENT MICRO-PATCH === */
    #settingsPanel .settings-subpage-back,
    #settingsPanel .settings-back-row,
    #settingsPanel .settings-back-btn,
    .settings-subpage-back,
    .settings-back-row,
    .settings-back-btn {
      min-height: 56px !important;
      height: 56px !important;
      padding-top: 0 !important;
      padding-bottom: 4px !important;
      /* optical lift: sits slightly higher between dividers */
      display: flex !important;
      align-items: center !important;
      box-sizing: border-box !important;
    }

    #settingsPanel .settings-subpage-back>*,
    #settingsPanel .settings-back-row>*,
    #settingsPanel .settings-back-btn>*,
    .settings-subpage-back>*,
    .settings-back-row>*,
    .settings-back-btn>* {
      transform: translateY(-2px);
    }

    /* Fallback for inline-created Back to Settings rows */
    #settingsPanel [onclick*="Settings"][class*="back"],
    .settings-panel [onclick*="Settings"][class*="back"] {
      padding-top: 0 !important;
      padding-bottom: 4px !important;
      align-items: center !important;
    }


    /* ===================== MOBILE POLISH PATCH V2 - SAFE SIDEBAR =====================
     CSS-only responsive layer. Keeps the existing sidebar/nav behaviour intact.
     No provider, memory, import/export, image-generation, or scenario logic touched.
  ================================================================================ */
    @media (max-width: 860px) {
      :root {
        --topbar-h: 48px;
        --mobile-gutter: 14px;
        --sidebar-w: 56px;
      }

      html,
      body {
        width: 100%;
        min-width: 0;
        overflow: hidden;
        overscroll-behavior: none;
        -webkit-text-size-adjust: 100%;
      }

      #app {
        display: flex !important;
        flex-direction: row !important;
        width: 100vw !important;
        height: 100dvh !important;
        min-height: 100dvh !important;
        overflow: hidden !important;
      }

      #sidebar,
      #sidebar.collapsed {
        position: relative !important;
        top: auto !important;
        right: auto !important;
        bottom: auto !important;
        left: auto !important;
        width: 56px !important;
        min-width: 56px !important;
        max-width: 56px !important;
        height: 100dvh !important;
        padding: 0 !important;
        flex: 0 0 56px !important;
        flex-direction: column !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
        border-top: 0 !important;
        background: var(--bg-panel) !important;
        z-index: 20 !important;
      }

      #sidebar .sidebar-logo,
      #sidebar.collapsed .sidebar-logo {
        height: 52px !important;
        padding: 0 !important;
        justify-content: center !important;
        flex: 0 0 52px !important;
      }

      #sidebar .sidebar-logo img {
        width: 38px !important;
        height: 38px !important;
        margin: 0 !important;
      }

      #sidebar .sidebar-logo-text,
      #sidebar .sidebar-collapse-btn,
      #sidebar .sidebar-section-label,
      #sidebar .chat-history-list,
      #sidebar .music-player,
      #sidebar .user-info,
      #sidebar .nav-label,
      #sidebar.collapsed .sidebar-logo-text,
      #sidebar.collapsed .sidebar-collapse-btn,
      #sidebar.collapsed .sidebar-section-label,
      #sidebar.collapsed .chat-history-list,
      #sidebar.collapsed .music-player,
      #sidebar.collapsed .user-info,
      #sidebar.collapsed .nav-label {
        display: none !important;
      }

      #sidebar .sidebar-nav,
      #sidebar.collapsed .sidebar-nav {
        width: 100% !important;
        padding: 8px 0 !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 4px !important;
        align-items: stretch !important;
        overflow: visible !important;
        flex-shrink: 0 !important;
      }

      #sidebar .nav-item,
      #sidebar.collapsed .nav-item {
        width: 100% !important;
        height: 48px !important;
        min-height: 48px !important;
        padding: 0 !important;
        margin: 0 !important;
        border-radius: 0 !important;
        border-right: 3px solid transparent !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0 !important;
        color: var(--text-secondary) !important;
        overflow: visible !important;
      }

      #sidebar .nav-item.active,
      #sidebar.collapsed .nav-item.active {
        border-right-color: var(--accent) !important;
        background: linear-gradient(90deg, rgba(232, 98, 26, 0.12), rgba(232, 98, 26, 0.04)) !important;
        color: var(--accent) !important;
      }

      #sidebar .nav-item svg,
      #sidebar .nav-item .material-symbols-outlined {
        width: 22px !important;
        height: 22px !important;
        font-size: 22px !important;
        flex: 0 0 auto !important;
      }

      #sidebar .sidebar-user-area,
      #sidebar.collapsed .sidebar-user-area {
        margin-top: auto !important;
        padding: 10px 0 12px !important;
        border-top: 1px solid var(--border) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex-shrink: 0 !important;
      }

      #sidebar .user-avatar,
      #sidebar.collapsed .user-avatar {
        width: 36px !important;
        height: 36px !important;
        font-size: 13px !important;
      }

      #main {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        width: auto !important;
        height: 100dvh !important;
        padding-bottom: 0 !important;
        overflow: hidden !important;
      }

      #topbar {
        height: 48px !important;
        padding: 0 10px !important;
        gap: 8px !important;
      }

      .topbar-search {
        max-width: none !important;
        min-width: 0 !important;
      }

      .topbar-search input {
        height: 34px !important;
        font-size: 13px !important;
        border-radius: 16px !important;
        padding-right: 10px !important;
      }

      .topbar-actions {
        gap: 4px !important;
        flex-shrink: 0 !important;
      }

      .topbar-btn,
      .chat-topbar-btn,
      .chat-topbar-icon-btn {
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
      }

      .topbar-avatar {
        width: 32px !important;
        height: 32px !important;
      }

      .view.active {
        min-height: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
      }

      #view-home,
      #view-scenarios,
      #view-create,
      #view-create-hub,
      #view-personas,
      #view-personas-hub,
      #view-characters-original,
      #view-scenario-detail,
      #view-settings,
      #view-edit-char,
      #view-ai-rules,
      #view-import-export,
      #view-model-settings,
      #view-continuity,
      #view-memory,
      #view-lore-hub,
      #view-explore {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
      }

      .home-content,
      .scenarios-content,
      .personas-content,
      .characters-content,
      .creator-content,
      .create-hub-content,
      .scenario-detail-content,
      .settings-content,
      .memory-content,
      .lore-hub-content,
      .continuity-content,
      .explore-content {
        width: 100% !important;
        max-width: none !important;
        padding-left: var(--mobile-gutter) !important;
        padding-right: var(--mobile-gutter) !important;
        padding-top: 16px !important;
        padding-bottom: 120px !important;
      }

      .section-header,
      .personas-header,
      .scenarios-content .section-header {
        gap: 12px !important;
        align-items: center !important;
        margin-bottom: 14px !important;
      }

      .section-header h3,
      .scenarios-content .section-header h3,
      .featured-header h2,
      .personas-header h2 {
        font-size: 16px !important;
        line-height: 1.2 !important;
      }

      .featured-banner {
        height: 340px !important;
      }

      .featured-banner-content {
        padding: 0 24px 28px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
      }

      .featured-banner-title {
        font-size: 24px !important;
        letter-spacing: 1.5px !important;
        margin-bottom: 8px !important;
        line-height: 1.2 !important;
      }

      .featured-banner-desc {
        font-size: 12px !important;
        margin-bottom: 14px !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
      }

      .featured-banner-actions .btn-primary,
      .featured-banner-actions .btn-secondary {
        font-size: 12px !important;
        padding: 8px 16px !important;
      }

      .scenario-detail-hero {
        height: 360px !important;
      }

      .scenario-detail-hero-img {
        left: 0 !important;
        -webkit-mask-image: none !important;
        mask-image: none !important;
      }

      .scenario-detail-hero-overlay {
        background:
          linear-gradient(to top,
            rgba(0,0,0,0.95) 0%,
            rgba(0,0,0,0.6) 40%,
            rgba(0,0,0,0.2) 100%) !important;
      }

      .scenario-detail-header {
        width: 100% !important;
        padding: 0 20px 28px !important;
      }

      .scenario-detail-title {
        font-size: 24px !important;
      }

      .scenario-detail-desc {
        font-size: 12px !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 3 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
      }

      .scenario-detail-body {
        padding: 20px 0 !important;
      }

      .featured-btn-start, .featured-btn-details {
        font-size: 14px !important;
        padding: 11px 20px !important;
      }

      .featured-nav-btn {
        opacity: 1 !important;
        width: 32px !important;
        height: 32px !important;
        background: rgba(0, 0, 0, 0.52) !important;
      }

      .featured-dots {
        display: none !important;
      }

      .scenario-grid,
      #storyCharactersList,
      .story-card-section-grid,
      .persona-grid,
      .personas-grid,
      .characters-grid,
      .settings-grid,
      .model-grid {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
      }

      .scenario-card {
        gap: 9px !important;
      }

      .scenario-card-img {
        border-radius: 12px !important;
      }

      .scenario-card-menu-btn {
        display: flex !important;
        width: 34px !important;
        height: 34px !important;
        background: rgba(0, 0, 0, 0.62) !important;
      }

      /* Creator Layout Stacking */
      .creator-main-row {
        flex-direction: column !important;
        gap: 16px !important;
      }

      .creator-left-col {
        width: 100% !important;
      }

      .creator-right-col {
        width: 100% !important;
      }

      .creator-bottom-actions {
        bottom: 64px !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
        background: var(--bg-panel) !important;
        border-top: 1px solid var(--border) !important;
        margin-left: calc(-1 * var(--mobile-gutter)) !important;
        margin-right: calc(-1 * var(--mobile-gutter)) !important;
        width: calc(100% + 2 * var(--mobile-gutter)) !important;
      }

      .personas-header {
        flex-wrap: wrap !important;
        gap: 10px !important;
      }

      .personas-header>div {
        flex-wrap: wrap !important;
        gap: 6px !important;
      }

      .char-modal-flex-row {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
      }

      .character-section-title-text {
        white-space: normal !important;
        line-height: 1.3 !important;
      }


      .scenario-card-title {
        font-size: 15px !important;
        -webkit-line-clamp: 2 !important;
      }

      .scenario-card-desc {
        font-size: 12px !important;
        -webkit-line-clamp: 2 !important;
      }

      .create-hub-content {
        gap: 14px !important;
      }

      .create-hub-title {
        font-size: 20px !important;
        margin-bottom: 2px !important;
      }

      .create-hub-card {
        height: 150px !important;
        border-radius: 15px !important;
      }

      .create-hub-card-label {
        left: 16px !important;
        bottom: 14px !important;
        font-size: 21px !important;
      }

      .create-hub-card-tag {
        top: 12px !important;
        right: 14px !important;
        font-size: 11px !important;
      }

      #chat-topbar {
        height: 48px !important;
        padding: 0 8px !important;
        gap: 8px !important;
      }

      .chat-topbar-scenario-img {
        width: 34px !important;
        height: 34px !important;
      }

      .chat-topbar-info {
        min-width: 0 !important;
      }

      .chat-topbar-name {
        font-size: 12px !important;
      }

      .chat-topbar-sub,
      .chat-topbar-badge {
        display: none !important;
      }

      .chat-topbar-actions {
        gap: 2px !important;
        max-width: 54vw !important;
        overflow-x: auto !important;
        scrollbar-width: none !important;
      }

      .chat-topbar-actions::-webkit-scrollbar {
        display: none;
      }

      .persona-picker-btn {
        max-width: 104px !important;
        min-width: 0 !important;
        padding: 4px 8px 4px 5px !important;
      }

      .persona-picker-name {
        max-width: 58px !important;
      }

      #personaPickerMenu.open {
        left: 62px !important;
        right: 8px !important;
        width: auto !important;
        max-width: calc(100vw - 70px) !important;
        max-height: min(76vh, 520px) !important;
        flex-direction: column !important;
      }

      .picker-list-col,
      .picker-preview-col {
        width: 100% !important;
        max-width: none !important;
        border-right: 0 !important;
      }

      .picker-preview-col {
        max-height: 230px !important;
        border-top: 1px solid var(--border) !important;
      }

      .picker-preview-hero {
        height: 95px !important;
      }

      .memory-card {
        margin: 10px var(--mobile-gutter) !important;
        border-radius: 13px !important;
      }

      .memory-card-header {
        padding: 12px !important;
        gap: 10px !important;
        align-items: flex-start !important;
      }

      .memory-card-header-right {
        flex-wrap: wrap !important;
        justify-content: flex-end !important;
      }

      .story-card,
      .char-card {
        border-radius: 12px !important;
      }

      .story-card[style*="row"],
      .story-card {
        flex-direction: column !important;
        gap: 10px !important;
      }

      .story-card-image {
        width: 100% !important;
        height: auto !important;
        min-width: 0 !important;
        aspect-ratio: 16 / 9 !important;
      }

      .char-card {
        flex-direction: row !important;
      }

      .char-card-image {
        width: 96px !important;
        height: 118px !important;
      }

      .creator-bottom-actions,
      .personaModal-footer,
      .charModal-footer,
      .scModal-footer,
      .cropModal-footer,
      .memEditModal-footer {
        gap: 10px !important;
        flex-wrap: wrap !important;
      }

      .creator-bottom-actions .btn-primary,
      .creator-bottom-actions .btn-secondary,
      .personaModal-footer .btn-primary,
      .personaModal-footer .btn-secondary,
      .charModal-footer .btn-primary,
      .charModal-footer .btn-secondary,
      .charModal-footer .btn-danger,
      .scModal-footer .btn-primary,
      .scModal-footer .btn-secondary,
      .scModal-footer .btn-danger {
        min-height: 40px !important;
        justify-content: center !important;
        flex: 1 1 auto !important;
      }

      #personaModal,
      #charModal,
      #scModal,
      #memEditModal,
      #cropModal,
      #settingsPanel,
      .modal,
      .settings-panel {
        width: calc(100vw - 72px) !important;
        max-width: calc(100vw - 72px) !important;
        max-height: 92dvh !important;
        border-radius: 16px !important;
      }

      .personaModal-header,
      .charModal-header,
      .scModal-header,
      .memEditModal-header {
        padding: 18px !important;
      }

      .personaModal-body,
      .charModal-body,
      .scModal-body,
      .memEditModal-body {
        padding: 18px !important;
        gap: 16px !important;
      }

      .persona-avatar-upload {
        width: min(170px, 58vw) !important;
        height: min(170px, 58vw) !important;
      }

      input,
      textarea,
      select,
      button {
        font-size: 16px;
      }
    }

    @media (max-width: 480px) {
      :root {
        --mobile-gutter: 12px;
        --sidebar-w: 52px;
      }

      #sidebar,
      #sidebar.collapsed {
        width: 52px !important;
        min-width: 52px !important;
        max-width: 52px !important;
        flex-basis: 52px !important;
      }

      #sidebar .nav-item,
      #sidebar.collapsed .nav-item {
        height: 46px !important;
        min-height: 46px !important;
      }

      #sidebar .nav-item svg,
      #sidebar .nav-item .material-symbols-outlined {
        width: 21px !important;
        height: 21px !important;
        font-size: 21px !important;
      }

      .home-content,
      .scenarios-content,
      .personas-content,
      .creator-content,
      .create-hub-content,
      .settings-content,
      .memory-content,
      .lore-hub-content,
      .continuity-content {
        padding-left: 12px !important;
        padding-right: 12px !important;
      }

      .featured-banner {
        height: 300px !important;
        min-height: 300px !important;
        padding-top: 0 !important;
      }

      .featured-banner-content {
        padding: 0 12px 16px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        bottom: 0 !important;
      }

      .featured-banner-title {
        font-size: 20px !important;
        line-height: 1.15 !important;
        margin-bottom: 4px !important;
      }

      .featured-banner-desc {
        -webkit-line-clamp: 2 !important;
        margin-bottom: 10px !important;
        font-size: 11px !important;
      }

      .featured-banner-actions .btn-primary,
      .featured-banner-actions .btn-secondary {
        padding: 7px 12px !important;
        font-size: 11px !important;
        height: auto !important;
      }
      
      .featured-banner-actions svg {
        width: 11px !important;
        height: 11px !important;
      }

      .create-hub-card {
        height: 132px !important;
      }

      .char-card-image {
        width: 84px !important;
        height: 108px !important;
      }

      #personaModal,
      #charModal,
      #scModal,
      #memEditModal,
      #cropModal,
      #settingsPanel,
      .modal,
      .settings-panel {
        width: calc(100vw - 64px) !important;
        max-width: calc(100vw - 64px) !important;
      }
    }

    /* Premium Model Selector Modal styling */
    #modelSelectorModal {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 20000;
      align-items: center;
      justify-content: center;
      pointer-events: auto;
    }
    #modelSelectorModal.active {
      display: flex;
    }
    #modelSelectorBackdrop {
      position: absolute;
      inset: 0;
      background: rgba(0, 0, 0, 0.75);
      z-index: 0;
    }
    #modelSelectorContainer {
      position: relative;
      z-index: 10;
      width: 100%;
      max-width: 920px;
      height: 85vh;
      max-height: 85vh;
      background: #09090b;
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 20px;
      display: flex;
      flex-direction: column;
      box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9);
      pointer-events: auto;
      overflow: hidden;
    }
    #modelSelectorHeader {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 20px 24px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.06);
      background: rgba(255,255,255,0.02);
    }
    .model-selector-scroll {
      flex: 1;
      overflow-y: auto;
      padding: 24px;
      display: flex;
      flex-direction: column;
      gap: 24px;
      will-change: transform;
    }
    .model-selector-scroll::-webkit-scrollbar {
      width: 6px;
    }
    .model-selector-scroll::-webkit-scrollbar-track {
      background: transparent;
    }
    .model-selector-scroll::-webkit-scrollbar-thumb {
      background: rgba(255,255,255,0.1);
      border-radius: 99px;
    }
    .model-selector-group-label {
      font-size: 11px;
      font-weight: 800;
      text-transform: uppercase;
      letter-spacing: 2px;
      margin-bottom: 14px;
      display: flex;
      align-items: center;
      gap: 12px;
    }
    .model-selector-group-label::after {
      content: "";
      flex: 1;
      height: 1px;
      background: linear-gradient(90deg, rgba(255,255,255,0.08), transparent);
    }
    .model-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
      gap: 16px;
      margin-bottom: 8px;
    }
    .model-card {
      position: relative;
      border-radius: 14px;
      border: 1px solid rgba(255, 255, 255, 0.06);
      background: rgba(255, 255, 255, 0.02);
      padding: 20px;
      cursor: pointer;
      overflow: hidden;
      display: flex;
      flex-direction: column;
      justify-content: flex-end;
      gap: 10px;
      transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
      min-height: 200px;
    }
    .model-card:hover {
      border-color: var(--accent);
      transform: translateY(-2px);
      box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    }
    .model-card.active {
      border-color: var(--accent);
      background: rgba(232, 98, 26, 0.04);
      box-shadow: 0 0 20px rgba(232, 98, 26, 0.12);
    }
    .model-card-banner {
      position: absolute;
      inset: 0;
      background-size: cover;
      background-position: center;
      opacity: 0.15;
      z-index: 0;
      transition: opacity 0.25s ease, transform 0.25s ease;
      pointer-events: none;
    }
    .model-card:hover .model-card-banner {
      opacity: 0.28;
      transform: scale(1.03);
    }
    .model-card-header {
      display: flex;
      justify-content: flex-start;
      align-items: center;
      z-index: 1;
      position: relative;
    }
    .model-card-name {
      font-size: 16px;
      font-weight: 800;
      color: #fff;
      font-family: var(--font-display);
    }
    .model-card-badge {
      display: none;
    }
    .model-card-desc {
      font-size: 11px;
      line-height: 1.5;
      color: rgba(255,255,255,0.9);
      margin: 0;
      z-index: 1;
      position: relative;
      text-shadow: 0 1px 3px rgba(0,0,0,0.7);
    }
    .model-card-footer {
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-size: 10px;
      color: rgba(255,255,255,0.85);
      z-index: 1;
      position: relative;
      margin-top: 4px;
      border-top: 1px solid rgba(255,255,255,0.1);
      padding-top: 8px;
      text-shadow: 0 1px 3px rgba(0,0,0,0.7);
    }
    .model-card.locked {
      cursor: pointer; /* make clickable so we can show warning or redirect */
      border-color: rgba(255, 255, 255, 0.03);
      background: rgba(255, 255, 255, 0.01);
    }
    .model-card.locked .model-card-name, 
    .model-card.locked .model-card-desc, 
    .model-card.locked .model-card-footer {
      opacity: 0.4;
    }
    .model-card-lock-overlay {
      position: absolute;
      inset: 0;
      background: rgba(9, 9, 11, 0.88);
      z-index: 3;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 8px;
      opacity: 0;
      transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
      backdrop-filter: blur(2px);
    }
    .model-card.locked:hover .model-card-lock-overlay {
      opacity: 1;
    }
    .model-card-lock-badge {
      font-size: 9px;
      font-weight: 800;
      background: linear-gradient(135deg, #a855f7, #ec4899);
      color: #fff;
      padding: 4px 10px;
      border-radius: 99px;
      display: flex;
      align-items: center;
      gap: 5px;
      box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }

    /* Sampling Parameters Modal */
    #samplingParamsModal {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 9998;
      align-items: center;
      justify-content: center;
      pointer-events: auto;
    }

    #samplingParamsModal.active {
      display: flex;
    }

    #samplingParamsBackdrop {
      position: absolute;
      inset: 0;
      background: rgba(0, 0, 0, 0.6);
      backdrop-filter: blur(4px);
      z-index: 0;
    }

    #samplingParamsContainer {
      position: relative;
      z-index: 10;
      width: 100%;
      max-width: 900px;
      height: 85vh;
      background: #09090b;
      border: 1px solid #27272a;
      border-radius: 16px;
      display: flex;
      flex-direction: column;
      box-shadow: 0 0 50px -12px rgba(0, 0, 0, 0.8);
      pointer-events: auto;
    }

    #samplingParamsHeader {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 20px 32px;
      border-bottom: 1px solid #27272a;
      background: #09090b;
    }

    #samplingParamsContent {
      flex: 1;
      overflow-y: auto;
      padding: 32px;
    }

    #samplingParamsContent::-webkit-scrollbar {
      width: 8px;
    }

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

    #samplingParamsContent::-webkit-scrollbar-thumb {
      background: #27272a;
      border-radius: 4px;
    }

    #samplingParamsContent::-webkit-scrollbar-thumb:hover {
      background: #3f3f46;
    }

    #samplingParamsFooter {
      padding: 20px 32px;
      border-top: 1px solid #27272a;
      background: #09090b;
      display: flex;
      gap: 12px;
      justify-content: flex-end;
    }

    .sampling-modal-btn {
      padding: 10px 20px;
      border-radius: 8px;
      border: 1px solid #27272a;
      background: #18181b;
      color: #e4e4e7;
      font-size: 13px;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.2s;
    }

    .sampling-modal-btn:hover {
      background: #27272a;
      border-color: #3f3f46;
    }

    .sampling-modal-btn.primary {
      background: white;
      color: black;
      border-color: white;
    }

    .sampling-modal-btn.primary:hover {
      background: #e4e4e7;
      border-color: #e4e4e7;
    }

    /* Range slider styling */
    input[type="range"] {
      -webkit-appearance: none;
      appearance: none;
      background: transparent;
      height: 24px;
      cursor: pointer;
    }

    input[type="range"]:focus {
      outline: none;
    }

    input[type="range"]::-webkit-slider-runnable-track {
      width: 100%;
      height: 4px;
      background: rgba(255, 255, 255, 0.2);
      border-radius: 2px;
      border: none;
    }

    input[type="range"]::-moz-range-track {
      width: 100%;
      height: 4px;
      background: rgba(255, 255, 255, 0.2);
      border-radius: 2px;
      border: none;
    }

    input[type="range"]::-webkit-slider-thumb {
      -webkit-appearance: none;
      appearance: none;
      width: 18px;
      height: 18px;
      border-radius: 50%;
      background: #ffffff;
      cursor: pointer;
      margin-top: -7px;
      box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(0,0,0,0.1);
      transition: transform 0.1s;
    }

    input[type="range"]::-webkit-slider-thumb:active {
      transform: scale(1.15);
    }

    input[type="range"]::-moz-range-thumb {
      width: 18px;
      height: 18px;
      border-radius: 50%;
      background: #ffffff;
      cursor: pointer;
      border: none;
      box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(0,0,0,0.1);
      transition: transform 0.1s;
    }

    input[type="range"]::-moz-range-thumb:active {
      transform: scale(1.15);
    }

    /* Global AI Rules Modal */
    #aiRulesModal {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 9998;
      align-items: center;
      justify-content: center;
      pointer-events: auto;
    }

    #aiRulesModal.active {
      display: flex;
    }

    #aiRulesBackdrop {
      position: absolute;
      inset: 0;
      background: rgba(0, 0, 0, 0.6);
      backdrop-filter: blur(4px);
      z-index: 0;
    }

    #aiRulesContainer {
      position: relative;
      z-index: 10;
      width: 100%;
      max-width: 900px;
      height: 85vh;
      background: #09090b;
      border: 1px solid #27272a;
      border-radius: 16px;
      display: flex;
      flex-direction: column;
      box-shadow: 0 0 50px -12px rgba(0, 0, 0, 0.8);
      pointer-events: auto;
    }

    #aiRulesHeader {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 20px 32px;
      border-bottom: 1px solid #27272a;
      background: #09090b;
    }

    #aiRulesContent {
      flex: 1;
      overflow-y: auto;
      padding: 32px;
      display: flex;
      flex-direction: column;
    }

    #aiRulesContent::-webkit-scrollbar {
      width: 8px;
    }

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

    #aiRulesContent::-webkit-scrollbar-thumb {
      background: #27272a;
      border-radius: 4px;
    }

    #aiRulesContent::-webkit-scrollbar-thumb:hover {
      background: #3f3f46;
    }

    #aiRulesFooter {
      padding: 20px 32px;
      border-top: 1px solid #27272a;
      background: #09090b;
      display: flex;
      gap: 12px;
      justify-content: space-between;
    }

    .ai-rules-textarea {
      flex: 1;
      background: #18181b;
      border: 1px solid #27272a;
      border-radius: 8px;
      padding: 16px;
      color: #e4e4e7;
      font-family: inherit;
      font-size: 14px;
      line-height: 1.6;
      resize: none;
      outline: none;
    }

    .ai-rules-textarea:focus {
      border-color: #3f3f46;
      background: #1a1a1d;
    }

    .ai-rules-textarea::placeholder {
      color: #71717a;
    }

    /* ── Settings Modal (two-column, FictionLab-style) ──────── */
    #accountModal {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 10000;
      align-items: center;
      justify-content: center;
      padding: 16px;
      background: rgba(0,0,0,0.75);
      backdrop-filter: blur(6px);
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.2s;
    }
    #accountModal.active { display: flex; opacity: 1; pointer-events: auto; }

    .sm-box {
      position: relative;
      display: flex;
      width: min(880px, 100%);
      height: min(620px, 90vh);
      background: #141414;
      border: 1px solid #2a2a2a;
      border-radius: 16px;
      overflow: hidden;
      box-shadow: 0 20px 60px rgba(0,0,0,0.7);
    }

    /* Left sidebar */
    .sm-sidebar {
      width: 200px;
      flex-shrink: 0;
      background: #0f0f0f;
      border-right: 1px solid #222;
      display: flex;
      flex-direction: column;
      overflow-y: auto;
    }
    .sm-sidebar-user {
      padding: 20px 16px 14px;
      border-bottom: 1px solid #222;
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .sm-sidebar-av {
      width: 36px;
      height: 36px;
      border-radius: 50%;
      background: #333;
      border: 2px solid #444;
      flex-shrink: 0;
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 13px;
      font-weight: 700;
      color: var(--accent);
    }
    .sm-sidebar-av img { width: 100%; height: 100%; object-fit: cover; }
    .sm-sidebar-name { font-size: 13px; font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .sm-sidebar-handle { font-size: 11px; color: #555; }

    .sm-nav { flex: 1; padding: 8px 0; }
    .sm-nav-item {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 10px 16px;
      font-size: 13px;
      font-weight: 500;
      color: #888;
      cursor: pointer;
      transition: color 0.15s, background 0.15s;
      border-radius: 0;
    }
    .sm-nav-item:hover { color: #ccc; background: rgba(255,255,255,0.04); }
    .sm-nav-item.active { color: #fff; background: rgba(250,130,17,0.12); border-left: 3px solid var(--accent); }
    .sm-nav-item svg { flex-shrink: 0; }

    .sm-sidebar-footer { padding: 12px 16px 16px; border-top: 1px solid #222; }
    .sm-logout-btn {
      width: 100%;
      background: transparent;
      border: 1px solid #3a2020;
      border-radius: 8px;
      padding: 8px;
      color: #e55;
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.2s;
    }
    .sm-logout-btn:hover { background: rgba(220,50,50,0.1); border-color: #e55; }

    /* Right content panel */
    .sm-content {
      flex: 1;
      overflow-y: auto;
      padding: 28px 32px 32px;
    }
    .sm-section { display: none; }
    .sm-section.active { display: block; }
    .sm-section-title {
      font-size: 20px;
      font-weight: 700;
      color: #fff;
      margin: 0 0 24px;
    }
    .sm-divider { height: 1px; background: #222; margin: 20px 0; }
    .sm-group-label {
      font-size: 11px;
      font-weight: 700;
      color: #555;
      text-transform: uppercase;
      letter-spacing: 0.8px;
      margin-bottom: 10px;
    }

    /* Close button */
    .sm-close {
      position: absolute;
      top: 14px;
      right: 14px;
      background: none;
      border: none;
      color: #666;
      font-size: 20px;
      cursor: pointer;
      width: 28px;
      height: 28px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 6px;
      transition: color 0.15s, background 0.15s;
      z-index: 2;
    }
    .sm-close:hover { color: #fff; background: rgba(255,255,255,0.08); }

    /* Banner */
    .sm-banner-zone {
      height: 100px;
      border-radius: 10px;
      border: 2px dashed #2e2e2e;
      background: linear-gradient(135deg, #1a0a00, #2d1200, #1a0500);
      background-size: cover;
      background-position: center;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      margin-bottom: 16px;
      transition: border-color 0.2s;
      position: relative;
      overflow: hidden;
    }
    .sm-banner-zone:hover { border-color: var(--accent); }
    .sm-banner-zone-label {
      font-size: 12px;
      color: #555;
      pointer-events: none;
      background: rgba(0,0,0,0.5);
      padding: 4px 10px;
      border-radius: 6px;
    }

    /* Avatar row */
    .sm-avatar-row {
      display: flex;
      align-items: center;
      gap: 16px;
      margin-bottom: 20px;
    }
    .sm-avatar-wrap { position: relative; width: 72px; height: 72px; cursor: pointer; flex-shrink: 0; }
    .sm-avatar-circle {
      width: 72px;
      height: 72px;
      border-radius: 50%;
      background: #333;
      border: 2px solid #444;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
      font-size: 22px;
      font-weight: 700;
      color: var(--accent);
      transition: border-color 0.2s;
    }
    .sm-avatar-circle img { width: 100%; height: 100%; object-fit: cover; }
    .sm-avatar-overlay {
      position: absolute;
      inset: 0;
      border-radius: 50%;
      background: rgba(0,0,0,0.55);
      display: flex;
      align-items: center;
      justify-content: center;
      opacity: 0;
      transition: opacity 0.2s;
      color: #fff;
      font-size: 18px;
    }
    .sm-avatar-wrap:hover .sm-avatar-overlay { opacity: 1; }
    .sm-avatar-wrap:hover .sm-avatar-circle { border-color: var(--accent); }
    .sm-avatar-upload-btn {
      background: #1e1e1e;
      border: 1px solid #333;
      border-radius: 8px;
      padding: 8px 14px;
      color: #ccc;
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      display: block;
      margin-bottom: 8px;
      transition: all 0.2s;
    }
    .sm-avatar-upload-btn:hover { border-color: var(--accent); color: #fff; }

    /* Form fields */
    .sm-field { margin-bottom: 14px; }
    .sm-label {
      display: block;
      font-size: 11px;
      font-weight: 700;
      color: #555;
      text-transform: uppercase;
      letter-spacing: 0.8px;
      margin-bottom: 6px;
    }
    .sm-input {
      width: 100%;
      background: #111;
      border: 1px solid #2a2a2a;
      border-radius: 8px;
      padding: 10px 12px;
      color: #e8e8e8;
      font-size: 14px;
      font-family: inherit;
      outline: none;
      box-sizing: border-box;
      transition: border-color 0.2s;
    }
    .sm-input:focus { border-color: #555; }
    .sm-textarea { resize: none; min-height: 80px; }
    .sm-char-count { text-align: right; font-size: 11px; color: #555; margin-top: 4px; }
    .sm-fields-row { display: flex; gap: 10px; }
    .sm-fields-row .sm-field { flex: 1; }

    /* Save button */
    .sm-save-btn {
      background: var(--accent);
      color: #fff;
      border: none;
      border-radius: 8px;
      padding: 10px 22px;
      font-size: 14px;
      font-weight: 600;
      cursor: pointer;
      margin-top: 8px;
      transition: background 0.2s;
    }
    .sm-save-btn:hover { background: #e07310; }

    /* Mature content slider */
    .sm-slider-wrap { margin-bottom: 6px; }
    .sm-slider {
      width: 100%;
      accent-color: var(--accent);
      cursor: pointer;
      height: 4px;
    }
    .sm-slider-track-labels {
      display: flex;
      justify-content: space-between;
      font-size: 10px;
      color: #555;
      margin-top: 4px;
    }
    .sm-slider-desc { font-size: 12px; color: #888; margin-top: 8px; min-height: 32px; }

    /* Import/Export grid */
    .sm-io-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 8px;
    }
    .sm-io-btn {
      background: #1a1a1a;
      border: 1px solid #2a2a2a;
      border-radius: 8px;
      padding: 10px 8px;
      font-size: 12px;
      font-weight: 600;
      color: #aaa;
      cursor: pointer;
      text-align: center;
      transition: all 0.2s;
    }
    .sm-io-btn:hover { border-color: var(--accent); color: #fff; }

    /* Model cards */
    .sm-model-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 10px;
      margin-bottom: 4px;
    }
    .sm-model-card {
      position: relative;
      border-radius: 10px;
      overflow: hidden;
      cursor: pointer;
      border: 2px solid transparent;
      transition: border-color 0.2s, transform 0.15s;
      aspect-ratio: 16/9;
    }
    .sm-model-card:hover { transform: translateY(-2px); }
    .sm-model-card.selected { border-color: var(--accent); }
    .sm-model-card-bg {
      position: absolute;
      inset: 0;
      background-size: cover;
      background-position: center;
    }
    .sm-model-card-overlay {
      position: absolute;
      inset: 0;
      background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.2) 60%);
    }
    .sm-model-card-body {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      padding: 8px 10px;
    }
    .sm-model-card-tier {
      display: inline-block;
      font-size: 9px;
      font-weight: 800;
      letter-spacing: 1px;
      padding: 2px 6px;
      border-radius: 4px;
      margin-bottom: 3px;
    }
    .sm-model-card-tier.free { background: rgba(255,255,255,0.15); color: #ccc; }
    .sm-model-card-tier.pro { background: rgba(250,130,17,0.3); color: #fa8211; }
    .sm-model-card-tier.ultra { background: rgba(138,89,255,0.3); color: #b78fff; }
    .sm-model-card-name { font-size: 13px; font-weight: 700; color: #fff; }
    .sm-model-card-desc { font-size: 10px; color: rgba(255,255,255,0.6); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .sm-model-card-locked {
      position: absolute;
      top: 6px;
      right: 6px;
      background: rgba(0,0,0,0.6);
      border-radius: 4px;
      padding: 2px 5px;
      font-size: 9px;
      color: #fa8211;
      font-weight: 700;
    }

    /* Toggle rows */
    .sm-toggle-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 12px 0;
      border-bottom: 1px solid #1e1e1e;
    }
    .sm-toggle-label { font-size: 13px; font-weight: 500; color: #ddd; }
    .sm-toggle-sub { font-size: 11px; color: #555; margin-top: 2px; }
    .sm-switch { position: relative; display: inline-block; width: 38px; height: 22px; }
    .sm-switch input { opacity: 0; width: 0; height: 0; }
    .sm-switch-slider {
      position: absolute;
      inset: 0;
      background: #333;
      border-radius: 11px;
      cursor: pointer;
      transition: background 0.2s;
    }
    .sm-switch-slider:before {
      content: '';
      position: absolute;
      width: 16px;
      height: 16px;
      left: 3px;
      bottom: 3px;
      background: #fff;
      border-radius: 50%;
      transition: transform 0.2s;
    }
    .sm-switch input:checked + .sm-switch-slider { background: var(--accent); }
    .sm-switch input:checked + .sm-switch-slider:before { transform: translateX(16px); }

    /* Response length pills */
    .sm-pills { display: flex; gap: 6px; }
    .sm-pill {
      flex: 1;
      padding: 8px;
      background: #1a1a1a;
      border: 1px solid #2a2a2a;
      border-radius: 8px;
      color: #888;
      font-size: 13px;
      font-weight: 600;
      cursor: pointer;
      text-align: center;
      transition: all 0.15s;
    }
    .sm-pill:hover { border-color: #444; color: #ccc; }
    .sm-pill.active { background: rgba(250,130,17,0.15); border-color: var(--accent); color: #fff; }

    /* Subscription tier card */
    .sm-tier-card {
      background: linear-gradient(135deg, #1a1a1a, #111);
      border: 1px solid #2a2a2a;
      border-radius: 12px;
      padding: 20px;
      margin-bottom: 12px;
    }
    .sm-tier-badge {
      display: inline-block;
      padding: 3px 10px;
      border-radius: 6px;
      font-size: 11px;
      font-weight: 800;
      letter-spacing: 1px;
      text-transform: uppercase;
      margin-bottom: 8px;
    }
    .sm-tier-badge.free { background: rgba(255,255,255,0.1); color: #aaa; }
    .sm-tier-badge.pro { background: rgba(250,130,17,0.2); color: #fa8211; }
    .sm-tier-badge.ultra { background: rgba(138,89,255,0.2); color: #b78fff; }

    /* Mobile */
    @media (max-width: 768px) {
      .sm-box { flex-direction: column; height: min(95vh, 700px); width: 100%; }
      .sm-sidebar { width: 100%; flex-direction: row; border-right: none; border-bottom: 1px solid #222; overflow-x: auto; overflow-y: hidden; box-sizing: border-box; }
      .sm-sidebar-user { display: none; }
      .sm-nav { display: flex; flex-direction: row; padding: 4px; }
      .sm-nav-item { padding: 8px 12px; white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; }
      .sm-nav-item.active { border-left: none; border-bottom-color: var(--accent); }
      .sm-sidebar-footer { display: none; }
      
      .sm-close { 
        display: flex !important; 
        position: fixed !important; 
        top: auto !important; 
        bottom: 24px !important; 
        right: 24px !important; 
        background: var(--bg-card) !important; 
        border: 1px solid var(--border) !important;
        box-shadow: 0 8px 32px rgba(0,0,0,0.8) !important;
        width: 50px !important;
        height: 50px !important;
        align-items: center !important;
        justify-content: center !important;
        z-index: 100000 !important;
      }
      
      .sm-logout-btn-mobile { display: block !important; }
      .sm-content { padding: 16px; padding-bottom: 80px; }
      .sm-model-grid { grid-template-columns: repeat(2, 1fr); }
      .sm-io-grid { grid-template-columns: repeat(2, 1fr); }
      .sm-mobile-bottom-bar { display: none !important; }
    }

    #accountBackdrop {
      position: absolute;
      inset: 0;
      background: rgba(0, 0, 0, 0.6);
      backdrop-filter: blur(4px);
      z-index: 0;
    }

    #accountContainer {
      position: relative;
      z-index: 10;
      width: 100%;
      max-width: 600px;
      max-height: 85vh;
      background: #09090b;
      border: 1px solid #27272a;
      border-radius: 16px;
      display: flex;
      flex-direction: column;
      box-shadow: 0 0 50px -12px rgba(0, 0, 0, 0.8);
      pointer-events: auto;
    }

    #accountHeader {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 20px 24px;
      border-bottom: 1px solid #27272a;
      background: #09090b;
      border-top-left-radius: 16px;
      border-top-right-radius: 16px;
    }

    /* Image Generation Modal */
    #imageGenModal {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 9998;
      align-items: center;
      justify-content: center;
      pointer-events: auto;
    }

    #imageGenModal.active {
      display: flex;
    }

    #imageGenBackdrop {
      position: absolute;
      inset: 0;
      background: rgba(0, 0, 0, 0.6);
      backdrop-filter: blur(4px);
      z-index: 0;
    }

    #imageGenContainer {
      position: relative;
      z-index: 10;
      width: 100%;
      max-width: 900px;
      max-height: 85vh;
      background: #09090b;
      border: 1px solid #27272a;
      border-radius: 16px;
      display: flex;
      flex-direction: column;
      box-shadow: 0 0 50px -12px rgba(0, 0, 0, 0.8);
      pointer-events: auto;
      overflow: hidden;
    }

    #imageGenHeader {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 20px 32px;
      border-bottom: 1px solid #27272a;
      background: #09090b;
    }

    #imageGenContent {
      flex: 1;
      overflow-y: auto;
      padding: 32px;
      display: flex;
      flex-direction: column;
      gap: 24px;
    }

    #imageGenContent::-webkit-scrollbar {
      width: 8px;
    }

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

    #imageGenContent::-webkit-scrollbar-thumb {
      background: #27272a;
      border-radius: 4px;
    }

    #imageGenContent::-webkit-scrollbar-thumb:hover {
      background: #3f3f46;
    }

    #imageGenFooter {
      padding: 20px 32px;
      border-top: 1px solid #27272a;
      background: #09090b;
      display: flex;
      gap: 12px;
      justify-content: flex-end;
    }

    .image-gen-section {
      display: flex;
      flex-direction: column;
      gap: 12px;
    }

    .image-gen-label {
      font-size: 11px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.1em;
      color: #71717a;
    }

    .image-gen-desc {
      font-size: 13px;
      color: #a1a1aa;
      margin-top: -4px;
    }

    .image-gen-input {
      width: 100%;
      padding: 12px 16px;
      background: #18181b;
      border: 1px solid #27272a;
      border-radius: 8px;
      color: #e4e4e7;
      font-family: inherit;
      font-size: 14px;
      transition: all 0.2s;
      outline: none;
    }

    .image-gen-input:hover {
      border-color: #3f3f46;
    }

    .image-gen-input:focus {
      border-color: #52525b;
      background: #1a1a1d;
    }

    .image-gen-textarea {
      width: 100%;
      padding: 12px 16px;
      background: #18181b;
      border: 1px solid #27272a;
      border-radius: 8px;
      color: #e4e4e7;
      font-family: inherit;
      font-size: 14px;
      line-height: 1.5;
      resize: vertical;
      min-height: 100px;
      outline: none;
      transition: all 0.2s;
    }

    .image-gen-textarea:hover {
      border-color: #3f3f46;
    }

    .image-gen-textarea:focus {
      border-color: #52525b;
      background: #1a1a1d;
    }

    .image-gen-dropdown {
      width: 100%;
      padding: 12px 16px;
      background: #18181b;
      border: 1px solid #27272a;
      border-radius: 8px;
      color: #e4e4e7;
      font-family: inherit;
      font-size: 14px;
      transition: all 0.2s;
      outline: none;
      cursor: pointer;
      appearance: none;
      -webkit-appearance: none;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 14px center;
      padding-right: 40px;
      box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .image-gen-dropdown:hover {
      border-color: #3f3f46;
    }

    .image-gen-dropdown:focus {
      border-color: #52525b;
      background: #1a1a1d;
    }

    .image-gen-dropdown option {
      background: #18181b;
      color: #e4e4e7;
    }

    /* Modal Layering Fixes */
    .auth-overlay, .modal-overlay {
      position: fixed !important;
      top: 0; left: 0; right: 0; bottom: 0;
      width: 100vw; height: 100vh;
      background: rgba(0,0,0,0.85) !important;
      backdrop-filter: blur(8px);
      z-index: 10000 !important;
      display: none;
      align-items: center;
      justify-content: center;
    }
    .auth-overlay.active, .modal-overlay.active {
      display: flex !important;
    }
    /* Specific Auth/Profile Modal Layout */
    .auth-modal {
      position: relative;
      z-index: 10001;
      width: 400px;
      max-width: 90vw;
      max-height: 90vh;
      overflow-y: auto;
      background: #141414;
      border: 1px solid #2d2d2d;
      border-radius: 20px;
      padding: 32px;
      box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8);
    }
    
    #editProfileModal .profile-edit-content {
      position: relative;
      z-index: 10001;
      width: 500px;
      max-width: 90vw;
      max-height: 90vh;
      overflow-y: auto;
      background: #141414;
      border: 1px solid #2d2d2d;
      border-radius: 20px;
      padding: 32px;
    }

    /* Account / Settings Modal visual refresh */
    #accountModal {
      background:
        radial-gradient(circle at 18% 12%, rgba(232, 98, 26, 0.16), transparent 30%),
        radial-gradient(circle at 86% 78%, rgba(46, 189, 217, 0.1), transparent 34%),
        rgba(0, 0, 0, 0.78) !important;
      backdrop-filter: blur(14px) saturate(1.1) !important;
    }

    #accountModal .sm-box {
      width: min(960px, calc(100vw - 32px)) !important;
      height: min(680px, calc(100vh - 32px)) !important;
      background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.06), transparent 28%),
        linear-gradient(180deg, #171717 0%, #101010 100%) !important;
      border: 1px solid rgba(255, 255, 255, 0.12) !important;
      border-radius: 18px !important;
      box-shadow:
        0 32px 90px rgba(0, 0, 0, 0.76),
        0 0 0 1px rgba(255, 255, 255, 0.035) inset,
        0 0 48px rgba(232, 98, 26, 0.08) !important;
    }

    #accountModal .sm-box::before {
      content: "";
      position: absolute;
      inset: 0;
      pointer-events: none;
      background: linear-gradient(90deg, rgba(232, 98, 26, 0.12), transparent 34%);
      opacity: 0.65;
      z-index: 0;
    }

    #accountModal .sm-sidebar,
    #accountModal .sm-content {
      position: relative;
      z-index: 1;
    }

    #accountModal .sm-sidebar {
      width: 236px !important;
      background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.012)),
        #0b0b0b !important;
      border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
      scrollbar-width: thin;
      scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
    }

    #accountModal .sm-sidebar-user {
      padding: 24px 18px 18px !important;
      border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
      background: rgba(255, 255, 255, 0.02);
    }

    #accountModal .sm-sidebar-av {
      width: 42px !important;
      height: 42px !important;
      background: linear-gradient(135deg, rgba(232, 98, 26, 0.22), rgba(46, 189, 217, 0.12)) !important;
      border: 1px solid rgba(255, 255, 255, 0.16) !important;
      box-shadow: 0 10px 24px rgba(0, 0, 0, 0.34);
    }

    #accountModal .sm-sidebar-name {
      max-width: 145px;
      font-size: 14px !important;
      font-weight: 750 !important;
    }

    #accountModal .sm-sidebar-handle {
      color: rgba(255, 255, 255, 0.46) !important;
      margin-top: 2px;
    }

    #accountModal .sm-nav {
      padding: 12px 10px !important;
    }

    #accountModal .sm-nav-item {
      min-height: 42px;
      margin: 2px 0;
      padding: 10px 12px !important;
      color: rgba(255, 255, 255, 0.62) !important;
      border: 1px solid transparent;
      border-radius: 10px !important;
      font-weight: 650 !important;
      letter-spacing: 0;
      transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease !important;
    }

    #accountModal .sm-nav-item:hover {
      color: #fff !important;
      background: rgba(255, 255, 255, 0.065) !important;
      border-color: rgba(255, 255, 255, 0.08);
      transform: translateX(2px);
    }

    #accountModal .sm-nav-item.active {
      color: #fff !important;
      background:
        linear-gradient(135deg, rgba(232, 98, 26, 0.22), rgba(232, 98, 26, 0.09)) !important;
      border-left: 1px solid rgba(232, 98, 26, 0.48) !important;
      border-color: rgba(232, 98, 26, 0.36) !important;
      box-shadow: 0 10px 28px rgba(232, 98, 26, 0.1);
    }

    #accountModal .sm-nav-item svg {
      color: currentColor;
      opacity: 0.9;
    }

    #accountModal .sm-sidebar-footer {
      padding: 14px 16px 18px !important;
      border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
      background: rgba(0, 0, 0, 0.14);
    }

    #accountModal .sm-sidebar-footer button:first-child {
      border-radius: 10px !important;
      background: rgba(255, 255, 255, 0.035) !important;
      border-color: rgba(255, 255, 255, 0.1) !important;
    }

    #accountModal .sm-logout-btn {
      border-radius: 10px !important;
      background: rgba(255, 68, 68, 0.055) !important;
    }

    #accountModal .sm-content {
      padding: 34px 38px 38px !important;
      background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 190px),
        rgba(10, 10, 10, 0.22);
      scrollbar-width: thin;
      scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
    }

    #accountModal .sm-content::-webkit-scrollbar,
    #accountModal .sm-sidebar::-webkit-scrollbar {
      width: 9px;
      height: 9px;
    }

    #accountModal .sm-content::-webkit-scrollbar-track,
    #accountModal .sm-sidebar::-webkit-scrollbar-track {
      background: transparent;
    }

    #accountModal .sm-content::-webkit-scrollbar-thumb,
    #accountModal .sm-sidebar::-webkit-scrollbar-thumb {
      background: rgba(255, 255, 255, 0.14);
      border: 3px solid transparent;
      border-radius: 999px;
      background-clip: content-box;
    }

    #accountModal .sm-section-title {
      margin-bottom: 26px !important;
      color: #fff !important;
      font-size: 24px !important;
      font-weight: 850 !important;
      line-height: 1.05;
      letter-spacing: 0 !important;
    }

    #accountModal .sm-group-label,
    #accountModal .sm-label {
      color: rgba(255, 255, 255, 0.46) !important;
      letter-spacing: 0.08em !important;
    }

    #accountModal .sm-divider {
      height: 1px !important;
      margin: 24px 0 !important;
      background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent) !important;
    }

    #accountModal .sm-input,
    #accountModal .settings-select,
    #accountModal textarea,
    #accountModal input[type="text"],
    #accountModal input[type="number"],
    #accountModal input[type="email"] {
      background: rgba(255, 255, 255, 0.045) !important;
      border: 1px solid rgba(255, 255, 255, 0.11) !important;
      border-radius: 10px !important;
      color: rgba(255, 255, 255, 0.92) !important;
      box-shadow: 0 1px 0 rgba(255, 255, 255, 0.035) inset;
    }

    #accountModal .sm-input:hover,
    #accountModal .settings-select:hover,
    #accountModal textarea:hover,
    #accountModal input[type="text"]:hover,
    #accountModal input[type="number"]:hover,
    #accountModal input[type="email"]:hover {
      border-color: rgba(255, 255, 255, 0.18) !important;
    }

    #accountModal .sm-input:focus,
    #accountModal .settings-select:focus,
    #accountModal textarea:focus,
    #accountModal input[type="text"]:focus,
    #accountModal input[type="number"]:focus,
    #accountModal input[type="email"]:focus {
      border-color: rgba(232, 98, 26, 0.72) !important;
      box-shadow: 0 0 0 3px rgba(232, 98, 26, 0.14) !important;
    }

    #accountModal .sm-banner-zone {
      height: 126px !important;
      border: 1px dashed rgba(255, 255, 255, 0.18) !important;
      border-radius: 14px !important;
      background-image: var(--sm-banner-bg,
        radial-gradient(circle at 18% 24%, rgba(232, 98, 26, 0.44), transparent 34%),
        radial-gradient(circle at 78% 68%, rgba(46, 189, 217, 0.26), transparent 38%),
        linear-gradient(135deg, #160d08, #1d1d1d 58%, #081319)) !important;
      background-size: cover !important;
      background-position: center var(--sm-banner-pos, 50%) !important;
      box-shadow: 0 16px 38px rgba(0, 0, 0, 0.32) inset;
    }

    #accountModal .sm-banner-zone:hover {
      border-color: rgba(232, 98, 26, 0.7) !important;
    }

    #accountModal .sm-banner-zone-label {
      background: rgba(0, 0, 0, 0.5) !important;
      color: rgba(255, 255, 255, 0.72) !important;
      border: 1px solid rgba(255, 255, 255, 0.1);
      border-radius: 999px !important;
      padding: 7px 12px !important;
    }

    #accountModal .sm-avatar-circle {
      background: linear-gradient(135deg, rgba(232, 98, 26, 0.28), rgba(46, 189, 217, 0.14)) !important;
      border: 1px solid rgba(255, 255, 255, 0.18) !important;
      box-shadow: 0 12px 28px rgba(0, 0, 0, 0.34);
    }

    #accountModal .sm-avatar-upload-btn,
    #accountModal .sm-io-btn,
    #accountModal .sm-pill,
    #accountModal .btn-secondary {
      background: rgba(255, 255, 255, 0.055) !important;
      border: 1px solid rgba(255, 255, 255, 0.11) !important;
      border-radius: 10px !important;
      color: rgba(255, 255, 255, 0.76) !important;
      box-shadow: 0 1px 0 rgba(255, 255, 255, 0.035) inset;
    }

    #accountModal .sm-avatar-upload-btn:hover,
    #accountModal .sm-io-btn:hover,
    #accountModal .sm-pill:hover,
    #accountModal .btn-secondary:hover {
      color: #fff !important;
      border-color: rgba(232, 98, 26, 0.44) !important;
      background: rgba(232, 98, 26, 0.1) !important;
    }

    #accountModal .sm-save-btn,
    #accountModal .btn-primary {
      border-radius: 10px !important;
      background: linear-gradient(135deg, #f47a20, #d94d12) !important;
      color: #fff !important;
      box-shadow: 0 12px 28px rgba(232, 98, 26, 0.22);
      transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease !important;
    }

    #accountModal .sm-save-btn:hover,
    #accountModal .btn-primary:hover {
      filter: brightness(1.05);
      transform: translateY(-1px);
      box-shadow: 0 16px 34px rgba(232, 98, 26, 0.28);
    }

    #accountModal .sm-pill.active {
      background: rgba(232, 98, 26, 0.2) !important;
      border-color: rgba(232, 98, 26, 0.72) !important;
      color: #fff !important;
      box-shadow: 0 0 0 1px rgba(232, 98, 26, 0.2) inset;
    }

    #accountModal .sm-io-grid {
      gap: 10px !important;
    }

    #accountModal .sm-io-btn {
      min-height: 74px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 5px;
    }

    #accountModal .sm-toggle-row {
      min-height: 62px;
      padding: 14px 0 !important;
      border-bottom: 1px solid rgba(255, 255, 255, 0.075) !important;
    }

    #accountModal .sm-toggle-label {
      color: rgba(255, 255, 255, 0.9) !important;
      font-weight: 700 !important;
    }

    #accountModal .sm-toggle-sub,
    #accountModal .sm-slider-desc,
    #accountModal .sm-char-count {
      color: rgba(255, 255, 255, 0.44) !important;
    }

    #accountModal .sm-switch {
      width: 46px !important;
      height: 26px !important;
      flex: 0 0 46px;
    }

    #accountModal .sm-switch-slider {
      background: rgba(255, 255, 255, 0.12) !important;
      border: 1px solid rgba(255, 255, 255, 0.12);
      border-radius: 999px !important;
    }

    #accountModal .sm-switch-slider:before {
      width: 20px !important;
      height: 20px !important;
      bottom: 2px !important;
      left: 3px !important;
      background: rgba(255, 255, 255, 0.92) !important;
      box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
    }

    #accountModal .sm-switch input:checked + .sm-switch-slider {
      background: linear-gradient(135deg, #f47a20, #d94d12) !important;
      border-color: rgba(232, 98, 26, 0.8);
    }

    #accountModal .sm-switch input:checked + .sm-switch-slider:before {
      transform: translateX(19px) !important;
    }

    #accountModal .sm-slider,
    #accountModal input[type="range"] {
      accent-color: var(--accent);
    }

    .sm-bubble-preview {
      position: relative;
      height: 108px;
      margin-top: 10px;
      border-radius: 12px;
      overflow: hidden;
      border: 1px solid rgba(255, 255, 255, 0.08);
      background: #0b0f16;
    }

    .sm-bubble-preview-bg {
      position: absolute;
      inset: 0;
      background:
        radial-gradient(circle at 22% 22%, rgba(59, 130, 246, 0.55), transparent 28%),
        radial-gradient(circle at 78% 26%, rgba(232, 98, 26, 0.45), transparent 24%),
        linear-gradient(135deg, #07111f 0%, #12111b 52%, #1d0f0f 100%);
      transform: scale(1.03);
    }

    .sm-bubble-preview-overlay {
      position: absolute;
      inset: 0;
      background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(0,0,0,0.12));
      pointer-events: none;
    }

    .sm-bubble-preview-bubble {
      position: absolute;
      left: 12px;
      right: 18px;
      bottom: 12px;
      padding: 10px 12px;
      border-radius: 12px 12px 12px 4px;
      border: 1px solid rgba(255,255,255,0.18);
      background: rgba(20, 20, 26, var(--chat-bubble-bg-alpha, 0.10));
      backdrop-filter: blur(20px) saturate(200%);
      -webkit-backdrop-filter: blur(20px) saturate(200%);
      box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.3),
        inset 0 -1px 0 rgba(0,0,0,0.16),
        0 8px 20px rgba(0,0,0,0.28);
      display: flex;
      flex-direction: column;
      gap: 3px;
      transition: background 0.12s ease, backdrop-filter 0.12s ease, -webkit-backdrop-filter 0.12s ease;
    }

    .sm-bubble-preview.no-glass .sm-bubble-preview-bubble {
      backdrop-filter: none;
      -webkit-backdrop-filter: none;
      box-shadow: 0 8px 20px rgba(0,0,0,0.24);
    }

    .sm-bubble-preview-kicker {
      font-size: 10px;
      font-weight: 800;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: rgba(255,255,255,0.58);
    }

    .sm-bubble-preview-text {
      font-size: 12px;
      line-height: 1.45;
      color: rgba(255,255,255,0.9);
    }

    #accountModal .sm-close {
      position: absolute !important;
      top: 16px !important;
      right: 16px !important;
      width: 36px !important;
      height: 36px !important;
      border: 1px solid rgba(255, 255, 255, 0.1) !important;
      background: rgba(255, 255, 255, 0.055) !important;
      border-radius: 10px !important;
      color: rgba(255, 255, 255, 0.64) !important;
      font-size: 18px !important;
    }

    #accountModal .sm-close:hover {
      color: #fff !important;
      background: rgba(255, 255, 255, 0.11) !important;
      border-color: rgba(255, 255, 255, 0.18) !important;
    }

    #accountModal #smModelSelectTrigger,
    #accountModal #ptModelSelectTrigger,
    #accountModal .sm-tier-card,
    #accountModal .api-key-card,
    #accountModal .settings-action-card,
    #accountModal .sm-folder-card {
      border-radius: 14px !important;
      border: 1px solid rgba(255, 255, 255, 0.1) !important;
      background: rgba(255, 255, 255, 0.045) !important;
      box-shadow: 0 1px 0 rgba(255, 255, 255, 0.035) inset;
    }

    @media (max-width: 768px) {
      #accountModal {
        padding: 10px !important;
        align-items: stretch !important;
      }

      #accountModal .sm-box {
        width: 100% !important;
        height: 100% !important;
        max-height: none !important;
        border-radius: 16px !important;
      }

      #accountModal .sm-sidebar {
        width: 100% !important;
        max-height: 66px;
        border-right: 0 !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
      }

      #accountModal .sm-nav {
        gap: 4px;
        padding: 8px !important;
      }

      #accountModal .sm-nav-item {
        min-height: 42px;
        padding: 8px 10px !important;
        border-radius: 9px !important;
      }

      #accountModal .sm-nav-item:hover {
        transform: none;
      }

      #accountModal .sm-nav-item.active {
        border-left: 1px solid rgba(232, 98, 26, 0.36) !important;
        border-bottom-color: rgba(232, 98, 26, 0.36) !important;
      }

      #accountModal .sm-content {
        padding: 22px 18px 86px !important;
      }

      #accountModal .sm-section-title {
        font-size: 22px !important;
        margin-bottom: 22px !important;
      }

      #accountModal .sm-close {
        position: fixed !important;
        bottom: 18px !important;
        right: 18px !important;
        top: auto !important;
        width: 52px !important;
        height: 52px !important;
        border-radius: 16px !important;
        background: linear-gradient(135deg, #f47a20, #d94d12) !important;
        color: #fff !important;
        box-shadow: 0 18px 40px rgba(0, 0, 0, 0.52) !important;
      }

      #accountModal .sm-fields-row,
      #accountModal .sm-io-grid {
        grid-template-columns: 1fr 1fr !important;
      }

      #accountModal .sm-banner-zone {
        height: 112px !important;
      }
    }

/* ── Block 3 ──────────────────────────────────────────────── */
    @keyframes imgOrbit {
      to {
        transform: rotate(360deg);
      }
    }

    @keyframes imgBrushSpin {

      0%,
      100% {
        transform: rotate(-12deg);
      }

      50% {
        transform: rotate(12deg);
      }
    }

    @keyframes imgGlowPulse {

      0%,
      100% {
        opacity: 0.5;
        transform: scale(0.9);
      }

      50% {
        opacity: 1;
        transform: scale(1.1);
      }
    }

    @keyframes imgStroke1 {

      0%,
      100% {
        opacity: 0;
      }

      30%,
      70% {
        opacity: 0.75;
      }
    }

    @keyframes imgStroke2 {

      0%,
      100% {
        opacity: 0;
      }

      30%,
      70% {
        opacity: 0.6;
      }
    }

    @keyframes imgSplat {

      0%,
      100% {
        opacity: 0;
        transform: scale(0);
      }

      40%,
      60% {
        opacity: 0.8;
        transform: scale(1);
      }
    }

    #imgGenOverlay.active {
      opacity: 1 !important;
      pointer-events: auto !important;
    }

    /* Profile View Layout */
    /* ── Full-width profile page ── */
    .profile-banner-wrap {
      background: linear-gradient(135deg, #1a0a00, #2d1200, #1a0500);
      background-size: cover;
      background-position: center;
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
    }

    .profile-banner-spacer {
      height: 140px;
    }

    .profile-hero {
      display: flex;
      align-items: flex-end;
      gap: 20px;
      padding: 0 32px 20px;
      flex-wrap: wrap;
    }

    .profile-hero-avatar {
      width: 140px;
      height: 140px;
      border-radius: 50%;
      border: 4px solid #181818;
      background: var(--accent);
      margin-top: -70px;
      overflow: hidden;
      flex-shrink: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 36px;
      font-weight: 700;
      color: #fff;
    }

    .profile-hero-avatar img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .profile-hero-info {
      flex: 1;
      min-width: 0;
      padding-top: 12px;
    }

    .profile-name-large {
      font-size: 22px;
      font-weight: 800;
      color: #fff;
      margin: 0 0 4px;
    }

    .profile-hero-meta {
      font-size: 13px;
      color: rgba(255,255,255,0.85);
    }

    .profile-hero-meta span {
      color: #fff;
      font-weight: 600;
    }

    @media (max-width: 768px) {
      .profile-hero-meta {
        display: none !important;
      }
    }

    .profile-bio {
      font-size: 13px;
      color: rgba(255,255,255,0.85);
      line-height: 1.5;
    }

    .profile-social-link {
      display: flex;
      align-items: center;
      gap: 6px;
      color: rgba(255,255,255,0.8);
      text-decoration: none;
      font-size: 13px;
      transition: color 0.2s;
    }

    .profile-social-link:hover { color: var(--accent); }

    /* Profile sections */
    .profile-section-block { margin-bottom: 32px; }

    /* ── Shared page heading style (gradient text, big) ──── */
    .page-heading {
      font-family: var(--font-display);
      font-size: 28px;
      font-weight: 800;
      background: linear-gradient(90deg, #fff 0%, var(--accent) 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
      letter-spacing: -0.5px;
      line-height: 1.1;
    }

    /* ── Profile Overview (carousel rows) ─────────────────── */
    .profile-ov-section { margin-bottom: 36px; }
    .profile-ov-section-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:16px; }
    .profile-ov-section-title {
      font-family: var(--font-display);
      font-size: 28px;
      font-weight: 800;
      background: linear-gradient(90deg, #fff 0%, var(--accent) 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
      letter-spacing: -0.5px;
    }
    /* Carousel */
    .profile-ov-grid {
      display: flex;
      gap: 14px;
      overflow-x: auto;
      padding-bottom: 10px;
      scrollbar-width: none;
    }
    .profile-ov-grid::-webkit-scrollbar { display: none; }
    .profile-ov-grid .showcase-card {
      flex-shrink: 0;
      width: 320px;
      aspect-ratio: 3/2;
    }

    .profile-section-head { display:flex; align-items:center; gap:10px; margin-bottom:12px; }
    .profile-section-name { font-size:15px; font-weight:700; color:var(--text-primary); }
    .profile-section-dot { width:10px; height:10px; border-radius:50%; flex-shrink:0; }
    .profile-section-actions { margin-left:auto; display:flex; gap:6px; }
    .profile-section-action-btn { background:none; border:1px solid var(--border); border-radius:6px; color:var(--text-dim); font-size:11px; padding:2px 8px; cursor:pointer; }
    .profile-section-action-btn:hover { color:var(--text-primary); border-color:var(--border-light); }
    .profile-section-strip { display:flex; gap:14px; overflow-x:auto; padding-bottom:8px; scrollbar-width:thin; scrollbar-color:var(--border) transparent; }
    .profile-section-strip::-webkit-scrollbar { height:3px; }
    .profile-section-strip::-webkit-scrollbar-thumb { background:var(--border); border-radius:2px; }
    .profile-section-card { flex-shrink:0; width:160px; cursor:pointer; border-radius:10px; overflow:hidden; background:var(--bg-card); border:1px solid var(--border); transition:transform 0.15s,border-color 0.15s; }
    .profile-section-card:hover { transform:translateY(-2px); border-color:var(--accent); }
    .profile-section-card-img { width:160px; height:100px; object-fit:cover; display:block; background:linear-gradient(135deg,#1a1a2e,#16213e); }
    .profile-section-card-body { padding:8px 10px; }
    .profile-section-card-title { font-size:12px; font-weight:600; color:#fff; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
    .profile-section-card-badge { font-size:9px; color:var(--text-dim); margin-top:2px; }
    .profile-add-section-bar { display:flex; align-items:center; gap:10px; margin-bottom:24px; }

    /* Notification bell */
    @keyframes bellGlow {
      0%,100% { box-shadow: 0 0 0 0 rgba(232,98,26,0); }
      50%      { box-shadow: 0 0 12px 4px rgba(232,98,26,0.55); }
    }
    .notif-bell {
      position: relative;
      cursor: pointer;
      padding: 9px;
      border-radius: 10px;
      color: var(--text-dim);
      background: none;
      border: none;
      transition: color 0.2s, background 0.2s;
    }
    .notif-bell svg { width: 24px; height: 24px; }
    .notif-bell:hover {
      color: var(--accent);
      background: rgba(232,98,26,0.1);
    }
    .notif-bell.has-unread {
      color: var(--accent);
      animation: bellGlow 2s ease-in-out infinite;
    }
    .notif-badge { position:absolute; top:1px; right:1px; background:var(--accent); color:#fff; font-size:9px; font-weight:800; min-width:15px; height:15px; border-radius:8px; display:flex; align-items:center; justify-content:center; padding:0 3px; pointer-events:none; }
    .notif-panel { position:fixed; top:54px; right:16px; width:340px; max-height:480px; background:var(--bg-panel); border:1px solid var(--border-light); border-radius:12px; box-shadow:0 12px 40px rgba(0,0,0,0.5); z-index:200; display:flex; flex-direction:column; overflow:hidden; }
    .notif-panel-head { padding:14px 16px 10px; border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between; }
    .notif-panel-title { font-size:14px; font-weight:700; color:var(--text-primary); }
    .notif-panel-body { flex:1; overflow-y:auto; }
    .notif-item { display:flex; gap:10px; padding:12px 16px; border-bottom:1px solid var(--border); cursor:pointer; transition:background 0.15s; }
    .notif-item:hover { background:rgba(255,255,255,0.03); }
    .notif-item.unread { background:rgba(232,98,26,0.06); }
    .notif-item-icon { width:32px; height:32px; border-radius:50%; background:rgba(232,98,26,0.15); display:flex; align-items:center; justify-content:center; flex-shrink:0; font-size:14px; }
    .notif-item-body { flex:1; min-width:0; }
    .notif-item-text { font-size:12px; color:var(--text-primary); line-height:1.4; }
    .notif-item-time { font-size:10px; color:var(--text-dim); margin-top:3px; }

    .profile-tabs-bar {
      display: flex;
      gap: 0;
      padding: 0 32px;
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
      overflow-x: auto;
      scrollbar-width: none;
      -webkit-overflow-scrolling: touch;
    }
    .profile-tabs-bar::-webkit-scrollbar { display: none; }
    @media (max-width: 600px) {
      .profile-tabs-bar { padding: 0 12px; }
      #profileTabContent { padding: 16px !important; }
    }

    .profile-tab {
      padding: 14px 20px;
      font-size: 13px;
      font-weight: 600;
      color: var(--text-dim);
      cursor: pointer;
      border-bottom: 2px solid transparent;
      margin-bottom: -1px;
      transition: all 0.2s;
      white-space: nowrap;
    }

    .profile-tab:hover { color: #fff; }

    .profile-tab.active {
      color: #fff;
      border-bottom-color: var(--accent);
    }

    /* ── Character Gallery ─────────────────────────────────────── */
    .char-gallery-wrap {
      display: flex;
      flex-direction: column;
      gap: 20px;
    }

    .char-gallery-toolbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    .char-gallery-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
      gap: 16px;
      padding: 4px;
    }

    .char-gallery-card {
      position: relative;
      border-radius: 12px;
      overflow: visible;
      cursor: default;
      background: var(--bg-card);
      border: 1px solid var(--border);
      transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    }

    .char-gallery-card:hover {
      transform: translateY(-3px);
      border-color: var(--accent);
      box-shadow: 0 6px 24px rgba(0,0,0,0.4);
    }

    .char-gallery-img {
      width: 100%;
      aspect-ratio: 3/4;
      overflow: hidden;
      border-radius: 11px 11px 0 0;
      background: linear-gradient(135deg, #1a1a2e, #16213e);
      display: flex;
      align-items: center;
      justify-content: center;
      position: relative;
    }

    .char-gallery-img img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .char-gallery-img-placeholder {
      opacity: 0.25;
    }

    .char-gallery-card-actions {
      position: absolute;
      top: 6px;
      right: 6px;
      display: flex;
      gap: 4px;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.15s;
    }

    .char-gallery-card:hover .char-gallery-card-actions {
      opacity: 1;
      pointer-events: auto;
    }

    .char-gallery-action-btn {
      width: 26px;
      height: 26px;
      border-radius: 50%;
      background: rgba(0,0,0,0.75);
      border: 1px solid rgba(255,255,255,0.15);
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      font-size: 11px;
    }

    .char-gallery-action-btn:hover { background: rgba(239,68,68,0.8); border-color: transparent; }

    .char-gallery-body {
      padding: 10px 12px 12px;
    }

    .char-gallery-name {
      font-weight: 700;
      font-size: 13px;
      color: var(--text-primary);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      margin-bottom: 6px;
    }

    .char-gallery-scenarios {
      display: flex;
      flex-wrap: wrap;
      gap: 4px;
      margin-bottom: 6px;
    }

    .char-gallery-scenario-pill {
      font-size: 10px;
      padding: 2px 7px;
      border-radius: 20px;
      background: rgba(var(--accent-rgb,229,100,40), 0.15);
      color: var(--accent);
      border: 1px solid rgba(var(--accent-rgb,229,100,40), 0.3);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: 100%;
    }

    .char-gallery-assign-btn {
      font-size: 10px;
      color: var(--text-dim);
      background: none;
      border: 1px dashed rgba(255,255,255,0.15);
      border-radius: 20px;
      padding: 2px 8px;
      cursor: pointer;
      transition: border-color 0.15s, color 0.15s;
    }

    .char-gallery-assign-btn:hover { border-color: var(--accent); color: var(--accent); }

    .char-gallery-add-card {
      border: 2px dashed rgba(255,255,255,0.12);
      border-radius: 12px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 8px;
      cursor: pointer;
      aspect-ratio: 3/4;
      color: var(--text-dim);
      font-size: 12px;
      transition: border-color 0.2s, color 0.2s;
    }

    .char-gallery-add-card:hover { border-color: var(--accent); color: var(--accent); }

    /* Scenario assign dropdown */
    .char-scenario-dropdown {
      position: absolute;
      bottom: calc(100% + 4px);
      left: 0;
      right: 0;
      background: var(--bg-secondary, #1e1e2e);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 6px 0;
      z-index: 200;
      box-shadow: 0 8px 24px rgba(0,0,0,0.5);
      max-height: 200px;
      overflow-y: auto;
    }

    .char-scenario-dropdown-item {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 7px 12px;
      font-size: 12px;
      cursor: pointer;
      color: var(--text-secondary);
      transition: background 0.1s;
    }

    .char-scenario-dropdown-item:hover { background: rgba(255,255,255,0.05); }

    .char-scenario-dropdown-item input[type=checkbox] {
      accent-color: var(--accent);
      width: 13px;
      height: 13px;
      flex-shrink: 0;
    }

    /* Character picker modal */
    .char-picker-modal {
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,0.7);
      z-index: 1000;
      display: flex;
      align-items: center;
      justify-content: center;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.2s;
    }

    .char-picker-modal.active {
      opacity: 1;
      pointer-events: auto;
    }

    .char-picker-box {
      background: var(--bg-secondary, #1e1e2e);
      border: 1px solid var(--border);
      border-radius: 16px;
      width: 540px;
      max-width: 95vw;
      max-height: 80vh;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }

    .char-picker-header {
      padding: 18px 20px;
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    .char-picker-title {
      font-weight: 700;
      font-size: 15px;
    }

    .char-picker-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
      gap: 12px;
      padding: 16px;
      overflow-y: auto;
    }

    .char-picker-item {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 6px;
      padding: 10px 8px;
      border-radius: 10px;
      cursor: pointer;
      border: 2px solid transparent;
      transition: border-color 0.15s, background 0.15s;
      text-align: center;
    }

    .char-picker-item:hover { background: rgba(255,255,255,0.05); }
    .char-picker-item.selected { border-color: var(--accent); background: rgba(var(--accent-rgb,229,100,40),0.1); }
    .char-picker-item.already-added { opacity: 0.4; cursor: not-allowed; }

    .char-picker-avatar {
      width: 72px;
      height: 72px;
      border-radius: 50%;
      overflow: hidden;
      background: rgba(255,255,255,0.06);
      border: 2px solid rgba(255,255,255,0.1);
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .char-picker-avatar img { width: 100%; height: 100%; object-fit: cover; }

    .char-picker-name {
      font-size: 11px;
      font-weight: 600;
      color: var(--text-primary);
      line-height: 1.3;
    }

    .char-picker-footer {
      padding: 14px 20px;
      border-top: 1px solid var(--border);
      display: flex;
      justify-content: flex-end;
      gap: 10px;
    }

    /* Moving Line Carousel */
    .moving-line-container {
      width: 100%;
      overflow: hidden;
      position: relative;
      padding: 20px 0;
    }

    .moving-line-track {
      display: flex;
      gap: 20px;
      width: max-content;
      animation: scroll 40s linear infinite;
    }

    .moving-line-track:hover {
      animation-play-state: paused;
    }

    @keyframes scroll {
      0% { transform: translateX(0); }
      100% { transform: translateX(-50%); }
    }

    .carousel-card {
      width: 320px;
      height: 190px;
      border-radius: 14px;
      overflow: hidden;
      position: relative;
      flex-shrink: 0;
      cursor: pointer;
      border: 1px solid var(--border);
      transition: transform 0.3s, border-color 0.2s, box-shadow 0.2s;
      box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    }

    .carousel-card:hover {
      transform: scale(1.04) translateY(-2px);
      border-color: var(--accent);
      box-shadow: 0 8px 28px rgba(0,0,0,0.45);
    }

    .carousel-card img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .carousel-card-overlay {
      position: absolute;
      inset: 0;
      background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.2) 60%, transparent 100%);
      display: flex;
      flex-direction: column;
      justify-content: flex-end;
      padding: 14px;
    }

    .carousel-card-name {
      font-size: 15px;
      font-weight: 700;
      color: #fff;
      text-shadow: 0 1px 4px rgba(0,0,0,0.6);
      line-height: 1.3;
    }

    .carousel-card-creator {
      font-size: 11px;
      color: rgba(255,255,255,0.65);
      margin-top: 3px;
    }

    .community-heading {
      display: flex;
      flex-direction: column;
      gap: 5px;
    }

    .community-heading-main {
      font-family: var(--font-display);
      font-size: 28px;
      font-weight: 800;
      background: linear-gradient(90deg, #fff 0%, var(--accent) 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
      letter-spacing: -0.5px;
      line-height: 1;
    }

    .community-heading-sub {
      font-size: 13px;
      color: #ffffff;
      font-weight: 400;
    }

    /* Community search bar */
    .community-search-row {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-top: 16px;
    }

    .community-search-wrap {
      position: relative;
      flex: 1;
      max-width: 420px;
    }

    .community-search-wrap svg {
      position: absolute;
      left: 12px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--text-dim);
      pointer-events: none;
    }

    .community-search-input {
      width: 100%;
      padding: 9px 14px 9px 36px;
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 8px;
      color: var(--text-primary);
      font-size: 13px;
      outline: none;
      transition: border-color 0.2s;
    }

    .community-search-input:focus {
      border-color: var(--accent);
    }

    .community-search-input::placeholder {
      color: var(--text-dim);
    }

    /* Genre row sections */
    .genre-row-section {
      margin-top: 28px;
    }

    .genre-row-header {
      display: flex;
      align-items: baseline;
      gap: 10px;
      margin-bottom: 14px;
    }

    .genre-row-title {
      font-family: var(--font-display);
      font-size: 16px;
      font-weight: 700;
      color: var(--text-primary);
    }

    .genre-row-count {
      font-size: 11px;
      color: var(--text-dim);
    }

    .genre-row-strip {
      display: flex;
      gap: 16px;
      overflow-x: auto;
      padding-bottom: 10px;
      scrollbar-width: thin;
      scrollbar-color: var(--border) transparent;
    }

    .genre-row-strip::-webkit-scrollbar {
      height: 4px;
    }

    .genre-row-strip::-webkit-scrollbar-thumb {
      background: var(--border);
      border-radius: 2px;
    }

    /* Showcase layout */
    .showcase-spotlight {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 14px;
      margin-top: 20px;
    }

    .showcase-card {
      position: relative;
      aspect-ratio: 3/2;
      border-radius: 12px;
      overflow: hidden;
      cursor: pointer;
      background: #1a1a2e;
      transition: transform 0.2s, box-shadow 0.2s;
    }

    .showcase-card:hover {
      transform: translateY(-3px);
      box-shadow: 0 12px 32px rgba(0,0,0,0.5);
    }

    .showcase-card img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block;
      transition: transform 0.3s;
    }

    .showcase-card:hover img {
      transform: scale(1.04);
    }

    .showcase-card-overlay {
      position: absolute;
      inset: 0;
      background: linear-gradient(to top, rgba(0,0,0,0.88) 0%, rgba(0,0,0,0.2) 55%, transparent 100%);
      display: flex;
      flex-direction: column;
      justify-content: flex-end;
      padding: 14px;
    }

    .showcase-card-tags {
      display: flex;
      gap: 5px;
      flex-wrap: wrap;
      margin-bottom: 6px;
    }

    .showcase-card-name {
      font-size: 14px;
      font-weight: 700;
      color: #fff;
      line-height: 1.3;
      margin-bottom: 4px;
    }

    .showcase-card-desc {
      font-size: 11px;
      color: rgba(255,255,255,0.72);
      line-height: 1.4;
      margin-bottom: 5px;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }

    .showcase-card-creator {
      font-size: 10px;
      color: rgba(255,255,255,0.5);
    }

    .showcase-card-creator:hover {
      color: rgba(255,255,255,0.85);
    }

    .showcase-section-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin: 28px 0 12px;
    }

    .showcase-section-title {
      font-size: 15px;
      font-weight: 700;
      color: var(--text-primary);
    }

    .showcase-browse-btn {
      background: none;
      border: none;
      color: var(--accent);
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      padding: 0;
    }

    .showcase-browse-btn:hover {
      opacity: 0.8;
    }

    .showcase-new-row {
      display: flex;
      gap: 14px;
      overflow-x: auto;
      padding-bottom: 10px;
      scrollbar-width: thin;
      scrollbar-color: var(--border) transparent;
    }

    .showcase-new-row::-webkit-scrollbar { height: 4px; }
    .showcase-new-row::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

    @media (max-width: 700px) {
      .showcase-spotlight {
        grid-template-columns: repeat(2, 1fr);
      }
    }

    @media (max-width: 480px) {
      .showcase-spotlight {
        grid-template-columns: 1fr;
      }
    }

    /* ── Home genre tabs ──────────────────────────────────── */
    .home-genre-tabs {
      display: flex;
      gap: 8px;
      overflow-x: auto;
      padding: 4px 0 12px;
      scrollbar-width: none;
      margin-bottom: 4px;
    }
    .home-genre-tabs::-webkit-scrollbar { display: none; }
    .home-genre-tab {
      flex-shrink: 0;
      padding: 7px 16px;
      border-radius: 20px;
      font-size: 13px;
      font-weight: 600;
      cursor: pointer;
      border: 1px solid var(--border);
      background: transparent;
      color: var(--text-dim);
      transition: background 0.15s, color 0.15s, border-color 0.15s;
      white-space: nowrap;
    }
    .home-genre-tab:hover { color: #fff; border-color: rgba(255,255,255,0.3); }
    .home-genre-tab.active {
      background: #fff;
      color: #111;
      border-color: #fff;
    }

    /* ── Home cards grid ──────────────────────────────────── */
    .home-cards-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 14px;
    }
    @media (max-width: 700px) { .home-cards-grid { grid-template-columns: repeat(2, 1fr); } }
    @media (max-width: 420px) { .home-cards-grid { grid-template-columns: 1fr; } }

    /* Larger text on home grid cards */
    .home-cards-grid .showcase-card-name { font-size: 16px; }
    .home-cards-grid .showcase-card-desc { font-size: 12px; }
    .home-cards-grid .showcase-card-creator { font-size: 11px; color: rgba(255,255,255,0.6); }
    .home-cards-grid .showcase-card-overlay { padding: 18px; }

    /* ── Floating Nodes Animation ──────────────────────────────────── */
    .floating-nodes-container {
      position: absolute;
      top: 0; left: 0; width: 100%; height: 100%;
      pointer-events: none;
      z-index: 0;
      overflow: hidden;
      opacity: 0.6;
    }
    .floating-nodes-container .node {
      position: absolute;
      background: radial-gradient(circle, rgba(249,115,22,0.8) 0%, rgba(249,115,22,0) 70%);
      border-radius: 50%;
      animation: floatNode 20s infinite linear;
      opacity: 0;
    }
    .floating-nodes-container .node-1 { width: 150px; height: 150px; top: 10%; left: 5%; animation-duration: 25s; animation-delay: 0s; }
    .floating-nodes-container .node-2 { width: 80px; height: 80px; top: 60%; left: 80%; animation-duration: 35s; animation-delay: -5s; }
    .floating-nodes-container .node-3 { width: 250px; height: 250px; top: 80%; left: 15%; animation-duration: 40s; animation-delay: -15s; }
    .floating-nodes-container .node-4 { width: 100px; height: 100px; top: 30%; left: 70%; animation-duration: 20s; animation-delay: -10s; }
    .floating-nodes-container .node-5 { width: 180px; height: 180px; top: 50%; left: 40%; animation-duration: 30s; animation-delay: -20s; }

    @keyframes floatNode {
      0% { transform: translateY(0) scale(1); opacity: 0; }
      20% { opacity: 0.3; }
      50% { transform: translateY(-100px) scale(1.1); opacity: 0.5; }
      80% { opacity: 0.3; }
      100% { transform: translateY(-200px) scale(1); opacity: 0; }
    }

    /* ── Home bottom bar ──────────────────────────────────── */
    .home-bottom-bar {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 12px;
      margin-top: 28px;
      padding-top: 24px;
      border-top: 1px solid var(--border);
    }
    .home-bottom-btn {
      display: flex;
      align-items: center;
      gap: 7px;
      padding: 10px 22px;
      border-radius: 8px;
      font-size: 13px;
      font-weight: 600;
      cursor: pointer;
      transition: opacity 0.15s;
    }
    .home-bottom-btn:hover { opacity: 0.85; }
    .home-bottom-btn-primary { background: var(--accent); color: #fff; border: none; }
    .home-bottom-btn-secondary { background: transparent; color: var(--text-primary); border: 1px solid var(--border); }
    .home-bottom-sep { color: var(--text-dim); font-size: 13px; }

    /* Explore view */
    #view-explore {
      overflow-y: auto;
    }

    .explore-content {
      max-width: 1100px;
      margin: 0 auto;
      width: 100%;
      padding: 32px 24px 40px;
    }

    .explore-header {
      margin-bottom: 24px;
    }

    .explore-title {
      font-family: var(--font-display);
      font-size: 28px;
      font-weight: 800;
      margin-bottom: 16px;
      background: linear-gradient(90deg, #fff 0%, var(--accent) 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
      letter-spacing: -0.5px;
    }

    .explore-search-row {
      display: flex;
      gap: 10px;
      align-items: center;
      flex-wrap: nowrap;
    }

    .explore-search-wrap {
      position: relative;
      flex: 1;
      min-width: 0;
    }

    .explore-search-wrap svg {
      position: absolute;
      left: 12px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--text-dim);
      pointer-events: none;
    }

    .explore-search-input {
      width: 100%;
      padding: 10px 14px 10px 38px;
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 8px;
      color: var(--text-primary);
      font-size: 14px;
      outline: none;
      transition: border-color 0.2s;
    }

    .explore-search-input:focus { border-color: var(--accent); }
    .explore-search-input::placeholder { color: var(--text-dim); }

    .explore-sort-select {
      padding: 10px 14px;
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 8px;
      color: var(--text-primary);
      font-size: 13px;
      outline: none;
      cursor: pointer;
      width: auto;
      min-width: 130px;
      flex-shrink: 0;
    }

    /* Category-based explore filter */
    .explore-cats-bar {
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
      margin-top: 14px;
      align-items: center;
    }
    @media (max-width: 700px) {
      .explore-cats-bar {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 6px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
      }
      .explore-cats-bar::-webkit-scrollbar { display: none; }
      .explore-cat-btn { flex-shrink: 0; }
    }

    .explore-cat-btn {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 5px 12px;
      border-radius: 20px;
      border: 1px solid var(--border);
      background: var(--bg-card);
      color: var(--text-dim);
      font-size: 12px;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.18s;
      user-select: none;
      white-space: nowrap;
    }

    .explore-cat-btn:hover {
      border-color: var(--accent);
      color: var(--text-primary);
    }

    .explore-cat-btn.active {
      background: rgba(232,98,26,0.15);
      border-color: var(--accent);
      color: var(--accent);
      font-weight: 600;
    }

    .explore-cat-btn.has-selected {
      border-color: var(--accent2);
      color: var(--accent2);
      background: rgba(46,189,217,0.1);
    }

    .explore-cat-btn .cat-count {
      font-size: 10px;
      background: var(--accent2);
      color: #000;
      border-radius: 8px;
      padding: 1px 5px;
      font-weight: 700;
      line-height: 1.4;
    }

    .explore-tag-strip {
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
      margin-top: 8px;
      padding: 10px 12px;
      background: rgba(255,255,255,0.03);
      border: 1px solid var(--border);
      border-radius: 8px;
      animation: fadeIn 0.15s ease;
    }

    .explore-active-tags-row {
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
      margin-top: 8px;
      min-height: 0;
    }

    .explore-active-tag {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 3px 8px 3px 10px;
      border-radius: 20px;
      background: rgba(46,189,217,0.15);
      border: 1px solid rgba(46,189,217,0.4);
      color: var(--accent2);
      font-size: 11px;
      font-weight: 600;
      cursor: pointer;
    }

    .explore-active-tag:hover { background: rgba(46,189,217,0.25); }
    .explore-active-tag svg { opacity: 0.7; }

    .explore-clear-all {
      font-size: 11px;
      color: var(--text-dim);
      background: none;
      border: none;
      cursor: pointer;
      padding: 4px 6px;
      border-radius: 4px;
      align-self: center;
    }
    .explore-clear-all:hover { color: var(--text-primary); }

    .explore-filter-bar {
      display: none; /* legacy — replaced by .explore-cats-bar */
    }

    .explore-results-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
      gap: 20px;
      margin-top: 20px;
      padding: 4px;
    }
    @media (max-width: 600px) {
      .explore-results-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
      }
    }
    @media (max-width: 360px) {
      .explore-results-grid {
        grid-template-columns: 1fr;
      }
    }

    .explore-card {
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 12px;
      overflow: hidden;
      cursor: pointer;
      transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    }

    .explore-card:hover {
      transform: translateY(-3px);
      box-shadow: 0 8px 28px rgba(0,0,0,0.45);
    }

    .explore-card-img {
      width: 100%;
      aspect-ratio: 16/9;
      overflow: hidden;
      background: linear-gradient(135deg, #1a1a2e, #16213e);
      position: relative;
    }

    .explore-card-img img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .explore-card-body {
      padding: 14px;
    }

    .explore-card-title {
      font-weight: 700;
      font-size: 14px;
      margin-bottom: 4px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .explore-card-desc {
      font-size: 12px;
      color: var(--text-dim);
      line-height: 1.5;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
      margin-bottom: 10px;
    }

    .explore-card-meta {
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-size: 11px;
      color: var(--text-dim);
    }

    .explore-card-creator {
      font-weight: 500;
      color: var(--text-secondary);
    }

    .explore-load-more {
      margin-top: 28px;
      text-align: center;
    }

    .explore-empty {
      text-align: center;
      padding: 60px 20px;
      color: var(--text-dim);
    }

    .explore-empty svg {
      margin-bottom: 12px;
      opacity: 0.4;
    }

    .genre-filter-bar {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      margin-bottom: 12px;
      margin-top: 14px;
    }

    .genre-pill {
      padding: 4px 12px;
      border-radius: 20px;
      border: 1px solid var(--border);
      background: var(--bg-card);
      color: var(--text-dim);
      font-size: 12px;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.18s;
      user-select: none;
    }

    .genre-pill:hover {
      border-color: var(--accent);
      color: var(--text-primary);
    }

    .genre-pill.active {
      background: rgba(46,189,217,0.15);
      border-color: var(--accent2);
      color: var(--accent2);
      font-weight: 600;
    }

    /* Tags shown on explore cards */
    .explore-card-tag {
      font-size: 10px;
      font-weight: 600;
      background: rgba(255,255,255,0.07);
      border: 1px solid rgba(255,255,255,0.12);
      color: var(--text-dim);
      padding: 2px 6px;
      border-radius: 20px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: 80px;
    }
    @media (max-width: 600px) {
      .explore-card-tag { font-size: 9px; padding: 1px 5px; max-width: 60px; }
      .explore-card-title { font-size: 12px; }
      .explore-card-desc { display: none; }
      .explore-card-body { padding: 10px; }
    }



    /* ── OOC messages ───────────────────────────────────────── */
    .ooc-bubble {
      color: #e8b84f !important;
      font-style: normal !important;
      background: rgba(232, 184, 79, 0.06) !important;
      border: 1px solid rgba(232, 184, 79, 0.18) !important;
    }
    .ooc-bubble * { color: inherit; font-style: normal !important; }

    /* ── Sidebar legal links ─────────────────────────────────── */
    .sidebar-legal {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      padding: 4px 14px 12px;
      font-size: 11px;
      color: rgba(128,128,128,0.45);
      flex-shrink: 0;
    }
    .sidebar-legal a {
      color: rgba(128,128,128,0.45);
      text-decoration: none;
      transition: color 0.15s;
    }
    .sidebar-legal a:hover { color: var(--accent); }
    .sidebar-legal span { opacity: 0.5; }

    /* ── Copyright corner ────────────────────────────────────── */
    .copyright-corner {
      position: absolute;
      bottom: 10px;
      right: 14px;
      font-size: 11px;
      color: rgba(128,128,128,0.35);
      pointer-events: none;
      z-index: 1;
      white-space: nowrap;
    }


/* ============================================================
   LANDING PAGE — seamless animated redesign
   ============================================================ */

#landingPage {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%; height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  z-index: 100;
  isolation: isolate;
  --lp-bg:     #000;
  --lp-panel:  #111;
  --lp-card:   #161616;
  --lp-border: rgba(255,255,255,0.06);
  --lp-accent: #e8621a;
  --lp-cyan:   #2ebdd9;
  --lp-dim:    #ffffff;
  --lp-muted:  #ffffff;
  background: transparent;
  color: #fff;
  font-family: 'Inter', sans-serif;
}
#landingPage::before {
  content: '';
  position: fixed;
  inset: -14%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.44;
  background:
    radial-gradient(circle at 18% 7%, rgba(255,112,24,0.54), transparent 30%),
    radial-gradient(circle at 82% 40%, rgba(255,112,24,0.18), transparent 34%),
    radial-gradient(circle at 38% 92%, rgba(255,112,24,0.15), transparent 34%),
    radial-gradient(circle at 22% 28%, rgba(255,143,49,0.74) 0 1.4px, rgba(255,143,49,0.24) 2.2px, transparent 11px),
    radial-gradient(circle at 77% 62%, rgba(255,143,49,0.58) 0 1.2px, rgba(255,143,49,0.18) 2px, transparent 10px),
    radial-gradient(circle, rgba(255,112,24,0.13) 1px, transparent 1.8px);
  background-size: 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 34px 34px;
  background-position: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0;
  mask-image: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent);
  animation: lp-orange-field 8s ease-in-out infinite;
}
#landingPage::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.32) 0%, transparent 16%, transparent 76%, rgba(0,0,0,0.54) 100%),
    radial-gradient(ellipse at center, transparent 0%, rgba(0,0,0,0.28) 84%);
}
#landingPage > * {
  position: relative;
  z-index: 1;
}

body.lp-active #app {
  display: none !important;
}

body.lp-active #mobileBottomNav {
  display: none !important;
}

/* Gradient text */
.lp-grad {
  background: linear-gradient(90deg, #ef4444, #e8621a, #f97316);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Twinkling star field animations ── */
.lp-stars-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.lp-star {
  position: absolute;
  width: 1.5px;
  height: 1.5px;
  background: #fff;
  border-radius: 50%;
  opacity: 0;
  will-change: opacity, transform;
}
.lp-star-twinkle-1 { animation: lp-twinkle 5s ease-in-out infinite; }
.lp-star-twinkle-2 { animation: lp-twinkle 7s ease-in-out infinite 1.8s; }
.lp-star-twinkle-3 { animation: lp-twinkle 6s ease-in-out infinite 3.2s; }
@keyframes lp-twinkle {
  0%, 100% { opacity: 0; transform: scale(0.6); }
  50% { opacity: 0.55; transform: scale(1.15); }
}

/* ── Scroll reveal ── */
.lp-animate {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s cubic-bezier(.22,1,.36,1), transform 0.7s cubic-bezier(.22,1,.36,1);
}
.lp-animate.lp-in {
  opacity: 1;
  transform: none;
}
.lp-animate-delay-1 { transition-delay: 0.1s; }
.lp-animate-delay-2 { transition-delay: 0.2s; }
.lp-animate-delay-3 { transition-delay: 0.3s; }
.lp-animate-delay-4 { transition-delay: 0.45s; }

/* ── Grid bg ── */
.lp-grid-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black 0%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black 0%, transparent 100%);
}

/* ── Orbs ── */
.lp-orb {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(100px);
  will-change: transform;
}
.lp-orb-1 {
  width: 700px; height: 700px;
  background: radial-gradient(circle, rgba(232,98,26,0.38), transparent 70%);
  top: -200px; left: -180px;
}
.lp-orb-2 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(46,189,217,0.25), transparent 70%);
  top: -100px; right: -150px;
}
.lp-orb-3 {
  width: 550px; height: 550px;
  background: radial-gradient(circle, rgba(139,92,246,0.18), transparent 70%);
  bottom: -150px; left: 30%;
}
@keyframes lp-breathe {
  0%,100% { opacity: .45; transform: scale(1); }
  50%      { opacity: .65; transform: scale(1.06); }
}
.lp-orb-1 { animation: lp-breathe 8s ease-in-out infinite; }
.lp-orb-2 { animation: lp-breathe 11s ease-in-out infinite reverse; }
.lp-orb-3 { animation: lp-breathe 9s ease-in-out infinite 2.2s; }

/* ── Masthead banner + beta strip ── */
.lp-masthead {
  width: 100%;
  position: relative;
  /* Sits just below the fixed nav (nav height ≈ 60px) */
  margin-top: 60px;
  background: #000;
  overflow: hidden;
}
.lp-masthead-img {
  width: 100%;
  display: block;
  max-height: 340px;
  object-fit: cover;
  object-position: center 20%;
}
.lp-beta-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 28px;
  background: linear-gradient(90deg, rgba(232,98,26,0.12) 0%, rgba(255,140,60,0.07) 50%, rgba(232,98,26,0.12) 100%);
  border-top: 1px solid rgba(232,98,26,0.3);
  border-bottom: 1px solid rgba(232,98,26,0.15);
  flex-wrap: wrap;
  gap: 10px;
}
.lp-beta-pill {
  flex-shrink: 0;
  background: rgba(232,98,26,0.18);
  border: 1px solid rgba(232,98,26,0.5);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 700;
  color: #f97316;
  letter-spacing: 0.04em;
  animation: lp-pulse-beta 2.4s ease-in-out infinite;
}
@keyframes lp-pulse-beta {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232,98,26,0); }
  50%       { box-shadow: 0 0 0 5px rgba(232,98,26,0.18); }
}
.lp-beta-text {
  flex: 1;
  font-size: 13px;
  color: rgba(255,255,255,0.75);
  line-height: 1.5;
  min-width: 200px;
}
.lp-beta-text strong { color: rgba(255,255,255,0.95); }
.lp-beta-report {
  flex-shrink: 0;
  background: var(--lp-accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 16px;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.lp-beta-report:hover { opacity: 0.85; }
@media (max-width: 600px) {
  .lp-masthead-img { max-height: 180px; object-position: 30% center; }
  .lp-beta-strip { padding: 10px 16px; }
  .lp-beta-text { font-size: 12px; }
}

/* ── Nav ── */
.lp-nav {
  position: fixed; top:0; left:0; right:0; z-index:200;
  background: rgba(8,8,8,0.75);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--lp-border);
}
.lp-nav-inner {
  max-width: 1160px; margin: 0 auto; padding: 0 32px;
  height: 60px; display: flex; align-items: center; gap: 32px;
}
.lp-nav-logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 700; color: #fff; flex-shrink:0;
}
.lp-nav-logo img { width: 32px; height: 32px; object-fit: contain; mix-blend-mode: lighten; }
.lp-nav-logo strong { color: var(--lp-accent); }
.lp-nav-links { display: flex; gap: 28px; }
.lp-nav-link {
  color: var(--lp-muted); text-decoration: none; font-size: 14px;
  font-weight: 500; cursor: pointer; transition: color .15s;
}
.lp-nav-link:hover { color: #fff; }
.lp-nav-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.lp-nav-mobile-btn { display: none; }

/* Buttons */
.lp-btn-primary {
  background: var(--lp-accent); color: #fff; border: none;
  border-radius: 30px; padding: 10px 22px; font-size: 14px; font-weight: 700;
  cursor: pointer; font-family: 'Inter',sans-serif;
  box-shadow: 0 0 20px rgba(232,98,26,0.35);
  transition: box-shadow .2s, transform .1s, opacity .15s;
}
.lp-btn-primary:hover { box-shadow: 0 0 36px rgba(232,98,26,0.6); transform: translateY(-1px); }
.lp-btn-ghost {
  background: rgba(255,255,255,0.05); color: #ccc;
  border: 1px solid rgba(255,255,255,0.12); border-radius: 30px;
  padding: 10px 22px; font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: 'Inter',sans-serif;
  transition: border-color .15s, color .15s, background .15s, transform .1s;
}
.lp-btn-ghost:hover { border-color: rgba(255,255,255,0.3); color: #fff; background: rgba(255,255,255,0.08); transform: translateY(-1px); }
.lp-btn-lg { padding: 14px 32px; font-size: 15px; }

/* ── Hero ── */
.lp-hero {
  position: relative; overflow: hidden;
  padding: clamp(72px, 8vw, 112px) 32px clamp(96px, 9vw, 132px);
  min-height: calc(100vh - 300px);
  display: flex; align-items: center;
  background: #000;
}
/* Vignette fade to black at bottom */
.lp-hero::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 220px;
  background: linear-gradient(to bottom, transparent, rgba(0,0,0,0.55));
  pointer-events: none; z-index: 1;
}
.lp-hero-inner {
  position: relative; z-index: 2;
  max-width: 1280px; margin: 0 auto; width: 100%;
  display: grid; grid-template-columns: minmax(0, 0.92fr) minmax(460px, 1.08fr);
  gap: clamp(36px, 5vw, 76px); align-items: center;
}
.lp-badge {
  display: inline-block;
  background: rgba(232,98,26,0.1); border: 1px solid rgba(232,98,26,0.28);
  color: var(--lp-accent); font-size: 11px; font-weight: 700;
  letter-spacing: 1px; padding: 6px 15px; border-radius: 20px; margin-bottom: 18px;
  text-transform: uppercase;
}
.lp-hero-h1 {
  font-size: clamp(42px, 5.4vw, 70px); font-weight: 900;
  line-height: 1.03; letter-spacing: 0; margin-bottom: 24px;
  max-width: 760px;
}
.lp-hero-sub {
  font-size: 18px; color: var(--lp-muted); line-height: 1.75;
  margin-bottom: 38px; max-width: 560px;
}
.lp-hero-content {
  position: relative;
  z-index: 6;
  max-width: 650px;
}
.lp-hero-ctas { display: flex; gap: 12px; flex-wrap: wrap; }

/* Mock chat */
.lp-hero-mock {
  position: relative;
  z-index: 3;
  justify-self: end;
  width: min(100%, 690px);
  margin-right: clamp(6px, 2vw, 28px);
  background: #0d0d0d; border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px; overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.04), 0 40px 100px rgba(0,0,0,0.7);
  transform: perspective(1000px) rotateY(-2deg) rotateX(1deg);
  transition: transform .6s cubic-bezier(.22,1,.36,1);
}
.lp-hero-mock:hover { transform: perspective(1000px) rotateY(0deg) rotateX(0deg); }
.lp-mock-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.05);
  background: rgba(255,255,255,0.02);
}
.lp-mock-scenario-dot { width: 34px; height: 34px; border-radius: 50%; flex-shrink:0; }
.lp-mock-scenario-name { font-size: 13px; font-weight: 700; }
.lp-mock-scenario-tag  { font-size: 10px; color: var(--lp-dim); margin-top:2px; }
.lp-mock-msgs { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.lp-mock-msg { display: flex; gap: 10px; align-items: flex-start; }
.lp-mock-msg-user { flex-direction: row-reverse; }
.lp-mock-av {
  width: 28px; height: 28px; border-radius: 8px; flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
  font-size:12px; font-weight:700; color:#fff;
}
.lp-mock-bubble {
  background: #161616; border: 1px solid rgba(255,255,255,0.05);
  border-radius: 12px; padding: 10px 14px;
  font-size: 13px; line-height: 1.6; max-width: 88%;
}
.lp-mock-bubble-bot { color: #c9d1d9; }
.lp-mock-bubble-user {
  background: rgba(232,98,26,0.1); border-color: rgba(232,98,26,0.2); color: #fff;
}
.lp-mock-input-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.05);
}
.lp-mock-input-field {
  flex:1; background: #161616; border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px; padding: 9px 13px; font-size: 13px; color: var(--lp-muted);
}
.lp-mock-send-btn {
  width:34px; height:34px; background: var(--lp-accent); border-radius: 8px;
  display:flex; align-items:center; justify-content:center; color:#fff; flex-shrink:0;
}

/* ── Pills ── */
.lp-pills { padding: 34px 32px 44px; background: transparent; }
.lp-pills-inner {
  max-width: 1060px; margin: 0 auto;
  display: flex; gap: 12px; justify-content: center; flex-wrap: wrap;
}
.lp-pill {
  display: flex; align-items: center; gap: 8px;
  background: rgba(12,12,12,0.82);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.16);
  box-shadow: 0 2px 18px rgba(0,0,0,0.44), inset 0 1px 0 rgba(255,255,255,0.08);
  border-radius: 24px; padding: 8px 17px;
  font-size: 13px; font-weight: 650; color: #d6d6d6; white-space: nowrap;
}

/* ── Creator suite ── */
.lp-create-suite {
  padding: clamp(84px, 8vw, 118px) 32px;
  background: transparent;
}
.lp-create-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.lp-create-item {
  min-height: 220px;
  border: 1px solid rgba(255,255,255,0.15);
  background: linear-gradient(180deg, rgba(18,18,18,0.92), rgba(7,7,7,0.82));
  border-radius: 8px;
  padding: 24px;
  transition: transform .24s, border-color .24s, background .24s, box-shadow .24s;
}
.lp-create-item:hover {
  transform: translateY(-4px);
  border-color: rgba(232,98,26,0.34);
  background: linear-gradient(180deg, rgba(44,20,11,0.88), rgba(10,10,10,0.86));
  box-shadow: 0 22px 58px rgba(0,0,0,0.54);
}
.lp-create-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(232,98,26,0.10);
  border: 1px solid rgba(232,98,26,0.20);
  color: var(--lp-accent);
  margin-bottom: 18px;
}
.lp-create-icon .material-symbols-outlined {
  font-size: 22px;
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}
.lp-create-title {
  font-size: 18px;
  font-weight: 850;
  color: #fff;
  letter-spacing: 0;
  margin-bottom: 10px;
}
.lp-create-item p {
  color: var(--lp-muted);
  font-size: 13.5px;
  line-height: 1.68;
  margin: 0;
}
.lp-create-flow {
  margin: 34px auto 0;
  max-width: 900px;
  display: grid;
  grid-template-columns: auto 1fr auto 1fr auto 1fr auto 1fr auto;
  align-items: center;
  gap: 12px;
}
.lp-create-step {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.lp-create-step strong {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(46,189,217,0.10);
  border: 1px solid rgba(46,189,217,0.22);
  color: var(--lp-cyan);
  font-size: 11px;
}
.lp-create-line {
  height: 1px;
  min-width: 24px;
  background: linear-gradient(90deg, rgba(46,189,217,0.34), rgba(232,98,26,0.28));
}

/* ── Feature sections ── seamless, no borders ── */
.lp-feature {
  padding: clamp(92px, 9vw, 130px) 32px;
  position: relative;
  background: transparent;
}
/* subtle alternating tint via pseudo */
.lp-feature:nth-child(odd) { background: transparent; }
.lp-feature-inner {
  max-width: 1180px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr 1fr;
  gap: clamp(64px, 8vw, 104px); align-items: center;
}
.lp-feature-flip .lp-feature-visual { order:1; }
.lp-feature-flip .lp-feature-text   { order:2; }

.lp-feature-label {
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1.8px; color: var(--lp-accent); margin-bottom: 16px;
}
.lp-feature-h2 {
  font-size: clamp(28px, 3.5vw, 46px); font-weight: 900;
  line-height: 1.12; letter-spacing: 0; margin-bottom: 20px;
}
.lp-feature-body {
  font-size: 16.5px; color: var(--lp-muted); line-height: 1.78; margin-bottom: 30px;
  max-width: 560px;
}
.lp-feature-list { list-style:none; padding:0; margin:0; display:flex; flex-direction:column; gap:13px; }
.lp-feature-list li {
  padding-left: 24px; position: relative;
  font-size: 14px; color: #c6c6c6; line-height: 1.55;
}
.lp-feature-list li::before { content:'✓'; position:absolute; left:0; color:var(--lp-accent); font-weight:700; }

/* Chips */
.lp-chip {
  display:inline-block; background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08); border-radius: 20px;
  padding: 3px 10px; font-size: 11px; font-weight: 600; color: #aaa;
}
.lp-chip-accent {
  background: rgba(232,98,26,0.1); border-color: rgba(232,98,26,0.25); color: var(--lp-accent);
}

/* ── Character card visual ── */
.lp-char-card {
  background: #141414; border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  transition: transform .4s cubic-bezier(.22,1,.36,1), box-shadow .4s;
}
.lp-char-card:hover { transform: translateY(-4px); box-shadow: 0 28px 80px rgba(0,0,0,0.7); }
.lp-char-card-sm { max-width: 260px; }
.lp-char-card-cover {
  height: 90px; position: relative; display:flex; align-items:flex-end; padding:12px;
}
.lp-char-card-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255,255,255,0.12); border: 3px solid #141414;
  display:flex; align-items:center; justify-content:center;
  font-size: 20px; font-weight: 800; color:#fff;
  position: absolute; bottom: -22px; left:14px;
}
.lp-char-card-body { padding: 28px 16px 16px; }
.lp-char-card-name { font-size:15px; font-weight:800; margin-bottom:3px; }
.lp-char-card-role { font-size:11px; color:var(--lp-dim); margin-bottom:10px; }
.lp-char-card-traits { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:10px; }
.lp-char-card-desc { font-size:12px; color:#888; line-height:1.6; margin-bottom:12px; }
.lp-char-card-playable { display:flex; align-items:center; gap:8px; }

/* ── Character screenshots (real-app) ── */
.lp-char-screenshots {
  position: relative;
  height: 600px;
  margin-left: -44px;
  transform-origin: center center;
}

@media (max-width: 1200px) {
  .lp-char-screenshots {
    transform: scale(0.85) translateX(16px);
  }
}
@media (max-width: 1024px) {
  .lp-char-screenshots {
    transform: scale(0.75) translateX(28px);
  }
}
.lp-charshot-wrap {
  position: absolute;
  animation: none !important;
}
.lp-charshot-wrap-main {
  width: 665px;
  top: 0;
  left: 0;
  z-index: 1;
}
.lp-charshot-wrap-edit {
  width: 414px;
  top: 200px;
  right: -10px;
  z-index: 2;
}
.lp-charshot-wrap-main:hover { z-index: 4; }
.lp-charshot-wrap-edit:hover { z-index: 4; }

.lp-charshot {
  width: 100%;
  display: block;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.72);
  animation: none !important;
  transition: transform 0.4s cubic-bezier(.22,1,.36,1),
              box-shadow 0.4s ease,
              filter 0.4s ease;
}
.lp-charshot-edit {
  border: 1px solid rgba(255,255,255,0.09);
  box-shadow: 0 16px 52px rgba(0,0,0,0.88);
}

/* Hover — smooth lift + colour glow */
.lp-charshot-main:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 32px 80px rgba(0,0,0,0.8), 0 0 48px rgba(232,98,26,0.3);
  filter: brightness(1.1);
}
.lp-charshot-edit:hover {
  transform: translateY(-8px) scale(1.03);
  box-shadow: 0 28px 72px rgba(0,0,0,0.88), 0 0 40px rgba(46,189,217,0.28);
  filter: brightness(1.1);
}


/* ── Vector Graph Memory Visual ── */
.lp-vector-graph {
  position: relative;
  width: 100%;
  height: 480px;
  background: radial-gradient(circle at center, rgba(18, 18, 22, 0.4), transparent 70%);
  border-radius: 20px;
}
.lp-vector-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.lp-vector-line {
  fill: none;
  stroke: rgba(255, 255, 255, 0.35);
  stroke-width: 1.5;
}
.lp-vector-line-active {
  stroke: var(--lp-accent);
  stroke-dasharray: 8 8;
  stroke-width: 2px;
  filter: drop-shadow(0 0 6px var(--lp-accent));
  animation: stroke-flow 2s linear infinite;
}
@keyframes stroke-flow {
  0% { stroke-dasharray: 10 10; stroke-dashoffset: 20; }
  100% { stroke-dasharray: 10 10; stroke-dashoffset: 0; }
}

.lp-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(18, 18, 22, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px 14px;
  width: 130px;
  height: 60px;
  text-align: center;
  color: var(--lp-dim);
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  transform: translate(-50%, -50%);
  will-change: transform;
  animation: float-node 6s ease-in-out infinite alternate;
}
.lp-node-icon { font-size: 16px; color: #777; font-variation-settings: 'FILL' 1; }

.lp-node-active {
  border-color: rgba(232, 98, 26, 0.4);
  color: #fff;
  box-shadow: 0 12px 32px rgba(232, 98, 26, 0.15), inset 0 1px 1px rgba(232, 98, 26, 0.2);
}
.lp-node-active .lp-node-icon {
  color: var(--lp-accent);
  filter: drop-shadow(0 0 4px var(--lp-accent));
}
.lp-node-match {
  position: absolute;
  top: -10px; right: -10px;
  background: var(--lp-accent);
  color: #fff;
  font-size: 9px;
  padding: 3px 6px;
  border-radius: 10px;
  font-weight: 900;
  box-shadow: 0 4px 10px rgba(232, 98, 26, 0.5);
  white-space: nowrap;
}

.lp-node-center {
  top: 50%; left: 50%;
  border-radius: 50%;
  width: 60px; height: 60px;
  padding: 0;
  border: 1px solid rgba(46, 189, 217, 0.4);
  box-shadow: 0 0 30px rgba(46, 189, 217, 0.2);
  color: var(--lp-cyan);
  animation: float-node 7s ease-in-out infinite alternate-reverse;
}
.lp-node-core {
  width: 16px; height: 16px;
  background: var(--lp-cyan);
  border-radius: 50%;
  box-shadow: 0 0 16px var(--lp-cyan);
}
.lp-node-pulse {
  position: absolute;
  inset: -10px;
  border: 1px solid var(--lp-cyan);
  border-radius: 50%;
  animation: pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}
@keyframes pulse-ring {
  0% { transform: scale(0.8); opacity: 0.8; }
  100% { transform: scale(1.6); opacity: 0; }
}

@keyframes float-node {
  0% { transform: translate(-50%, -50%) translateY(0); }
  100% { transform: translate(-50%, -50%) translateY(-10px); }
}

/* Positioning */
.lp-node-1 { top: 12%; left: 20%; animation-delay: 0s; }
.lp-node-2 { top: 15%; left: 80%; animation-delay: -1s; }
.lp-node-3 { top: 50%; left: 85%; animation-delay: -2s; }
.lp-node-4 { top: 85%; left: 75%; animation-delay: -4s; }
.lp-node-5 { top: 82%; left: 25%; animation-delay: -3s; }
.lp-node-6 { top: 45%; left: 12%; animation-delay: -5s; }

/* ── Image Gen Feature Visual ── */
.lp-imggen-wrap {
  position: relative;
  padding-top: 32px;
}
.lp-imggen-glow {
  position: absolute;
  bottom: -24px;
  left: 15%;
  right: 15%;
  height: 56px;
  background: rgba(232, 98, 26, 0.38);
  filter: blur(38px);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}
.lp-imggen-frame {
  position: relative;
  z-index: 1;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 28px 80px rgba(0,0,0,0.75), 0 0 60px rgba(232,98,26,0.12), 0 0 0 1px rgba(255,255,255,0.07);
  transition: box-shadow 0.45s ease;
  will-change: transform;
  animation: float-card 6s ease-in-out infinite alternate-reverse;
}
.lp-imggen-frame:hover {
  transform: translateY(-10px);
  box-shadow: 0 44px 110px rgba(0,0,0,0.88), 0 0 90px rgba(232,98,26,0.32), 0 0 0 1px rgba(255,255,255,0.12);
}
.lp-imggen-ref-card {
  position: absolute;
  top: 0;
  left: 24px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  filter: drop-shadow(0 12px 28px rgba(0,0,0,0.85));
  animation: float-card 5s ease-in-out infinite alternate;
}
@keyframes float-card {
  0%   { transform: translateY(0px); }
  100% { transform: translateY(-10px); }
}
.lp-imggen-ref-img {
  width: 150px;
  height: 187px;
  object-fit: cover;
  object-position: top center;
  border-radius: 14px;
  border: 2px solid rgba(232, 98, 26, 0.65);
}
.lp-imggen-ref-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #e8621a;
  background: rgba(10, 10, 10, 0.92);
  border: 1px solid rgba(232,98,26,0.35);
  padding: 3px 10px;
  border-radius: 8px;
  backdrop-filter: blur(6px);
  white-space: nowrap;
}

/* ── Scene Images Feature Gallery ── */
.lp-scene-gallery {
  position: relative;
  min-height: 560px;
  padding: 34px;
  border: 1px solid rgba(232, 98, 26, 0.28);
  border-radius: 28px;
  background:
    radial-gradient(circle at 14% 10%, rgba(232, 98, 26, 0.18), transparent 32%),
    radial-gradient(circle at 88% 14%, rgba(46, 189, 217, 0.09), transparent 28%),
    linear-gradient(145deg, rgba(10, 10, 10, 0.96), rgba(3, 3, 3, 0.98));
  box-shadow: 0 34px 100px rgba(0, 0, 0, 0.68), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  overflow: visible;
  isolation: isolate;
}

.lp-scene-gallery::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: radial-gradient(rgba(255, 112, 28, 0.2) 1px, transparent 1.5px);
  background-size: 28px 28px;
  opacity: 0.35;
  pointer-events: none;
  z-index: -1;
}

.lp-scene-gallery::after {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: -26px;
  height: 70px;
  border-radius: 50%;
  background: rgba(232, 98, 26, 0.24);
  filter: blur(42px);
  pointer-events: none;
  z-index: -2;
}

.lp-scene-card {
  position: absolute;
  overflow: hidden;
  border-radius: 22px;
  background: #050505;
  border: 1px solid rgba(255, 255, 255, 0.11);
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.72);
  transition: transform 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
}

.lp-scene-card:hover {
  transform: translateY(-8px);
  border-color: rgba(232, 98, 26, 0.42);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.82), 0 0 40px rgba(232, 98, 26, 0.18);
}

.lp-scene-card img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  filter: saturate(0.95) brightness(0.7);
  transform: scale(1.02);
  transition: filter 0.35s ease, transform 0.35s ease;
}

.lp-scene-card:hover img {
  filter: saturate(1.12) brightness(0.82);
  transform: scale(1.06);
}

.lp-scene-card-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0.78)),
    radial-gradient(circle at 15% 100%, rgba(232, 98, 26, 0.24), transparent 44%);
  pointer-events: none;
}

.lp-scene-card-copy {
  position: absolute;
  left: clamp(18px, 4vw, 34px);
  right: clamp(18px, 4vw, 34px);
  bottom: clamp(18px, 4vw, 34px);
  z-index: 2;
}

.lp-scene-card-copy span {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-bottom: 10px;
  padding: 7px 15px;
  border-radius: 999px;
  border: 1px solid rgba(255, 139, 58, 0.5);
  background: rgba(232, 98, 26, 0.2);
  color: #ffb071;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  box-shadow: 0 0 22px rgba(232, 98, 26, 0.18);
}

.lp-scene-card-copy h3 {
  margin: 0;
  color: #fff;
  font-size: clamp(20px, 2.65vw, 36px);
  line-height: 1.02;
  font-weight: 950;
  letter-spacing: 0;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.85);
}

.lp-scene-card-small .lp-scene-card-copy {
  left: 18px;
  right: 18px;
  bottom: 18px;
}

.lp-scene-card-small .lp-scene-card-copy h3 {
  font-size: 18px;
}

.lp-scene-card-main {
  left: 6%;
  top: 9%;
  width: 46%;
  height: 78%;
}

.lp-scene-card-wide {
  right: 5%;
  top: 9%;
  width: 46%;
  height: 36%;
}

.lp-scene-card-harbour {
  left: 54%;
  bottom: 9%;
  width: 22%;
  height: 35%;
}

.lp-scene-card-castle {
  right: 5%;
  bottom: 9%;
  width: 22%;
  height: 35%;
}

.lp-scene-toast {
  position: absolute;
  z-index: 8;
  min-width: 190px;
  padding: 15px 18px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(9, 10, 12, 0.88);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.78), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: lp-scene-toast-float 5.5s ease-in-out infinite alternate;
}

.lp-scene-toast span {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 10px;
  border-radius: 50%;
  background: var(--lp-cyan);
  box-shadow: 0 0 15px rgba(46, 189, 217, 0.75);
}

.lp-scene-toast strong {
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0;
}

.lp-scene-toast i {
  display: block;
  width: 100%;
  height: 6px;
  margin-top: 14px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--lp-cyan), #ffb36d 65%, var(--lp-accent) 82%, rgba(255, 255, 255, 0.12) 82%),
    rgba(255, 255, 255, 0.08);
}

.lp-scene-toast-left {
  top: 3%;
  left: 2%;
}

.lp-scene-toast-right {
  top: 4%;
  right: 3%;
  animation-delay: -1.2s;
}

.lp-scene-toast-bottom {
  right: 11%;
  bottom: 0;
  animation-delay: -2.4s;
}

@keyframes lp-scene-toast-float {
  0% { transform: translateY(0); }
  100% { transform: translateY(-10px); }
}

@media (max-width: 1050px) {
  .lp-scene-gallery {
    min-height: 500px;
    padding: 22px;
  }

  .lp-scene-toast {
    min-width: 160px;
    padding: 12px 14px 13px;
  }

  .lp-scene-toast strong {
    font-size: 13px;
  }
}

@media (max-width: 720px) {
  .lp-scene-gallery {
    min-height: auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 16px;
    border-radius: 22px;
  }

  .lp-scene-card,
  .lp-scene-card-main,
  .lp-scene-card-wide,
  .lp-scene-card-harbour,
  .lp-scene-card-castle {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .lp-scene-card-main {
    aspect-ratio: 4 / 5;
  }

  .lp-scene-toast {
    display: none;
  }
}

/* ── App Memory Map (Dynamic CSS Graph) ── */
#mgLegend {
  align-items: stretch;
  min-width: 210px;
  max-width: min(280px, calc(100vw - 40px));
}

#mgLegend .mg-legend-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 10px !important;
  width: 100%;
  min-width: 0;
  text-align: left;
}

#mgLegend .mg-legend-symbol {
  flex: 0 0 24px;
  width: 24px;
  min-width: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#mgLegend .mg-legend-label {
  min-width: 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

#mgLegend .mg-legend-character-label {
  color: rgba(255, 255, 255, 0.62);
}

#mgLegend .mg-legend-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

#mgLegend .mg-legend-sub {
  color: rgba(255, 255, 255, 0.42);
  font-size: 9px;
  line-height: 1.25;
}

#mgLegend .mg-legend-current {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(46, 189, 217, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

#mgLegend .mg-legend-current span,
#mgLegend .mg-legend-character-dotwrap span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: block;
}

#mgLegend .mg-legend-current span {
  background: #06b6d4;
  box-shadow: 0 0 6px #06b6d4;
}

#mgLegend .mg-legend-dashed {
  width: 20px;
  height: 0;
  border-bottom: 2px dashed #e8621a;
  box-shadow: 0 0 6px rgba(232, 98, 26, 0.3);
}

#mgLegend .mg-legend-line {
  width: 20px;
  height: 0;
  border-bottom: 2px solid rgba(255, 255, 255, 0.3);
}

#mgLegend .mg-legend-shared {
  width: 20px;
  height: 2px;
  background: rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

#mgLegend .mg-legend-shared span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}

#mgLegend .mg-legend-shared span:first-child {
  background: #a855f7;
}

#mgLegend .mg-legend-shared span:last-child {
  background: #06b6d4;
}

#mgLegend .mg-legend-pinned {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.02);
}

#mgLegend .mg-legend-pinned span {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 7px;
  height: 7px;
  background: #fa8211;
  border-radius: 50%;
}

#mgLegend .mg-legend-character-dotwrap {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  align-items: center;
  justify-content: center;
}

.mg-graph {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.mg-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.mg-line {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 1.5;
}
.mg-line-strong {
  stroke: rgba(255, 255, 255, 0.3);
  stroke-width: 2.5;
}

.mg-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(18, 18, 22, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px 14px;
  width: 140px;
  height: 60px;
  text-align: center;
  color: var(--lp-dim);
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  transform: translate(-50%, -50%);
  cursor: pointer;
  will-change: transform;
  animation: float-node 6s ease-in-out infinite alternate;
  transition: border-color 0.2s, box-shadow 0.2s, color 0.2s;
  z-index: 5;
}
.mg-node:hover {
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 12px 30px rgba(0,0,0,0.7), inset 0 0 10px rgba(255, 255, 255, 0.05);
  z-index: 6;
  color: #fff;
}
.mg-node-active {
  border-color: rgba(232, 98, 26, 0.4) !important;
  color: #fff !important;
  box-shadow: 0 12px 32px rgba(232, 98, 26, 0.15), inset 0 1px 1px rgba(232, 98, 26, 0.2) !important;
}
.mg-node-active .material-symbols-outlined {
  filter: drop-shadow(0 0 4px var(--lp-accent));
}

/* ── Active & Pulsing Nodes ── */
.mg-node-active {
  border-color: rgba(232, 98, 26, 0.6) !important;
  box-shadow: 0 0 20px rgba(232, 98, 26, 0.3), inset 0 0 10px rgba(232, 98, 26, 0.2) !important;
}
.mg-node-center {
  position: absolute;
  top: 50%; left: 50%;
  border-radius: 50%;
  width: 50px; height: 50px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(18, 18, 22, 0.9);
  border: 1px solid rgba(46, 189, 217, 0.4);
  box-shadow: 0 0 30px rgba(46, 189, 217, 0.2);
  transform: translate(-50%, -50%);
  z-index: 10;
}
.mg-node-core {
  width: 20px; height: 20px;
  background: #2ebdd9;
  border-radius: 50%;
  box-shadow: 0 0 16px #2ebdd9;
}
.mg-node-pulse {
  position: absolute;
  inset: -14px;
  border: 1.5px solid #2ebdd9;
  border-radius: 50%;
  animation: pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}
.mg-line-active {
  fill: none;
  stroke: var(--lp-accent);
  stroke-width: 2;
  filter: drop-shadow(0 0 6px var(--lp-accent));
  animation: stroke-flow 2s linear infinite;
}

/* ── Memory Map: Mobile Nodes ── */
@media (max-width: 640px) {
  .mg-node {
    width: 100px;
    height: 48px;
    padding: 7px 10px;
    font-size: 10px;
    gap: 4px;
    border-radius: 10px;
  }
  .mg-node .material-symbols-outlined {
    font-size: 16px !important;
  }
  .mg-node-center {
    width: 40px;
    height: 40px;
  }
  .mg-node-core {
    width: 16px;
    height: 16px;
  }
  .mg-node-pulse {
    inset: -10px;
  }
}

/* ── Memory Map: Node dimmed (for search/filter) ── */
.mg-node-dimmed {
  opacity: 0.18 !important;
  pointer-events: none;
  filter: grayscale(0.6);
}

/* ── Memory Map: Connected link highlight ── */
.mg-link-highlight {
  stroke: #06b6d4 !important;
  stroke-width: 3 !important;
  opacity: 1 !important;
  filter: drop-shadow(0 0 4px rgba(6, 182, 215, 0.5));
  transition: stroke 0.2s, stroke-width 0.2s;
}

/* ── Memory Map: Search bar ── */
#mgSearchWrap {
  position: relative;
  display: flex;
  align-items: center;
}
#mgSearchInput {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: #fff;
  font-size: 12px;
  font-family: inherit;
  padding: 6px 10px 6px 30px;
  width: 160px;
  outline: none;
  transition: border-color 0.2s, width 0.2s;
}
#mgSearchInput::placeholder {
  color: rgba(255,255,255,0.25);
}
#mgSearchInput:focus {
  border-color: rgba(6, 182, 215, 0.5);
  width: 200px;
}
#mgSearchIcon {
  position: absolute;
  left: 9px;
  color: rgba(255,255,255,0.3);
  font-size: 15px;
  pointer-events: none;
}
@media (max-width: 640px) {
  #mgSearchInput {
    width: 120px;
    font-size: 11px;
    padding: 5px 8px 5px 28px;
  }
  #mgSearchInput:focus {
    width: 150px;
  }
}

/* ── Memory Map: Detail panel — mobile bottom sheet ── */
#mgDetail {
  transition: transform 0.25s ease, opacity 0.2s ease;
}
@media (max-width: 640px) {
  #mgDetail {
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-height: 50vh !important;
    border-radius: 16px 16px 0 0 !important;
    border-bottom: none !important;
    transform: translateY(100%);
    opacity: 0;
  }
  #mgDetail.mg-detail-open {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ── Memory Map: Header hint hidden on mobile ── */
.mg-hint-text {
  font-size: 10px;
  color: rgba(255,255,255,0.18);
}
@media (max-width: 640px) {
  .mg-hint-text {
    display: none;
  }
}

/* ── Image gen ── */
.lp-imggen-mock {
  background: #111; border: 1px solid rgba(255,255,255,0.07);
  border-radius: 16px; padding: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.lp-imggen-prompt { display:flex; gap:10px; align-items:flex-start; margin-bottom:14px; }
.lp-imggen-shimmer {
  background: linear-gradient(135deg, #0d0d1a, #0a0a12);
  border: 1px solid rgba(255,255,255,0.06); border-radius: 12px;
  height: 180px; position:relative; overflow:hidden;
  display:flex; align-items:flex-end; padding:12px; margin-bottom:12px;
}
.lp-imggen-shimmer-wave {
  position:absolute; inset:0;
  background: linear-gradient(90deg, transparent, rgba(232,98,26,0.07) 40%, rgba(46,189,217,0.07) 60%, transparent);
  animation: lp-shimmer 2.8s ease-in-out infinite;
}
@keyframes lp-shimmer { 0%{transform:translateX(-100%)} 100%{transform:translateX(100%)} }
.lp-imggen-caption { position:relative; font-size:11px; color:var(--lp-muted); background:rgba(0,0,0,0.5); border-radius:6px; padding:4px 10px; }
.lp-imggen-chips { display:flex; gap:6px; flex-wrap:wrap; }

/* ── Inferno section ── */
.lp-inferno-section {
  position: relative;
  overflow: hidden;
  background: transparent;
}
.lp-inferno-bg {
  position: absolute;
  inset: 0;
  background-image: url('/assets/inferno-bg.png');
  background-size: cover;
  background-position: center 30%;
  pointer-events: none;
  -webkit-mask-image:
    linear-gradient(to right,  transparent 0%,  black 20%, black 100%),
    linear-gradient(to bottom, transparent 0%,  black 14%, black 86%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(to right,  transparent 0%,  black 20%, black 100%),
    linear-gradient(to bottom, transparent 0%,  black 14%, black 86%, transparent 100%);
  mask-composite: intersect;
}
.lp-inferno-section::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom, rgba(5,5,5,0.88) 0%, transparent 18%, transparent 82%, rgba(5,5,5,0.88) 100%),
    linear-gradient(90deg, rgba(5,0,0,0.96) 0%, rgba(5,0,0,0.82) 40%, rgba(5,0,0,0.2) 68%, transparent 100%);
  z-index: 1;
  pointer-events: none;
}
.lp-inferno-section .lp-feature-inner {
  position: relative;
  z-index: 2;
}
.lp-inferno-grad {
  background: linear-gradient(90deg, #ef4444, #b91c1c, #f97316);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.lp-inferno-section .lp-feature-list li::before { color: #ef4444; }

/* Inferno model card mock */
.lp-inferno-card {
  background: linear-gradient(160deg, rgba(120,10,10,0.35), rgba(5,0,0,0.92));
  border: 1px solid rgba(239,68,68,0.28);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 24px 72px rgba(0,0,0,0.75), 0 0 50px rgba(239,68,68,0.1);
  transition: transform .4s cubic-bezier(.22,1,.36,1), box-shadow .4s, border-color .3s;
  max-width: 560px;
  margin: 0 auto;
}
.lp-inferno-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 36px 100px rgba(0,0,0,0.88), 0 0 80px rgba(239,68,68,0.22);
  border-color: rgba(239,68,68,0.52);
}
.lp-inferno-card-banner {
  position: relative;
  height: 295px;
  overflow: hidden;
}
.lp-inferno-card-banner::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0; height: 50%;
  background: linear-gradient(to top, rgba(5,0,0,0.65) 0%, transparent 100%);
  pointer-events: none;
}
.lp-inferno-card-banner img {
  width: 100%;
  height: 295px;
  object-fit: cover;
  object-position: center 20%;
  display: block;
}
.lp-inferno-card-body { padding: 22px 26px 30px; }
.lp-inferno-card-badge {
  display: inline-block;
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1.3px; color: #ef4444;
  background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.32);
  border-radius: 20px; padding: 4px 13px; white-space: nowrap;
  margin-bottom: 10px;
}
.lp-inferno-card-name {
  font-size: 28px; font-weight: 900; color: #fff;
  letter-spacing: 0; line-height: 1.1;
  margin-bottom: 14px;
}
.lp-inferno-card-specs {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.1px; color: rgba(239,68,68,0.82);
  margin-bottom: 12px;
}
.lp-inferno-card-desc {
  font-size: 14px; color: #bbb; line-height: 1.7; margin: 0;
}

/* ── Community ── */
.lp-community {
  position: relative;
  overflow: hidden;
  padding: clamp(96px, 9vw, 128px) 32px;
  background: transparent;
}
@keyframes lp-orange-field {
  0%, 100% {
    opacity: 0.36;
    filter: brightness(0.85);
    background-position: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0;
  }
  42% {
    opacity: 0.62;
    filter: brightness(1.28);
    background-position: 1.5% -1%, -1% 1%, 0.5% 0.75%, 1% -1%, -0.8% 1.2%, 0 0;
  }
  68% {
    opacity: 0.48;
    filter: brightness(1.05);
    background-position: -0.5% 0.8%, 0.8% -0.4%, -1% 0.5%, -0.6% 0.7%, 1% -0.6%, 0 0;
  }
}
.lp-section-inner { max-width:1180px; margin:0 auto; }
.lp-community .lp-section-inner { position: relative; z-index: 1; }
.lp-section-header { text-align:center; margin-bottom:64px; }
.lp-section-h2 { font-size:clamp(30px,3.7vw,48px); font-weight:900; letter-spacing:0; margin-bottom:18px; line-height:1.12; }
.lp-section-sub { font-size:16.5px; color:var(--lp-muted); line-height:1.75; max-width:660px; margin:0 auto; }

.lp-builder-showcase {
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: 260px 178px;
  gap: 18px;
  max-width: 1040px;
  margin: 0 auto;
  min-height: auto;
  padding: 52px;
  border: 1px solid rgba(232,98,26,0.16);
  border-radius: 30px;
  background:
    radial-gradient(circle at 18% 16%, rgba(232,98,26,0.22), transparent 34%),
    radial-gradient(circle at 88% 22%, rgba(46,189,217,0.12), transparent 32%),
    linear-gradient(135deg, rgba(232,98,26,0.09), transparent 42%, rgba(46,189,217,0.04) 100%),
    rgba(0,0,0,0.16);
  box-shadow: inset 0 0 100px rgba(0,0,0,0.8), 0 34px 100px rgba(0,0,0,0.6);
  isolation: isolate;
  overflow: hidden;
}
.lp-builder-showcase::before {
  content: '';
  position: absolute;
  inset: 16px;
  border-radius: inherit;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255,255,255,0.022) 1px, transparent 1px);
  background-size: 64px 64px;
  opacity: .42;
  pointer-events: none;
  mask-image: linear-gradient(to bottom, transparent, #000 12%, #000 88%, transparent);
}
.lp-cover-card {
  position: relative;
  z-index: 1;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 22px;
  background: #060708;
  box-shadow: 0 26px 90px rgba(0,0,0,0.62), 0 0 48px rgba(232,98,26,0.08);
  transition: transform .32s ease, border-color .32s ease, box-shadow .32s ease;
}
.lp-cover-card:hover {
  transform: translateY(-5px);
  border-color: rgba(232,98,26,0.45);
  box-shadow: 0 34px 100px rgba(0,0,0,0.72), 0 0 54px rgba(232,98,26,0.16);
  z-index: 3;
}
.lp-cover-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(.98) brightness(.72) contrast(1.04);
  transform: scale(1.01);
  transition: transform .55s ease, filter .32s ease;
}
.lp-cover-card:hover img {
  transform: scale(1.055);
  filter: saturate(1.08) brightness(.86) contrast(1.06);
}
.lp-cover-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.82) 0%, rgba(0,0,0,0.28) 44%, transparent 100%);
  pointer-events: none;
}
.lp-cover-main {
  grid-column: 1 / 7;
  grid-row: 1 / 3;
  width: auto;
  height: auto;
  transform: none;
}
.lp-cover-main:hover { transform: translateY(-5px); }
.lp-cover-wide {
  grid-column: 7 / 13;
  grid-row: 1 / 2;
  width: auto;
  height: auto;
  transform: none;
}
.lp-cover-wide:hover { transform: translateY(-5px); }
.lp-cover-small {
  width: auto;
  height: auto;
}
.lp-cover-small-a {
  grid-column: 7 / 10;
  grid-row: 2 / 3;
  transform: none;
}
.lp-cover-small-a:hover { transform: translateY(-5px); }
.lp-cover-small-b {
  grid-column: 10 / 13;
  grid-row: 2 / 3;
  transform: none;
}
.lp-cover-small-b:hover { transform: translateY(-5px); }
.lp-cover-small-c {
  display: none;
}
.lp-cover-chip {
  position: absolute;
  z-index: 2;
  left: 20px;
  bottom: 62px;
  display: inline-flex;
  width: max-content;
  max-width: calc(100% - 40px);
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(232,98,26,0.2);
  border: 1px solid rgba(232,98,26,0.38);
  color: #ffb267;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .8px;
  text-transform: uppercase;
  box-shadow: 0 12px 34px rgba(0,0,0,0.42);
}
.lp-cover-title {
  position: absolute;
  z-index: 2;
  left: 20px;
  right: 20px;
  bottom: 20px;
  color: #fff;
  font-size: clamp(17px, 2vw, 24px);
  font-weight: 900;
  line-height: 1.08;
  letter-spacing: 0;
  text-shadow: 0 2px 16px rgba(0,0,0,0.78);
}
.lp-cover-small .lp-cover-title { left: 16px; right: 16px; bottom: 16px; font-size: 14px; }
@keyframes lp-builder-image-drift {
  0% { transform: scale(1.01) translate3d(-6px, -4px, 0); }
  100% { transform: scale(1.045) translate3d(6px, 4px, 0); }
}
.lp-builder-note {
  position: absolute;
  z-index: 4;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "dot text"
    "track track";
  align-items: center;
  gap: 8px 10px;
  min-width: 188px;
  padding: 14px 16px 15px;
  border: 1px solid rgba(255,255,255,0.11);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(18,18,18,0.9), rgba(5,6,8,0.72));
  color: #fff;
  font-size: 13px;
  font-weight: 850;
  box-shadow: 0 20px 58px rgba(0,0,0,0.62), inset 0 1px 0 rgba(255,255,255,0.06);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  animation: lp-builder-note-drift 5s ease-in-out infinite alternate;
}
.lp-note-dot {
  grid-area: dot;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2ebdd9;
  box-shadow: 0 0 18px rgba(46,189,217,0.82);
}
.lp-note-text { grid-area: text; white-space: nowrap; }
.lp-note-track {
  grid-area: track;
  display: block;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
}
.lp-note-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2ebdd9, #ff8a2b);
  box-shadow: 0 0 18px rgba(232,98,26,0.38);
}
.lp-builder-note-one { left: 28px; top: 28px; }
.lp-builder-note-two { right: 28px; top: 28px; color: #ffb267; animation-delay: -1.5s; }
.lp-builder-note-three { display: none; }
.lp-builder-note-four { right: 11%; bottom: 6%; animation-delay: -2.2s; }
@keyframes lp-builder-note-drift {
  0% { transform: translateY(0); }
  100% { transform: translateY(-10px); }
}

@media(max-width:1200px){
  .lp-cover-small-c,
  .lp-builder-note-four { display: none; }
  .lp-cover-small-b { grid-column: 10 / 13; grid-row: 2 / 3; width: auto; }
  .lp-builder-note-three { left: 50%; bottom: 24px; }
}

.lp-scenario-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:18px; }
.lp-scenario-card {
  background:#111; border:1px solid rgba(255,255,255,0.06);
  border-radius:16px; overflow:hidden; cursor:pointer;
  transition: transform .25s, border-color .25s, box-shadow .25s;
}
.lp-scenario-card:hover { transform:translateY(-5px); border-color:rgba(255,255,255,0.14); box-shadow:0 20px 50px rgba(0,0,0,0.5); }
.lp-scenario-cover { height:140px; position:relative; overflow:hidden; }
.lp-scenario-cover-glow { position:absolute; inset:0; }
.lp-scenario-info { padding:16px; }
.lp-scenario-tags { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:8px; }
.lp-tag {
  font-size:10px; font-weight:700; padding:2px 9px; border-radius:20px;
  background:rgba(232,98,26,0.1); border:1px solid rgba(232,98,26,0.2);
  color:var(--lp-accent); letter-spacing:.3px;
}
.lp-tag-dark { background:rgba(255,255,255,0.04); border-color:rgba(255,255,255,0.08); color:var(--lp-muted); }
.lp-scenario-title { font-size:15px; font-weight:800; margin-bottom:4px; }
.lp-scenario-creator { font-size:11px; font-weight:650; color:var(--lp-muted); margin-bottom:8px; }
.lp-scenario-desc  { font-size:12.5px; color:var(--lp-dim); line-height:1.6; }
.lp-section-cta { text-align:center; margin-top:42px; }

/* ── Pricing ── */
.lp-pricing { padding: clamp(96px, 9vw, 128px) 32px; background:transparent; }
.lp-pricing-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:22px; align-items:stretch; }
.lp-pricing-card {
  background:#111; border:1px solid rgba(255,255,255,0.07);
  border-radius:16px; padding:30px 26px;
  position:relative; display:flex; flex-direction:column;
  transition: transform .3s, box-shadow .3s;
}
.lp-pricing-card:hover { transform:translateY(-4px); box-shadow:0 24px 60px rgba(0,0,0,0.5); }
.lp-pricing-featured { border-color:rgba(232,98,26,0.35); background:linear-gradient(160deg,rgba(232,98,26,0.07),#111); }
.lp-pricing-popular {
  position:absolute; top:-11px; left:50%; transform:translateX(-50%);
  background:linear-gradient(135deg,var(--lp-accent),#c2410c);
  color:#fff; font-size:10px; font-weight:800;
  padding:3px 14px; border-radius:20px; white-space:nowrap; letter-spacing:.5px;
}
.lp-pricing-tier { font-size:12px; font-weight:800; text-transform:uppercase; letter-spacing:1px; margin-bottom:8px; }
.lp-pricing-price { font-size:42px; font-weight:900; color:#fff; margin-bottom:6px; line-height:1; }
.lp-pricing-period { font-size:14px; font-weight:400; color:var(--lp-dim); }
.lp-pricing-desc { font-size:13.5px; color:var(--lp-dim); line-height:1.5; margin-bottom:22px; min-height:40px; }
.lp-pricing-features { list-style:none; padding:0; margin:0 0 26px; display:flex; flex-direction:column; gap:10px; flex:1; }
.lp-pricing-features li { font-size:13.5px; color:#bbb; padding-left:20px; position:relative; line-height:1.45; }
.lp-pricing-features li::before { content:'✓'; position:absolute; left:0; color:var(--lp-accent); font-weight:700; }
.lp-pricing-btn { width:100%; justify-content:center; border-radius:30px; }
.lp-pricing-note { text-align:center; font-size:13px; color:var(--lp-dim); margin-top:28px; }

.group-relationship-list { display:flex; flex-direction:column; gap:8px; }
.group-relationship-tools {
  display:grid;
  grid-template-columns:minmax(150px,1fr) minmax(130px,0.7fr) auto;
  gap:8px;
  align-items:center;
  margin-bottom:10px;
}
.group-relationship-empty {
  border:1px dashed rgba(255,255,255,0.12);
  border-radius:8px;
  color:#fff;
  font-size:12px;
  padding:12px;
  background:rgba(255,255,255,0.035);
}
.group-relationship-row {
  display:grid;
  grid-template-columns:minmax(190px,1.05fr) minmax(185px,0.9fr) minmax(260px,1.45fr) 38px;
  gap:8px;
  align-items:start;
}
.group-relationship-row select,
.group-relationship-row input {
  min-width:0;
  height:44px;
  border-radius:8px;
  border:1px solid rgba(255,255,255,0.12);
  background:rgba(255,255,255,0.055);
  color:#fff;
  font-size:13px;
  line-height:1.2;
  padding:0 14px;
  text-overflow:ellipsis;
}
.rel-picker {
  min-width: 0;
}
.rel-picker-trigger {
  width: 100%;
  min-width: 0;
  height: 44px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.055);
  color: #fff;
  font-size: 13px;
  line-height: 1.2;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  text-align: left;
}
.rel-picker-trigger:hover {
  border-color: rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
}
.rel-picker-trigger:disabled,
.rel-picker-disabled .rel-picker-trigger {
  opacity: 0.86;
  color: rgba(255,255,255,0.82);
  border-color: rgba(232,98,26,0.24);
  background: rgba(232,98,26,0.06);
  cursor: default;
}
.rel-picker-trigger-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rel-picker-trigger-label.is-placeholder {
  color: rgba(255,255,255,0.46);
}
.rel-picker-trigger-meta {
  font-size: 18px;
  color: rgba(255,255,255,0.48);
  flex-shrink: 0;
}
.rel-picker-panel {
  position: fixed;
  z-index: 9500;
  max-height: 340px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(20,20,22,0.98);
  box-shadow: 0 24px 70px rgba(0,0,0,0.55);
  backdrop-filter: blur(18px);
  overflow: hidden;
}
.rel-picker-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.rel-picker-search-row .material-symbols-outlined {
  font-size: 18px;
  color: rgba(255,255,255,0.42);
}
.rel-picker-search {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: #fff;
  font-size: 14px;
}
.rel-picker-options {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 284px;
  overflow-y: auto;
  padding: 8px;
}
.rel-picker-option {
  width: 100%;
  border: 0;
  background: transparent;
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  cursor: pointer;
}
.rel-picker-option:hover {
  background: rgba(255,255,255,0.08);
}
.rel-picker-option.active {
  background: linear-gradient(135deg, rgba(232,98,26,0.22), rgba(46,189,217,0.12));
  box-shadow: inset 0 0 0 1px rgba(232,98,26,0.28);
}
.rel-picker-option-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.rel-picker-option-meta {
  flex-shrink: 0;
  color: rgba(255,255,255,0.46);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.rel-picker-empty {
  padding: 18px 14px;
  color: rgba(255,255,255,0.48);
  font-size: 13px;
  text-align: center;
}
.group-relationship-row select:disabled {
  opacity:0.86;
  color:rgba(255,255,255,0.78);
  border-color:rgba(232,98,26,0.24);
  background:rgba(232,98,26,0.06);
}
.rel-targets {
  display:flex;
  flex-direction:column;
  gap:8px;
  min-width:0;
}
.rel-target-entry {
  display:flex;
  gap:8px;
  min-width:0;
}
.rel-target-entry select {
  flex:1;
}
.group-relationship-add-target,
.group-relationship-target-remove {
  border-radius:8px;
  border:1px solid rgba(255,255,255,0.12);
  background:rgba(255,255,255,0.055);
  color:#fff;
  cursor:pointer;
  font-weight:800;
}
.group-relationship-add-target {
  min-height:34px;
  padding:0 12px;
  color:var(--accent2);
  text-align:left;
}
.group-relationship-target-remove {
  width:38px;
  height:44px;
  flex:0 0 auto;
  font-size:16px;
}
.group-relationship-remove {
  width:38px;
  height:38px;
  border-radius:8px;
  border:1px solid rgba(255,255,255,0.12);
  background:rgba(255,255,255,0.055);
  color:#fff;
  cursor:pointer;
  font-size:18px;
  line-height:1;
}
.group-relationship-preview {
  margin-top:12px;
  border:1px solid rgba(46,189,217,0.18);
  border-radius:8px;
  background:rgba(46,189,217,0.045);
  padding:10px 12px;
}
.group-relationship-preview-title {
  color:#fff;
  font-size:10px;
  font-weight:900;
  letter-spacing:1px;
  text-transform:uppercase;
  margin-bottom:6px;
}
.group-relationship-preview-line,
.group-relationship-preview-empty {
  color:rgba(255,255,255,0.72);
  font-size:12px;
  line-height:1.45;
}
@media (max-width: 760px) {
  .group-relationship-row { grid-template-columns:1fr; }
  .group-relationship-tools { grid-template-columns:1fr; }
  .group-relationship-remove,
  .group-relationship-add-target { width:100%; }
}

/* Tier stat blocks */
.lp-pricing-stats { display:flex; gap:8px; margin:0 0 24px; }
.lp-pstat {
  flex:1; background:rgba(255,255,255,0.04); border:1px solid rgba(255,255,255,0.07);
  border-radius:10px; padding:10px 6px; text-align:center;
}
.lp-pstat-num { display:block; font-size:18px; font-weight:800; color:#fff; line-height:1.1; }
.lp-pstat-label { display:block; font-size:10px; color:var(--lp-dim); margin-top:2px; }
.lp-pstat-mid { border-color:rgba(251,191,36,0.2); background:rgba(251,191,36,0.05); }
.lp-pstat-mid .lp-pstat-num { color:#fbbf24; }
.lp-pstat-pro { border-color:rgba(249,115,22,0.2); background:rgba(249,115,22,0.05); }
.lp-pstat-pro .lp-pstat-num { color:#fa8211; }

/* Feature comparison table */
.lp-compare { margin-top:48px; overflow-x:auto; }
.lp-compare-table {
  width:100%; border-collapse:collapse; font-size:13.5px;
}
.lp-compare-table thead th {
  padding:10px 16px; font-size:12px; font-weight:700; text-transform:uppercase;
  letter-spacing:.8px; border-bottom:1px solid rgba(255,255,255,0.1);
}
.lp-compare-feature-col { text-align:left; color:var(--lp-dim); width:40%; }
.lp-compare-tier-col { text-align:center; width:20%; }
.lp-compare-mid { color:#fbbf24 !important; }
.lp-compare-pro { color:#fa8211 !important; }
.lp-compare-table tbody tr { border-bottom:1px solid rgba(255,255,255,0.05); transition:background .15s; }
.lp-compare-table tbody tr:hover { background:rgba(255,255,255,0.03); }
.lp-compare-table tbody tr:last-child { border-bottom:none; }
.lp-compare-table td {
  padding:11px 16px; color:#ccc; text-align:center; vertical-align:middle;
}
.lp-compare-table td:first-child { text-align:left; color:#e5e7eb; font-weight:500; }
.lp-compare-dash { color:rgba(255,255,255,0.2) !important; font-size:16px; }
.lp-compare-check { color:var(--lp-accent) !important; font-size:15px; font-weight:700; }

/* ── CTA banner ── */
.lp-cta {
  position: relative; overflow: hidden;
  padding: 0;
  min-height: 420px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
}
.lp-cta-bg {
  position: absolute; inset: 0;
  background-image: url('assets/lp-banner.png?v=86');
  background-size: cover; background-position: center;
  filter: brightness(0.68);
}
.lp-cta-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(8,8,8,0.5) 0%, rgba(8,8,8,0.2) 50%, rgba(8,8,8,0.7) 100%);
}
.lp-cta-inner {
  position: relative; z-index: 2;
  max-width: 760px; margin: 0 auto; padding: 104px 32px;
  text-align: center;
}
.lp-cta-h2 { font-size:clamp(36px,5vw,62px); font-weight:900; letter-spacing:0; margin-bottom:18px; line-height:1.08; }
.lp-cta-sub { font-size:16.5px; color:rgba(255,255,255,0.78); line-height:1.75; margin-bottom:38px; }
.lp-cta-inner .lp-hero-ctas { justify-content:center; }

/* ── Footer ── */
.lp-footer { background:rgba(5,5,5,0.72); border-top:1px solid rgba(255,255,255,0.05); padding:64px 32px 0; }
.lp-footer-inner {
  max-width:1160px; margin:0 auto;
  display:grid; grid-template-columns:280px 1fr; gap:64px;
  padding-bottom:48px; border-bottom:1px solid rgba(255,255,255,0.05);
}
.lp-footer-logo { display:flex; align-items:center; gap:10px; margin-bottom:14px; }
.lp-footer-name { font-size:15px; font-weight:700; }
.lp-footer-name strong { color:var(--lp-accent); }
.lp-footer-tagline { font-size:13px; color:var(--lp-dim); line-height:1.65; }
.lp-footer-cols { display:grid; grid-template-columns:repeat(4,1fr); gap:32px; }
.lp-footer-col-title { font-size:11px; font-weight:800; text-transform:uppercase; letter-spacing:1px; color:#fff; margin-bottom:14px; }
.lp-footer-link { display:block; font-size:13px; color:var(--lp-dim); text-decoration:none; margin-bottom:9px; transition:color .15s; cursor:pointer; }
.lp-footer-link:hover { color:#fff; }
.lp-footer-bottom {
  max-width:1160px; margin:0 auto; padding:20px 0;
  display:flex; justify-content:space-between;
  font-size:12px; color:var(--lp-dim);
}

/* ── Floating Hero Assets ── */
.lp-floating-assets {
  position: absolute;
  top: 0;
  right: 0;
  width: min(58vw, 980px);
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}
/* Left pair — behind hero text so the headline stays readable */
.lp-floating-back  { z-index: 1; }
/* Right pair — above hero content so they're visible over the chat widget */
.lp-floating-front { z-index: 3; }

.lp-float-item {
  position: absolute;
  pointer-events: auto;
  border-radius: 16px;
  background: rgba(13, 13, 13, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 16px;
  width: clamp(150px, 12vw, 220px);
  transition: transform 0.5s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.5s ease, border-color 0.3s ease;
  user-select: none;
  will-change: transform;
}

.lp-float-item:hover {
  transform: scale(1.05) translateY(-5px) rotate(1deg) !important;
  box-shadow: 0 20px 40px rgba(232, 98, 26, 0.15), 0 0 30px rgba(232, 98, 26, 0.1), inset 0 1px 2px rgba(255, 255, 255, 0.1);
  border-color: rgba(232, 98, 26, 0.3);
  cursor: grab;
}

/* Fallback card styling */
.lp-float-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  transition: opacity 0.4s ease;
}

.lp-float-fallback-icon {
  width: 32px;
  height: 32px;
  stroke: var(--lp-accent);
  flex-shrink: 0;
}

.lp-float-fallback-title {
  font-family: 'Cinzel', serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
}

.lp-float-fallback-sub {
  font-size: 11px;
  color: var(--lp-muted);
  line-height: 1.3;
}

/* Image styling */
.lp-float-img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  display: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}

/* Image states */
.lp-float-item.img-loaded .lp-float-img {
  display: block;
  opacity: 1;
}

.lp-float-item.img-loaded .lp-float-fallback {
  display: none;
  opacity: 0;
}

.lp-float-item.img-loaded {
  padding: 6px;
  background: rgba(13, 13, 13, 0.7);
  width: clamp(170px, 15vw, 260px);
}

/* Placements stay inside the right-side hero stage so they never cover the headline. */
.lp-float-item-1 {
  top: 5%;
  left: 3%;
  animation: lp-float-drift-1 12s ease-in-out infinite alternate;
}

.lp-float-item-2 {
  bottom: 7%;
  right: 8%;
  animation: lp-float-drift-2 15s ease-in-out infinite alternate;
}

.lp-float-item-3 {
  top: 6%;
  right: 2%;
  animation: lp-float-drift-3 14s ease-in-out infinite alternate;
}

.lp-float-item-4 {
  bottom: 3%;
  left: 4%;
  animation: lp-float-drift-4 16s ease-in-out infinite alternate;
}

/* Floating Animations */
@keyframes lp-float-drift-1 {
  0% { transform: translateY(0px) rotate(-1deg); }
  100% { transform: translateY(-14px) translateX(6px) rotate(1deg); }
}

@keyframes lp-float-drift-2 {
  0% { transform: translateY(0px) rotate(1.5deg); }
  100% { transform: translateY(-16px) translateX(-5px) rotate(-1.5deg); }
}

@keyframes lp-float-drift-3 {
  0% { transform: translateY(0px) rotate(-2deg); }
  100% { transform: translateY(12px) translateX(-6px) rotate(1deg); }
}

@keyframes lp-float-drift-4 {
  0% { transform: translateY(0px) rotate(1deg); }
  100% { transform: translateY(-12px) translateX(5px) rotate(-2deg); }
}

/* ── Responsive ── */
@media(max-width:1280px){
  .lp-hero-inner { grid-template-columns: minmax(0, 0.95fr) minmax(420px, 1.05fr); }
  .lp-hero-h1 { font-size: clamp(42px, 5vw, 62px); }
  .lp-hero-mock { width: min(100%, 610px); }
  .lp-floating-assets { width: min(56vw, 760px); }
  .lp-float-item.img-loaded { width: clamp(150px, 13vw, 220px); }
}
@media(max-width:1080px){
  .lp-hero-inner { grid-template-columns: minmax(0, 1fr) minmax(380px, 0.9fr); gap: 32px; }
  .lp-floating-assets { display: none; }
}
@media(max-width:900px){
  .lp-hero-inner    { grid-template-columns:1fr; }
  .lp-hero-content  { transform: none; }
  .lp-hero-mock     { display:none; }
  .lp-floating-assets,.lp-floating-front { display:none !important; }
  .lp-inferno-bg { display: none; }
  .lp-inferno-section { background: rgba(0,0,0,0.12); }
  .lp-inferno-section::before { display: none; }
  .lp-hero { padding-top: 72px; padding-bottom: 88px; min-height: auto; }
  .lp-hero-sub { max-width: 680px; }
  .lp-feature { padding-top: 72px; padding-bottom: 82px; }
  .lp-create-suite,.lp-community,.lp-pricing { padding-top: 78px; padding-bottom: 86px; }
  .lp-feature-inner { display:flex; flex-direction:column; gap:48px; align-items:stretch; }
  .lp-feature-flip .lp-feature-text { order:-1; }
  .lp-feature-flip .lp-feature-visual { order:0; }
  .lp-create-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lp-create-flow { grid-template-columns: repeat(5, auto); justify-content: center; row-gap: 10px; }
  .lp-create-line { display: none; }
  .lp-scenario-grid { grid-template-columns:repeat(2,1fr); }
  .lp-builder-showcase {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: 300px 170px;
    min-height: auto;
    padding: 22px;
    max-width: 720px;
  }
  .lp-cover-main { grid-column: 1 / 3; grid-row: 1 / 2; width: auto; height: auto; }
  .lp-cover-wide { grid-column: 1 / 2; grid-row: 2 / 3; width: auto; height: auto; }
  .lp-cover-small { height: auto; }
  .lp-cover-small-a { grid-column: 2 / 3; grid-row: 2 / 3; width: auto; }
  .lp-cover-small-b { display: none; }
  .lp-cover-small-c { display: none; }
  .lp-cover-small .lp-cover-title { font-size: 12px; line-height: 1.05; }
  .lp-builder-note { min-width: 164px; padding: 12px 14px 13px; font-size: 12px; }
  .lp-builder-note-one { left: 14px; top: 26px; }
  .lp-builder-note-two { right: 14px; top: 26px; }
  .lp-builder-note-three { display: none; }
  .lp-builder-note-four { display: none; }
  .lp-pricing-grid  { grid-template-columns:1fr; max-width:400px; margin:0 auto; }
  .lp-footer-inner  { grid-template-columns:1fr; gap:40px; }
  .lp-footer-cols   { grid-template-columns:repeat(2,1fr); }
  .lp-nav-links,.lp-nav-actions { display:none; }
  .lp-nav-mobile-btn { display:block; margin-left:auto; }
  
  .lp-char-screenshots { height: 380px; margin: 0 auto; width: 100%; max-width: 500px; transform: none; }
  .lp-charshot-wrap-main { width: 80%; top: 0; left: 0; }
  .lp-charshot-wrap-edit { width: 65%; top: 60px; right: 0; }
  
  .lp-vector-graph { height: 320px; }
}
@media(max-width:540px){
  .lp-feature { padding-top: 58px; padding-bottom: 66px; }
  .lp-hero,.lp-feature,.lp-create-suite,.lp-community,.lp-pricing { padding-left:20px; padding-right:20px; }
  .lp-hero-h1 { font-size: clamp(36px, 11vw, 48px); }
  .lp-hero-sub,.lp-feature-body,.lp-section-sub,.lp-cta-sub { font-size: 15.5px; }
  .lp-pills { padding-left: 20px; padding-right: 20px; }
  .lp-pill { width: calc(50% - 6px); justify-content: center; padding-left: 10px; padding-right: 10px; }
  .lp-community,.lp-pricing { padding-top: 66px; padding-bottom: 74px; }
  .lp-create-suite { padding-top: 66px; padding-bottom: 74px; }
  .lp-create-grid { grid-template-columns: 1fr; }
  .lp-create-item { min-height: auto; }
  .lp-create-flow { grid-template-columns: repeat(2, auto); }
  .lp-section-header { margin-bottom: 42px; }
  .lp-builder-showcase {
    grid-template-columns: 1fr;
    grid-template-rows: 230px 150px 130px;
    min-height: auto;
    padding: 12px;
    border-radius: 18px;
  }
  .lp-cover-card { border-radius: 15px; }
  .lp-cover-main { grid-column: 1; grid-row: 1 / 2; width: auto; height: auto; }
  .lp-cover-wide { grid-column: 1; grid-row: 2 / 3; width: auto; height: auto; }
  .lp-cover-small { height: auto; }
  .lp-cover-small-a { grid-column: 1; grid-row: 3 / 4; width: auto; }
  .lp-cover-small-b { display: none; }
  .lp-cover-small-c { display: none; }
  .lp-cover-chip { left: 14px; bottom: 12px; font-size: 9px; padding: 5px 10px; }
  .lp-cover-main .lp-cover-chip,
  .lp-cover-wide .lp-cover-chip { bottom: 52px; }
  .lp-cover-title { left: 14px; right: 14px; bottom: 14px; font-size: 15px; }
  .lp-cover-small .lp-cover-title { font-size: 12px; }
  .lp-builder-note { min-width: 132px; padding: 10px 11px 11px; font-size: 11px; border-radius: 13px; }
  .lp-builder-note-one { left: 10px; top: 12px; }
  .lp-builder-note-two { right: 10px; top: 12px; }
  .lp-builder-note-three { left: 5%; bottom: 2%; }
  .lp-builder-note-four { display: none; }
  .lp-cta-inner { padding:82px 20px; }
  .lp-footer { padding:40px 20px 0; }
  .lp-scenario-grid  { grid-template-columns:1fr; }
  .lp-footer-cols    { grid-template-columns:1fr 1fr; }
  .lp-footer-bottom  { flex-direction:column; gap:6px; text-align:center; }
  .lp-inferno-card-banner, .lp-inferno-card-banner img { height:200px; }
  
  .lp-char-screenshots { height: 320px; }
  .lp-charshot-wrap-edit { top: 40px; }
  
  .lp-vector-graph { height: 240px; }
}
@media(max-width:900px){
  .lp-inferno-bg { opacity:1; background-position:center center; }
  .lp-inferno-section::before {
    background:
      linear-gradient(to bottom, #050505 0%, transparent 15%, transparent 85%, #050505 100%),
      linear-gradient(180deg, transparent 0%, rgba(5,0,0,0.55) 100%);
  }
  .lp-inferno-card { max-width:100%; }
  .lp-inferno-card-banner, .lp-inferno-card-banner img { height:240px; }
}

/* ── Scenario Creator — desktop textarea sizes ──────────────────────────── */
@media (min-width: 769px) {
  /* Description card — same column layout, don't go wild */
  #scenarioDesc { height: 240px !important; }

  /* Greeting — this is the main writing canvas, give it room */
  #scenarioGreeting { min-height: 280px; }

  /* Custom Instructions */
  #scenarioInstructions { min-height: 240px; }

  /* World / Lore boxes — matched baseline */
  #bsDetails      { min-height: 320px; }
  #bsRelationships { min-height: 320px; }
  #bsLocations    { min-height: 320px; }
  #bsHistory      { min-height: 320px; }
}

/* ── Scenario Creator Refresh ───────────────────────────────────────── */
#view-create {
  background: var(--bg-app);
}

#view-create .creator-content {
  max-width: 1180px;
  padding: 34px 44px 120px;
}

#view-create .creator-title {
  position: relative;
  justify-content: flex-start;
  text-align: left;
  margin: 0 0 28px;
  padding: 28px 30px;
  min-height: 132px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: var(--bg-panel);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: 0;
}

#view-create .creator-title::before {
  content: "Build the world, cast the roles, set the first spark.";
  position: absolute;
  left: 31px;
  bottom: 26px;
  width: auto;
  height: auto;
  flex: none;
  background: none;
  color: rgba(255, 255, 255, 0.56);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

#view-create .creator-title::after {
  content: "";
  position: absolute;
  inset: 0;
  flex: none;
  height: auto;
  background:
    linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.055) 58%, transparent 100%),
    radial-gradient(circle at 92% 20%, rgba(46, 189, 217, 0.14), transparent 24%);
  pointer-events: none;
}

#view-create .form-section {
  position: relative;
  margin: 0 0 22px;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.095);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.018)),
    rgba(10, 10, 10, 0.78);
  box-shadow:
    0 18px 52px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.045);
  overflow: visible;
}

#view-create .form-section::before {
  display: none;
}

#view-create .form-section-title {
  position: relative;
  margin: -4px -4px 20px;
  padding: 0 0 16px;
  border-left: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.075);
  background: none !important;
  box-shadow: none !important;
  color: rgba(255, 255, 255, 0.92);
  font-size: 12px;
  letter-spacing: 0.12em;
}

#view-create .form-section-title .section-icon {
  width: 68px;
  height: 68px;
  object-fit: contain;
  margin-right: 6px;
}

#view-create .form-section-title svg {
  width: 28px;
  height: 28px;
  padding: 6px;
  border-radius: 9px;
  background: rgba(232, 98, 26, 0.12);
  border: 1px solid rgba(232, 98, 26, 0.22);
}

#view-create .form-section-title.blue svg { background: rgba(59, 130, 246, 0.12); border-color: rgba(59, 130, 246, 0.24); }
#view-create .form-section-title.green svg { background: rgba(16, 185, 129, 0.12); border-color: rgba(16, 185, 129, 0.24); }
#view-create .form-section-title.purple svg { background: rgba(139, 92, 246, 0.12); border-color: rgba(139, 92, 246, 0.24); }
#view-create .form-section-title.amber svg { background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.24); }

#view-create .creator-main-row {
  gap: 24px !important;
  align-items: stretch !important;
}

#view-create .creator-left-col {
  width: min(36%, 360px) !important;
}

#view-create .creator-right-col {
  gap: 14px !important;
}

#view-create .form-group {
  position: relative;
  margin-bottom: 0;
}

#view-create .form-label,
#view-create .backstory-sub-label {
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  letter-spacing: 0.02em;
}

#view-create input,
#view-create textarea,
#view-create select,
#view-create .intro-editor-body {
  border: 1px solid rgba(255, 255, 255, 0.105) !important;
  border-radius: 12px !important;
  background: var(--bg-input) !important;
  color: var(--text-primary) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

#view-create input:hover,
#view-create textarea:hover,
#view-create select:hover,
#view-create .intro-editor-body:hover {
  border-color: rgba(255, 255, 255, 0.18) !important;
}

#view-create input:focus,
#view-create textarea:focus,
#view-create select:focus,
#view-create .intro-editor-body:focus {
  border-color: rgba(232, 98, 26, 0.64) !important;
  box-shadow: 0 0 0 3px rgba(232, 98, 26, 0.13), inset 0 1px 0 rgba(255, 255, 255, 0.045) !important;
}

#view-create textarea::placeholder,
#view-create input::placeholder,
#view-create .intro-editor-body:empty::before {
  color: rgba(255, 255, 255, 0.34) !important;
}

#view-create .char-count {
  color: rgba(255, 255, 255, 0.42);
  font-size: 11px;
  margin-top: 6px;
}

#view-create .image-upload-area {
  min-height: 220px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(232, 98, 26, 0.12), rgba(46, 189, 217, 0.06)),
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.08), transparent 36%),
    rgba(255, 255, 255, 0.035);
  color: rgba(255, 255, 255, 0.58);
  box-shadow: inset 0 0 45px rgba(0, 0, 0, 0.34);
}

#view-create .image-upload-area::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.28));
}

#view-create .image-upload-area svg,
#view-create .image-upload-area span {
  position: relative;
  z-index: 1;
}

#view-create .image-upload-area:hover {
  border-color: rgba(232, 98, 26, 0.72);
  color: #fff;
  background:
    linear-gradient(135deg, rgba(232, 98, 26, 0.18), rgba(46, 189, 217, 0.08)),
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.1), transparent 36%),
    rgba(255, 255, 255, 0.045);
}

#view-create .btn-upload-action,
#view-create .btn-secondary,
#view-create .tag-picker-trigger,
#view-create .warn-chip {
  border-radius: 11px !important;
  background: rgba(255, 255, 255, 0.055) !important;
  border: 1px solid rgba(255, 255, 255, 0.11) !important;
  color: rgba(255, 255, 255, 0.72) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

#view-create .btn-upload-action:hover,
#view-create .btn-secondary:hover,
#view-create .tag-picker-trigger:hover,
#view-create .tag-picker-trigger.open,
#view-create .warn-chip:hover {
  color: #fff !important;
  border-color: rgba(232, 98, 26, 0.46) !important;
  background: rgba(232, 98, 26, 0.1) !important;
}

#view-create .warn-chip.active[data-warn="violence"]  { background: rgba(232,123,53,0.18) !important; border-color: #e87b35 !important; color: #e87b35 !important; }
#view-create .warn-chip.active[data-warn="gore"]      { background: rgba(204,34,34,0.18)  !important; border-color: #cc2222 !important; color: #e06060 !important; }
#view-create .warn-chip.active[data-warn="sexual"]    { background: rgba(155,89,182,0.18) !important; border-color: #9b59b6 !important; color: #c39bd3 !important; }
#view-create .warn-chip.active[data-warn="noncon"]    { background: rgba(200,30,30,0.18)  !important; border-color: #cc2222 !important; color: #e08080 !important; }
#view-create .warn-chip.active[data-warn="dubcon"]    { background: rgba(200,100,30,0.18) !important; border-color: #d06020 !important; color: #e0a070 !important; }
#view-create .warn-chip.active[data-warn="substance"] { background: rgba(41,128,185,0.18) !important; border-color: #2980b9 !important; color: #7fc4f0 !important; }
#view-create .warn-chip.active[data-warn="language"]  { background: rgba(127,140,141,0.18)!important; border-color: #7f8c8d !important; color: #aab7b8 !important; }
#view-create .warn-chip.active[data-warn="dark"]      { background: rgba(80,60,120,0.22)  !important; border-color: #7d6aaa !important; color: #b2a4d4 !important; }
#view-create .warn-chip.active[data-warn="trauma"]    { background: rgba(100,60,160,0.18) !important; border-color: #8060b0 !important; color: #c0a0e0 !important; }
#view-create .warn-chip.active[data-warn="dead-dove"] { background: rgba(160,160,180,0.15)!important; border-color: #9090a8 !important; color: #c0c0d0 !important; }

#view-create .btn-primary,
#view-create .creator-bottom-actions .btn-primary {
  border-radius: 11px !important;
  background: linear-gradient(135deg, #f47a20, #d94d12) !important;
  box-shadow: 0 14px 30px rgba(232, 98, 26, 0.22);
}

#view-create .btn-primary:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

#view-create .intro-editor-toolbar {
  gap: 5px !important;
  padding: 9px !important;
  border: 1px solid rgba(255, 255, 255, 0.105) !important;
  border-bottom: 0 !important;
  border-radius: 12px 12px 0 0;
  background: rgba(20, 20, 22, 0.96) !important;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

#view-create .intro-editor-toolbar button,
#view-create .intro-editor-toolbar select {
  min-height: 34px;
  font-size: 14px;
  border-radius: 8px !important;
  background: rgba(0, 0, 0, 0.18) !important;
}

#view-create .intro-font-btn {
  min-height: 34px;
  font-size: 15px;
}

#view-create .intro-editor-body {
  min-height: 280px;
  border-radius: 0 0 12px 12px !important;
  padding: 18px;
  font-size: 16px;
  line-height: 1.72;
}

#view-create .backstory-subsections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

#view-create .world-building-hint {
  position: relative;
  margin: -8px 0 18px;
  padding: 12px 14px 12px 40px;
  border: 1px solid rgba(46, 189, 217, 0.18);
  border-radius: 13px;
  background:
    linear-gradient(135deg, rgba(46, 189, 217, 0.08), rgba(232, 98, 26, 0.055)),
    rgba(255, 255, 255, 0.024);
  color: rgba(255, 255, 255, 0.64);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
}

#view-create .world-building-hint::before {
  content: "i";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  border: 1px solid rgba(46, 189, 217, 0.34);
  border-radius: 50%;
  color: rgba(135, 221, 235, 0.82);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

#view-create .backstory-sub {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.025);
}

#view-create .backstory-sub textarea {
  min-height: 320px !important;
  height: 320px;
  flex: 1 1 auto;
}

#view-create #bsLocations,
#view-create #bsHistory {
  min-height: 320px !important;
}

#view-create .tag-selected-pill {
  border-color: rgba(232, 98, 26, 0.5);
  background: rgba(232, 98, 26, 0.16);
  box-shadow: 0 8px 18px rgba(232, 98, 26, 0.08);
}

#view-create .tag-picker-popup {
  border-color: rgba(255, 255, 255, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02)),
    #101010;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.58);
}

#view-create .publish-row {
  padding: 16px;
  margin-bottom: 10px;
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.026);
}

#view-create .publish-row:last-child {
  margin-bottom: 0;
}

#view-create .publish-row-label {
  font-weight: 750;
}

#view-create .publish-row-sub {
  color: rgba(255, 255, 255, 0.52);
}

#view-create .pub-toggle-track {
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

#view-create .pub-toggle-track.on {
  background: linear-gradient(135deg, #f47a20, #d94d12);
  border-color: rgba(232, 98, 26, 0.7);
}

#view-create .warn-chips {
  gap: 10px;
}

#view-create .warn-chip {
  border-radius: 999px !important;
  padding: 8px 14px;
}

#view-create #timestampHelperSection > div {
  border-radius: 16px !important;
  background:
    linear-gradient(135deg, rgba(232, 98, 26, 0.11), rgba(46, 189, 217, 0.045)),
    rgba(255, 255, 255, 0.025) !important;
}

#view-create #storyCharsEmpty {
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.024);
}

#view-create .creator-bottom-actions {
  position: sticky;
  bottom: 18px;
  z-index: 8;
  width: fit-content;
  margin: 24px 0 0 auto;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.105);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.025)),
    rgba(14, 14, 14, 0.78);
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.38),
    0 0 34px rgba(232, 98, 26, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.055);
  backdrop-filter: blur(14px);
}

#view-create .creator-bottom-actions .btn-primary,
#view-create .creator-bottom-actions .btn-secondary {
  min-height: 44px;
  padding: 12px 24px;
}

@media (max-width: 920px) {
  #view-create .creator-content {
    padding: 22px 18px 116px;
  }

  #view-create .creator-title {
    min-height: 116px;
    padding: 24px;
    font-size: 28px;
  }

  #view-create .creator-title::before {
    left: 25px;
    bottom: 22px;
  }

  #view-create .creator-main-row {
    flex-direction: column !important;
  }

  #view-create .creator-left-col {
    width: 100% !important;
  }

  #view-create .backstory-subsections {
    grid-template-columns: 1fr;
  }

  #view-create .form-section {
    padding: 18px;
  }

  #view-create .publish-row {
    align-items: flex-start;
    flex-direction: column;
  }

  #view-create .creator-bottom-actions {
    bottom: 10px !important;
    width: 100% !important;
    margin: 20px 0 0 !important;
    padding: 10px !important;
    border: 1px solid rgba(255, 255, 255, 0.105) !important;
    border-radius: 14px !important;
    background:
      linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.025)),
      rgba(14, 14, 14, 0.78) !important;
    box-shadow:
      0 18px 50px rgba(0, 0, 0, 0.38),
      0 0 34px rgba(232, 98, 26, 0.08),
      inset 0 1px 0 rgba(255, 255, 255, 0.055) !important;
  }

  #view-create .creator-bottom-actions .btn-primary,
  #view-create .creator-bottom-actions .btn-secondary {
    flex: 1;
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  #view-create .backstory-sub textarea {
    min-height: 260px !important;
    height: 260px;
  }
}

/* ── Image Generation Modal Cards ───────────────────────────────── */
.imggen-model-card {
  position: relative;
  border-radius: 14px;
  border: 2px solid rgba(255,255,255,0.07);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  min-height: 130px;
  display: flex;
  flex-direction: column;
}
.imggen-model-card:hover {
  border-color: rgba(232,98,26,0.45);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
}
.imggen-model-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(232,98,26,0.22), 0 8px 28px rgba(0,0,0,0.5);
}
.imggen-model-card.active::after {
  content: '✓';
  position: absolute;
  top: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
  color: #fff;
  z-index: 5;
  line-height: 22px;
  text-align: center;
}
.imggen-card-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.imggen-card-content {
  position: relative;
  z-index: 2;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 8px;
}
.imggen-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.imggen-card-name {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  font-family: var(--font-display);
  text-shadow: 0 1px 5px rgba(0,0,0,0.8);
}
.imggen-card-badge {
  font-size: 9px;
  font-weight: 800;
  background: rgba(255,255,255,0.12);
  color: #fff;
  padding: 3px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1px solid rgba(255,255,255,0.18);
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  white-space: nowrap;
}
.imggen-card-desc {
  font-size: 11px;
  line-height: 1.55;
  color: rgba(255,255,255,0.75);
  margin: 0;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}
.imggen-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.imggen-tier-badge {
  font-size: 9px;
  font-weight: 800;
  background: linear-gradient(135deg, rgba(232,98,26,0.3), rgba(232,98,26,0.14));
  color: #fa8211;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border: 1px solid rgba(232,98,26,0.35);
}
.imggen-default-card {
  min-height: 160px;
  margin-bottom: 4px;
}
.imggen-default-card .imggen-card-name {
  font-size: 20px;
}
.imggen-default-card .imggen-card-desc {
  font-size: 12px;
}
.imggen-lock-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.84);
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 12px;
}

/* ── Story Continuity Panel ──────────────────────────────── */

/* Character chip */
.cont-char-chip {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px;
  padding: 14px 16px;
  transition: border-color 0.2s ease;
}
.cont-char-chip:hover { border-color: rgba(46,189,217,0.25); }
.cont-char-initial {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(46,189,217,0.35), rgba(46,189,217,0.15));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  color: #2ebdd9;
  flex-shrink: 0;
  border: 2px solid rgba(46,189,217,0.2);
}
.cont-char-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}
.cont-char-status {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  line-height: 1.5;
}

/* Timeline */
.cont-timeline-item {
  display: flex;
  gap: 0;
  margin-bottom: 0;
}
.cont-timeline-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 28px;
  flex-shrink: 0;
}
.cont-timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.15);
  flex-shrink: 0;
  margin-top: 3px;
}
.cont-timeline-dot-current {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(232,98,26,0.5);
}
.cont-timeline-line {
  width: 2px;
  flex: 1;
  background: rgba(255,255,255,0.08);
  margin: 4px 0;
  min-height: 20px;
}
.cont-timeline-content {
  flex: 1;
  padding: 0 0 18px 10px;
}
.cont-timeline-event {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  line-height: 1.4;
}
.cont-badge {
  font-size: 10px;
  font-weight: 700;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.6);
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.1);
  white-space: nowrap;
}
.cont-badge-elapsed {
  background: rgba(232,98,26,0.1);
  color: rgba(232,98,26,0.8);
  border-color: rgba(232,98,26,0.2);
}

/* Active plot beats */
.cont-plotbeat-card {
  background:
    linear-gradient(135deg, rgba(245,158,11,0.10), rgba(0,0,0,0.12)),
    rgba(255,255,255,0.03);
  border: 1px solid rgba(245,158,11,0.22);
  border-radius: 11px;
  padding: 13px 15px;
  margin-bottom: 10px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
.cont-plotbeat-title {
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  line-height: 1.45;
}
.cont-plotbeat-stakes {
  margin-top: 8px;
  font-size: 12px;
  color: rgba(255,255,255,0.66);
  line-height: 1.45;
}
.cont-plotbeat-status-active {
  background: rgba(245,158,11,0.10);
  color: #f59e0b;
  border-color: rgba(245,158,11,0.25);
}
.cont-plotbeat-status-overdue {
  background: rgba(239,68,68,0.12);
  color: #ef4444;
  border-color: rgba(239,68,68,0.28);
}

/* Knowledge map */
.cont-knowledge-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.cont-knowledge-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
}
.cont-knowledge-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 5px;
}
.cont-knowledge-label {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  white-space: nowrap;
  flex-shrink: 0;
  padding: 2px 6px;
  border-radius: 3px;
}
.cont-status-label {
  background: rgba(52,211,153,0.12);
  color: rgba(52,211,153,0.9);
  border: 1px solid rgba(52,211,153,0.2);
}
.cont-knows-label {
  background: rgba(46,189,217,0.12);
  color: rgba(46,189,217,0.9);
  border: 1px solid rgba(46,189,217,0.2);
}
.cont-unkn-label {
  background: rgba(232,98,26,0.1);
  color: rgba(232,98,26,0.85);
  border: 1px solid rgba(232,98,26,0.2);
}
.cont-knowledge-text {
  font-size: 12px;
  color: rgba(255,255,255,0.65);
  line-height: 1.5;
}

/* Cast Board */
.cast-board-overlay {
  position: fixed;
  inset: 0;
  z-index: 1210;
  background:
    radial-gradient(circle at 20% 10%, color-mix(in srgb, var(--cast-accent, #f59e0b) 12%, transparent), transparent 30%),
    radial-gradient(circle at 88% 18%, rgba(46,189,217,0.10), transparent 34%),
    #06080d;
  display: flex;
  align-items: stretch;
  justify-content: center;
}
.cast-board-shell {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  color: var(--text-primary);
}
.cast-board-header {
  height: 68px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: rgba(5,7,12,0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.cast-kicker {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--cast-accent, #f59e0b);
}
.cast-board-header h2 {
  margin: 3px 0 0;
  font-size: 18px;
  font-family: var(--font-display);
  color: #fff;
}
.cast-board-close {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}
.cast-board-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.cast-board-canvas {
  min-height: 0;
  overflow: auto;
  padding: 28px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
  background-image: radial-gradient(rgba(255,255,255,0.045) 1px, transparent 0);
  background-size: 28px 28px;
}
.cast-board-tree-canvas {
  display: block;
  padding: 26px;
}
.cast-tree-stage {
  width: min(1180px, 100%);
  margin: 0 auto;
}
.cast-tree-section-title {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--cast-accent, #f59e0b) 78%, transparent);
  margin: 0 0 12px;
}
.cast-tree-section-title-spaced {
  margin-top: 28px;
}
.cast-family-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.cast-family-link,
.cast-tree-group {
  border: 1px solid color-mix(in srgb, var(--cast-accent, #f59e0b) 18%, transparent);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.018));
  box-shadow: 0 20px 60px rgba(0,0,0,0.24);
}
.cast-family-link {
  padding: 14px;
}
.cast-family-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(100px, 150px) minmax(220px, 1fr);
  align-items: center;
  gap: 12px;
}
.cast-tree-connector {
  position: relative;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cast-accent, #f59e0b);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.cast-tree-connector::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 1px solid color-mix(in srgb, var(--cast-accent, #f59e0b) 48%, transparent);
}
.cast-tree-connector span {
  position: relative;
  z-index: 1;
  background: #0b0d12;
  border: 1px solid color-mix(in srgb, var(--cast-accent, #f59e0b) 26%, transparent);
  border-radius: 999px;
  padding: 5px 10px;
}
.cast-link-note {
  margin-top: 9px;
  color: rgba(255,255,255,0.54);
  font-size: 11px;
  line-height: 1.45;
}
.cast-tree-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 132px;
  border: 1px solid rgba(255,255,255,0.075);
  border-radius: 12px;
  background: rgba(3,5,10,0.64);
  padding: 12px 10px;
  text-align: center;
  appearance: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.cast-tree-node:hover {
  border-color: color-mix(in srgb, var(--cast-accent, #f59e0b) 28%, transparent);
  background: rgba(9,12,20,0.82);
}
.cast-tree-node:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--cast-accent, #f59e0b) 72%, transparent);
  outline-offset: 2px;
}
.cast-tree-avatar {
  width: 76px;
  height: 76px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--cast-accent, #f59e0b);
  font-size: 16px;
  font-weight: 900;
  background: color-mix(in srgb, var(--cast-accent, #f59e0b) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--cast-accent, #f59e0b) 25%, transparent);
  overflow: hidden;
}
.cast-tree-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cast-tree-person {
  min-width: 0;
  width: 100%;
}
.cast-tree-name {
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 100%;
}
.cast-tree-empty {
  border: 1px dashed color-mix(in srgb, var(--cast-accent, #f59e0b) 22%, transparent);
  border-radius: 10px;
  color: rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.025);
  padding: 18px;
  font-size: 12px;
  line-height: 1.5;
}
.cast-tree-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}
.cast-tree-group {
  overflow: hidden;
}
.cast-tree-group-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  background: color-mix(in srgb, var(--cast-accent, #f59e0b) 5.5%, transparent);
}
.cast-tree-group-head h3 {
  margin: 0;
  color: #fff;
  font-size: 13px;
}
.cast-tree-group-head p {
  margin: 5px 0 0;
  font-size: 11px;
  color: rgba(255,255,255,0.48);
  line-height: 1.4;
}
.cast-tree-group-head > span {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 900;
  color: var(--cast-accent, #f59e0b);
  border: 1px solid color-mix(in srgb, var(--cast-accent, #f59e0b) 25%, transparent);
  border-radius: 999px;
  padding: 3px 8px;
  height: fit-content;
}
.cast-tree-group-members {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
}
.cast-tree-group-hierarchy {
  grid-column: 1 / -1;
}
.cast-tree-group-location .cast-tree-group-head {
  border-left: 3px solid var(--cast-accent, #66bb6a);
}
.cast-hierarchy-tree {
  padding: 24px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-x: auto;
}
.cast-hierarchy-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  min-width: min-content;
}
.cast-hierarchy-couple {
  display: inline-flex;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
  position: relative;
}
.cast-hierarchy-couple-paired::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 2px;
  background: color-mix(in srgb, var(--cast-accent, #f59e0b) 55%, transparent);
  transform: translate(-50%, -50%);
}
.cast-hierarchy-has-children > .cast-hierarchy-couple::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -22px;
  height: 22px;
  border-left: 2px solid color-mix(in srgb, var(--cast-accent, #f59e0b) 62%, transparent);
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--cast-accent, #f59e0b) 20%, transparent));
}
.cast-hierarchy-couple .cast-tree-node {
  width: 132px;
  min-width: 132px;
}
.cast-hierarchy-children {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 14px;
  padding-top: 22px;
  position: relative;
}
.cast-hierarchy-children::before {
  display: none;
}
.cast-hierarchy-children::after {
  content: "";
  position: absolute;
  top: 0;
  left: 66px;
  right: 66px;
  border-top: 2px solid color-mix(in srgb, var(--cast-accent, #f59e0b) 55%, transparent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--cast-accent, #f59e0b) 16%, transparent);
}
.cast-hierarchy-children-single::after {
  display: none;
}
.cast-hierarchy-child {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  position: relative;
}
.cast-hierarchy-child::before {
  content: "";
  position: absolute;
  top: -22px;
  left: 50%;
  height: 22px;
  border-left: 2px solid color-mix(in srgb, var(--cast-accent, #f59e0b) 55%, transparent);
  z-index: 0;
}
.cast-hierarchy-edge {
  display: none;
}
.cast-hierarchy-loose {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  border-top: 1px solid rgba(255,255,255,0.07);
  padding-top: 14px;
}
.cast-group {
  align-self: start;
  border: 1px solid color-mix(in srgb, var(--cast-accent, #f59e0b) 18%, transparent);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.018));
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  overflow: hidden;
}
.cast-group-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 15px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  background: color-mix(in srgb, var(--cast-accent, #f59e0b) 6%, transparent);
}
.cast-group-head h3 {
  margin: 0;
  color: #fff;
  font-size: 14px;
}
.cast-group-head p {
  margin: 5px 0 0;
  font-size: 11px;
  color: rgba(255,255,255,0.48);
  line-height: 1.45;
}
.cast-group-head > span {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 800;
  color: var(--cast-accent, #f59e0b);
  border: 1px solid color-mix(in srgb, var(--cast-accent, #f59e0b) 25%, transparent);
  border-radius: 999px;
  padding: 3px 8px;
  height: fit-content;
}
.cast-group-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
}
.cast-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid rgba(255,255,255,0.075);
  border-radius: 8px;
  background: rgba(3,5,10,0.56);
  padding: 10px;
}
.cast-avatar {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--cast-accent, #f59e0b);
  font-size: 13px;
  font-weight: 900;
  background: color-mix(in srgb, var(--cast-accent, #f59e0b) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--cast-accent, #f59e0b) 25%, transparent);
  overflow: hidden;
}
.cast-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cast-card-main {
  min-width: 0;
  flex: 1;
}
.cast-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.cast-name {
  font-size: 12.5px;
  font-weight: 800;
  color: #fff;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cast-status {
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255,255,255,0.46);
}
.cast-summary {
  font-size: 11.5px;
  line-height: 1.45;
  color: rgba(255,255,255,0.56);
}
.cast-status-deceased {
  border-color: rgba(244,63,94,0.34);
  background: rgba(244,63,94,0.055);
}
.cast-status-deceased .cast-status { color: #fb7185; }
.cast-tree-node.cast-status-deceased {
  filter: grayscale(1);
  opacity: 0.58;
  border-color: rgba(148,163,184,0.24);
  background: rgba(148,163,184,0.055);
}
.cast-tree-node.cast-status-deceased .cast-tree-avatar {
  color: #94a3b8;
  background: rgba(148,163,184,0.12);
  border-color: rgba(148,163,184,0.25);
}
.cast-tree-node.cast-status-missing .cast-tree-name { color: #c084fc; }
.cast-tree-node.cast-status-injured .cast-tree-name { color: var(--cast-accent, #f59e0b); }
.cast-board-side {
  min-height: 0;
  overflow: auto;
  border-left: 1px solid rgba(255,255,255,0.08);
  background: rgba(5,7,12,0.62);
  padding: 20px;
}
.cast-side-title {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.42);
  margin-bottom: 10px;
}
.cast-side-title-spaced {
  margin-top: 22px;
}
.cast-relation-line,
.cast-empty-note {
  font-size: 12px;
  line-height: 1.55;
  color: rgba(255,255,255,0.62);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 8px;
  padding: 9px 10px;
  background: rgba(255,255,255,0.03);
  margin-bottom: 8px;
}
.cast-relation-line strong {
  color: rgba(255,255,255,0.86);
}
.cast-relation-line span {
  display: inline-block;
  color: var(--cast-accent, #f59e0b);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 0 5px;
}
.cast-relation-line em,
.cast-relation-line small {
  display: block;
  margin-top: 5px;
  color: rgba(255,255,255,0.48);
  font-style: normal;
}
@media (max-width: 820px) {
  .cast-board-body {
    grid-template-columns: 1fr;
  }
  .cast-board-side {
    border-left: 0;
    border-top: 1px solid rgba(255,255,255,0.08);
    max-height: 34vh;
  }
  .cast-board-canvas {
    padding: 16px;
    grid-template-columns: 1fr;
  }
  .cast-board-tree-canvas {
    padding: 14px;
  }
  .cast-hierarchy-tree {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    padding: 18px 12px 20px;
  }
  .cast-hierarchy-unit {
    width: max-content;
    min-width: max-content;
    margin: 0 auto;
  }
  .cast-family-row {
    grid-template-columns: 1fr;
  }
  .cast-tree-connector {
    height: 24px;
  }
  .cast-tree-connector::before {
    left: 50%;
    right: auto;
    top: -8px;
    bottom: -8px;
    border-top: 0;
    border-left: 1px solid color-mix(in srgb, var(--cast-accent, #f59e0b) 42%, transparent);
  }
  .cast-tree-groups {
    grid-template-columns: 1fr;
  }
  .cast-hierarchy-couple,
  .cast-hierarchy-children {
    flex-direction: row;
    align-items: flex-start;
    width: max-content;
    min-width: max-content;
    margin-left: auto;
    margin-right: auto;
  }
  .cast-hierarchy-children {
    gap: 12px;
    padding-top: 18px;
  }
  .cast-hierarchy-children::after {
    display: block;
    left: 66px;
    right: 66px;
    transform: none;
    width: auto;
    min-width: 0;
    max-width: none;
  }
  .cast-hierarchy-child::before {
    top: -18px;
    height: 18px;
  }
  .cast-hierarchy-couple .cast-tree-node {
    width: 132px;
    min-width: 132px;
  }
  .cast-hierarchy-loose {
    flex-wrap: wrap;
    justify-content: center;
  }
  .cast-board-header {
    height: auto;
    padding: 12px 14px;
  }
}

/* ── Cast Board: Compact square avatar cards (mobile + desktop) ── */
.cast-tree-node-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.cast-tree-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 120px;
  padding: 14px 10px 12px;
  border: 1px solid rgba(255,255,255,0.075);
  border-radius: 10px;
  background: rgba(3,5,10,0.64);
  text-align: center;
  cursor: default;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}
.cast-tree-card:hover {
  border-color: color-mix(in srgb, var(--cast-accent, #f59e0b) 28%, transparent);
  background: rgba(9,12,20,0.82);
}
.cast-tree-card-avatar {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--cast-accent, #f59e0b);
  font-size: 16px;
  font-weight: 900;
  background: color-mix(in srgb, var(--cast-accent, #f59e0b) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--cast-accent, #f59e0b) 25%, transparent);
  overflow: hidden;
}
.cast-tree-card-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cast-tree-card-name {
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 100%;
}
.cast-tree-card-role {
  color: rgba(255,255,255,0.45);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 100%;
}
.cast-tree-card.cast-status-deceased {
  filter: grayscale(1);
  opacity: 0.5;
  border-color: rgba(148,163,184,0.24);
}
.cast-tree-card.cast-status-deceased .cast-tree-card-avatar {
  color: #94a3b8;
  background: rgba(148,163,184,0.12);
  border-color: rgba(148,163,184,0.25);
}
.cast-tree-card.cast-status-missing .cast-tree-card-name { color: #c084fc; }
.cast-tree-card.cast-status-injured .cast-tree-card-name { color: var(--cast-accent, #f59e0b); }

.cast-status-picker-overlay {
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 4000;
}
.cast-status-picker {
  width: 220px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(180deg, rgba(9,12,20,0.96), rgba(4,6,12,0.96));
  box-shadow: 0 20px 50px rgba(0,0,0,0.4);
  padding: 10px;
}
.cast-status-picker-popover {
  position: fixed;
}
.cast-status-picker-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.cast-status-picker-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
  text-align: left;
}
.cast-status-picker-btn:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.14);
  transform: translateY(-1px);
}
.cast-status-picker-btn.active {
  border-color: color-mix(in srgb, var(--cast-accent, #f59e0b) 44%, transparent);
  background: color-mix(in srgb, var(--cast-accent, #f59e0b) 16%, rgba(255,255,255,0.04));
  color: var(--cast-accent, #fbbf24);
}

/* Hierarchy tree with cards */
.cast-hierarchy-cards {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 16px 8px;
}
.cast-hierarchy-cards-couple {
  display: inline-flex;
  align-items: stretch;
  justify-content: center;
  gap: 8px;
  position: relative;
  padding-bottom: 28px;
}
/* Couple link — centered in gap between paired cards */
.cast-hierarchy-cards-couple > .cast-tree-card + .cast-tree-card::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 50%;
  width: 8px;
  height: 3px;
  background: color-mix(in srgb, var(--cast-accent, #f59e0b) 70%, transparent);
  transform: translateY(-50%);
  z-index: 3;
  pointer-events: none;
}
.cast-hierarchy-cards-children {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 10px;
  padding-top: 28px;
  position: relative;
}
/* Parent vertical — couple::after, from content bottom through padding to bar+2px */
.cast-hierarchy-cards-has-children > .cast-hierarchy-cards-couple::after {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(100% - 28px);
  width: 2px;
  height: 30px;
  background: color-mix(in srgb, var(--cast-accent, #f59e0b) 62%, transparent);
  transform: translateX(-50%);
  z-index: 3;
  pointer-events: none;
}
/* Horizontal bar */
.cast-hierarchy-cards-children::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  height: 2px;
  width: calc(100% - 100px);
  min-width: 40px;
  max-width: 500px;
  background: color-mix(in srgb, var(--cast-accent, #f59e0b) 55%, transparent);
  z-index: 1;
  pointer-events: none;
}
.cast-hierarchy-cards-children-single::before { display: none; }
.cast-hierarchy-cards-child {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  position: relative;
}
/* Child vertical — from child top to bar+2px */
.cast-hierarchy-cards-child::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 100%;
  width: 2px;
  height: 30px;
  background: color-mix(in srgb, var(--cast-accent, #f59e0b) 55%, transparent);
  transform: translateX(-50%);
  z-index: 1;
  pointer-events: none;
}
.cast-hierarchy-cards-loose {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  border-top: 1px solid rgba(255,255,255,0.07);
  padding-top: 12px;
}

/* Restore the original family-tree renderer */
@media (min-width: 641px) {
  .cast-hierarchy-tree { display: block; }
  .cast-hierarchy-cards { display: none; }
}

@media (max-width: 640px) {
  .cast-hierarchy-tree { display: block; }
  .cast-hierarchy-cards { display: none; }
}

/* Spin animation for sync badge */
@keyframes spin { to { transform: rotate(360deg); } }

/* Modern Creator Hubs */
#view-personas-hub,
#view-characters-original {
  background:
    radial-gradient(circle at 18% 0%, rgba(168, 85, 247, 0.12), transparent 34%),
    radial-gradient(circle at 88% 8%, rgba(232, 98, 26, 0.12), transparent 32%),
    #050505;
}

#view-personas-hub .personas-content,
#view-characters-original .characters-content {
  max-width: 1240px;
  padding: 28px clamp(18px, 3vw, 44px) 64px;
}

.persona-hub-hero,
.character-hub-hero {
  border-radius: 8px !important;
  min-height: 210px;
  padding: 34px clamp(22px, 4vw, 52px) 30px !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
  box-shadow: 0 20px 70px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.06) !important;
}

.persona-hub-hero {
  /* removed to allow inline overrides */
}

.character-hub-hero {
  /* removed to allow inline overrides */
}

.persona-hub-hero-title,
.character-hub-hero-title {
  font-size: clamp(28px, 4vw, 48px) !important;
  font-weight: 600 !important;
  letter-spacing: -0.5px !important;
  margin-bottom: 10px !important;
}

.char-count, .sm-char-count {
  display: none !important;
}

.persona-hub-hero-desc,
.character-hub-hero-desc {
  max-width: 620px;
  color: rgba(255,255,255,0.72) !important;
  font-size: 14px !important;
}

.persona-hub-controls,
.character-hub-controls {
  margin-top: 4px;
}

.persona-hub-controls .btn-secondary,
.character-hub-controls .btn-secondary,
#personaSelectBar .btn-secondary,
#chSelectBar .btn-secondary {
  border-radius: 8px !important;
  min-height: 36px;
  background: rgba(255,255,255,0.06) !important;
  border-color: rgba(255,255,255,0.12) !important;
}

.persona-hub-controls .btn-primary,
.character-hub-controls .btn-primary {
  border-radius: 8px !important;
  min-height: 36px;
  box-shadow: 0 12px 32px rgba(232,98,26,0.24);
}

#personaSelectBar,
#chSelectBar {
  border-radius: 8px !important;
  padding: 12px 14px !important;
  margin-bottom: 14px !important;
}

.personas-search,
.characters-search {
  margin: 0 0 18px !important;
}

.personas-search input,
.characters-search input {
  height: 46px !important;
  border-radius: 8px !important;
  background: rgba(255,255,255,0.045) !important;
  border-color: rgba(255,255,255,0.11) !important;
}

.personas-grid,
.characters-grid {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
  gap: 14px !important;
}

.persona-card {
  min-height: 172px;
  border-radius: 8px !important;
  background: linear-gradient(145deg, rgba(255,255,255,0.075), rgba(255,255,255,0.028)) !important;
  border-color: rgba(255,255,255,0.1) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

.persona-card:hover {
  border-color: rgba(236,72,153,0.36) !important;
  box-shadow: 0 18px 40px rgba(0,0,0,0.34), 0 0 0 1px rgba(236,72,153,0.1) !important;
}

.persona-card-img {
  width: 132px !important;
  height: auto !important;
  min-height: 172px;
  background: linear-gradient(145deg, rgba(236,72,153,0.12), rgba(0,0,0,0.35)) !important;
}

.persona-card-img img,
.character-card-img img {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: cover !important;
}

.persona-card-body {
  padding: 16px !important;
  justify-content: flex-end;
}

.persona-card-name {
  font-size: 18px !important;
  line-height: 1.15;
  margin-bottom: 7px !important;
}

.persona-card-desc {
  font-size: 12px !important;
  line-height: 1.5 !important;
  -webkit-line-clamp: 3 !important;
}

.character-section-block {
  border-radius: 8px !important;
  background: rgba(255,255,255,0.025);
}

.character-section-dropzone {
  padding: 14px !important;
}

.character-card {
  border-radius: 8px !important;
  background: linear-gradient(145deg, rgba(255,255,255,0.07), rgba(255,255,255,0.025)) !important;
  min-height: 138px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

.character-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 38px rgba(0,0,0,0.32) !important;
}

/* Lore card modal refinements */
#scModal {
  width: min(760px, 96vw) !important;
  border-radius: 12px !important;
  background: linear-gradient(145deg, #131313, #0a0a0a) !important;
  border-color: rgba(255,255,255,0.1) !important;
}

.story-card-calendar {
  display: inline-flex;
  width: fit-content;
  margin: 2px 0 8px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(232,98,26,0.12);
  border: 1px solid rgba(232,98,26,0.28);
  color: rgba(255,190,140,0.95);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sc-calendar-field input[type="datetime-local"] {
  width: 100%;
}

@media (max-width: 780px) {
  .persona-card {
    min-height: 132px;
  }
  .persona-card-img {
    width: 110px !important;
    min-height: 132px;
  }
  .persona-hub-hero,
  .character-hub-hero {
    min-height: 190px;
  }
}

.scenario-graph-overlay {
  position: fixed;
  inset: 0;
  z-index: 320;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 18px;
  background:
    radial-gradient(circle at top left, rgba(245, 158, 11, 0.14), transparent 30%),
    radial-gradient(circle at top right, rgba(34, 211, 238, 0.12), transparent 28%),
    rgba(4, 6, 10, 0.74);
  backdrop-filter: blur(18px);
}

.scenario-graph-shell {
  width: min(1780px, 100%);
  height: min(980px, calc(100vh - 24px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    linear-gradient(180deg, rgba(20, 24, 34, 0.98), rgba(7, 10, 18, 0.98));
  box-shadow:
    0 44px 120px rgba(0, 0, 0, 0.62),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.scenario-graph-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(34, 211, 238, 0.07) 50%, rgba(0, 0, 0, 0));
}

.scenario-graph-kicker {
  margin-bottom: 6px;
  color: rgba(255, 191, 115, 0.92);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.scenario-graph-toolbar-copy h2 {
  margin: 0;
  color: #fff;
  font-size: clamp(28px, 2.2vw, 36px);
  line-height: 1;
}

.scenario-graph-toolbar-copy p {
  margin: 8px 0 0;
  color: rgba(220, 228, 242, 0.74);
  font-size: 14px;
}

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

.scenario-graph-body {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
}

.scenario-graph-canvas-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.05) 1.1px, transparent 1.1px),
    linear-gradient(135deg, rgba(245, 158, 11, 0.09), rgba(8, 14, 22, 0.28) 34%, rgba(34, 211, 238, 0.08));
  background-size: 34px 34px, cover;
}

.scenario-graph-canvas-wrap.with-dock .scenario-graph-minimap-shell {
  right: 392px;
}

.scenario-graph-canvas-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(8, 10, 18, 0.02), rgba(8, 10, 18, 0.2)),
    radial-gradient(circle at center, transparent 55%, rgba(0, 0, 0, 0.24));
}

.scenario-graph-canvas-tools {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 2;
  display: flex;
  gap: 10px;
}

.scenario-graph-canvas-tools .btn-secondary {
  background: rgba(9, 13, 22, 0.82);
  backdrop-filter: blur(10px);
}

.scenario-graph-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: grab;
}

.scenario-graph-viewport:active {
  cursor: grabbing;
}

.scenario-graph-stage {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.scenario-graph-lines {
  position: absolute;
  inset: 0;
  overflow: visible;
}

.scenario-graph-line {
  fill: none;
  stroke: var(--edge-gradient, var(--edge-accent, rgba(102, 214, 232, 0.62)));
  stroke-width: 2.4;
  stroke-dasharray: 9 8;
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--edge-accent, #22d3ee) 24%, transparent));
  cursor: pointer;
  transition: stroke 0.18s ease, stroke-width 0.18s ease, opacity 0.18s ease;
}

.scenario-graph-line.selected {
  stroke: rgba(255, 191, 115, 0.98);
  stroke-width: 3.2;
  opacity: 1;
}

.scenario-graph-node {
  position: absolute;
  width: 196px;
  min-height: 136px;
  padding: 18px 16px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  border-radius: 24px;
  border: 1px solid color-mix(in srgb, var(--graph-accent) 48%, rgba(255,255,255,0.06));
  --node-bg-top: rgb(8, 10, 18);
  --node-bg-bottom: rgb(6, 8, 14);
  --node-grad-opacity: 18%;
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--graph-accent) var(--node-grad-opacity), transparent), transparent 75%),
    linear-gradient(180deg, var(--node-bg-top), var(--node-bg-bottom));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--graph-accent) 18%, transparent),
    0 0 20px color-mix(in srgb, var(--graph-accent) 16%, transparent),
    0 0 40px color-mix(in srgb, var(--graph-accent) 8%, transparent);
  cursor: pointer;
  color: #fff;
  text-align: center;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

.scenario-graph-node:hover,
.scenario-graph-node.selected {
  border-color: color-mix(in srgb, var(--graph-accent) 74%, white 12%);
  --node-bg-top: rgb(14, 18, 28);
  --node-bg-bottom: rgb(10, 13, 20);
  --node-grad-opacity: 28%;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--graph-accent) 30%, transparent),
    0 0 32px color-mix(in srgb, var(--graph-accent) 32%, transparent),
    0 0 64px color-mix(in srgb, var(--graph-accent) 16%, transparent);
  transform: translateY(-2px);
}

.scenario-graph-node-badge {
  align-self: flex-start;
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--graph-accent) 18%, rgba(255,255,255,0.02));
  border: 1px solid color-mix(in srgb, var(--graph-accent) 34%, rgba(255,255,255,0.12));
  color: color-mix(in srgb, var(--graph-accent) 72%, white 22%);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.scenario-graph-node-avatar {
  width: 74px;
  height: 74px;
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid color-mix(in srgb, var(--graph-accent) 48%, rgba(255,255,255,0.1));
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
    rgba(11, 14, 22, 0.98);
  color: color-mix(in srgb, var(--graph-accent) 76%, white 22%);
  font-size: 24px;
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.scenario-graph-node-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}

.scenario-graph-node-title {
  width: 100%;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.scenario-graph-inspector {
  min-width: 0;
  overflow: auto;
  padding: 20px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(13, 16, 26, 0.96), rgba(8, 10, 18, 0.98));
}

.scenario-graph-panel {
  margin-bottom: 16px;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.scenario-graph-panel h3 {
  margin: 0 0 12px;
  color: #fff;
  font-size: 15px;
}

.scenario-graph-panel label {
  display: block;
  margin: 10px 0 6px;
  color: rgba(220, 228, 242, 0.78);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.scenario-graph-selected-title {
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.15;
}

.scenario-graph-selected-meta {
  margin-top: 4px;
  color: rgba(255, 191, 115, 0.9);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.scenario-graph-inspector-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 0;
}

.scenario-graph-selected-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.scenario-graph-selected-preview {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

.scenario-graph-selected-avatar {
  width: 74px;
  height: 74px;
  flex-shrink: 0;
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(249, 115, 22, 0.3);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.015)), rgba(11, 14, 22, 0.98);
  color: #ffd2ae;
  font-size: 22px;
  font-weight: 800;
}

.scenario-graph-selected-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scenario-graph-selected-preview-copy {
  min-width: 0;
  flex: 1;
}

.scenario-graph-detail-block + .scenario-graph-detail-block {
  margin-top: 12px;
}

.scenario-graph-detail-block .settings-input {
  width: 100%;
  margin-top: 2px;
}

.scenario-graph-detail-block textarea.settings-input {
  min-height: 82px;
  resize: vertical;
  line-height: 1.45;
}

/* Priority dropdown dark theme in graph inspector */
.scenario-graph-detail-block .settings-input.sc-graph-priority {
  background: rgba(15, 13, 22, 0.92);
  border: 1px solid rgba(249, 115, 22, 0.24);
  color: #ffd8ba;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 10px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23ffb87a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.scenario-graph-detail-block .settings-input.sc-graph-priority:focus {
  border-color: rgba(249, 115, 22, 0.48);
  outline: none;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.12);
}

.scenario-graph-detail-block .settings-input.sc-graph-priority option {
  background: #0d0d13;
  color: #fff;
}

.scenario-graph-colour-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.scenario-graph-colour-swatch {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08);
  padding: 0;
  box-sizing: border-box;
}

.scenario-graph-colour-swatch:hover {
  transform: scale(1.2);
  border-color: rgba(255,255,255,0.5);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.16), 0 0 12px currentColor;
}

.scenario-graph-colour-swatch.active {
  border-color: rgba(255,255,255,0.9);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.2), 0 0 16px currentColor;
  transform: scale(1.15);
}

.scenario-graph-priority-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
  margin-bottom: 4px;
}

.scenario-graph-priority-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: rgba(220,228,242,0.68);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.14s ease;
  user-select: none;
}

.scenario-graph-priority-pill:hover {
  background: rgba(249,115,22,0.08);
  border-color: rgba(249,115,22,0.24);
  color: #ffd8ba;
  transform: translateY(-1px);
}

.scenario-graph-priority-pill.active {
  background: rgba(249,115,22,0.16);
  border-color: rgba(249,115,22,0.42);
  color: #ffd4b0;
  font-weight: 700;
}

.scenario-graph-trigger-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.scenario-graph-trigger-ai-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid rgba(249, 115, 22, 0.24);
  background: rgba(249, 115, 22, 0.08);
  color: #ffb87a;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.scenario-graph-trigger-ai-btn:hover {
  border-color: rgba(249, 115, 22, 0.48);
  background: rgba(249, 115, 22, 0.16);
  color: #ffd0ab;
}

.scenario-graph-trigger-ai-btn.loading {
  animation: sg-spin 0.9s linear infinite;
}

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

.scenario-graph-detail-copy {
  color: rgba(245, 247, 251, 0.92);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.scenario-graph-selected-accent {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
}

.scenario-graph-selected-accent span {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.04);
}

.scenario-graph-selected-accent code {
  color: rgba(239, 221, 204, 0.82);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.scenario-graph-toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 14px;
  padding: 12px 13px;
  border-radius: 16px;
  border: 1px solid rgba(249, 115, 22, 0.14);
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.scenario-graph-toggle-row:hover {
  background: rgba(249, 115, 22, 0.08);
  border-color: rgba(249, 115, 22, 0.28);
  transform: translateY(-1px);
}

.scenario-graph-toggle-row input {
  margin-top: 3px;
  accent-color: #f97316;
}

.scenario-graph-toggle-row strong {
  color: #fff;
  font-size: 13px;
}

.scenario-graph-toggle-copy {
  display: inline-block;
  margin-top: 4px;
  color: rgba(239, 221, 204, 0.64);
  font-size: 12px;
  line-height: 1.45;
  font-weight: 500;
}

.scenario-graph-empty-note {
  color: rgba(220, 228, 242, 0.64);
  font-size: 13px;
  line-height: 1.5;
  padding: 8px 0;
}

.scenario-graph-empty-note.scenario-graph-hint {
  color: rgba(220, 228, 242, 0.42);
  font-size: 11px;
  line-height: 1.5;
}

.scenario-graph-suggestion {
  padding: 12px 13px;
  border-radius: 16px;
  border: 1px solid rgba(255, 171, 94, 0.22);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.09), rgba(255, 255, 255, 0.03));
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.scenario-graph-suggestion:hover {
  border-color: rgba(255, 171, 94, 0.42);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.15), rgba(255, 255, 255, 0.05));
  transform: translateY(-1px);
}

.scenario-graph-suggestion + .scenario-graph-suggestion {
  margin-top: 10px;
}

.scenario-graph-suggestion-copy {
  color: rgba(245, 247, 251, 0.9);
  font-size: 13px;
  line-height: 1.45;
}

.scenario-graph-suggestion-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.scenario-graph-suggestion-actions .btn-accept {
  border-color: rgba(34, 197, 94, 0.28);
  background: rgba(34, 197, 94, 0.08);
  color: #86efac;
}

.scenario-graph-suggestion-actions .btn-accept:hover {
  border-color: rgba(34, 197, 94, 0.5);
  background: rgba(34, 197, 94, 0.16);
  color: #bbf7d0;
}

.scenario-graph-suggestion-actions .btn-dismiss {
  border-color: rgba(239, 68, 68, 0.18);
  background: rgba(239, 68, 68, 0.05);
  color: rgba(252, 165, 165, 0.85);
}

.scenario-graph-suggestion-actions .btn-dismiss:hover {
  border-color: rgba(239, 68, 68, 0.36);
  background: rgba(239, 68, 68, 0.1);
  color: #fecaca;
}

@media (max-width: 1180px) {
  .scenario-graph-body {
    grid-template-columns: 1fr;
  }

  .scenario-graph-inspector {
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }
}

@media (max-width: 780px) {
  .scenario-graph-overlay {
    padding: 10px;
  }

  .scenario-graph-shell {
    height: calc(100vh - 20px);
    border-radius: 22px;
  }

  .scenario-graph-toolbar {
    padding: 18px 16px;
  }

  .scenario-graph-toolbar-actions {
    justify-content: flex-start;
  }

  .scenario-graph-canvas-tools {
    top: 12px;
    left: 12px;
    flex-wrap: wrap;
  }

  .scenario-graph-inspector {
    padding: 14px;
  }
}

.scenario-graph-shell {
  background: linear-gradient(180deg, rgba(16, 10, 7, 0.985), rgba(7, 7, 7, 0.99));
}

.scenario-graph-toolbar {
  background: linear-gradient(135deg, rgba(234, 88, 12, 0.16), rgba(18, 10, 7, 0.4) 48%, rgba(0, 0, 0, 0));
}

.scenario-graph-toolbar-copy p,
.scenario-graph-empty-note,
.scenario-graph-panel label {
  color: rgba(239, 221, 204, 0.72);
}

.scenario-graph-body {
  grid-template-columns: 290px minmax(0, 1fr) 360px;
}

.scenario-graph-sidebar {
  min-width: 0;
  overflow: auto;
  padding: 20px;
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  background: linear-gradient(180deg, rgba(20, 12, 9, 0.94), rgba(9, 8, 8, 0.98));
}

.scenario-graph-palette {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scenario-graph-palette-section {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.025);
}

.scenario-graph-palette-title {
  margin-bottom: 10px;
  color: rgba(255, 186, 122, 0.95);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.scenario-graph-palette-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
  color: #fff;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.scenario-graph-palette-item + .scenario-graph-palette-item {
  margin-top: 8px;
}

.scenario-graph-palette-item:hover {
  transform: translateY(-1px);
  border-color: rgba(249, 115, 22, 0.42);
  background: linear-gradient(180deg, rgba(249, 115, 22, 0.12), rgba(255, 255, 255, 0.03));
}

.scenario-graph-palette-item .material-symbols-outlined {
  color: #fb923c;
}

.scenario-graph-palette-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
}

.scenario-graph-palette-copy strong {
  font-size: 13px;
  font-weight: 700;
}

.scenario-graph-palette-copy span {
  color: rgba(239, 221, 204, 0.58);
  font-size: 11px;
}

.scenario-graph-canvas-wrap {
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.04) 1.1px, transparent 1.1px),
    linear-gradient(135deg, rgba(120, 44, 16, 0.28), rgba(10, 10, 10, 0.82) 38%, rgba(27, 15, 10, 0.92));
}

.scenario-graph-link-banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(249, 115, 22, 0.34);
  background: rgba(17, 11, 8, 0.9);
  color: rgba(255, 226, 204, 0.95);
  font-size: 12px;
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
}

.scenario-graph-canvas-tools .btn-secondary,
.scenario-graph-toolbar-actions .btn-secondary,
.scenario-graph-panel .btn-secondary {
  border-color: rgba(249, 115, 22, 0.2);
}

.scenario-graph-toolbar-actions .btn-secondary.active {
  background: rgba(249, 115, 22, 0.18);
  border-color: rgba(249, 115, 22, 0.4);
  color: #ffd8ba;
}

.scenario-graph-link-type,
.scenario-graph-link-input {
  min-width: 142px;
}

.scenario-graph-line {
  stroke: var(--edge-gradient, var(--edge-accent, rgba(249, 115, 22, 0.55)));
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--edge-accent, #f97316) 22%, transparent));
}

.scenario-graph-line.selected {
  stroke: rgba(255, 204, 156, 0.98);
}

.scenario-graph-node {
  width: 194px;
  min-height: 132px;
  background: linear-gradient(180deg, rgb(10, 10, 12), rgb(6, 6, 8));
}

.scenario-graph-node.node-character,
.scenario-graph-node.node-lore {
  width: 150px;
  min-height: 102px;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 12px 10px 10px;
}

.scenario-graph-node.node-group,
.scenario-graph-node.node-location {
  width: 308px;
  min-height: 142px;
  align-items: flex-start;
  text-align: left;
  gap: 10px;
  padding: 18px 18px 18px 22px;
  border-left: 4px solid color-mix(in srgb, var(--graph-accent) 88%, white 12%);
  --node-bg-top: rgb(20, 20, 22);
  --node-bg-bottom: rgb(16, 16, 18);
  --node-grad-opacity: 12%;
}

.scenario-graph-node.node-group .scenario-graph-node-title,
.scenario-graph-node.node-group .scenario-graph-node-sub,
.scenario-graph-node.node-location .scenario-graph-node-title,
.scenario-graph-node.node-location .scenario-graph-node-sub {
  width: 100%;
}

.scenario-graph-node.node-group .scenario-graph-node-avatar,
.scenario-graph-node.node-location .scenario-graph-node-avatar {
  width: 60px;
  height: 60px;
  border-radius: 16px;
}

.scenario-graph-node.node-lore .scenario-graph-node-avatar {
  width: 56px;
  height: 56px;
  border-radius: 15px;
}

.scenario-graph-node.node-group .scenario-graph-node-title,
.scenario-graph-node.node-location .scenario-graph-node-title {
  font-size: 15px;
}

.scenario-graph-node.node-lore .scenario-graph-node-title {
  font-size: 11px;
  line-height: 1.04;
}

.scenario-graph-node.node-lore .scenario-graph-node-sub {
  width: 100%;
  font-size: 10px;
  line-height: 1.3;
}

.scenario-graph-node.node-character .scenario-graph-node-avatar {
  width: 56px;
  height: 56px;
  border-radius: 15px;
  border-width: 1px;
}

.scenario-graph-node.node-character .scenario-graph-node-title {
  font-size: 11px;
  line-height: 1.04;
}

.scenario-graph-node-sub {
  max-width: 100%;
  color: rgba(239, 221, 204, 0.66);
  font-size: 11px;
  line-height: 1.4;
}

.scenario-graph-node.node-group {
  --node-bg-top: rgb(22, 18, 26);
  --node-bg-bottom: rgb(15, 12, 20);
}

.scenario-graph-node.node-location {
  --node-bg-top: rgb(16, 22, 18);
  --node-bg-bottom: rgb(11, 16, 13);
}

.scenario-graph-node.node-lore {
  --node-bg-top: rgb(24, 24, 26);
  --node-bg-bottom: rgb(16, 16, 18);
}

.scenario-graph-inspector {
  background: linear-gradient(180deg, rgba(12, 10, 10, 0.97), rgba(7, 7, 8, 0.985));
}

.scenario-graph-panel {
  background: rgba(255, 255, 255, 0.022);
}

.scenario-graph-suggestion {
  border-color: rgba(249, 115, 22, 0.22);
  background: linear-gradient(180deg, rgba(234, 88, 12, 0.11), rgba(255, 255, 255, 0.03));
}

@media (max-width: 1180px) {
  .scenario-graph-body {
    grid-template-columns: 1fr;
  }

  .scenario-graph-sidebar {
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  }
}

@media (max-width: 780px) {
  .scenario-graph-selected-title-row,
  .scenario-graph-selected-preview {
    flex-direction: column;
    align-items: flex-start;
  }
}

.scenario-graph-shell {
  position: relative;
}

.scenario-graph-toolbar {
  position: relative;
  z-index: 5;
}

.scenario-graph-toolbar-actions {
  justify-content: flex-end;
}

.scenario-graph-badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  margin-left: 8px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(249, 115, 22, 0.22);
  color: #ffd7bc;
  font-size: 11px;
  font-weight: 800;
}

.scenario-graph-canvas-wrap {
  flex: 1;
}

.scenario-graph-canvas-tools {
  right: 18px;
  left: 18px;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}

.scenario-graph-minimap-shell {
  position: absolute;
  right: 20px;
  bottom: 20px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}

.scenario-graph-minimap-shell.collapsed .scenario-graph-minimap-panel {
  display: none;
}

.scenario-graph-minimap-toggle {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  border: 1px solid rgba(249, 115, 22, 0.28);
  background: rgba(8, 10, 14, 0.9);
  color: #ffd4b0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 22px 44px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(14px);
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.scenario-graph-minimap-toggle:hover {
  transform: translateY(-1px);
  border-color: rgba(249, 115, 22, 0.52);
  background: rgba(22, 13, 9, 0.96);
}

.scenario-graph-minimap-toggle .material-symbols-outlined {
  font-size: 22px;
}

.scenario-graph-minimap-panel {
  width: 246px;
  padding: 12px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(16, 10, 9, 0.96), rgba(9, 10, 12, 0.96));
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(18px);
  pointer-events: auto;
}

.scenario-graph-minimap-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: rgba(255, 229, 208, 0.88);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.scenario-graph-minimap-canvas {
  width: 100%;
  padding: 0;
  border: 1px solid rgba(249, 115, 22, 0.16);
  border-radius: 16px;
  overflow: hidden;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(8, 14, 22, 0.34) 36%, rgba(34, 211, 238, 0.1));
  background-size: 24px 24px, cover;
  cursor: pointer;
}

.scenario-graph-minimap-canvas svg {
  width: 100%;
  height: auto;
  display: block;
}

.scenario-graph-minimap-line {
  fill: none;
  stroke: rgba(255, 183, 120, 0.42);
  stroke-width: 1.35;
  stroke-dasharray: 5 4;
}

.scenario-graph-minimap-view {
  fill: rgba(34, 211, 238, 0.1);
  stroke: rgba(125, 239, 255, 0.92);
  stroke-width: 2;
}

.scenario-graph-gesture-note {
  max-width: min(420px, 80vw);
  padding: 11px 14px;
  border-radius: 999px;
  border: 1px solid rgba(249, 115, 22, 0.2);
  background: rgba(8, 10, 14, 0.82);
  color: rgba(255, 231, 214, 0.82);
  font-size: 12px;
  line-height: 1.35;
  backdrop-filter: blur(12px);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.24);
  pointer-events: auto;
}

.scenario-graph-viewport {
  touch-action: none;
}

.scenario-graph-stage {
  overflow: visible;
}

.scenario-graph-line-preview {
  stroke: var(--edge-accent, rgba(255, 214, 170, 0.92));
  stroke-dasharray: 8 5;
  stroke-width: 3;
  opacity: 0.9;
}

.scenario-graph-node {
  padding-right: 16px;
  user-select: none;
  -webkit-user-select: none;
}

.scenario-graph-node-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: crosshair;
  box-shadow: none;
  transition: transform 0.16s ease, filter 0.16s ease;
}

.scenario-graph-node-handle-top {
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
}

.scenario-graph-node-handle-bottom {
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
}

.scenario-graph-node-handle-left {
  left: -7px;
  top: 50%;
  transform: translateY(-50%);
}

.scenario-graph-node-handle-right {
  right: -7px;
  top: 50%;
  transform: translateY(-50%);
}

.scenario-graph-node-handle-top:hover,
.scenario-graph-node-handle-bottom:hover {
  transform: translateX(-50%) scale(1.22);
  filter: brightness(1.2);
}

.scenario-graph-node-handle-left:hover,
.scenario-graph-node-handle-right:hover {
  transform: translateY(-50%) scale(1.22);
  filter: brightness(1.2);
}

.scenario-graph-node-handle-dot {
  width: 1px;
  height: 1px;
  border-radius: 999px;
  background: transparent;
  box-shadow:
    0 0 0 2px rgba(8, 10, 14, 0.9),
    0 0 14px color-mix(in srgb, var(--graph-accent) 80%, transparent),
    0 0 28px color-mix(in srgb, var(--graph-accent) 50%, transparent);
  pointer-events: none;
  transition: none;
}

.scenario-graph-node-handle:hover .scenario-graph-node-handle-dot {
  width: 1px;
  height: 1px;
  box-shadow:
    0 0 0 2px rgba(8, 10, 14, 0.9),
    0 0 20px color-mix(in srgb, var(--graph-accent) 90%, transparent),
    0 0 40px color-mix(in srgb, var(--graph-accent) 60%, transparent);
}

.scenario-graph-minimap-line {
  stroke: var(--edge-accent, rgba(255, 183, 120, 0.42));
}

.scenario-graph-inspector {
  position: absolute;
  top: 20px;
  right: 20px;
  bottom: 20px;
  width: min(360px, calc(100% - 40px));
  z-index: 4;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(18px);
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.scenario-graph-inspector.docked {
  opacity: 1;
  transform: translateX(0);
}

.scenario-graph-inspector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.scenario-graph-selected-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.scenario-graph-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scenario-graph-pill {
  appearance: none;
  border: 1px solid rgba(249, 115, 22, 0.18);
  background: rgba(255, 255, 255, 0.03);
  color: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.scenario-graph-pill:hover,
.scenario-graph-pill.active {
  border-color: rgba(249, 115, 22, 0.44);
  background: rgba(249, 115, 22, 0.16);
  color: #ffd9bf;
}

.scenario-graph-link-chooser {
  position: fixed;
  width: 320px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  z-index: 8;
  padding: 16px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(16, 10, 9, 0.98), rgba(9, 10, 12, 0.98));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(18px);
}

.scenario-graph-link-chooser.mobile {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  top: auto;
  width: auto;
  max-width: none;
}

.scenario-graph-link-chooser-title {
  color: #fff;
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 12px;
}

.scenario-graph-link-chooser-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.scenario-graph-link-advanced {
  margin-top: 12px;
}

.scenario-graph-picker-backdrop {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(2, 3, 5, 0.52);
  backdrop-filter: blur(8px);
}

.scenario-graph-picker {
  width: min(720px, 100%);
  max-height: min(76vh, 760px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(17, 11, 9, 0.985), rgba(8, 9, 11, 0.99));
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.52);
}

.scenario-graph-picker-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.scenario-graph-picker-head h3 {
  margin: 4px 0 0;
  color: #fff;
  font-size: 28px;
  line-height: 1;
}

.scenario-graph-picker-search {
  flex-shrink: 0;
}

.scenario-graph-picker-list {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.scenario-graph-picker-item,
.scenario-graph-picker-create {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: #fff;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.scenario-graph-picker-item:hover,
.scenario-graph-picker-create:hover {
  transform: translateY(-1px);
  border-color: rgba(249, 115, 22, 0.34);
  background: rgba(249, 115, 22, 0.12);
}

.scenario-graph-picker-main {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.scenario-graph-picker-action-copy,
.scenario-graph-picker-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.scenario-graph-picker-action-copy {
  flex: 1;
}

.scenario-graph-picker-action-copy strong,
.scenario-graph-picker-copy strong {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
}

.scenario-graph-picker-action-copy span,
.scenario-graph-picker-copy span {
  color: rgba(239, 221, 204, 0.64);
  font-size: 12px;
  line-height: 1.4;
}

.scenario-graph-picker-avatar {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(249, 115, 22, 0.24);
  background: linear-gradient(180deg, rgba(32, 23, 18, 0.96), rgba(12, 13, 16, 0.98));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.scenario-graph-picker-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scenario-graph-picker-avatar-fallback {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #f6c388;
}

.scenario-graph-picker-item.is-character {
  padding-top: 11px;
  padding-bottom: 11px;
}

.scenario-graph-picker-item.selected {
  border-color: rgba(249, 115, 22, 0.48);
  background: rgba(249, 115, 22, 0.14);
  box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.18);
}

@media (max-width: 980px) {
  .scenario-graph-toolbar {
    padding-bottom: 16px;
  }

  .scenario-graph-toolbar-copy h2 {
    font-size: clamp(26px, 7vw, 38px);
  }

  .scenario-graph-toolbar-actions {
    justify-content: flex-start;
  }

  .scenario-graph-inspector.mobile {
    top: auto;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-height: min(72vh, 620px);
    border-radius: 24px 24px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    padding: 18px 16px 22px;
  }

  .scenario-graph-canvas-tools {
    top: 12px;
    right: 12px;
    left: 12px;
  }

  .scenario-graph-canvas-wrap.with-dock .scenario-graph-minimap-shell,
  .scenario-graph-minimap-shell {
    right: 12px;
    bottom: 12px;
  }

  .scenario-graph-gesture-note {
    max-width: calc(100vw - 48px);
    font-size: 11px;
  }
}

@media (max-width: 720px) {
  .scenario-graph-overlay {
    padding: 0;
  }

  .scenario-graph-shell {
    width: 100%;
    height: 100vh;
    border-radius: 0;
  }

  .scenario-graph-toolbar {
    padding: 16px 14px 14px;
  }

  .scenario-graph-toolbar-actions .btn-secondary,
  .scenario-graph-toolbar-actions .btn-primary {
    padding-left: 11px;
    padding-right: 11px;
  }

  .scenario-graph-node {
    width: 188px;
    min-height: 140px;
  }

  .scenario-graph-node.node-group,
  .scenario-graph-node.node-location {
    width: 274px;
  }

  .scenario-graph-node.node-lore {
    width: 150px;
  }

  .scenario-graph-node-avatar {
    width: 82px;
    height: 82px;
  }

  .scenario-graph-minimap-panel {
    width: min(220px, calc(100vw - 32px));
  }

  .scenario-graph-picker-backdrop {
    padding: 10px;
    align-items: flex-end;
  }

  .scenario-graph-picker {
    width: 100%;
    max-height: 84vh;
    border-radius: 24px 24px 18px 18px;
  }

  .scenario-graph-colour-swatch {
    width: 42px;
    height: 42px;
    border-radius: 10px;
  }

  .scenario-graph-inspector.mobile {
    padding-bottom: 28px;
  }
}
