/* ===== 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;
    --dashboard-width: 100%;
    --grid-card-min: 300px;
    --page-padding: clamp(16px, 3vw, 48px);
}

html {
    font-size: 16px;
    height: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    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;
    width: 100%;
    max-width: 100vw;
}

button,
a,
input,
select,
textarea {
    -webkit-tap-highlight-color: transparent;
}

button,
.header-btn,
.card-action-btn,
.upload-menu-item {
    touch-action: manipulation;
}

::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: 10px;
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--white);
    color: var(--black);
    border-color: var(--white);
    font-weight: 700;
    letter-spacing: 0.03em;
    box-shadow: 0 2px 12px rgba(255, 255, 255, 0.12);
}

.btn-primary:hover {
    background: #e8e8e8;
    border-color: #e8e8e8;
    box-shadow: 0 4px 16px rgba(255, 255, 255, 0.16);
}

.btn-outline {
    background: #141414;
    border-color: #3a3a3a;
    color: #d4d4d4;
}

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

.btn-danger {
    background: #121212;
    border-color: #3a3a3a;
    color: #c8c8c8;
}

.btn-danger:hover {
    border-color: #ff6b6b;
    color: #fff;
    background: rgba(255, 107, 107, 0.12);
}

.btn-full { width: 100%; }
.btn-sm {
    min-height: 40px;
    padding: 10px 14px;
    font-size: 0.86rem;
    border-radius: 8px;
}

/* ===== 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;
    width: 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: none;
    width: 100%;
    margin: 0 auto;
    padding: 0 clamp(16px, 3vw, 48px);
    height: 66px;
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.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: 10px;
    border: 1px solid #3a3a3a;
    background: #141414;
    color: var(--white);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease, transform 0.12s ease;
    white-space: nowrap;
}

.header-btn:hover {
    border-color: #666;
    background: #1c1c1c;
}

.header-btn:active {
    transform: scale(0.97);
}

.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: none;
    width: 100%;
    margin: 0 auto;
    padding: 16px clamp(16px, 3vw, 48px) 24px;
    min-width: 0;
    box-sizing: border-box;
}

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

#image-panel {
    width: 100%;
    max-width: 100%;
    margin: 0;
}

#pdf-panel {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

#pdf-panel .workspace-card {
    width: 100%;
    max-width: 100%;
    margin: 0;
}

/* Hero search (main page) */
.main-search-hero {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    width: 100%;
    padding: 32px 0 24px;
    margin-bottom: 4px;
    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.25;
    color: var(--white);
    margin-bottom: 24px;
    padding: 0 4px;
}

.hero-search-pill {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    max-width: 820px;
    margin: 0 auto;
    padding: 15px 22px 15px 24px;
    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; }
.workspace-card .empty-state { margin: 16px; }
.workspace-card .pdf-list { padding: 12px; }

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

.search-results-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gray-dark);
    padding: 14px 16px 0;
    margin: 0;
}

#search-pdfs-section {
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

#search-pdfs-section .pdf-list {
    padding: 8px 12px 12px;
}

#image-results.workspace-card {
    border: none;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}

#image-results .empty-state {
    margin: 8px 0 0;
}

/* 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 — 2 columns filling full screen width */
.image-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
    width: 100%;
}

.image-list-item {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    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: 100px;
    min-width: 100px;
    min-height: 100px;
    align-self: stretch;
    flex-shrink: 0;
    border-radius: 10px;
    overflow: hidden;
    background: var(--black);
    border: 1px solid var(--border);
}

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

.image-list-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    justify-content: flex-start;
}

.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.05rem;
    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: 4px 10px;
    border-radius: 999px;
    border: 1px solid #3a3a3a;
    background: #1c1c1c;
    color: #e0e0e0;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    white-space: nowrap;
    max-width: 46%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-list-keywords {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.45;
    color: #b0b0b0;
    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.78rem;
    font-weight: 600;
    color: #b8b8b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-list-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
    padding-top: 4px;
    flex-wrap: nowrap;
}

.image-list-actions .card-action-btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: 38px;
    padding: 9px 8px;
    font-size: 0.82rem;
    border-radius: 8px;
}

.card-action-btn {
    flex: 1;
    min-height: 38px;
    padding: 9px 12px;
    border-radius: 8px;
    border: 1px solid #3a3a3a;
    background: #141414;
    color: #d8d8d8;
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
}

.card-action-btn:hover {
    color: var(--black);
    background: var(--white);
    border-color: var(--white);
    box-shadow: 0 2px 10px rgba(255, 255, 255, 0.14);
}

.card-action-btn:active {
    transform: scale(0.96);
}

.card-action-btn.danger {
    color: #e8e8e8;
    background: #161616;
    border-color: #444;
}

.card-action-btn.danger:hover {
    color: #fff;
    background: rgba(255, 90, 90, 0.18);
    border-color: #ff7070;
    box-shadow: 0 2px 10px rgba(255, 90, 90, 0.15);
}

/* PDF — 2 columns filling full screen width */
.pdf-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
    width: 100%;
}

.pdf-item {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 12px;
    padding: 12px;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.22);
    transition: border-color var(--transition), background var(--transition);
}

.pdf-item:hover {
    border-color: #444;
    background: #141414;
}

.pdf-icon {
    width: 100px;
    min-width: 100px;
    min-height: 100px;
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--white);
    flex-shrink: 0;
    background: var(--black);
}

.pdf-icon svg {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.pdf-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    justify-content: flex-start;
}

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

.pdf-title {
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--white);
}

.pdf-date {
    font-size: 0.76rem;
    color: #b0b0b0;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pdf-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    flex-wrap: nowrap;
}

.pdf-actions .card-action-btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: 38px;
    padding: 9px 8px;
    font-size: 0.82rem;
    text-decoration: none;
    text-align: center;
}

.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 — full screen */
.search-popup-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 900;
    background: var(--black);
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
    overflow: hidden;
}

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

.search-popup-panel {
    width: 100%;
    max-width: none;
    min-height: 100dvh;
    height: 100%;
    margin: 0;
    border: none;
    border-radius: 0;
    background: var(--black);
    box-shadow: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: searchPopupIn 0.18s ease;
}

@keyframes searchPopupIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.search-popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    padding: 14px 18px;
    padding-top: max(14px, env(safe-area-inset-top, 0px));
    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 {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 18px;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.search-popup-images.image-list {
    padding: 0;
}

.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;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.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 {
        gap: 10px;
    }

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

    .image-list-thumb {
        min-height: 90px;
    }

    .pdf-icon {
        width: 90px;
        min-width: 90px;
        min-height: 90px;
    }

    .pdf-icon svg {
        width: 26px;
        height: 26px;
    }

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

@media (min-width: 1100px) {
    .image-list {
        gap: 14px;
    }

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

    .image-list-thumb {
        min-height: 104px;
    }

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

    .pdf-list {
        gap: 14px;
    }

    .pdf-icon {
        width: 104px;
        min-width: 104px;
        min-height: 104px;
        border-radius: 10px;
    }

    .pdf-icon svg {
        width: 30px;
        height: 30px;
    }

    .pdf-title {
        font-size: 0.92rem;
    }
}

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

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

@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 clamp(14px, 3.5vw, 20px);
        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 clamp(14px, 3.5vw, 20px) 20px;
    }

    .main-search-hero {
        padding: 26px 0 22px;
        margin-bottom: 8px;
    }

    .main-search-title {
        margin-bottom: 20px;
    }

    .hero-search-pill {
        padding: 14px 18px 14px 20px;
        gap: 12px;
        border-radius: 999px;
    }

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

    .image-list {
        gap: 8px;
    }

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

    .modal {
        width: 100%;
        max-width: 100%;
    }

    .modal .form-row {
        grid-template-columns: 1fr;
    }

    .modal form {
        padding: 14px;
    }

    .form-group input,
    .form-input,
    textarea.form-input,
    select.form-input,
    .filter-input {
        font-size: 16px;
    }

    .workspace-card {
        border-radius: 10px;
    }

    .workspace-top {
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        gap: 8px;
    }

    .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-list {
        gap: 8px;
    }

    .workspace-card .pdf-list {
        padding: 8px;
    }

    .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;
    }
}

/* Phones — single column, comfortable cards */
@media (max-width: 600px) {
    .image-list,
    .pdf-list {
        grid-template-columns: 1fr;
        gap: 10px;
    }

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

    .image-list-item {
        align-items: flex-start;
    }

    .image-list-thumb-wrap {
        width: 84px;
        min-width: 84px;
        height: 84px;
        min-height: 84px;
        align-self: flex-start;
        border-radius: 10px;
    }

    .image-list-thumb {
        min-height: 0;
        height: 100%;
    }

    .image-list-body {
        gap: 5px;
    }

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

    .image-list-keywords {
        font-size: 0.84rem;
        -webkit-line-clamp: 2;
    }

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

    .image-list-badge {
        font-size: 0.66rem;
        padding: 3px 9px;
    }

    .image-list-actions .card-action-btn {
        min-height: 38px;
        padding: 9px 8px;
        font-size: 0.8rem;
    }

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

    .pdf-item {
        align-items: flex-start;
        gap: 12px;
        padding: 12px;
        border-radius: 12px;
    }

    .pdf-icon {
        width: 84px;
        min-width: 84px;
        height: 84px;
        min-height: 84px;
        align-self: flex-start;
        border-radius: 10px;
    }

    .pdf-icon svg {
        width: 26px;
        height: 26px;
    }

    .pdf-title {
        font-size: 0.95rem;
    }

    .pdf-date {
        font-size: 0.76rem;
    }

    .pdf-actions .card-action-btn {
        min-height: 38px;
        padding: 9px 8px;
        font-size: 0.8rem;
    }

    .workspace-card .pdf-list {
        padding: 8px 4px;
    }
}

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

    .app-main {
        padding: 12px clamp(12px, 3vw, 16px) 18px;
    }

    .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 clamp(12px, 3vw, 16px);
        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: 22px 0 18px;
    }

    .main-search-title {
        font-size: clamp(1.2rem, 5.2vw, 1.5rem);
        line-height: 1.3;
        margin-bottom: 18px;
    }

    .hero-search-pill {
        padding: 13px 16px 13px 18px;
        gap: 10px;
        border-radius: 999px;
        width: 100%;
    }

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

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

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

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

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

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

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

    .image-list {
        gap: 8px;
    }

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

    .image-list-thumb-wrap {
        width: 72px;
        min-width: 72px;
        height: 72px;
        min-height: 72px;
        align-self: flex-start;
        border-radius: 8px;
    }

    .image-list-thumb {
        min-height: 0;
        height: 100%;
    }

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

    .image-list-keywords {
        font-size: 0.74rem;
        -webkit-line-clamp: 2;
    }

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

    .image-list-badge {
        font-size: 0.6rem;
        padding: 3px 7px;
        max-width: 50%;
    }

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

    .image-list-actions .card-action-btn {
        min-height: 34px;
        font-size: 0.72rem;
        padding: 7px 5px;
    }

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

    .pdf-list {
        gap: 8px;
    }

    .pdf-item {
        gap: 8px;
        padding: 8px;
    }

    .pdf-icon {
        width: 72px;
        min-width: 72px;
        height: 72px;
        min-height: 72px;
        align-self: flex-start;
        border-radius: 8px;
    }

    .pdf-icon svg {
        width: 24px;
        height: 24px;
    }

    .pdf-title {
        font-size: 0.82rem;
    }

    .pdf-date {
        font-size: 0.68rem;
    }

    .pdf-actions {
        gap: 5px;
    }

    .pdf-actions .card-action-btn {
        min-height: 34px;
        font-size: 0.72rem;
        padding: 7px 5px;
    }

    .workspace-card .pdf-list {
        padding: 6px 4px;
    }
}

/* Very small width */
@media (max-width: 320px) {
    .header-inner {
        padding: 8px 10px;
        gap: 6px;
    }

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

    .header-btn svg {
        width: 10px;
        height: 10px;
    }

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

    .hero-search-pill {
        padding: 12px 14px 12px 16px;
        gap: 9px;
        border-radius: 999px;
    }

    .main-search-title {
        font-size: clamp(1.1rem, 4.8vw, 1.35rem);
    }

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

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

/* Landscape phones */
@media (max-width: 768px) and (max-height: 500px) {
    .main-search-hero {
        padding: 12px 0 16px;
    }

    .main-search-title {
        margin-bottom: 12px;
        font-size: 1.15rem;
    }

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

    .modal {
        max-height: 96dvh;
    }
}

/* Large screens — 2 wide cards fill full width */
@media (min-width: 1200px) {
    .image-list,
    .pdf-list {
        gap: 18px;
    }

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

    .image-list-thumb {
        min-height: 112px;
    }

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

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

    .pdf-icon {
        width: 112px;
        min-width: 112px;
        min-height: 112px;
    }

    .pdf-icon svg {
        width: 32px;
        height: 32px;
    }

    .pdf-title {
        font-size: 1rem;
    }

    .hero-search-pill {
        padding: 16px 24px 16px 26px;
    }
}

@media (min-width: 1600px) {
    .image-list,
    .pdf-list {
        gap: 20px;
    }

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

    .image-list-thumb {
        min-height: 120px;
    }

    .pdf-icon {
        width: 120px;
        min-width: 120px;
        min-height: 120px;
    }

    .pdf-icon svg {
        width: 34px;
        height: 34px;
    }
}

/* Tablet — balanced 2 column */
@media (min-width: 521px) and (max-width: 768px) {
    .image-list-thumb-wrap {
        width: 60px;
        height: 60px;
    }

    .pdf-icon {
        width: 90px;
        min-width: 90px;
        min-height: 90px;
    }

    .pdf-icon svg {
        width: 26px;
        height: 26px;
    }
}

/* 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(clamp(16px, 4vw, 24px), env(safe-area-inset-left));
        padding-right: max(clamp(16px, 4vw, 24px), env(safe-area-inset-right));
        padding-bottom: max(24px, env(safe-area-inset-bottom));
    }

    @media (max-width: 480px) {
        .app-main {
            padding-left: max(clamp(12px, 3vw, 16px), env(safe-area-inset-left));
            padding-right: max(clamp(12px, 3vw, 16px), env(safe-area-inset-right));
            padding-bottom: max(18px, env(safe-area-inset-bottom));
        }
    }

    .login-body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
        padding-bottom: 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));
    }

    .app-header {
        padding-top: env(safe-area-inset-top);
    }
}
