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

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

  @keyframes slideIn {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
  }

  @keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
  }

  @keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
  }

  :root {
    --bg: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    --sidebar: linear-gradient(180deg, #171717 0%, #1f1f1f 100%);
    --input-bg: #2f2f2f;
    --border: #3f3f3f;
    --text: #ececec;
    --text-muted: #8e8ea0;
    --accent: #10a37f;
    --user-bubble: #2f2f2f;
    --ai-bubble: rgba(255, 255, 255, 0.05);
    --font: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --border-radius: 16px;
  }

  body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    display: flex;
    height: 100vh;
    overflow: hidden;
    animation: fadeIn 1s ease;
  }

  /* Sidebar */
  #sidebar {
    width: 260px;
    background: var(--sidebar);
    display: flex;
    flex-direction: column;
    padding: 12px;
    gap: 4px;
    flex-shrink: 0;
    box-shadow: var(--shadow);
    animation: slideIn 0.8s ease;
  }

  #new-chat-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--border-radius);
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    font-family: var(--font);
    transition: all 0.3s ease;
    width: 100%;
    text-align: left;
    backdrop-filter: blur(10px);
  }

  #new-chat-btn:hover { 
    background: rgba(255, 255, 255, 0.1); 
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    animation: pulse 0.6s ease;
  }

  #new-chat-btn svg { flex-shrink: 0; }

.sidebar-label {
  font-size: 12px;
  color: var(--text-muted);
  padding: 16px 12px 6px;
  font-weight: 500;
}

#history-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 4px;
  overscroll-behavior: contain;
}

#history-list::-webkit-scrollbar {
  width: 6px;
}

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

.history-item {
  padding: 8px 12px;
  border-radius: var(--border-radius);
  font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
  }

  .history-item:hover { 
    background: rgba(255, 255, 255, 0.05); 
    color: var(--text); 
    transform: translateX(5px);
  }
  .history-item.active { 
    background: rgba(16, 163, 127, 0.2); 
    color: var(--text); 
    box-shadow: 0 2px 10px rgba(16, 163, 127, 0.3);
  }

  #skill-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin-top: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    cursor: pointer;
    font-family: var(--font);
    text-align: left;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
  }

  #skill-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(16, 163, 127, 0.3);
  }

  #skill-btn svg {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
  }

  #active-skill-label {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 2px;
  }

  /* Main */
  #main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  /* Header */
  #header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.02);
  }

  #header-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    animation: fadeIn 1.2s ease;
  }

  #header-spacer {
    width: 40px;
    height: 40px;
  }

  #login-overlay {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: none;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 72px 24px 24px;
    background: rgba(0, 0, 0, 0.28);
  }

  #login-overlay.show {
    display: flex;
  }

  #login-card {
    width: min(360px, calc(100vw - 32px));
    background: rgba(32, 33, 36, 0.95);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 18px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(20px);
    animation: fadeIn 0.5s ease;
  }

  #login-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
  }

  #login-card h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.25;
  }

  #login-card p {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.45;
  }

  #close-login {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
  }

  #close-login:hover {
    background: #303134;
    color: var(--text);
  }

  #google-login-btn {
    width: 100%;
    min-height: 48px;
    border: 1px solid #dadce0;
    border-radius: 999px;
    background: #fff;
    color: #1f1f1f;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    cursor: pointer;
    font-weight: 600;
    font-family: var(--font);
  }

  #google-login-btn:hover { background: #f8fafd; }
  #google-login-btn svg { width: 20px; height: 20px; }

  #google-button-wrap {
    display: flex;
    justify-content: center;
    min-height: 44px;
  }

  #google-config-warning {
    display: none;
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(248, 113, 113, 0.35);
    border-radius: 12px;
    background: rgba(248, 113, 113, 0.10);
    color: #fca5a5;
    font-size: 12px;
    line-height: 1.45;
  }

  #signed-in-box {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #2a2a2a;
  }

  #signed-in-box.show { display: flex; }

  #signed-in-avatar {
    width: 42px; height: 42px;
    border-radius: 50%;
    object-fit: cover;
    background: #3a3a3a;
  }

  #signed-in-name, #signed-in-email { display: block; }
  #signed-in-name { font-size: 14px; font-weight: 600; }
  #signed-in-email { margin-top: 2px; color: var(--text-muted); font-size: 12px; overflow-wrap: anywhere; }

  #logout-google-btn {
    margin-left: auto;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    padding: 8px 12px;
    font-family: var(--font);
    font-size: 12px;
  }
  #logout-google-btn:hover { background: #353535; }

  #login-note {
    margin-top: 14px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.45;
    text-align: center;
  }

  .auth-note { margin-top: 8px; color: var(--text-muted); font-size: 13px; }

  #skill-overlay {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.45);
  }

  #skill-overlay.show { display: flex; }

  #skill-card {
    width: min(720px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    overflow: auto;
    background: rgba(32, 33, 36, 0.95);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(20px);
    animation: fadeIn 0.5s ease;
  }

  #skill-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
  }

  #skill-card h2, #skill-card p { margin: 0; }
  #skill-card h2 { font-size: 20px; line-height: 1.25; }
  #skill-card p { margin-top: 6px; color: var(--text-muted); font-size: 13px; line-height: 1.5; }

  #close-skill {
    width: 36px; height: 36px;
    border: 0; border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 22px;
  }
  #close-skill:hover { background: #303134; color: var(--text); }

  #skill-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .skill-option {
    min-height: 104px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    cursor: pointer;
    font-family: var(--font);
    text-align: left;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
  }

  .skill-option:hover, .skill-option.active {
    border-color: var(--accent);
    background: rgba(16, 163, 127, 0.1);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(16, 163, 127, 0.3);
  }

  .skill-option strong, .skill-option small { display: block; }
  .skill-option strong { font-size: 15px; }
  .skill-option small { margin-top: 8px; color: var(--text-muted); font-size: 12px; line-height: 1.45; }

  /* Messages */
  #messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    animation: fadeIn 1s ease;
  }

  #messages::-webkit-scrollbar { width: 6px; }
  #messages::-webkit-scrollbar-track { background: transparent; }
  #messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

  .message { animation: fadeIn 0.5s ease; }

  /* Welcome screen */
  #welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 40px;
    animation: fadeIn 1.5s ease;
  }

  #welcome h1 {
    font-size: 28px;
    font-weight: 600;
    color: var(--text);
    animation: bounce 2s ease;
  }

  .suggestion-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    max-width: 560px;
  }

  .suggestion-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    backdrop-filter: blur(10px);
  }

  .suggestion-card:hover { 
    background: rgba(255, 255, 255, 0.1); 
    border-color: var(--accent); 
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(16, 163, 127, 0.3);
  }

  .suggestion-card .title { font-size: 14px; font-weight: 500; color: var(--text); margin-bottom: 4px; }
  .suggestion-card .sub { font-size: 12px; color: var(--text-muted); }

  /* Message row */
  .msg-row {
    padding: 16px 24px;
    display: flex;
    gap: 16px;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
  }

  .msg-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
  }

  .msg-avatar.ai { background: var(--accent); color: #fff; }

  .msg-avatar.user {
    background: linear-gradient(135deg, #0f6bb7, #0b4d8a);
    border: 1px solid rgba(138, 180, 248, 0.45);
    color: #fff;
  }

  .msg-avatar.user::before, .msg-avatar.user::after { display: none; }

  .msg-avatar.user.has-image {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.18);
    padding: 0;
  }

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

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

  .msg-content {
    flex: 1;
    font-size: 15px;
    line-height: 1.7;
    color: var(--text);
    padding-top: 4px;
  }

  .msg-content.user { color: var(--text); }

  .msg-content pre {
    background: #1a1a1a;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    overflow-x: auto;
    margin: 12px 0;
    font-size: 13px;
    font-family: monospace;
  }

  .msg-content code {
    background: #1a1a1a;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: monospace;
  }

  .msg-content pre code { background: none; padding: 0; }

  /* Typing indicator */
  .typing { display: flex; gap: 4px; align-items: center; padding-top: 4px; }
  .typing span {
    width: 6px; height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: bounce 1.2s infinite;
  }
  .typing span:nth-child(2) { animation-delay: 0.2s; }
  .typing span:nth-child(3) { animation-delay: 0.4s; }

  @keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-6px); opacity: 1; }
  }

  /* Input area */
  #input-area {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    padding: 12px 24px 18px;
    flex-shrink: 0;
    background: linear-gradient(180deg, transparent 0%, rgba(31, 32, 33, 0.86) 46%, rgba(31, 32, 33, 0.96) 100%);
  }

  #input-wrap {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    max-width: 900px;
    margin: 0 auto;
    padding: 12px;
    border-radius: 18px;
    border: 1px solid rgba(16, 163, 127, 0.36);
    background: linear-gradient(180deg, rgba(52, 53, 54, 0.94), rgba(42, 43, 44, 0.96));
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.24);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
  }

  #input-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 18px 46px rgba(0, 0, 0, 0.3);
  }

  #attachment-strip {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    max-width: 800px;
    margin: 0 auto 8px;
  }
  #attachment-strip.show { display: flex; }

  .attachment-chip {
    display: flex; align-items: center; gap: 8px;
    max-width: min(260px, 100%); min-height: 38px;
    padding: 6px 8px;
    border: 1px solid var(--border); border-radius: 12px;
    background: #2a2a2a; color: var(--text); font-size: 12px;
  }
  .attachment-chip img { width: 28px; height: 28px; border-radius: 8px; object-fit: cover; }

  .attachment-icon {
    width: 28px; height: 28px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    background: #3a3a3a; color: var(--text); flex-shrink: 0;
    font-size: 13px; font-weight: 700;
  }

  .attachment-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .remove-attachment {
    width: 22px; height: 22px; border: 0; border-radius: 50%;
    background: transparent; color: var(--text-muted); cursor: pointer; flex-shrink: 0;
  }
  .remove-attachment:hover { background: #3a3a3a; color: var(--text); }

  #attach-btn {
    width: 38px; height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text); cursor: pointer; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; line-height: 1;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
  }
  #attach-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(16, 163, 127, 0.3);
  }

  #attach-menu {
    position: absolute; left: 50%; bottom: 84px; z-index: 62;
    display: none;
    width: min(300px, calc(100vw - 32px));
    padding: 10px;
    border: 1px solid var(--border); border-radius: 18px;
    background: #202124;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
    transform: translateX(-50%);
  }
  #attach-menu.show { display: block; }
  #attach-menu-title { padding: 4px 6px 10px; color: var(--text-muted); font-size: 12px; font-weight: 600; }

  .attach-option {
    display: flex; align-items: center; gap: 10px;
    width: 100%; min-height: 52px;
    border: 1px solid transparent; border-radius: 14px;
    background: transparent; color: var(--text);
    cursor: pointer; padding: 8px 10px;
    font-family: var(--font); text-align: left;
  }
  .attach-option:hover { background: #2a2a2a; border-color: #444; }
  .attach-option strong, .attach-option small { display: block; }
  .attach-option small { margin-top: 2px; color: var(--text-muted); font-size: 11px; }

  .attach-option-icon {
    width: 32px; height: 32px; border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    background: #313131; flex-shrink: 0;
  }

  #model-btn {
    display: flex; align-items: center; gap: 8px;
    min-width: 0; max-width: 190px; height: 34px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 999px;
    background: rgba(20, 20, 20, 0.62);
    color: var(--text); cursor: pointer; flex-shrink: 0;
    padding: 0 10px;
    font-family: var(--font); font-size: 13px;
  }
  #model-btn:hover { background: #343434; border-color: #555; }

  .model-logo {
    width: 22px; height: 22px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0; color: #111; font-size: 12px; font-weight: 800;
  }
  .model-logo.gemini { background: linear-gradient(135deg, #8ab4f8, #b69df8 50%, #fdd663); }
  .model-logo.openai { background: #f2f2f2; }
  .model-logo.gpt { background: #81c995; }

  #active-model-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  #response-style {
    display: inline-flex; align-items: center; gap: 2px;
    height: 34px; padding: 3px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 999px;
    background: rgba(20, 20, 20, 0.34);
    flex-shrink: 0;
  }

  .response-style-btn {
    height: 26px; border: 0; border-radius: 999px;
    background: transparent; color: var(--text-muted);
    cursor: pointer; padding: 0 11px;
    font-family: var(--font); font-size: 12px; font-weight: 600;
    transition: all 0.15s ease;
  }
  .response-style-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
  .response-style-btn.active { color: #111; background: var(--accent); }

  #model-menu {
    position: absolute; left: 50%; bottom: 84px; z-index: 60;
    display: none;
    width: min(340px, calc(100vw - 32px));
    max-height: min(520px, calc(100vh - 140px));
    padding: 10px;
    border: 1px solid var(--border); border-radius: 18px;
    background: #202124;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
    transform: translateX(-50%);
    overflow: hidden;
  }
  #model-menu.show { display: block; }
  #model-menu-title { padding: 4px 6px 10px; color: var(--text-muted); font-size: 12px; font-weight: 600; }

  #model-list {
    display: grid; gap: 6px;
    max-height: min(456px, calc(100vh - 202px));
    overflow-y: auto; padding-right: 4px;
    overscroll-behavior: contain;
  }
  #model-list::-webkit-scrollbar { width: 6px; }
  #model-list::-webkit-scrollbar-track { background: transparent; }
  #model-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

  .model-option {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    align-items: center; gap: 8px;
    width: 100%; min-height: 48px;
    border: 1px solid transparent; border-radius: 14px;
    background: transparent; color: var(--text);
    cursor: pointer; padding: 7px 9px;
    font-family: var(--font); text-align: left;
  }
  .model-option:hover, .model-option.active { background: #2a2a2a; border-color: #444; }
  .model-option strong, .model-option small { display: block; }
  .model-option small { color: var(--text-muted); font-size: 11px; margin-top: 2px; }
  .model-check { color: var(--accent); font-size: 16px; }

  #user-input {
    flex: 1; width: 100%;
    background: transparent; border: none;
    color: var(--text); font-size: 15px;
    font-family: var(--font); resize: none; outline: none;
    min-height: 34px; max-height: 150px;
    line-height: 1.5; padding: 2px 2px 0;
  }
  #user-input::placeholder { color: var(--text-muted); }

  #input-toolbar {
    display: flex; align-items: center; gap: 8px; min-width: 0;
  }

  #toolbar-spacer { flex: 1; min-width: 8px; }

  #char-counter { font-size: 11px; color: var(--text-muted); flex-shrink: 0; min-width: 22px; text-align: right; }

  #send-btn {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, var(--accent), #087a60);
    border: none; border-radius: 50%;
    cursor: pointer; display: flex;
    align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(16, 163, 127, 0.3);
  }
  #send-btn:hover {
    background: linear-gradient(135deg, #0d8f6e, var(--accent));
    transform: scale(1.1);
    box-shadow: 0 4px 20px rgba(16, 163, 127, 0.5);
  }
  #send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
  #send-btn svg { color: white; }

  #disclaimer { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 10px; }

  /* API key setup */
  #setup-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    display: none; align-items: center; justify-content: center;
    z-index: 100; pointer-events: none;
  }

  #setup-box {
    background: #2f2f2f;
    border: 1px solid var(--border); border-radius: 16px;
    padding: 32px; width: 480px;
    display: flex; flex-direction: column; gap: 16px;
    pointer-events: auto;
  }

  #setup-box h2 { font-size: 20px; font-weight: 600; }
  #setup-box p { font-size: 14px; color: var(--text-muted); line-height: 1.6; }

  #setup-box input {
    background: var(--input-bg);
    border: 1px solid var(--border); border-radius: 10px;
    color: var(--text); font-family: var(--font); font-size: 14px;
    padding: 10px 14px; width: 100%;
  }
  #setup-box input:focus { outline: none; border-color: var(--accent); }

  #setup-save {
    background: var(--accent); border: none; border-radius: 10px;
    color: white; cursor: pointer; font-family: var(--font);
    font-size: 14px; font-weight: 500; padding: 10px;
    transition: background 0.15s;
  }
  #setup-save:hover { background: #0d8f6e; }
  #setup-error { color: #f87171; font-size: 13px; display: none; }

/* Skill picker animations */
#skill-overlay {
  opacity: 0; backdrop-filter: blur(0);
  transition: opacity 0.18s ease, backdrop-filter 0.18s ease;
}
#skill-overlay.show { opacity: 1; backdrop-filter: blur(6px); }

#skill-card { transform: translateY(14px) scale(0.98); opacity: 0; }
#skill-overlay.show #skill-card { animation: skillCardIn 0.22s cubic-bezier(.2, .8, .2, 1) forwards; }

.skill-option {
  position: relative; overflow: hidden;
  transform: translateY(8px); opacity: 0;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}
#skill-overlay.show .skill-option {
  animation: skillOptionIn 0.24s ease forwards;
  animation-delay: calc(var(--skill-index, 0) * 45ms);
}
.skill-option::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(120deg, transparent, rgba(16, 163, 127, 0.14), transparent);
  transform: translateX(-120%); transition: transform 0.42s ease;
}
.skill-option:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22); }
.skill-option:hover::before, .skill-option.selecting::before { transform: translateX(120%); }
.skill-option.selecting { border-color: var(--accent); animation: skillSelectPulse 0.18s ease forwards; }

@keyframes skillCardIn { to { transform: translateY(0) scale(1); opacity: 1; } }
@keyframes skillOptionIn { to { transform: translateY(0); opacity: 1; } }
@keyframes skillSelectPulse { 50% { transform: scale(0.98); } 100% { transform: scale(1); } }

/* Login/Auth page */
.auth-page {
  min-height: 100vh; display: block; overflow: auto;
  background:
    radial-gradient(circle at 20% 15%, rgba(16, 163, 127, 0.16), transparent 30%),
    radial-gradient(circle at 80% 20%, rgba(138, 180, 248, 0.12), transparent 28%),
    var(--bg);
}
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 32px 18px; }
.auth-back { position: fixed; top: 20px; left: 20px; color: var(--text-muted); text-decoration: none; font-size: 14px; }
.auth-back:hover { color: var(--text); }
.auth-panel { width: min(460px, 100%); border: 1px solid var(--border); border-radius: 18px; background: #202124; box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42); padding: 24px; }
.auth-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 24px; }
.auth-logo { width: 44px; height: 44px; border-radius: 50%; position: relative; overflow: hidden; flex-shrink: 0; background: #101413; }
.auth-logo::before { content: ""; position: absolute; inset: -6px; background: conic-gradient(from 0deg, #19c37d, #8ab4f8, #fdd663, #19c37d); animation: avatarSpin 3.2s linear infinite; }
.auth-logo::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: #101413; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14); }
.auth-brand h1, .auth-step-title h2 { margin: 0; font-size: 22px; line-height: 1.25; }
.auth-brand p, .auth-step-title p { margin-top: 6px; color: var(--text-muted); font-size: 13px; line-height: 1.5; }
.auth-step { display: none; }
.auth-step.active { display: block; animation: authStepIn 0.18s ease forwards; }
#google-login-page { display: flex; justify-content: center; min-height: 44px; }
#google-login-warning { margin-top: 10px; color: var(--text-muted); text-align: center; font-size: 12px; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--text-muted); font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ""; height: 1px; flex: 1; background: var(--border); }
.auth-form { display: grid; gap: 14px; }
.auth-form label { display: grid; gap: 7px; color: var(--text); font-size: 13px; }
.auth-form input { min-height: 44px; border: 1px solid var(--border); border-radius: 10px; background: var(--input-bg); color: var(--text); font: inherit; padding: 0 12px; }
.auth-form input:focus { border-color: var(--accent); outline: none; }
.auth-form button { min-height: 44px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; cursor: pointer; font: inherit; font-weight: 700; }
.auth-form button:hover { background: #0d8f6e; }
.auth-form .auth-secondary { border: 1px solid var(--border); background: transparent; color: var(--text); }
.auth-form .auth-secondary:hover { background: #2a2a2a; }
.phone-input { display: grid; grid-template-columns: auto 1fr; align-items: center; border: 1px solid var(--border); border-radius: 10px; background: var(--input-bg); overflow: hidden; }
.phone-input:focus-within { border-color: var(--accent); }
.phone-input span { color: var(--text); padding: 0 12px; border-right: 1px solid var(--border); }
.phone-input input { border: 0; border-radius: 0; }
.auth-error { min-height: 18px; color: #f87171; font-size: 12px; }
@keyframes authStepIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 520px) {
  .auth-shell { align-items: stretch; padding-top: 72px; }
  .auth-back { top: 16px; left: 16px; }
  .auth-panel { padding: 18px; }
}

/* Mobile sidebar */
#sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99; }
#sidebar-overlay.show { display: block; }
#menu-btn { width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 50%; background: rgba(255,255,255,0.05); color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; flex-shrink: 0; }
#menu-btn:hover { background: rgba(255,255,255,0.1); }
#header-spacer { display: none; }
#sidebar-top { display: flex; flex-direction: column; gap: 4px; }
#sidebar-footer { margin-top: auto; padding: 8px 0 4px; display: flex; gap: 6px; flex-wrap: wrap; }
#sidebar-footer button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 8px; border: 1px solid var(--border); border-radius: var(--border-radius); background: rgba(255,255,255,0.05); color: var(--text-muted); cursor: pointer; font-family: var(--font); font-size: 12px; transition: all 0.2s; min-width: 60px; }
#sidebar-footer button:hover { background: rgba(255,255,255,0.1); color: var(--text); }
#sidebar-logout-btn:hover { border-color: #f87171; color: #f87171 !important; }

/* Scroll btn */
#scroll-btn {
  position: absolute; bottom: 110px; right: 20px;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--input-bg);
  color: var(--text); cursor: pointer; display: none;
  align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3); transition: all 0.2s; z-index: 10;
}
#scroll-btn:hover { background: rgba(255,255,255,0.1); transform: translateY(2px); }
#main { position: relative; }

/* Message actions */
.msg-actions { display: flex; align-items: center; gap: 8px; padding: 2px 0 0 50px; opacity: 0; transition: opacity 0.2s; }
.msg-row:hover .msg-actions { opacity: 1; }
.msg-time { font-size: 11px; color: var(--text-muted); }
.msg-copy-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 13px; padding: 2px 6px; border-radius: 6px; transition: all 0.15s; }
.msg-copy-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); }

/* Code block */
.code-block-wrap { border-radius: 10px; overflow: hidden; margin: 8px 0; border: 1px solid var(--border); }
.code-block-header { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; background: rgba(255,255,255,0.05); font-size: 12px; color: var(--text-muted); }
.copy-code-btn { background: none; border: 1px solid var(--border); color: var(--text-muted); cursor: pointer; font-size: 11px; padding: 2px 8px; border-radius: 6px; transition: all 0.15s; }
.copy-code-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.code-block-wrap pre { margin: 0; border-radius: 0; border: none; }

/* History item */
.history-item { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.history-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; line-height: 1.35; }
.history-delete { flex-shrink: 0; background: none; border: none; color: transparent; cursor: pointer; font-size: 15px; padding: 2px 5px; border-radius: 6px; line-height: 1; transition: all 0.15s; }
.history-item:hover .history-delete { color: var(--text-muted); }
.history-delete:hover { background: rgba(248,113,113,0.15); color: #f87171 !important; }
.history-empty, .history-overflow {
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.035);
  border: 1px dashed rgba(255,255,255,0.08);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}
.history-empty strong {
  display: block;
  margin-bottom: 3px;
  color: var(--text);
  font-size: 12px;
}
.history-empty span {
  display: block;
}
.history-overflow {
  text-align: center;
  border-style: solid;
  background: rgba(138,180,248,0.05);
}

/* Markdown */
.msg-content h2, .msg-content h3, .msg-content h4 { margin: 10px 0 4px; color: var(--text); line-height: 1.3; }
.msg-content h2 { font-size: 1.15em; }
.msg-content h3 { font-size: 1.05em; }
.msg-content h4 { font-size: 0.98em; }
.msg-content ul, .msg-content ol { padding-left: 20px; margin: 6px 0; }
.msg-content li { margin: 3px 0; line-height: 1.5; }

/* History rename & export */
.history-rename, .history-export { flex-shrink: 0; background: none; border: none; color: transparent; cursor: pointer; font-size: 13px; padding: 2px 5px; border-radius: 6px; line-height: 1; transition: all 0.15s; }
.history-item:hover .history-rename, .history-item:hover .history-export { color: var(--text-muted); }
.history-rename:hover { background: rgba(138, 180, 248, 0.15); color: #8ab4f8 !important; }
.history-export:hover { background: rgba(16, 163, 127, 0.15); color: var(--accent) !important; }

/* Light theme */
[data-theme="light"] {
  --bg: linear-gradient(135deg, #f0f0f0 0%, #e8e8e8 100%);
  --sidebar: linear-gradient(180deg, #e2e2e2 0%, #ececec 100%);
  --input-bg: #ffffff; --border: #d0d0d0; --text: #1a1a1a; --text-muted: #666;
  --accent: #10a37f; --user-bubble: #e8e8e8; --ai-bubble: rgba(0,0,0,0.04);
  --shadow: 0 4px 20px rgba(0,0,0,0.1);
}
[data-theme="light"] body { background: var(--bg); }
[data-theme="light"] .msg-content.user { background: #dceffe; }
[data-theme="light"] .msg-content.assistant { background: #f5f5f5; }
[data-theme="light"] pre { background: #e8e8e8 !important; }
[data-theme="light"] code { background: #e0e0e0; color: #1a1a1a; }
[data-theme="light"] .code-block-wrap { border-color: #ccc; }
[data-theme="light"] .code-block-header { background: #ddd; }
[data-theme="light"] #setup-box { background: #fff; }
[data-theme="light"] #skill-card, [data-theme="light"] #login-card { background: #fff; }
[data-theme="light"] .skill-option { background: #f5f5f5; border-color: #ddd; }
[data-theme="light"] .model-option { background: #f5f5f5; }
[data-theme="light"] #model-menu, [data-theme="light"] #attach-menu { background: #fff; border-color: #ddd; }
[data-theme="light"] #confirm-box { background: #fff; }
[data-theme="light"] .history-item:hover { background: rgba(0,0,0,0.05); }
[data-theme="light"] .history-item.active { background: rgba(16,163,127,0.15); }

/* Sidebar profile */
#sidebar-profile { display: flex; align-items: center; gap: 10px; padding: 8px 4px 12px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
#sidebar-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex-shrink: 0; overflow: hidden; }
#sidebar-avatar img { width: 100%; height: 100%; object-fit: cover; }
#sidebar-user-info { display: flex; flex-direction: column; overflow: hidden; }
#sidebar-user-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sidebar-user-email { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Sidebar section header */
.sidebar-section-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 4px 6px; }
.sidebar-section-header .sidebar-label { padding: 0; }
#clear-history-btn { display: flex; align-items: center; gap: 4px; background: none; border: none; color: var(--text-muted); font-size: 11px; cursor: pointer; padding: 3px 6px; border-radius: 6px; font-family: var(--font); transition: all 0.15s; }
#clear-history-btn:hover { color: #f87171; background: rgba(248,113,113,0.1); }

/* Theme toggle */
#theme-toggle-btn { display: flex; align-items: center; gap: 5px; }

/* Header actions */
#header-actions { display: flex; align-items: center; gap: 6px; position: relative; z-index: 1210; }
#export-btn { width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 50%; background: rgba(255,255,255,0.05); color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
#export-btn:hover { background: rgba(255,255,255,0.1); border-color: var(--accent); }

/* Confirm dialog */
#confirm-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 300; align-items: center; justify-content: center; }
#confirm-overlay.show { display: flex; }
#confirm-box { background: #202124; border: 1px solid var(--border); border-radius: 14px; padding: 24px; max-width: 340px; width: 90%; box-shadow: 0 20px 60px rgba(0,0,0,0.5); animation: fadeIn 0.15s ease; }
#confirm-msg { color: var(--text); font-size: 14px; line-height: 1.5; margin-bottom: 20px; }
#confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }
#confirm-cancel { padding: 8px 16px; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--text); cursor: pointer; font-family: var(--font); font-size: 13px; transition: all 0.15s; }
#confirm-cancel:hover { background: rgba(255,255,255,0.08); }
#confirm-ok { padding: 8px 16px; border: none; border-radius: 8px; background: #f87171; color: #fff; cursor: pointer; font-family: var(--font); font-size: 13px; font-weight: 600; transition: all 0.15s; }
#confirm-ok:hover { background: #ef4444; }

/* User dropdown */
#user-menu-wrap { position: relative; z-index: 1220; }
#user-btn { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--border); background: var(--accent); color: #fff; cursor: pointer; font-size: 15px; font-weight: 700; font-family: var(--font); display: flex; align-items: center; justify-content: center; overflow: hidden; transition: all 0.2s; padding: 0; }
#user-btn:hover { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(16,163,127,0.25); }
#user-btn-initial { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; border-radius: 50%; overflow: hidden; }
#user-dropdown { display: none; position: fixed; top: 82px; right: 18px; min-width: 240px; max-width: min(320px, calc(100vw - 24px)); background: #202124; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 18px 44px rgba(0,0,0,0.46); z-index: 1300; overflow: hidden; animation: dropdownIn 0.15s cubic-bezier(.2,.8,.2,1); }
#user-dropdown.show { display: block; }
@keyframes dropdownIn { from { opacity: 0; transform: translateY(-6px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
#user-dropdown-email { padding: 12px 16px; font-size: 13px; color: var(--text-muted); font-weight: 500; word-break: break-all; }
.user-dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }
.user-dropdown-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: none; border: none; color: var(--text); font-family: var(--font); font-size: 14px; cursor: pointer; text-align: left; transition: background 0.15s; }
.user-dropdown-item:hover { background: rgba(255,255,255,0.07); }
.user-dropdown-item svg { flex-shrink: 0; color: var(--text-muted); }
.user-dropdown-item.danger { color: #f87171; }
.user-dropdown-item.danger svg { color: #f87171; }
.user-dropdown-item.danger:hover { background: rgba(248,113,113,0.1); }
[data-theme="light"] #user-dropdown { background: #fff; box-shadow: 0 8px 32px rgba(0,0,0,0.15); }
[data-theme="light"] .user-dropdown-item:hover { background: rgba(0,0,0,0.05); }

/* Visual refresh */
:root {
  --surface-1: rgba(29, 30, 31, 0.82);
  --surface-2: rgba(42, 43, 44, 0.78);
  --line-soft: rgba(255, 255, 255, 0.08);
  --accent-blue: #8ab4f8;
  --accent-gold: #fdd663;
  --accent-rose: #f87171;
}

body {
  background:
    linear-gradient(120deg, rgba(138, 180, 248, 0.08), transparent 32%),
    linear-gradient(240deg, rgba(253, 214, 99, 0.06), transparent 36%),
    linear-gradient(180deg, #18191a 0%, #222323 100%);
}

body::before {
  content: ""; position: fixed; 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.02) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.65), transparent 82%);
}

#main { background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0.01)), transparent; position: relative; }

#sidebar {
  width: 292px; margin: 6px 0 6px 6px;
  border: 1px solid var(--line-soft); border-radius: 14px;
  background: linear-gradient(180deg, rgba(24,25,26,0.94), rgba(18,19,20,0.96));
  box-shadow: 14px 0 44px rgba(0,0,0,0.22);
}

#sidebar-avatar, #user-btn.logged-in { box-shadow: 0 0 0 3px rgba(138,180,248,0.12); }

#new-chat-btn, #skill-btn { min-height: 46px; border-radius: 14px; background: rgba(255,255,255,0.065); }
#new-chat-btn { border: 1px solid transparent; }
#skill-btn { border-color: rgba(138,180,248,0.22); }
#new-chat-btn:hover, #skill-btn:hover { transform: translateY(-1px); border-color: rgba(138,180,248,0.36); box-shadow: 0 10px 24px rgba(0,0,0,0.18); }

.sidebar-section-header { padding-top: 22px; }
.sidebar-label { color: #b8c7ee; font-weight: 700; }
.history-item { border-radius: 12px; }
.history-item:hover { background: rgba(138,180,248,0.08); transform: none; }
.history-item.active { background: linear-gradient(90deg, rgba(16,163,127,0.18), rgba(138,180,248,0.08)); box-shadow: inset 3px 0 0 var(--accent); }
#sidebar-footer button { border-radius: 999px; background: rgba(255,255,255,0.06); }

#header { min-height: 78px; background: rgba(31,32,33,0.62); border-bottom-color: var(--line-soft); z-index: 1200; overflow: visible; }
#header-title { font-weight: 800; }
#menu-btn, #export-btn, #user-btn { background: rgba(255,255,255,0.07); box-shadow: inset 0 1px 0 rgba(255,255,255,0.06); }

#messages { padding-bottom: 220px; position: relative; z-index: 1; }

#welcome { justify-content: center; gap: 28px; padding-bottom: 200px; position: relative; z-index: 1; }
#welcome h1 { font-size: 36px; line-height: 1.12; font-weight: 850; text-align: center; animation: none; }
#welcome h1::after { content: ""; display: block; width: 88px; height: 3px; margin: 18px auto 0; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-blue), var(--accent-gold)); }

.suggestion-grid { max-width: 680px; gap: 12px; }
.suggestion-card { position: relative; min-height: 84px; border-radius: 14px; border-color: rgba(255,255,255,0.09); background: linear-gradient(135deg, rgba(255,255,255,0.075), rgba(255,255,255,0.035)); box-shadow: inset 0 1px 0 rgba(255,255,255,0.06); }
.suggestion-card::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 999px 999px 0; background: var(--accent-blue); }
.suggestion-card:nth-child(2)::before { background: var(--accent-gold); }
.suggestion-card:nth-child(3)::before { background: var(--accent); }
.suggestion-card:nth-child(4)::before { background: var(--accent-rose); }
.suggestion-card:nth-child(5)::before { background: #b69df8; }
.suggestion-card:nth-child(6)::before { background: #7dd3fc; }
.suggestion-card:hover { transform: translateY(-2px); border-color: rgba(138,180,248,0.38); background: linear-gradient(135deg, rgba(138,180,248,0.12), rgba(255,255,255,0.055)); box-shadow: 0 16px 34px rgba(0,0,0,0.24); }
.suggestion-card .title { font-size: 15px; font-weight: 760; }
.suggestion-card .sub { margin-top: 6px; font-size: 13px; line-height: 1.35; }

.quick-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 720px; }
.quick-actions button { min-height: 34px; border: 1px solid rgba(255,255,255,0.1); border-radius: 999px; background: rgba(255,255,255,0.055); color: var(--text-muted); cursor: pointer; padding: 0 13px; font-family: var(--font); font-size: 13px; font-weight: 650; transition: all 0.16s ease; }
.quick-actions button:hover { color: var(--text); border-color: rgba(138,180,248,0.35); background: rgba(138,180,248,0.1); transform: translateY(-1px); }

.msg-row { max-width: 860px; }
.msg-content { font-size: 16px; }

#model-btn, #response-style, #attach-btn { border-color: rgba(255,255,255,0.09); }
#send-btn { background: linear-gradient(135deg, var(--accent), #087a60); }
#disclaimer { margin-top: 10px; }

[data-theme="light"] body { background: linear-gradient(120deg, rgba(19,115,181,0.08), transparent 32%), linear-gradient(240deg, rgba(211,148,11,0.08), transparent 36%), linear-gradient(180deg, #f5f7fb 0%, #edf0f6 100%); }
[data-theme="light"] #sidebar { background: rgba(255,255,255,0.9); }
[data-theme="light"] #header { background: rgba(255,255,255,0.68); }
[data-theme="light"] .suggestion-card { background: rgba(255,255,255,0.78); }
[data-theme="light"] #input-area { background: linear-gradient(180deg, transparent 0%, rgba(245,247,251,0.86) 46%, rgba(245,247,251,0.96) 100%); }
[data-theme="light"] #input-wrap { background: rgba(255,255,255,0.94); }

/* AI mode */
#ai-mode-btn { height: 34px; border: 1px solid rgba(255,255,255,0.09); border-radius: 999px; background: rgba(20,20,20,0.4); color: var(--text); cursor: pointer; flex-shrink: 0; padding: 0 14px; font-family: var(--font); font-size: 12px; font-weight: 750; transition: all 0.16s ease; }
#ai-mode-btn:hover { border-color: rgba(138,180,248,0.35); background: rgba(138,180,248,0.11); }
#ai-mode-menu { position: absolute; left: 50%; bottom: 126px; z-index: 63; display: none; width: min(330px, calc(100vw - 32px)); padding: 10px; border: 1px solid var(--border); border-radius: 18px; background: #202124; box-shadow: 0 24px 80px rgba(0,0,0,0.45); transform: translateX(-50%); }
#ai-mode-menu.show { display: grid; gap: 8px; }
#ai-mode-title { padding: 4px 6px 2px; color: var(--text-muted); font-size: 12px; font-weight: 700; }
.ai-mode-option { display: grid; gap: 3px; width: 100%; min-height: 64px; border: 1px solid transparent; border-radius: 14px; background: transparent; color: var(--text); cursor: pointer; padding: 10px 12px; font-family: var(--font); text-align: left; }
.ai-mode-option small { color: var(--text-muted); line-height: 1.35; }
.ai-mode-option:hover, .ai-mode-option.active { border-color: rgba(138,180,248,0.34); background: rgba(138,180,248,0.09); }
[data-theme="light"] #ai-mode-menu { background: #fff; border-color: #ddd; }

/* Token counter */
.token-info { font-size: 11px; color: var(--text-muted); background: rgba(255,255,255,0.05); padding: 2px 8px; border-radius: 10px; border: 1px solid var(--border); cursor: default; transition: all 0.15s; }
.token-info:hover { background: rgba(255,255,255,0.1); color: var(--text); }
[data-theme="light"] .token-info { background: rgba(0,0,0,0.04); }

/* Pin chat */
.history-group-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); padding: 10px 4px 4px; }
.history-pin { flex-shrink: 0; background: none; border: none; color: transparent; cursor: pointer; font-size: 13px; padding: 2px 4px; border-radius: 6px; line-height: 1; transition: all 0.15s; opacity: 0; }
.history-item:hover .history-pin { opacity: 1; color: var(--text-muted); }
.history-pin.active { opacity: 1 !important; color: var(--accent) !important; }
.history-pin:hover { background: rgba(16,163,127,0.15); color: var(--accent) !important; }
.history-item.pinned { border-left: 2px solid var(--accent); padding-left: 8px; }

/* ========== MOBILE LAYOUT FIX ========== */
@media (max-width: 700px) {
  body {
    height: 100dvh;
    min-height: 100dvh;
  }

  #sidebar {
    position: fixed; left: 0; top: 0; height: 100%;
    z-index: 100; width: min(86vw, 310px);
    margin: 0; border-radius: 0 16px 16px 0;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(.2,.8,.2,1);
  }
  #sidebar.open { transform: translateX(0); }
  #main { width: 100%; }

  #header { min-height: 72px; padding: 10px 14px; z-index: 1200; overflow: visible; }
  #header-actions, #user-menu-wrap, #user-dropdown { z-index: 1300; }
  #user-dropdown { top: 74px; right: 10px; min-width: 220px; max-width: calc(100vw - 20px); }

  #messages { padding: 10px 0 8px; padding-bottom: 154px; }

  .msg-row { max-width: none; padding: 12px 14px; gap: 10px; }
  .msg-avatar { width: 30px; height: 30px; }
  .msg-content { min-width: 0; font-size: 15px; line-height: 1.62; overflow-wrap: break-word; word-break: normal; }
  .msg-actions { padding-left: 40px; opacity: 1; }

  #welcome {
    align-items: stretch;
    justify-content: flex-start;
    gap: 16px;
    padding: 20px 14px calc(154px + env(safe-area-inset-bottom));
  }

  #welcome h1 { text-align: left; font-size: 28px; }
  #welcome h1::after { margin-left: 0; }

  .suggestion-grid { grid-template-columns: 1fr 1fr; max-width: none; gap: 10px; }
  .suggestion-card { min-height: 88px; padding: 12px; }
  .suggestion-card .title { font-size: 14px; line-height: 1.2; }
  .suggestion-card .sub { margin-top: 5px; font-size: 12px; line-height: 1.25; }
  .quick-actions { justify-content: flex-start; gap: 6px; }
  .quick-actions button { min-height: 32px; font-size: 12px; padding: 0 11px; }

  #input-area {
    padding: 6px 10px calc(10px + env(safe-area-inset-bottom));
  }

  #input-wrap {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
    border-radius: 18px;
    max-width: none;
  }

  #user-input { width: 100%; min-height: 22px; max-height: 88px; font-size: 15px; }
  #char-counter { display: none; }

  #input-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 70px 38px 38px;
    grid-template-areas:
      "model mode attach send"
      "style style style style";
    gap: 6px;
  }

  #model-btn { grid-area: model; width: 100%; max-width: none; min-width: 0; height: 38px; }
  #ai-mode-btn { grid-area: mode; width: 100%; min-width: 0; height: 38px; padding: 0 8px; font-size: 11px; }
  #response-style { grid-area: style; width: 100%; justify-content: space-between; min-height: 36px; }
  .response-style-btn { flex: 1; min-height: 36px; padding: 0 4px; font-size: 11px; }
  #toolbar-spacer { display: none; }
  #attach-btn { grid-area: attach; justify-self: end; width: 38px; height: 38px; }
  #send-btn { grid-area: send; justify-self: end; width: 38px; height: 38px; }

  #scroll-btn { right: 14px; bottom: calc(128px + env(safe-area-inset-bottom)); width: 42px; height: 42px; z-index: 25; }
  #model-menu, #attach-menu, #ai-mode-menu { bottom: calc(118px + env(safe-area-inset-bottom)); }

  #ai-mode-menu { width: min(300px, calc(100vw - 24px)); }
  #disclaimer { margin-top: 6px; font-size: 11px; }
}

@media (max-width: 420px) {
  #response-style { overflow: hidden; }
  .response-style-btn { font-size: 11px; }
}

@media (max-width: 360px) {
  #welcome { padding-left: 18px; padding-right: 18px; }
  .suggestion-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  #login-overlay { align-items: flex-end; justify-content: center; padding: 16px; }
  #skill-grid { grid-template-columns: 1fr; }
}
