/* ===== BLACK & WHITE — LIGHTWEIGHT THEME ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

img, picture, video, canvas, svg {
    display: block;
    max-width: 100%;
}

:root {
    --black: #0a0a0a;
    --white: #ffffff;
    --gray: #999999;
    --gray-dark: #666666;
    --border: #2a2a2a;
    --surface: #111111;
    --radius: 8px;
    --radius-lg: 10px;
    --font: 'DM Sans', system-ui, sans-serif;
    --transition: 0.15s ease;
}

html {
    font-size: 16px;
    height: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--black);
    color: var(--white);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

::selection { background: #333; color: var(--white); }
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-thumb { background: #444; }

/* ===== LOGIN ===== */
.login-body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 0;
    background: var(--black);
    overflow-x: hidden;
    overflow-y: auto;
}

.login-wrapper {
    width: 100%;
    max-width: 480px;
    padding: 16px 20px;
    margin: auto;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px 36px 36px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.login-brand {
    text-align: center;
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.brand-mark {
    width: 56px;
    height: 56px;
    margin: 0 auto 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    color: var(--black);
    border: none;
    border-radius: 14px;
    flex-shrink: 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.brand-mark svg {
    width: 30px;
    height: 30px;
    display: block;
    stroke: currentColor;
}

.brand-mark.sm {
    width: 40px;
    height: 40px;
    margin: 0;
    border-radius: 11px;
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.3);
}

.brand-mark.sm svg {
    width: 22px;
    height: 22px;
}

.brand-eyebrow {
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--gray);
    margin-bottom: 10px;
}

.brand-title {
    font-size: 2.1rem;
    font-weight: 700;
    color: var(--white);
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.brand-sub {
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--gray);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.login-form { display: flex; flex-direction: column; gap: 18px; }

.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-group label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--gray);
}

.form-group input,
.form-input,
textarea.form-input,
select.filter-input {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--black);
    color: var(--white);
    font-family: var(--font);
    font-size: 1rem;
    outline: none;
    transition: border-color var(--transition);
}

.login-card .form-group label {
    font-size: 0.95rem;
    color: #b8b8b8;
}

.login-card .form-group input {
    padding: 14px 16px;
    font-size: 1.05rem;
    min-height: 52px;
    border-radius: 10px;
}

.password-field {
    position: relative;
    display: flex;
    align-items: center;
}

.password-field input {
    width: 100%;
    padding-right: 52px;
}

.password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--gray);
    cursor: pointer;
    transition: color var(--transition), background var(--transition);
}

.password-toggle:hover {
    color: var(--white);
    background: rgba(255, 255, 255, 0.06);
}

.password-toggle svg {
    display: block;
}

.login-card .btn-full {
    min-height: 56px;
    padding: 15px 20px;
    font-size: 1.08rem;
}

.login-card .alert {
    font-size: 0.95rem;
    padding: 12px 14px;
}

.form-group input:focus,
.form-input:focus,
textarea.form-input:focus,
.filter-input:focus,
.global-search-input:focus {
    border-color: var(--white);
}

.form-group input::placeholder,
.global-search-input::placeholder { color: var(--gray-dark); }

.alert {
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 14px;
    border: 1px solid var(--border);
    color: var(--gray);
    background: #1a1a1a;
}

.ai-status {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 0.82rem;
    border: 1px solid var(--border);
    background: #141414;
    color: var(--gray);
}

.ai-status.loading {
    color: var(--white);
    border-color: #444;
}

.ai-status.success {
    color: var(--white);
    border-color: #3a3a3a;
    background: #161616;
}

.ai-status.error {
    color: #cfcfcf;
    border-color: #333;
    background: #121212;
}

textarea.form-input {
    resize: vertical;
    min-height: 68px;
    line-height: 1.45;
}

.login-footer {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.82rem;
    color: var(--gray);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--white);
    color: var(--black);
    border-color: var(--white);
    font-weight: 700;
    letter-spacing: 0.03em;
}

.btn-primary:hover { background: #e8e8e8; border-color: #e8e8e8; }

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--gray);
}

.btn-outline:hover { border-color: var(--white); color: var(--white); }

.btn-danger {
    background: transparent;
    border-color: var(--border);
    color: var(--gray);
}

.btn-danger:hover { border-color: var(--white); color: var(--white); }

.btn-full { width: 100%; }
.btn-sm { min-height: 38px; padding: 10px 16px; font-size: 0.88rem; }

/* ===== APP SHELL ===== */
.dashboard-body {
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--black);
    overflow-x: hidden;
}

.app-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    width: 100%;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
    background: var(--black);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
}

.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
    height: 66px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    flex-shrink: 1;
    min-width: 0;
    padding: 4px 0;
}

.brand-name {
    font-size: clamp(1.05rem, 3.5vw, 1.4rem);
    font-weight: 700;
    color: var(--white);
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    padding: 4px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
}

.nav-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 7px 12px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--gray);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--transition), background var(--transition);
    white-space: nowrap;
}

.nav-pill:hover { color: var(--white); background: #1a1a1a; }

.nav-pill.active {
    color: var(--black);
    background: var(--white);
    font-weight: 600;
}

.nav-dropdown { position: relative; }

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 190px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    z-index: 50;
}

.nav-dropdown.open .nav-dropdown-menu { display: block; }
.nav-dropdown.open .nav-dropdown-toggle { color: var(--white); background: #1a1a1a; }

.nav-sub-btn {
    width: 100%;
    display: block;
    padding: 8px 10px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--gray);
    font-family: var(--font);
    font-size: 0.8rem;
    text-align: left;
    cursor: pointer;
    transition: color var(--transition), background var(--transition);
}

.nav-sub-btn:hover { color: var(--white); background: #1a1a1a; }
.nav-sub-btn.active { color: var(--black); background: var(--white); font-weight: 600; }

.header-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.header-spacer {
    flex: 1;
}

.header-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 12px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--white);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition), background var(--transition);
    white-space: nowrap;
}

.header-btn:hover {
    border-color: #555;
    background: #1a1a1a;
}

.upload-dropdown {
    position: relative;
}

.upload-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 230px;
    max-height: min(70vh, 480px);
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    z-index: 120;
}

.upload-dropdown.open .upload-dropdown-menu {
    display: block;
}

.upload-dropdown.open .header-btn {
    border-color: var(--white);
    background: #1a1a1a;
}

.upload-menu-item {
    width: 100%;
    display: block;
    padding: 11px 12px;
    border: none;
    border-radius: 5px;
    background: transparent;
    color: var(--gray);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: color var(--transition), background var(--transition);
}

.upload-menu-item:hover {
    color: var(--white);
    background: #1a1a1a;
}

.upload-menu-group {
    padding: 2px 0;
}

.upload-menu-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 11px 12px;
    border: none;
    border-radius: 5px;
    background: transparent;
    color: var(--gray);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-align: left;
    cursor: pointer;
    transition: color var(--transition), background var(--transition);
}

.upload-menu-toggle:hover {
    color: var(--white);
    background: #1a1a1a;
}

.upload-menu-chevron {
    flex-shrink: 0;
    color: var(--gray-dark);
    transition: transform var(--transition);
}

.upload-menu-group.is-collapsed .upload-menu-chevron {
    transform: rotate(-90deg);
}

.upload-menu-subitems {
    padding: 0 0 2px 6px;
}

.upload-menu-group.is-collapsed .upload-menu-subitems {
    display: none;
}

.upload-menu-label {
    display: block;
    padding: 6px 10px 4px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gray-dark);
}

.upload-menu-divider {
    height: 1px;
    margin: 4px 6px;
    background: var(--border);
}

.global-search-wrap { position: relative; }

.global-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray);
    pointer-events: none;
}

.global-search-input {
    width: 200px;
    padding: 7px 10px 7px 32px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--white);
    font-family: var(--font);
    font-size: 0.8rem;
    outline: none;
    transition: border-color var(--transition);
}

.header-signout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    color: var(--gray);
    text-decoration: none;
    transition: color var(--transition), border-color var(--transition), background var(--transition);
    flex-shrink: 0;
}

.header-signout svg {
    display: block;
}

.header-signout:hover {
    color: var(--white);
    border-color: var(--white);
    background: #1a1a1a;
}

/* Action bar */
.action-bar {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #151515 0%, #101010 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.action-bar-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--gray);
    padding: 6px 12px 6px 0;
    border-right: 1px solid var(--border);
    white-space: nowrap;
    flex-shrink: 0;
}

.action-bar-label-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
}

.action-bar-buttons {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.action-chip {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 10px;
    min-height: 34px;
    border-radius: 8px;
    border: 1px solid #333;
    background: #0c0c0c;
    color: #d4d4d4;
    font-family: var(--font);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
}

.action-chip-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
    transition: background 0.18s ease;
}

.action-chip-icon svg {
    display: block;
}

.action-chip:hover {
    color: var(--white);
    border-color: #666;
    background: #141414;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.action-chip:active,
.action-chip.is-active {
    color: var(--black);
    background: var(--white);
    border-color: var(--white);
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(255, 255, 255, 0.15);
}

.action-chip:active .action-chip-icon,
.action-chip.is-active .action-chip-icon {
    background: rgba(0, 0, 0, 0.08);
}

.action-chip-muted:active,
.action-chip-muted.is-active {
    border-style: solid;
    color: var(--black);
}

.action-chip-muted {
    border-style: dashed;
    border-color: #3a3a3a;
    color: var(--gray);
}

.action-chip-muted:hover {
    color: var(--white);
    border-color: #666;
}

.header-actions {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.action-chip-upload {
    flex: 0 0 auto;
    min-width: 0;
    background: var(--white);
    color: var(--black);
    border-color: var(--white);
}

.action-chip-upload .action-chip-icon {
    background: rgba(0, 0, 0, 0.08);
}

.action-chip-upload:hover {
    color: var(--black);
    background: #e8e8e8;
    border-color: #e8e8e8;
}

.action-chip-upload:active,
.action-chip-upload.is-active {
    color: var(--white);
    background: #1a1a1a;
    border-color: var(--white);
    box-shadow: 0 2px 10px rgba(255, 255, 255, 0.1);
}

.action-chip-upload:active .action-chip-icon,
.action-chip-upload.is-active .action-chip-icon {
    background: rgba(255, 255, 255, 0.12);
}

/* Main */
.app-main {
    flex: 1;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    padding: 16px 20px 24px;
    min-width: 0;
}

.content-panel {
    width: 100%;
    min-width: 0;
}

/* Hero search (main page) */
.main-search-hero {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 28px 16px 32px;
    margin-bottom: 16px;
    overflow: hidden;
}

.main-search-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 70% 55% at 50% 45%, rgba(255, 255, 255, 0.07) 0%, transparent 68%);
    pointer-events: none;
}

.main-search-title {
    position: relative;
    z-index: 1;
    font-size: clamp(1.35rem, 2.8vw, 1.85rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
    color: var(--white);
    margin-bottom: 22px;
}

.hero-search-pill {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    max-width: 820px;
    padding: 14px 18px 14px 22px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #161616;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.03) inset, 0 8px 32px rgba(0, 0, 0, 0.35);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.hero-search-pill:focus-within {
    border-color: #444;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06) inset, 0 8px 36px rgba(0, 0, 0, 0.45);
}

.hero-search-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: var(--gray);
}

.hero-search-input {
    flex: 1;
    min-width: 0;
    padding: 8px 0;
    border: none;
    background: transparent;
    color: var(--white);
    font-family: var(--font);
    font-size: 1.05rem;
    outline: none;
}

.hero-search-input::placeholder {
    color: var(--gray-dark);
}

/* Workspace */
.workspace-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    overflow: hidden;
    max-width: 100%;
}

.workspace-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
}

.view-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.crumb { font-size: 0.84rem; font-weight: 500; color: var(--gray); }
.crumb.is-current { color: var(--white); font-weight: 600; }
.crumb-sep { color: var(--gray-dark); font-size: 0.8rem; }

.result-badge {
    padding: 3px 8px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--black);
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--white);
    white-space: nowrap;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--black);
}

.filter-bar-full {
    padding: 8px 12px;
}

.search-field-wrap {
    position: relative;
    width: 100%;
    flex: 1;
}

.search-field-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray);
    pointer-events: none;
}

.filter-input-full {
    width: 100%;
    padding: 8px 12px 8px 36px;
    font-size: 0.86rem;
    border-radius: 8px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 130px;
}

.filter-group-wide { flex: 2; min-width: 180px; }

.filter-group label {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--gray);
}

.workspace-card .image-list { padding: 12px 14px 14px; }
.workspace-card .empty-state { margin: 16px; }
.workspace-card .pdf-list { padding: 14px 16px 16px; }

/* Welcome */
.welcome-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.welcome-hero {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}

.welcome-hero-logo {
    width: 36px;
    height: 36px;
    margin: 0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    border: none;
    border-radius: 9px;
    color: var(--black);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.22);
}

.welcome-hero-logo svg {
    width: 20px;
    height: 20px;
    display: block;
}

.welcome-hero-text {
    flex: 1;
    min-width: 0;
    text-align: left;
}

.welcome-hero h2 {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
    line-height: 1.2;
    white-space: nowrap;
}

.welcome-hero p {
    margin: 2px 0 0;
    font-size: 0.74rem;
    color: var(--gray);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stats-strip {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    margin: 0;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--black);
}

.stat-item {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    padding: 0 14px;
    gap: 7px;
}

.stat-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--white);
    line-height: 1;
}

.stat-label {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--gray);
    white-space: nowrap;
}

.stat-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    flex-shrink: 0;
}

.welcome-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gray);
    padding: 0 2px;
}

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

.welcome-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px 18px 18px;
    min-height: 130px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    text-align: left;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    font-family: var(--font);
    color: var(--white);
}

.welcome-card:hover {
    border-color: var(--white);
    background: #161616;
}

.welcome-card-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--black);
    color: var(--white);
    flex-shrink: 0;
}

.welcome-card-icon svg {
    width: 18px;
    height: 18px;
    display: block;
}

.welcome-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.welcome-card-num {
    display: block;
    font-size: 0.62rem;
    font-weight: 700;
    color: var(--gray);
    margin-bottom: 6px;
    letter-spacing: 0.12em;
}

.welcome-card h3 {
    font-size: 0.98rem;
    font-weight: 600;
    margin-bottom: 5px;
    line-height: 1.25;
}

.welcome-card p {
    font-size: 0.78rem;
    color: var(--gray);
    line-height: 1.45;
}

.welcome-card-arrow {
    margin-top: auto;
    font-size: 0.85rem;
    color: var(--gray);
    transition: color var(--transition);
}

.welcome-card:hover .welcome-card-arrow {
    color: var(--white);
}

/* Image list */
.image-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.image-list-item {
    display: flex;
    align-items: stretch;
    gap: 16px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.22);
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
}

.image-list-item:hover {
    border-color: #444;
    background: #141414;
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.3);
}

.image-list-thumb-wrap {
    width: 88px;
    height: 88px;
    flex-shrink: 0;
    border-radius: 12px;
    overflow: hidden;
    background: var(--black);
    border: 1px solid var(--border);
}

.image-list-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.image-list-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.image-list-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.image-list-title {
    flex: 1;
    min-width: 0;
    font-size: 1.12rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--white);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.image-list-badge {
    flex-shrink: 0;
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid #333;
    background: #1a1a1a;
    color: #d8d8d8;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.image-list-keywords {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--gray);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.image-list-location {
    font-size: 0.82rem;
    font-weight: 600;
    color: #a8a8a8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-list-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: auto;
    padding-top: 6px;
}

.image-list-actions .card-action-btn {
    flex: 0 0 auto;
    min-width: 80px;
    min-height: 40px;
    padding: 10px 14px;
    font-size: 0.88rem;
    border-radius: 6px;
}

.card-action-btn {
    flex: 1;
    min-height: 36px;
    padding: 9px 10px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--gray);
    font-family: var(--font);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.card-action-btn:hover {
    color: var(--black);
    background: var(--white);
    border-color: var(--white);
}

/* PDF */
.pdf-list { display: flex; flex-direction: column; gap: 8px; }

.pdf-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color var(--transition);
}

.pdf-item:hover { border-color: #555; }

.pdf-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--white);
    flex-shrink: 0;
}

.pdf-info { flex: 1; min-width: 0; }

.pdf-title {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pdf-date { font-size: 0.72rem; color: var(--gray); margin-top: 2px; }
.pdf-actions { display: flex; gap: 6px; }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 20px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    color: var(--gray);
}

.empty-state-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--white);
    margin-bottom: 4px;
}

.empty-state-desc { font-size: 0.82rem; color: var(--gray); }

/* Search popup */
.search-popup-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 900;
    background: rgba(0, 0, 0, 0.72);
    padding: 24px 20px;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
}

.search-popup-overlay.open {
    display: flex;
}

.search-popup-panel {
    width: 100%;
    max-width: 960px;
    margin-top: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
    overflow: hidden;
    animation: searchPopupIn 0.2s ease;
}

@keyframes searchPopupIn {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.search-popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: #0e0e0e;
}

.search-popup-header h3 {
    font-size: clamp(0.88rem, 2.5vw, 1rem);
    font-weight: 600;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-popup-count {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--gray);
    white-space: nowrap;
}

.search-popup-body {
    max-height: min(70vh, 640px);
    overflow-y: auto;
    padding: 16px;
}

.search-popup-section + .search-popup-section {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.search-popup-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gray-dark);
    margin-bottom: 12px;
}

.search-popup-pdfs {
    gap: 8px;
}

.search-popup-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px 20px;
    color: var(--gray);
    font-size: 0.9rem;
    font-weight: 500;
}

.search-popup-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #333;
    border-top-color: var(--white);
    border-radius: 50%;
    animation: searchSpin 0.65s linear infinite;
}

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

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

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

.modal {
    width: 100%;
    max-width: 480px;
    max-height: min(92vh, 900px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal form {
    padding: 18px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

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

.modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.modal-close {
    width: 34px;
    height: 34px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--gray);
    font-size: 1.15rem;
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition);
}

.modal-close:hover { color: var(--white); border-color: var(--white); }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.file-drop {
    position: relative;
    padding: 24px 16px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition);
}

.file-drop:hover { border-color: var(--white); }

.file-drop input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-drop-text { color: var(--gray); font-size: 0.84rem; }

.file-preview img {
    max-width: 100%;
    max-height: 140px;
    border-radius: var(--radius);
    object-fit: contain;
}

/* Toast */
.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--white);
    font-size: 0.82rem;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.toast.show { opacity: 1; }
.toast.success { border-color: var(--white); }
.toast.error { border-color: var(--gray); color: var(--gray); }

/* ===== RESPONSIVE ===== */

/* Tablet landscape & small laptops */
@media (max-width: 1024px) {
    .welcome-grid { grid-template-columns: repeat(2, 1fr); }
    .welcome-card { min-height: 120px; }

    .image-list-thumb-wrap {
        width: 80px;
        height: 80px;
    }

    .image-list-title {
        font-size: 1.05rem;
    }
}

@media (max-width: 900px) {
    .image-list-item {
        gap: 14px;
        padding: 12px 14px;
    }

    .image-list-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .image-list-badge {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .image-list-actions {
        width: 100%;
        justify-content: stretch;
    }

    .image-list-actions .card-action-btn {
        flex: 1 1 0;
        min-width: 0;
    }
}

@media (min-width: 1025px) {
    .welcome-panel { justify-content: flex-start; }
}

/* Tablet portrait */
@media (max-width: 768px) {
    .login-body {
        padding: 16px 0;
        align-items: flex-start;
    }

    .login-wrapper {
        padding: 12px 16px;
    }

    .login-card {
        padding: 28px 22px;
    }

    .brand-title {
        font-size: clamp(1.5rem, 6vw, 1.75rem);
    }

    .brand-mark {
        width: 48px;
        height: 48px;
    }

    .brand-mark svg {
        width: 24px;
        height: 24px;
    }

    .header-inner {
        flex-wrap: nowrap;
        height: auto;
        min-height: 58px;
        padding: 10px 14px;
        gap: 10px;
    }

    .header-spacer {
        flex: 0 0 8px;
        min-width: 8px;
    }

    .header-tools {
        gap: 8px;
    }

    .header-btn {
        min-height: 40px;
        padding: 10px 14px;
        font-size: 0.88rem;
    }

    .header-signout {
        width: 40px;
        height: 40px;
    }

    .upload-dropdown-menu {
        right: 0;
        left: auto;
        min-width: 220px;
        max-width: min(280px, calc(100vw - 24px));
    }

    .app-main {
        padding: 14px 14px 20px;
    }

    .main-search-hero {
        padding: 22px 10px 28px;
        margin-bottom: 12px;
    }

    .main-search-title {
        margin-bottom: 18px;
        padding: 0 4px;
    }

    .hero-search-pill {
        padding: 12px 16px;
        gap: 10px;
    }

    .hero-search-input {
        font-size: 16px;
        padding: 6px 0;
    }

    .image-list-item {
        gap: 12px;
        padding: 12px;
    }

    .image-list-thumb-wrap {
        width: 76px;
        height: 76px;
        border-radius: 10px;
    }

    .image-list-body {
        flex: 1;
        min-width: 0;
    }

    .image-list-title {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .image-list-location {
        white-space: normal;
    }

    .workspace-card .image-list {
        padding: 10px;
    }

    .workspace-top {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-bar {
        flex-direction: column;
        padding: 12px;
    }

    .filter-group {
        min-width: 0;
        width: 100%;
    }

    .welcome-grid {
        grid-template-columns: 1fr;
    }

    .welcome-hero {
        flex-wrap: wrap;
        gap: 10px;
        padding: 10px 12px;
    }

    .welcome-hero-text {
        flex: 1 1 140px;
        min-width: 0;
    }

    .stats-strip {
        width: 100%;
        justify-content: center;
        padding: 8px 10px;
    }

    .stat-item { padding: 2px 0; }
    .stat-divider { width: 32px; height: 1px; }

    .pdf-item {
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px;
    }

    .pdf-info {
        flex: 1 1 calc(100% - 52px);
        min-width: 0;
    }

    .pdf-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .search-popup-overlay {
        padding: 0;
        align-items: stretch;
    }

    .search-popup-panel {
        margin-top: 0;
        max-width: 100%;
        min-height: 100dvh;
        border-radius: 0;
        border-left: none;
        border-right: none;
        display: flex;
        flex-direction: column;
    }

    .search-popup-body {
        flex: 1;
        max-height: none;
        padding: 12px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .search-popup-header {
        padding: 12px 14px;
        flex-wrap: wrap;
    }

    .search-popup-count {
        order: 3;
        width: 100%;
        padding-left: 0;
        white-space: normal;
    }

    .modal-overlay {
        padding: 12px;
        align-items: flex-end;
    }

    .modal {
        max-height: 92dvh;
        border-radius: 12px 12px 0 0;
    }

    .modal-actions {
        flex-direction: column-reverse;
        gap: 8px;
    }

    .modal-actions .btn {
        width: 100%;
    }

    .toast {
        left: 12px;
        right: 12px;
        bottom: 12px;
        text-align: center;
    }
}

/* Large phones */
@media (max-width: 600px) {
    .image-list-item {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .image-list-thumb-wrap {
        width: 100%;
        height: 160px;
        border-radius: 12px;
    }

    .image-list-head {
        flex-direction: row;
        align-items: flex-start;
        justify-content: space-between;
    }

    .image-list-actions {
        gap: 8px;
    }

    .image-list-actions .card-action-btn {
        flex: 1 1 calc(33.333% - 6px);
        min-width: 0;
    }
}

@media (max-width: 480px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 24px 18px;
        border-radius: 10px;
    }

    .login-card .form-group input {
        min-height: 48px;
        font-size: 16px;
    }

    .brand-name {
        max-width: min(140px, 38vw);
    }

    .header-inner {
        padding: 8px 12px;
        gap: 8px;
    }

    .header-btn {
        padding: 10px 12px;
        font-size: 0.84rem;
    }

    .upload-dropdown-menu {
        position: fixed;
        top: calc(env(safe-area-inset-top, 0px) + 58px);
        right: 12px;
        left: 12px;
        min-width: 0;
        max-width: none;
        width: auto;
    }

    .main-search-hero {
        padding: 18px 6px 22px;
    }

    .main-search-title {
        font-size: clamp(1.15rem, 5vw, 1.45rem);
        line-height: 1.25;
    }

    .hero-search-pill {
        border-radius: 14px;
        padding: 12px 14px;
        max-width: 100%;
    }

    .hero-search-icon {
        width: 18px;
        height: 18px;
    }

    .image-list-keywords {
        -webkit-line-clamp: 3;
    }

    .image-list-actions .card-action-btn {
        flex: 1 1 calc(33.333% - 4px);
        min-width: 0;
        min-height: 38px;
        font-size: 0.82rem;
        padding: 9px 10px;
    }

    .empty-state {
        padding: 32px 16px;
    }

    .search-popup-panel {
        margin-top: 0;
        border-radius: 0;
    }

    .search-popup-header h3 {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .pdf-actions .btn {
        flex: 1;
    }

    .file-drop {
        padding: 20px 12px;
    }
}

/* Small phones */
@media (max-width: 380px) {
    .brand-name {
        max-width: min(110px, 34vw);
        font-size: 1rem;
    }

    .header-btn span,
    .header-btn {
        gap: 4px;
    }

    .image-list-thumb-wrap {
        height: 140px;
    }

    .image-list-title {
        font-size: 1rem;
    }

    .image-list-keywords {
        font-size: 0.84rem;
    }

    .image-list-location {
        font-size: 0.76rem;
    }

    .image-list-actions {
        flex-direction: column;
    }

    .image-list-actions .card-action-btn {
        flex: 1 1 auto;
        width: 100%;
    }

    .pdf-actions {
        flex-direction: column;
    }

    .pdf-actions .btn {
        width: 100%;
    }
}

/* Very small width */
@media (max-width: 320px) {
    .header-btn {
        padding: 10px;
        font-size: 0.8rem;
    }

    .login-wrapper {
        padding: 10px 12px;
    }

    .login-card {
        padding: 20px 14px;
    }
}

/* Large screens */
@media (min-width: 1400px) {
    .app-main {
        max-width: 1320px;
    }

    .image-list {
        gap: 14px;
    }
}

/* Short screens */
@media (max-height: 760px) {
    .login-body {
        align-items: flex-start;
    }

    .login-card {
        padding: 24px 20px;
    }

    .main-search-hero {
        padding-top: 16px;
        padding-bottom: 20px;
    }
}

/* Safe area (notched phones) */
@supports (padding: max(0px)) {
    .app-header {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .app-main {
        padding-left: max(14px, env(safe-area-inset-left));
        padding-right: max(14px, env(safe-area-inset-right));
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }

    .toast {
        bottom: max(12px, env(safe-area-inset-bottom));
    }

    .modal-overlay {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .search-popup-overlay {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}
