/* ===== Apple 2027 HIG — Liquid Glass ===== */
/* Liquid glass aesthetic: deep translucency, vibrant gradients,
   multi-layer backdrop-blur, glowing accents, seamless transitions. */

:root { color-scheme: light dark; }

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", sans-serif;
    background: light-dark(#f0f0f3, #0a0a0d);
    color: light-dark(#1a1a1e, #f0f0f5);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 14px;
    line-height: 1.47059;
}

a { color: light-dark(#0066d9, #5a9fff); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
input, textarea { font-family: inherit; }

/* ---- Layout ---- */

.app-container {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-width: 100%;
    background:
        radial-gradient(ellipse 80% 60% at 50% -10%, light-dark(rgba(0,102,217,0.06), rgba(90,159,255,0.08)) 0%, transparent 100%),
        radial-gradient(ellipse 60% 50% at 20% 90%, light-dark(rgba(255,45,85,0.04), rgba(255,45,85,0.06)) 0%, transparent 100%),
        light-dark(#f0f0f3, #0a0a0d);
}

.page {
    flex: 1;
    padding: 32px 24px;
    overflow-y: auto;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    color: light-dark(#1a1a1e, #f0f0f5);
    letter-spacing: -0.022em;
    line-height: 1.14286;
    margin: 0 0 4px;
}

.page-subtitle {
    font-size: 14px;
    color: light-dark(#6e6e73, #98989d);
    margin: 0 0 24px;
    font-weight: 400;
}

/* ---- Navbar (Liquid Glass Toolbar) ---- */

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    height: 48px;
    background: light-dark(
        linear-gradient(135deg, rgba(255,255,255,0.75), rgba(255,255,255,0.55)),
        linear-gradient(135deg, rgba(44,44,46,0.75), rgba(44,44,46,0.55))
    );
    backdrop-filter: saturate(160%) blur(30px);
    border-bottom: 1px solid light-dark(rgba(255,255,255,0.5), rgba(255,255,255,0.06));
    box-shadow: 0 1px 0 light-dark(rgba(0,0,0,0.03), rgba(255,255,255,0.04) inset);
    position: relative;
    z-index: 50;
    flex-shrink: 0;
}

.navbar::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: light-dark(rgba(0,0,0,0.04), rgba(255,255,255,0.04));
}

.navbar-brand {
    color: light-dark(#1a1a1e, #f0f0f5);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar-user {
    font-size: 12px;
    color: light-dark(#6e6e73, #98989d);
    font-weight: 400;
}

.navbar-dropdown-btn {
    padding: 5px 14px;
    background: linear-gradient(135deg, #0066d9, #0055b3);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    line-height: 1.33337;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(0,102,217,0.25);
}

.navbar-dropdown-btn:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 14px rgba(0,102,217,0.35);
}

/* ---- Dropdown (Liquid Glass Menu) ---- */

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: light-dark(
        linear-gradient(135deg, rgba(255,255,255,0.92), rgba(255,255,255,0.85)),
        linear-gradient(135deg, rgba(44,44,46,0.92), rgba(44,44,46,0.85))
    );
    backdrop-filter: saturate(160%) blur(40px);
    border-radius: 14px;
    border: 1px solid light-dark(rgba(255,255,255,0.6), rgba(255,255,255,0.08));
    box-shadow:
        0 8px 40px light-dark(rgba(0,0,0,0.1), rgba(0,0,0,0.5)),
        0 1px 0 light-dark(rgba(0,0,0,0.03), rgba(255,255,255,0.04) inset);
    z-index: 200;
    min-width: 160px;
    overflow: hidden;
    padding: 4px;
}

.dropdown-item {
    display: block;
    padding: 8px 14px;
    color: light-dark(#1a1a1e, #f0f0f5);
    font-size: 13px;
    text-decoration: none;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s, transform 0.15s;
}

.dropdown-item:hover {
    background: light-dark(rgba(0,102,217,0.08), rgba(90,159,255,0.12));
    transform: translateX(2px);
}

.dropdown-item-danger {
    color: #ff3b30;
}

.dropdown-item-danger:hover {
    background: light-dark(rgba(255,59,48,0.08), rgba(255,59,48,0.15));
}

.dropdown-divider {
    border-top: 1px solid light-dark(rgba(0,0,0,0.06), rgba(255,255,255,0.08));
    margin: 4px 0;
}

/* ---- Cards (Liquid Glass) ---- */

.card {
    background: light-dark(
        linear-gradient(135deg, rgba(255,255,255,0.85), rgba(255,255,255,0.7)),
        linear-gradient(135deg, rgba(44,44,46,0.85), rgba(44,44,46,0.7))
    );
    backdrop-filter: saturate(160%) blur(24px);
    border-radius: 14px;
    border: 1px solid light-dark(rgba(255,255,255,0.5), rgba(255,255,255,0.06));
    box-shadow: 0 4px 24px light-dark(rgba(0,0,0,0.04), rgba(0,0,0,0.25));
    padding: 24px;
    margin-bottom: 20px;
    transition: box-shadow 0.3s, transform 0.3s;
}

.card:hover {
    box-shadow: 0 8px 32px light-dark(rgba(0,0,0,0.06), rgba(0,0,0,0.35));
}

.card-title {
    font-size: 17px;
    font-weight: 600;
    color: light-dark(#1a1a1e, #f0f0f5);
    margin: 0 0 16px;
    letter-spacing: -0.01em;
}

/* ---- Forms ---- */

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid light-dark(rgba(0,0,0,0.08), rgba(255,255,255,0.1));
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    background: light-dark(
        linear-gradient(135deg, rgba(255,255,255,0.9), rgba(255,255,255,0.75)),
        linear-gradient(135deg, rgba(58,58,60,0.9), rgba(58,58,60,0.75))
    );
    backdrop-filter: blur(8px);
    color: light-dark(#1a1a1e, #f0f0f5);
    transition: border-color 0.2s, box-shadow 0.2s;
}

/* <select> elements rendered as `.form-input` need explicit theming because
   the OS-native dropdown otherwise paints options against the platform's
   default chrome (typically a near-white background on Windows/Linux, dark on
   recent macOS), which clashes with the page in either color scheme. We
   strip the native appearance, paint a chevron, and force both the closed
   control and the drop-down options onto the same theme tokens. */
select.form-input,
.form-input[type="select"],
.form-input[multiple] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 32px;
    background-image:
        linear-gradient(45deg, transparent 50%, currentColor 50%),
        linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position:
        calc(100% - 18px) 50%,
        calc(100% - 13px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}
select.form-input:focus,
.form-input[type="select"]:focus,
.form-input[multiple]:focus {
    background-image:
        linear-gradient(45deg, transparent 50%, #5a9fff 50%),
        linear-gradient(135deg, #5a9fff 50%, transparent 50%);
}

.form-input option,
.form-input optgroup {
    background: light-dark(#ffffff, #2c2c2e);
    color: light-dark(#1a1a1e, #f0f0f5);
}
.form-input option:checked,
.form-input option:hover {
    background: light-dark(rgba(0,122,255,0.18), rgba(10,132,255,0.32));
    color: light-dark(#1a1a1e, #f0f0f5);
}
.form-input:disabled,
.form-input option:disabled {
    color: light-dark(#a1a1a6, #6e6e72);
    cursor: not-allowed;
}

.form-input:focus {
    border-color: light-dark(#0066d9, #5a9fff);
    box-shadow:
        0 0 0 3px light-dark(rgba(0,102,217,0.12), rgba(90,159,255,0.15)),
        0 0 20px light-dark(rgba(0,102,217,0.06), rgba(90,159,255,0.08));
}

.form-input-file {
    width: 100%;
    padding: 8px 0;
    font-size: 13px;
    color: light-dark(#1a1a1e, #f0f0f5);
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: light-dark(#6e6e73, #98989d);
    margin-bottom: 6px;
}

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

.form-help {
    font-size: 12px;
    color: light-dark(#6e6e73, #98989d);
    margin-top: 4px;
}

/* ---- Buttons (Liquid Glass) ---- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 18px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    line-height: 1.33337;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s, background 0.2s;
    min-height: 32px;
}

.btn:disabled { opacity: 0.5; cursor: default; transform: none !important; }
.btn-primary {
    background: linear-gradient(135deg, #0066d9, #0055b3);
    color: white;
    box-shadow: 0 2px 8px rgba(0,102,217,0.25);
}
.btn-primary:hover:not(:disabled) {
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(0,102,217,0.35);
}
.btn-danger {
    background: linear-gradient(135deg, #ff3b30, #d62d20);
    color: white;
    box-shadow: 0 2px 8px rgba(255,59,48,0.25);
}
.btn-danger:hover:not(:disabled) {
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(255,59,48,0.35);
}
.btn-secondary {
    background: light-dark(
        linear-gradient(135deg, rgba(255,255,255,0.85), rgba(255,255,255,0.65)),
        linear-gradient(135deg, rgba(58,58,60,0.85), rgba(58,58,60,0.65))
    );
    color: light-dark(#1a1a1e, #f0f0f5);
    border: 1px solid light-dark(rgba(0,0,0,0.08), rgba(255,255,255,0.1));
    box-shadow: 0 1px 0 light-dark(rgba(0,0,0,0.02), rgba(255,255,255,0.04) inset);
}
.btn-secondary:hover:not(:disabled) {
    background: light-dark(
        linear-gradient(135deg, rgba(0,102,217,0.10), rgba(0,102,217,0.06)),
        linear-gradient(135deg, rgba(90,159,255,0.14), rgba(90,159,255,0.08))
    );
    color: light-dark(#0066d9, #5a9fff);
    border-color: light-dark(rgba(0,102,217,0.25), rgba(90,159,255,0.3));
}
.btn-sm { padding: 4px 12px; font-size: 12px; min-height: 26px; }

/* ---- Messages ---- */

.msg-success { font-size: 13px; color: #34c759; margin: 10px 0 0; }
.msg-error { font-size: 13px; color: #ff3b30; margin: 10px 0 0; }
.msg-info { font-size: 13px; color: light-dark(#6e6e73, #98989d); margin: 10px 0 0; }

/* ---- Table ---- */

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 500;
    color: light-dark(#6e6e73, #98989d);
    font-size: 11px;
    letter-spacing: 0.03em;
    border-bottom: 1px solid light-dark(rgba(0,0,0,0.06), rgba(255,255,255,0.08));
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid light-dark(rgba(0,0,0,0.04), rgba(255,255,255,0.06));
    color: light-dark(#1a1a1e, #f0f0f5);
    line-height: 1.4;
}

.table tr:last-child td { border-bottom: none; }

.badge {
    font-weight: 500;
    font-size: 12px;
}

.badge-success { color: #34c759; }
.badge-warning { color: #ff9f0a; }

/* ---- Conversation Sidebar (Liquid Glass) ---- */

.chat-layout {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.conv-sidebar {
    width: 260px;
    min-width: 260px;
    border-right: 1px solid light-dark(rgba(0,0,0,0.04), rgba(255,255,255,0.06));
    display: flex;
    flex-direction: column;
    background: light-dark(
        linear-gradient(180deg, rgba(245,245,247,0.6), rgba(245,245,247,0.3)),
        linear-gradient(180deg, rgba(28,28,30,0.6), rgba(28,28,30,0.3))
    );
    backdrop-filter: blur(20px);
}

.conv-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid light-dark(rgba(0,0,0,0.04), rgba(255,255,255,0.06));
}

.conv-heading {
    font-size: 13px;
    font-weight: 600;
    color: light-dark(#1a1a1e, #f0f0f5);
}

.conv-list {
    flex: 1;
    min-width: 0;
    overflow: hidden auto;
    padding: 4px;
}

.conv-item-group {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-bottom: 1px;
    position: relative;
}

.conv-item {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
    display: flex;
    align-items: center;
    gap: 2px;
}

.conv-item:hover {
    background: light-dark(rgba(0,102,217,0.05), rgba(90,159,255,0.07));
    transform: translateX(2px);
}

.conv-item-active {
    background: light-dark(
        linear-gradient(135deg, rgba(0,102,217,0.08), rgba(0,102,217,0.04)),
        linear-gradient(135deg, rgba(90,159,255,0.15), rgba(90,159,255,0.08))
    );
}

.conv-item-title {
    flex: 1;
    font-size: 12px;
    color: light-dark(#1a1a1e, #f0f0f5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-more-btn {
    background: none;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    font-size: 14px;
    color: light-dark(rgba(0,0,0,0.3), rgba(255,255,255,0.3));
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
    letter-spacing: 0;
    line-height: 1;
}

.conv-item:hover .conv-more-btn {
    opacity: 1;
}

.conv-more-btn:hover {
    opacity: 1 !important;
    color: light-dark(#1a1a1e, #f0f0f5);
    background: light-dark(rgba(0,0,0,0.06), rgba(255,255,255,0.08));
}

/* ---- Context Menu ---- */

.conv-ctxmenu {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 2px;
    z-index: 300;
    background: light-dark(
        linear-gradient(135deg, rgba(255,255,255,0.95), rgba(255,255,255,0.9)),
        linear-gradient(135deg, rgba(44,44,46,0.95), rgba(44,44,46,0.9))
    );
    backdrop-filter: saturate(160%) blur(40px);
    border-radius: 10px;
    border: 1px solid light-dark(rgba(255,255,255,0.6), rgba(255,255,255,0.08));
    box-shadow: 0 8px 30px light-dark(rgba(0,0,0,0.1), rgba(0,0,0,0.4));
    padding: 4px;
    min-width: 130px;
}

.ctxmenu-item {
    display: block;
    padding: 7px 12px;
    font-size: 12px;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    color: light-dark(#1a1a1e, #f0f0f5);
    transition: background 0.1s;
}

.ctxmenu-item:hover {
    background: light-dark(rgba(0,102,217,0.08), rgba(90,159,255,0.12));
}

.ctxmenu-danger {
    color: #ff3b30;
}

.ctxmenu-danger:hover {
    background: light-dark(rgba(255,59,48,0.08), rgba(255,59,48,0.15));
}



.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background:
        radial-gradient(ellipse 70% 50% at 30% 20%, light-dark(rgba(0,102,217,0.03), rgba(90,159,255,0.04)) 0%, transparent 100%),
        radial-gradient(ellipse 50% 50% at 80% 80%, light-dark(rgba(255,45,85,0.02), rgba(255,45,85,0.03)) 0%, transparent 100%);
}

/* ---- Rename input ---- */

.conv-edit-input {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid light-dark(rgba(0,102,217,0.4), rgba(90,159,255,0.4));
    border-radius: 4px;
    font-size: 12px;
    outline: none;
    background: light-dark(rgba(255,255,255,0.9), rgba(58,58,60,0.9));
    color: light-dark(#1a1a1e, #f0f0f5);
}

/* ---- Streaming indicator ---- */

.conv-streaming-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: light-dark(#0066d9, #5a9fff);
    animation: pulse-dot 1s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.75); }
}

/* ---- Typing Indicator ---- */

.typing-indicator {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 2px 0;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: light-dark(#3d3d42, #a3a3ab);
    animation: typing-bounce 1.2s ease-in-out infinite;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

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

/* ---- Chat (Liquid Glass Bubbles) ---- */

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

.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 72%;
}

.chat-msg-user { align-self: flex-end; align-items: flex-end; }
.chat-msg-bot { align-self: flex-start; align-items: flex-start; max-width: 82%; }

.chat-msg-name {
    font-size: 11px;
    color: light-dark(#6e6e73, #98989d);
    margin-bottom: 3px;
    font-weight: 500;
    padding: 0 4px;
}

.chat-msg-bubble {
    padding: 12px 18px;
    border-radius: 18px;
    line-height: 1.5;
    font-size: 15px;
    overflow-wrap: break-word;
    transition: box-shadow 0.3s;
}

.chat-msg-user .chat-msg-bubble {
    background: linear-gradient(135deg, #0066d9, #0055b3);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow:
        0 2px 12px rgba(0,102,217,0.25),
        0 1px 0 rgba(255,255,255,0.1) inset;
}

.chat-msg-bot .chat-msg-bubble {
    background: light-dark(
        linear-gradient(135deg, rgba(255,255,255,0.9), rgba(255,255,255,0.75)),
        linear-gradient(135deg, rgba(44,44,46,0.9), rgba(44,44,46,0.75))
    );
    backdrop-filter: blur(16px);
    color: light-dark(#1a1a1e, #f0f0f5);
    border-bottom-left-radius: 4px;
    border: 1px solid light-dark(rgba(255,255,255,0.5), rgba(255,255,255,0.06));
    box-shadow:
        0 2px 12px light-dark(rgba(0,0,0,0.04), rgba(0,0,0,0.2)),
        0 1px 0 light-dark(rgba(0,0,0,0.02), rgba(255,255,255,0.04) inset);
}

.chat-msg-bubble p { margin: 0 0 8px; }
.chat-msg-bubble p:last-child { margin-bottom: 0; }
.chat-msg-bubble ul, .chat-msg-bubble ol { margin: 4px 0; padding-left: 20px; }
.chat-msg-bubble code {
    background: light-dark(rgba(0,0,0,0.06), rgba(255,255,255,0.1));
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 13px;
}
.chat-msg-bubble pre {
    background: light-dark(rgba(0,0,0,0.04), rgba(255,255,255,0.04));
    padding: 12px 16px;
    border-radius: 10px;
    overflow-x: auto;
    margin: 8px 0;
    backdrop-filter: blur(8px);
}
.chat-msg-bubble pre code {
    background: none;
    padding: 0;
    font-size: 13px;
}
.chat-msg-bubble strong { font-weight: 600; }
.chat-msg-bubble table {
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 13px;
    width: 100%;
}
.chat-msg-bubble th, .chat-msg-bubble td {
    border: 1px solid light-dark(rgba(0,0,0,0.12), rgba(255,255,255,0.15));
    padding: 6px 10px;
    text-align: left;
    vertical-align: top;
}
.chat-msg-bubble th {
    background: light-dark(rgba(0,0,0,0.04), rgba(255,255,255,0.06));
    font-weight: 600;
}

/* ---- Chat Input Bar (Liquid Glass) ---- */

.chat-input-bar {
    padding: 12px 24px;
    border-top: 1px solid light-dark(rgba(0,0,0,0.04), rgba(255,255,255,0.06));
    background: light-dark(
        linear-gradient(135deg, rgba(255,255,255,0.8), rgba(255,255,255,0.6)),
        linear-gradient(135deg, rgba(44,44,46,0.8), rgba(44,44,46,0.6))
    );
    backdrop-filter: saturate(160%) blur(30px);
}

.chat-input-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 10px 18px;
    border: 1px solid light-dark(rgba(0,0,0,0.06), rgba(255,255,255,0.08));
    border-radius: 24px;
    font-size: 15px;
    outline: none;
    background: light-dark(
        linear-gradient(135deg, rgba(255,255,255,0.9), rgba(255,255,255,0.75)),
        linear-gradient(135deg, rgba(58,58,60,0.9), rgba(58,58,60,0.75))
    );
    backdrop-filter: blur(8px);
    color: light-dark(#1a1a1e, #f0f0f5);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input:focus {
    border-color: light-dark(#0066d9, #5a9fff);
    box-shadow:
        0 0 0 3px light-dark(rgba(0,102,217,0.1), rgba(90,159,255,0.12)),
        0 0 24px light-dark(rgba(0,102,217,0.04), rgba(90,159,255,0.06));
}

/* ---- Chat uploads bar ---- */

.chat-uploads-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 0 4px;
}

.chat-uploads-label {
    font-size: 12px;
    color: light-dark(#6b6b72, #a3a3ab);
    font-weight: 600;
}

.chat-uploads-empty {
    font-size: 12px;
    color: light-dark(#9a9aa2, #66667a);
}

.chat-upload-error {
    font-size: 12px;
    color: #ff3b5c;
    padding: 2px 0 4px;
}

.chat-upload-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 16px;
    font-size: 12px;
    background: light-dark(rgba(0,0,0,0.05), rgba(255,255,255,0.06));
    border: 1px solid light-dark(rgba(0,0,0,0.08), rgba(255,255,255,0.1));
    max-width: 100%;
}

.chat-upload-chip.chip-adopted {
    border-color: light-dark(#0a7a3d, #3ddc84);
    background: light-dark(rgba(10,122,61,0.08), rgba(61,220,132,0.1));
}

.chat-upload-chip.chip-failed {
    border-color: light-dark(#d91040, #ff5c7a);
    background: light-dark(rgba(217,16,64,0.08), rgba(255,92,122,0.1));
}

.chip-name {
    font-weight: 600;
    color: light-dark(#1a1a1e, #f0f0f5);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chip-topics {
    display: inline-flex;
    gap: 4px;
    flex-wrap: wrap;
}

.chip-topic {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    background: light-dark(rgba(0,102,217,0.1), rgba(90,159,255,0.14));
    color: light-dark(#0066d9, #8ab8ff);
}

.chip-action {
    border: none;
    background: transparent;
    cursor: pointer;
    color: light-dark(#0066d9, #5a9fff);
    font-weight: 700;
    padding: 0 2px;
    line-height: 1;
}

.chip-action.chip-delete {
    color: light-dark(#d91040, #ff5c7a);
    opacity: 0.7;
}

.chip-action.chip-delete:hover {
    opacity: 1;
}

.chat-upload-btn {
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 6px 8px;
    border-radius: 12px;
    background: light-dark(rgba(0,0,0,0.04), rgba(255,255,255,0.05));
    border: 1px solid light-dark(rgba(0,0,0,0.06), rgba(255,255,255,0.08));
    flex-shrink: 0;
}

.chat-upload-btn:hover {
    background: light-dark(rgba(0,102,217,0.1), rgba(90,159,255,0.14));
}

/* ---- Chat upload strip + drawer + status ---- */

.chat-upload-strip {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    min-height: 26px;
}

.chat-upload-chip.chip-extracted {
    border-color: light-dark(#0a7a3d, #3ddc84);
    background: light-dark(rgba(10,122,61,0.08), rgba(61,220,132,0.1));
}

.chat-upload-chip.chip-pending {
    border-color: light-dark(#b98a00, #ffd45c);
    background: light-dark(rgba(185,138,0,0.08), rgba(255,212,92,0.1));
}

.status-indicator {
    font-size: 12px;
    line-height: 1;
    flex-shrink: 0;
}

.status-ok {
    color: light-dark(#0a7a3d, #3ddc84);
}

.status-err {
    color: light-dark(#d91040, #ff5c7a);
    font-weight: 700;
}

.status-spinner {
    display: inline-block;
    animation: chat-spin 1s linear infinite;
}

@keyframes chat-spin {
    to { transform: rotate(360deg); }
}

.chat-drawer-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 90;
}

.chat-drawer {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 360px;
    max-width: 90vw;
    background: light-dark(#ffffff, #17171b);
    box-shadow: -12px 0 30px rgba(0, 0, 0, 0.25);
    z-index: 91;
    display: flex;
    flex-direction: column;
    padding: 16px;
    border-left: 1px solid light-dark(rgba(0,0,0,0.08), rgba(255,255,255,0.08));
}

.chat-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.chat-drawer-list {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-drawer-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 10px;
    border: 1px solid light-dark(rgba(0,0,0,0.08), rgba(255,255,255,0.1));
    background: light-dark(rgba(0,0,0,0.03), rgba(255,255,255,0.04));
    font-size: 12px;
}

.chat-drawer-item .chip-name {
    max-width: 150px;
}

.drawer-spacer {
    flex: 1;
}

.chip-error {
    font-size: 10px;
    color: light-dark(#d91040, #ff5c7a);
    background: light-dark(rgba(217,16,64,0.08), rgba(255,92,122,0.1));
    padding: 1px 6px;
    border-radius: 10px;
}

/* ---- Login (Liquid Glass) ---- */

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 24px;
    background:
        radial-gradient(ellipse 90% 60% at 50% 0%, light-dark(rgba(0,102,217,0.06), rgba(90,159,255,0.08)) 0%, transparent 100%),
        radial-gradient(ellipse 70% 50% at 30% 100%, light-dark(rgba(255,45,85,0.04), rgba(255,45,85,0.06)) 0%, transparent 100%),
        light-dark(#f0f0f3, #0a0a0d);
}

.login-box {
    background: light-dark(
        linear-gradient(135deg, rgba(255,255,255,0.85), rgba(255,255,255,0.7)),
        linear-gradient(135deg, rgba(44,44,46,0.85), rgba(44,44,46,0.7))
    );
    backdrop-filter: saturate(160%) blur(40px);
    border-radius: 20px;
    border: 1px solid light-dark(rgba(255,255,255,0.5), rgba(255,255,255,0.06));
    box-shadow:
        0 8px 40px light-dark(rgba(0,0,0,0.06), rgba(0,0,0,0.4)),
        0 1px 0 light-dark(rgba(0,0,0,0.02), rgba(255,255,255,0.04) inset);
    padding: 40px 36px;
    width: 100%;
    max-width: 380px;
}

.login-title {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.027em;
    color: light-dark(#1a1a1e, #f0f0f5);
    margin-bottom: 4px;
    text-align: center;
}

.login-subtitle {
    font-size: 14px;
    color: light-dark(#6e6e73, #98989d);
    margin-bottom: 28px;
    text-align: center;
}

/* ---- Profile ---- */

.profile-section {
    max-width: 420px;
}

/* ---- Admin ---- */

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.admin-section {
    background: light-dark(
        linear-gradient(135deg, rgba(255,255,255,0.85), rgba(255,255,255,0.7)),
        linear-gradient(135deg, rgba(44,44,46,0.85), rgba(44,44,46,0.7))
    );
    backdrop-filter: saturate(160%) blur(24px);
    border-radius: 14px;
    border: 1px solid light-dark(rgba(255,255,255,0.5), rgba(255,255,255,0.06));
    box-shadow: 0 4px 24px light-dark(rgba(0,0,0,0.04), rgba(0,0,0,0.25));
    padding: 24px;
}

.admin-section-title {
    font-size: 17px;
    font-weight: 600;
    color: light-dark(#1a1a1e, #f0f0f5);
    margin-bottom: 16px;
}

/* ---- User list ---- */

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

.user-row {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: light-dark(
        linear-gradient(135deg, rgba(255,255,255,0.7), rgba(255,255,255,0.45)),
        linear-gradient(135deg, rgba(60,60,62,0.5), rgba(44,44,46,0.35))
    );
    backdrop-filter: blur(12px);
    border: 1px solid light-dark(rgba(255,255,255,0.5), rgba(255,255,255,0.07));
    border-radius: 12px;
    box-shadow: 0 2px 12px light-dark(rgba(0,0,0,0.05), rgba(0,0,0,0.2));
    transition: transform 0.2s, box-shadow 0.2s;
}

.user-row:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px light-dark(rgba(0,0,0,0.07), rgba(0,0,0,0.3));
}

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

.user-name { font-size: 14px; font-weight: 600; color: light-dark(#1a1a1e, #f0f0f5); }
.user-email { font-size: 12px; color: light-dark(#6e6e73, #98989d); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { align-self: flex-start; font-size: 11px; color: light-dark(#0066d9, #5a9fff); font-weight: 600; background: light-dark(rgba(0,102,217,0.1), rgba(90,159,255,0.15)); border-radius: 999px; padding: 3px 10px; margin-top: 2px; }

.user-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    border-top: 1px solid light-dark(rgba(0,0,0,0.06), rgba(255,255,255,0.07));
    padding-top: 10px;
}

/* ---- Ingest button row ---- */

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

/* ---- File info ---- */

.selected-file {
    font-size: 13px;
    color: light-dark(#6e6e73, #98989d);
    margin: 8px 0 12px;
}

/* ---- Upload queue ---- */

.upload-queue {
    margin-top: 10px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid light-dark(rgba(0,0,0,0.08), rgba(255,255,255,0.08));
    border-radius: 10px;
}

.upload-queue-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    font-size: 13px;
    border-bottom: 1px solid light-dark(rgba(0,0,0,0.05), rgba(255,255,255,0.05));
}

.upload-queue-item:last-child {
    border-bottom: none;
}

.upload-queue-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.upload-status-pending {
    color: light-dark(#6e6e73, #98989d);
    white-space: nowrap;
}

.upload-status-uploading {
    color: #007aff;
    white-space: nowrap;
}

.upload-status-done {
    color: #34c759;
    white-space: nowrap;
}

.upload-status-failed {
    color: #ff3b30;
    white-space: nowrap;
}

/* ---- Password form ---- */

.password-form {
    max-width: 420px;
    margin: 0 auto;
}

/* ---- Admin Tabs ---- */

.tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid light-dark(rgba(0,0,0,0.06), rgba(255,255,255,0.06));
    padding-bottom: 0;
}

.tab-btn {
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    background: none;
    cursor: pointer;
    color: light-dark(#6e6e73, #98989d);
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.tab-btn:hover {
    color: light-dark(#1a1a1e, #f0f0f5);
}

.tab-active {
    color: light-dark(#0066d9, #5a9fff);
    border-bottom-color: light-dark(#0066d9, #5a9fff);
}

/* ---- Analytics ---- */

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

.stat-card {
    background: light-dark(
        linear-gradient(135deg, rgba(255,255,255,0.85), rgba(255,255,255,0.7)),
        linear-gradient(135deg, rgba(44,44,46,0.85), rgba(44,44,46,0.7))
    );
    backdrop-filter: blur(16px);
    border: 1px solid light-dark(rgba(255,255,255,0.5), rgba(255,255,255,0.06));
    border-radius: 14px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 2px 12px light-dark(rgba(0,0,0,0.04), rgba(0,0,0,0.2));
}

.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: light-dark(#6e6e73, #98989d);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: light-dark(#1a1a1e, #f0f0f5);
}

.analytics-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.analytics-table th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    color: light-dark(#6e6e73, #98989d);
    border-bottom: 1px solid light-dark(rgba(0,0,0,0.04), rgba(255,255,255,0.06));
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.analytics-table td {
    padding: 10px 16px;
    color: light-dark(#1a1a1e, #f0f0f5);
    border-bottom: 1px solid light-dark(rgba(0,0,0,0.03), rgba(255,255,255,0.04));
}

.analytics-table tr:last-child td {
    border-bottom: none;
}

/* ---- Loading screen ---- */

.loading-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100dvh;
    background: light-dark(#f0f0f3, #0a0a0d);
}

.loading-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid light-dark(rgba(0,0,0,0.06), rgba(255,255,255,0.06));
    border-top-color: light-dark(#0066d9, #5a9fff);
    border-radius: 50%;
    animation: spin 0.7s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

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

/* ---- Responsive ---- */

@media (max-width: 640px) {
    .page { padding: 20px 16px; }
    .navbar { padding: 0 16px; }
    .conv-sidebar { display: none; }
    .chat-messages { padding: 16px; }
    .chat-input-bar { padding: 12px 16px; }
    .login-box { padding: 32px 24px; }
    .card { padding: 20px; }
    .chat-msg { max-width: 88%; }
    .chat-msg-bot { max-width: 92%; }
}

/* ---- Files page (Liquid Glass) ---- */

.files-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 16px;
    margin-top: 12px;
}

.files-sidebar {
    background: light-dark(
        linear-gradient(135deg, rgba(255,255,255,0.75), rgba(255,255,255,0.55)),
        linear-gradient(135deg, rgba(44,44,46,0.75), rgba(44,44,46,0.55))
    );
    backdrop-filter: saturate(160%) blur(30px);
    border: 1px solid light-dark(rgba(255,255,255,0.5), rgba(255,255,255,0.06));
    border-radius: 14px;
    padding: 12px;
    height: fit-content;
    box-shadow: 0 4px 24px light-dark(rgba(0,0,0,0.04), rgba(0,0,0,0.25));
}
.files-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.files-sidebar-heading {
    font-weight: 600;
    font-size: 13px;
    color: light-dark(#1d1d1f, #f0f0f5);
}
.files-empty {
    color: light-dark(#6e6e73, #98989d);
    font-size: 13px;
    padding: 8px 4px;
}
.files-tree {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.files-tree-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
}
.files-tree-toggle {
    width: 18px;
    height: 24px;
    background: transparent;
    border: none;
    color: light-dark(#6e6e73, #98989d);
    font-size: 11px;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.files-tree-item {
    background: transparent;
    border: none;
    color: light-dark(#1a1a1e, #f0f0f5);
    font-size: 13px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    flex: 1;
    text-align: left;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.files-tree-item:hover {
    background: light-dark(rgba(0,102,217,0.08), rgba(90,159,255,0.12));
}
.files-tree-item-active {
    background: linear-gradient(135deg, #0066d9, #0055b3);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0,102,217,0.25);
}
.files-tree-item-active:hover {
    background: linear-gradient(135deg, #0066d9, #0055b3);
}
.files-tree-item:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    color: light-dark(#6e6e73, #98989d);
}
.files-tree-item:disabled:hover {
    background: transparent;
}
.files-tree-menu {
    background: transparent;
    border: none;
    color: light-dark(#6e6e73, #98989d);
    cursor: pointer;
    font-size: 14px;
    padding: 0 4px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.files-tree-row:hover .files-tree-menu { opacity: 1; }
.files-tree-menu:hover {
    color: light-dark(#0066d9, #5a9fff);
    background: light-dark(rgba(0,102,217,0.08), rgba(90,159,255,0.12));
}

.files-main {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.files-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    background: light-dark(
        linear-gradient(135deg, rgba(255,255,255,0.75), rgba(255,255,255,0.55)),
        linear-gradient(135deg, rgba(44,44,46,0.75), rgba(44,44,46,0.55))
    );
    backdrop-filter: saturate(160%) blur(30px);
    border: 1px solid light-dark(rgba(255,255,255,0.5), rgba(255,255,255,0.06));
    border-radius: 14px;
    padding: 8px 12px;
    box-shadow: 0 4px 24px light-dark(rgba(0,0,0,0.04), rgba(0,0,0,0.25));
}
.files-crumb {
    background: transparent;
    border: none;
    color: light-dark(#1a1a1e, #f0f0f5);
    font-size: 13px;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 8px;
    transition: background 0.15s;
}
.files-crumb:hover {
    background: light-dark(rgba(0,102,217,0.08), rgba(90,159,255,0.12));
}
.files-crumb-active {
    background: linear-gradient(135deg, #0066d9, #0055b3);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0,102,217,0.25);
}
.files-crumb-active:hover {
    background: linear-gradient(135deg, #0066d9, #0055b3);
}
.files-crumb-sep {
    color: light-dark(#6e6e73, #98989d);
    font-size: 13px;
}

.files-actions-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.files-card {
    background: light-dark(
        linear-gradient(135deg, rgba(255,255,255,0.85), rgba(255,255,255,0.7)),
        linear-gradient(135deg, rgba(44,44,46,0.85), rgba(44,44,46,0.7))
    );
    backdrop-filter: saturate(160%) blur(30px);
    border: 1px solid light-dark(rgba(255,255,255,0.5), rgba(255,255,255,0.06));
    border-radius: 14px;
    box-shadow: 0 4px 24px light-dark(rgba(0,0,0,0.04), rgba(0,0,0,0.25));
    padding: 0;
    overflow: hidden;
}
.files-table {
    background: transparent;
}
.files-table tbody tr {
    transition: background 0.15s;
}
.files-table tbody tr:hover {
    background: light-dark(rgba(0,102,217,0.04), rgba(90,159,255,0.06));
}

.files-table td {
    white-space: nowrap;
}
.files-table td:first-child {
    max-width: 320px;
}
.files-table td:first-child .files-trunc {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.files-row-link {
    background: transparent;
    border: none;
    color: light-dark(#0066d9, #5a9fff);
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    text-align: left;
    transition: color 0.15s;
}
.files-row-link:hover { color: light-dark(#0055b3, #80b6ff); }

.files-row-menu {
    background: transparent;
    border: none;
    color: light-dark(#6e6e73, #98989d);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.files-table tr:hover .files-row-menu { opacity: 1; }
.files-row-menu:hover {
    color: light-dark(#0066d9, #5a9fff);
    background: light-dark(rgba(0,102,217,0.08), rgba(90,159,255,0.12));
}

.files-pagination {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid light-dark(rgba(0,0,0,0.08), rgba(255,255,255,0.08));
    font-size: 13px;
    color: light-dark(#48484a, #c7c7cc);
}
.files-pagination-label {
    white-space: nowrap;
}
.files-pagination-spacer {
    flex: 1;
}
.files-pagination-info {
    font-weight: 500;
    min-width: 90px;
    text-align: center;
}


.files-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}
.files-badge-private {
    background: light-dark(rgba(0,0,0,0.06), rgba(255,255,255,0.08));
    color: light-dark(#6e6e73, #98989d);
}
.files-badge-shared { color: light-dark(#0066d9, #5a9fff); }
.files-badge-global { color: light-dark(#ff9f0a, #ffb84d); }
.files-badge-completed { color: #34c759; }
.files-badge-pending { color: #ff9f0a; }

.files-empty-state {
    padding: 32px 16px;
    text-align: center;
    color: light-dark(#6e6e73, #98989d);
    font-size: 14px;
}

/* ---- Modal (Liquid Glass Sheet) ---- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: light-dark(rgba(0,0,0,0.4), rgba(0,0,0,0.6));
    backdrop-filter: saturate(160%) blur(30px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-card {
    background: light-dark(
        linear-gradient(135deg, rgba(255,255,255,0.85), rgba(255,255,255,0.7)),
        linear-gradient(135deg, rgba(44,44,46,0.85), rgba(44,44,46,0.7))
    );
    backdrop-filter: saturate(160%) blur(40px);
    border-radius: 14px;
    border: 1px solid light-dark(rgba(255,255,255,0.5), rgba(255,255,255,0.06));
    padding: 24px;
    width: min(420px, calc(100vw - 32px));
    box-shadow:
        0 10px 40px light-dark(rgba(0,0,0,0.2), rgba(0,0,0,0.5)),
        0 1px 0 light-dark(rgba(0,0,0,0.02), rgba(255,255,255,0.04) inset);
    max-height: 90vh;
    overflow-y: auto;
}
.modal-card .card-title {
    font-size: 17px;
    font-weight: 600;
    color: light-dark(#1a1a1e, #f0f0f5);
    margin: 0 0 16px;
    letter-spacing: -0.01em;
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #ff3b30, #d62d20);
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.33337;
    min-height: 32px;
    box-shadow: 0 2px 8px rgba(255,59,48,0.25);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
}
.btn-danger:disabled { opacity: 0.5; cursor: default; transform: none !important; }
.btn-danger:hover:not(:disabled) {
    transform: scale(1.03);
    box-shadow: 0 4px 14px rgba(255,59,48,0.35);
}

.share-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid light-dark(rgba(0,0,0,0.04), rgba(255,255,255,0.06));
    font-size: 14px;
}
.share-row:last-child {
    border-bottom: none;
}

.chat-scope-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

/* ---------------------------------------------------------------------------
   Forms Workshop
   --------------------------------------------------------------------------- */

.forms-page { display: flex; flex-direction: column; min-height: 0; }

.forms-layout {
    display: grid;
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
    margin-top: 20px;
}

@media (max-width: 900px) {
    .forms-layout { grid-template-columns: 1fr; }
}

.forms-rail {
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: 12px;
    max-height: calc(100dvh - 140px);
    padding: 16px;
    border-radius: 16px;
    background: light-dark(rgba(255,255,255,0.72), rgba(28,28,30,0.72));
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid light-dark(rgba(0,0,0,0.06), rgba(255,255,255,0.08));
}

/* (moved .forms-rail-head, .forms-stage-head, .forms-count styles to the
   Forms rail block at the bottom of this section, where the rule-prefix
   catalog layout is consolidated.) */

.btn-link {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: 13px;
    color: #007aff;
    cursor: pointer;
}
.btn-link:disabled { color: light-dark(#c7c7cc, #48484a); cursor: default; }

.forms-stage-filter { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid light-dark(rgba(0,0,0,0.08), rgba(255,255,255,0.12));
    background: light-dark(rgba(255,255,255,0.6), rgba(255,255,255,0.06));
    color: light-dark(#3a3a3c, #ebebf5);
    cursor: pointer;
}
.chip-active {
    background: #007aff;
    border-color: #007aff;
    color: #fff;
}

.forms-rail-scroll {
    display: flex;
    flex-direction: column;
    gap: 18px;
    overflow-y: auto;
    padding-right: 4px;
}

.forms-stage { display: flex; flex-direction: column; gap: 4px; }

/* Forms rail: tighter spacing to match files-page section-header rhythm. */
.forms-rail { display: flex; flex-direction: column; gap: 6px; }
.forms-rail .section-header { margin-bottom: 4px; }
.forms-count {
    font-size: 12px;
    color: light-dark(#6e6e73, #98989d);
    font-weight: 500;
}
.forms-stage-head { padding: 6px 10px 4px; margin-bottom: 0; }
.forms-stage-head h4 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: light-dark(#6e6e73, #98989d);
}

.form-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 10px;
    cursor: pointer;
    border: 1px solid transparent;
}
.form-item:hover { background: light-dark(rgba(0,0,0,0.035), rgba(255,255,255,0.05)); }
.form-item-selected {
    background: light-dark(rgba(0,122,255,0.09), rgba(10,132,255,0.16));
    border-color: light-dark(rgba(0,122,255,0.25), rgba(10,132,255,0.35));
}
.form-item input[type="checkbox"] { margin-top: 3px; flex-shrink: 0; }

.form-item-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.form-item-name {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.3;
}

.form-num {
    flex-shrink: 0;
    padding: 1px 6px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    background: light-dark(rgba(0,0,0,0.06), rgba(255,255,255,0.12));
    color: light-dark(#3a3a3c, #ebebf5);
}

.form-item-purpose { font-size: 12px; color: light-dark(#6e6e73, #98989d); line-height: 1.35; }

.form-item-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 2px; }

.form-official-link {
    font-size: 11.5px;
    font-weight: 500;
    color: #007aff;
    text-decoration: none;
}
.form-official-link:hover { text-decoration: underline; }

.form-item-rule { font-size: 11px; color: light-dark(#8e8e93, #8e8e93); }

/* Inline "Drafting notes" disclosure under each form-item. Uses native
   <details>/<summary> so it stays lightweight and keyboard-accessible; we
   only restyle the marker and the paragraph to match the form-item-rule
   tone instead of the default browser disclosure. */
.form-item-notes {
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.4;
    color: light-dark(#4a4a4f, #b4b4bb);
}
.form-item-notes > summary {
    list-style: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    color: light-dark(#3a3a3c, #ebebf5);
    padding: 1px 0;
}
.form-item-notes > summary::-webkit-details-marker { display: none; }
.form-item-notes > summary::before {
    content: "▸";
    font-size: 10px;
    color: light-dark(#8e8e93, #8e8e93);
    transition: transform 0.15s ease;
}
.form-item-notes[open] > summary::before { transform: rotate(90deg); }
.form-item-notes > summary:hover { color: #007aff; }
.form-item-notes > p {
    margin: 6px 0 0;
    padding: 8px 10px;
    border-radius: 8px;
    background: light-dark(rgba(0,0,0,0.03), rgba(255,255,255,0.05));
}

.forms-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* Source textarea: same glass / radius / border as .form-input (declared
   on the same element). We only add textarea-specific sizing here. */
.forms-source-input {
    min-height: 160px;
    resize: vertical;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    border-radius: 12px;
}

/* Source card uses slightly less vertical padding than .card default to keep
   the section header breathing room tighter with the textarea below. */
.forms-source-card { padding: 20px 22px; }

.forms-hint { font-size: 13px; color: light-dark(#6e6e73, #98989d); margin: 0 0 12px; line-height: 1.45; }

.forms-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.forms-status { font-size: 13px; color: light-dark(#6e6e73, #98989d); }

.error-banner {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    color: #ff3b30;
    background: light-dark(rgba(255,59,48,0.08), rgba(255,59,48,0.14));
    border: 1px solid light-dark(rgba(255,59,48,0.2), rgba(255,59,48,0.28));
}

.loading-inline { display: flex; justify-content: center; padding: 32px 0; }

.forms-workflow-card { margin-top: 0; }
.forms-workflow { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; }

.forms-workflow-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px solid light-dark(rgba(0,0,0,0.04), rgba(255,255,255,0.06));
}
.forms-workflow-step:last-child { border-bottom: none; }

.forms-workflow-num {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: light-dark(rgba(0,0,0,0.06), rgba(255,255,255,0.1));
}

.forms-workflow-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.forms-workflow-label { font-size: 14px; font-weight: 500; }
.forms-workflow-detail { font-size: 12.5px; color: light-dark(#6e6e73, #98989d); }

.forms-drafts { display: flex; flex-direction: column; gap: 14px; }

.forms-draft-card { margin-top: 0; }

.forms-draft-head {
    margin-bottom: 12px;
}

.forms-draft-title {
    margin: 0;
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 16px;
    font-weight: 600;
}

.forms-draft-meta { font-size: 12px; color: light-dark(#6e6e73, #98989d); }

.markdown-body {
    font-size: 14px;
    line-height: 1.6;
    overflow-wrap: break-word;
}
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin: 16px 0 8px; font-weight: 600; }
.markdown-body h1 { font-size: 18px; }
.markdown-body h2 { font-size: 16px; }
.markdown-body h3 { font-size: 15px; }
.markdown-body p { margin: 0 0 10px; }
.markdown-body ol, .markdown-body ul { margin: 0 0 10px; padding-left: 22px; }
.markdown-body li { margin-bottom: 4px; }
.markdown-body table { border-collapse: collapse; margin: 0 0 10px; width: 100%; }
.markdown-body th, .markdown-body td {
    border: 1px solid light-dark(rgba(0,0,0,0.1), rgba(255,255,255,0.14));
    padding: 6px 8px;
    text-align: left;
    font-size: 13px;
}
.markdown-body th { background: light-dark(rgba(0,0,0,0.03), rgba(255,255,255,0.05)); }
.markdown-body code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    padding: 1px 5px;
    border-radius: 5px;
    background: light-dark(rgba(0,0,0,0.05), rgba(255,255,255,0.1));
}
.markdown-body blockquote {
    margin: 0 0 10px;
    padding-left: 12px;
    border-left: 3px solid light-dark(rgba(0,0,0,0.14), rgba(255,255,255,0.2));
    color: light-dark(#6e6e73, #98989d);
}

/* ---- Forms Workshop: upload widget, history, source usage, viewer ---- */

.forms-file-input {
    padding: 8px 10px;
    font-size: 13px;
}

.forms-upload-list {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.forms-upload-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    background: light-dark(rgba(0,0,0,0.03), rgba(255,255,255,0.05));
}

.forms-draft-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.forms-side-card {
    padding: 14px 16px;
}

.forms-side-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid light-dark(rgba(0,0,0,0.08), rgba(255,255,255,0.12));
}

.forms-history {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 420px;
    overflow-y: auto;
}

.forms-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.forms-history-item:hover {
    background: light-dark(rgba(0,0,0,0.04), rgba(255,255,255,0.06));
}

.forms-history-open {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: flex-start;
    background: none;
    border: none;
    padding: 0;
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.forms-history-name {
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.forms-history-meta {
    font-size: 11px;
    color: light-dark(#6e6e73, #98989d);
}

.forms-history-del {
    color: light-dark(#a2544f, #d98076);
    font-size: 11px;
}

.forms-citations {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 420px;
    overflow-y: auto;
}

.forms-citation-item {
    padding: 10px;
    border-radius: 8px;
    background: light-dark(rgba(0,0,0,0.03), rgba(255,255,255,0.05));
}

.forms-citation-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 4px;
}

.forms-citation-doc {
    font-size: 12px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.forms-citation-count {
    font-size: 11px;
    white-space: nowrap;
    color: light-dark(#0a58c2, #6aa9ff);
}

.forms-citation-preview {
    margin: 0 0 6px;
    font-size: 11px;
    line-height: 1.45;
    color: light-dark(#4a4a4f, #b4b4bb);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.forms-citation-meta {
    font-size: 10px;
    color: light-dark(#86868b, #86868b);
}

.forms-viewer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: light-dark(rgba(0,0,0,0.35), rgba(0,0,0,0.6));
    backdrop-filter: blur(6px);
}

.forms-viewer {
    width: min(860px, 100%);
    max-height: 88vh;
    overflow-y: auto;
    padding: 22px 26px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.28);
}

.forms-viewer-subhead {
    margin: 22px 0 8px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: light-dark(#6e6e73, #98989d);
}

.forms-sources {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.forms-source-item {
    padding: 10px 12px;
    border-radius: 8px;
    background: light-dark(rgba(0,0,0,0.03), rgba(255,255,255,0.05));
}

.forms-source-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 600;
}

.forms-source-sim {
    font-size: 11px;
    font-weight: 400;
    color: light-dark(#6e6e73, #98989d);
}

.forms-source-text {
    margin: 0;
    font-size: 11px;
    line-height: 1.5;
    color: light-dark(#4a4a4f, #b4b4bb);
    max-height: 7.5em;
    overflow-y: auto;
}

/* Overlap highlighting in grounding passages and key-passage cards. */
.forms-source-text mark,
.forms-keypassages mark {
    background: light-dark(#ffe9a8, #4a3f18);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

.forms-keypassages {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid light-dark(#e4e4e7, #2a2a30);
}

.forms-keypassages .forms-viewer-subhead {
    margin-bottom: 4px;
}

/* ---- Forms Workshop: page-level tabs + persistent selection strip ---- */

.forms-toptabs {
    display: flex;
    gap: 6px;
    margin: 12px 0 16px;
    padding: 4px;
    border-radius: 12px;
    background: light-dark(rgba(0,0,0,0.04), rgba(255,255,255,0.05));
    border: 1px solid light-dark(rgba(0,0,0,0.06), rgba(255,255,255,0.08));
}

.forms-toptab {
    flex: 1;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    color: light-dark(#6e6e73, #98989d);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.forms-toptab:hover {
    color: light-dark(#1a1a1e, #f0f0f5);
}

.forms-toptab-active {
    background: light-dark(
        linear-gradient(135deg, rgba(255,255,255,0.95), rgba(255,255,255,0.85)),
        linear-gradient(135deg, rgba(58,58,60,0.95), rgba(58,58,60,0.85))
    );
    color: light-dark(#1a1a1e, #f0f0f5);
    border-color: light-dark(rgba(0,0,0,0.08), rgba(255,255,255,0.10));
    box-shadow: 0 1px 3px light-dark(rgba(0,0,0,0.06), rgba(0,0,0,0.30));
}

.forms-picked {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    margin-bottom: 12px;
    border-radius: 12px;
    background: light-dark(rgba(0,122,255,0.06), rgba(10,132,255,0.12));
    border: 1px solid light-dark(rgba(0,122,255,0.20), rgba(10,132,255,0.30));
}
.forms-picked-label {
    font-size: 13px;
    font-weight: 600;
    color: light-dark(#0066d9, #6aa9ff);
}

.forms-empty-card {
    text-align: center;
    padding: 40px 24px;
}
.forms-empty-card .card-title { margin-bottom: 8px; }
.forms-empty-card .forms-hint { margin-bottom: 18px; }

.forms-history-card,
.forms-reference-card { padding: 20px 22px; }
