/* ============================================================
   Legal Docs Pro — Claude-Style Modern UI Design
   Style: Warm, Soft, Modern, Professional AI Interface
   ============================================================ */

/* ── Reset & Base ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    /* Backgrounds: Warm off-white */
    --bg-page: #FAF8F5;
    --bg-surface: #FFFFFF;
    --bg-surface-hover: #F2EFE9;
    
    /* Borders: Soft, warm grey-beige */
    --border-subtle: #E8E6E1;
    --border-strong: #D5D2CC;

    /* Actions: Charcoal primary */
    --primary: #C18B63; /* Soft Terracotta accent */
    --primary-hover: #A5734F;
    
    --cta-bg: #2D2B2A; /* Charcoal */
    --cta-hover: #45423E;

    /* Text: Warm Dark Charcoal */
    --text-primary: #2D2B2A;
    --text-secondary: #6B6865;
    --text-muted: #9F9B96;

    /* Semantic */
    --success: #5F7A61;
    --success-bg: rgba(95, 122, 97, 0.1);
    --warning: #C18B63;
    --warning-bg: rgba(193, 139, 99, 0.1);
    --danger: #A75C54;
    --danger-bg: rgba(167, 92, 84, 0.1);
    --info: #647B91;
    --info-bg: rgba(100, 123, 145, 0.1);

    /* Layout & Scale */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    --shadow-soft: 0 4px 12px rgba(45, 43, 42, 0.04);
    --shadow-float: 0 12px 32px rgba(45, 43, 42, 0.08);

    --transition-fast: 150ms cubic-bezier(0.25, 0.1, 0.25, 1);
    --transition-base: 300ms cubic-bezier(0.25, 0.1, 0.25, 1);

    --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "Helvetica Neue", sans-serif;
    --font-heading: "Charter", "Georgia", "Source Serif Pro", serif;
}

html { font-size: 15px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { font-family: var(--font-sans); background: var(--bg-page); color: var(--text-primary); line-height: 1.5; min-height: 100vh; }

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 { font-weight: 500; color: var(--text-primary); line-height: 1.25; }
h1 { font-family: var(--font-heading); font-size: 2.5rem; letter-spacing: -0.01em; margin-bottom: 0.75rem; color: #1F1D1C; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; font-weight: 600; }

a { color: var(--text-primary); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 4px; transition: all var(--transition-fast); cursor: pointer; }
a:hover { color: var(--primary); text-decoration-color: var(--primary); }

p { font-size: 1.0625rem; color: var(--text-secondary); line-height: 1.6; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(45, 43, 42, 0.15); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(45, 43, 42, 0.25); }

/* ── Top Navigation ── */
.app-layout { display: flex; flex-direction: column; min-height: 100vh; }

.top-nav {
    position: sticky; top: 0; left: 0; right: 0; height: 64px;
    background: rgba(250, 248, 245, 0.9); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-subtle);
    z-index: 100; display: flex; align-items: center; justify-content: center;
}

.top-nav-container {
    width: 100%; max-width: 1080px; padding: 0 2rem;
    display: flex; align-items: center; justify-content: space-between;
}

.nav-brand { display: flex; align-items: center; gap: 0.625rem; text-decoration: none; border: none; }
.brand-icon {
    width: 28px; height: 28px; color: var(--primary);
    display: flex; align-items: center; justify-content: center;
}
.brand-icon svg { width: 22px; height: 22px; stroke-width: 2; }
.brand-text { font-size: 1.125rem; font-family: var(--font-heading); font-weight: 600; color: var(--text-primary); }

.main-nav { display: flex; align-items: center; gap: 2rem; }
.nav-item {
    font-size: 0.9375rem; color: var(--text-secondary); text-decoration: none;
    cursor: pointer; transition: color var(--transition-fast); font-weight: 500;
}
.nav-item:hover { color: var(--text-primary); }
.nav-item.active { color: var(--text-primary); border-bottom: 2px solid var(--text-primary); padding-bottom: 4px; }

.nav-user { display: flex; align-items: center; gap: 0.5rem; }
.user-info { display: flex; align-items: center; gap: 0.5rem; }
.user-avatar { width: 32px; height: 32px; background: #EADCD1; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 0.8125rem; font-weight: 600; color: #72513B; }
.btn-logout { background: none; border: none; color: var(--text-secondary); cursor: pointer; transition: color var(--transition-fast); }
.btn-logout:hover { color: var(--danger); }

/* Profile Dropdown Panel */
.profile-panel {
    display: none; position: absolute; right: 0; top: calc(100% + 8px);
    width: 280px; background: var(--bg-surface); border-radius: var(--radius-lg);
    box-shadow: 0 8px 30px rgba(0,0,0,0.12); z-index: 1000;
    border: 1px solid var(--border-subtle);
    animation: fadeSlideDown 0.15s ease;
}
.profile-panel.open { display: block; }
@keyframes fadeSlideDown { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:translateY(0); } }
.pp-header { display:flex; align-items:center; gap:0.75rem; padding:1rem; border-bottom:1px solid var(--border-subtle); }
.pp-avatar {
    width:40px; height:40px; border-radius:50%; background:#EADCD1; color:#72513B;
    display:flex; align-items:center; justify-content:center; font-size:1rem; font-weight:700; flex-shrink:0;
}
.pp-name { font-size:0.9375rem; font-weight:600; color:var(--text-primary); }
.pp-uname { font-size:0.75rem; color:var(--text-muted); }
.pp-section { padding:0.75rem 1rem; }
.pp-label { display:block; font-size:0.75rem; font-weight:500; color:var(--text-muted); margin-bottom:0.25rem; }
.pp-input {
    width:100%; padding:0.5rem 0.625rem; border:1px solid var(--border-subtle);
    border-radius:8px; font-size:0.8125rem; background:var(--bg-page);
    transition:border-color var(--transition-fast); box-sizing:border-box;
}
.pp-input:focus { border-color:var(--primary); outline:none; }
.pp-expand-btn {
    display:flex; align-items:center; justify-content:space-between; width:100%;
    padding:0; background:none; border:none; font-size:0.8125rem; font-weight:500;
    color:var(--text-secondary); cursor:pointer;
}
.pp-expand-btn:hover { color:var(--primary); }
.pp-pw-fields { display:none; }
.pp-pw-fields.open { display:block; }
.pp-footer { padding:0.75rem 1rem; border-top:1px solid var(--border-subtle); }
.pp-save-btn {
    width:100%; padding:0.5rem; font-size:0.8125rem; font-weight:600;
    border:none; border-radius:8px; cursor:pointer;
    background:var(--primary); color:#fff; transition:opacity var(--transition-fast);
}
.pp-save-btn:hover { opacity:0.9; }

/* Wizard Steps */
.wizard-bar {
    display:flex; align-items:center; justify-content:center; gap:0;
    padding:1.5rem 2rem 1rem; margin-bottom:0.5rem;
}
.wizard-step {
    display:flex; align-items:center; gap:0.5rem; cursor:pointer;
    color:var(--text-muted); transition:color 0.2s;
}
.wizard-step span { font-size:0.875rem; font-weight:500; }
.wizard-step.active { color:var(--primary); }
.wizard-step.active .wizard-num { background:var(--primary); color:#fff; }
.wizard-step.done { color:var(--text-primary); }
.wizard-step.done .wizard-num { background:var(--text-primary); color:#fff; }
.wizard-num {
    width:28px; height:28px; border-radius:50%; display:flex; align-items:center; justify-content:center;
    font-size:0.8125rem; font-weight:700; border:2px solid currentColor;
    background:transparent; color:inherit; transition:all 0.2s;
}
.wizard-line { width:48px; height:2px; background:var(--border-subtle); margin:0 0.5rem; }

.wizard-panel { padding:0 2rem 2rem; }
.wizard-panel-header {
    display:flex; align-items:center; justify-content:space-between;
    margin-bottom:1.25rem; gap:1rem;
}

/* Wizard Step 1 */
.drafts-drawer {
    margin-top:1.5rem; padding:1rem; background:var(--bg-page);
    border-radius:var(--radius-lg); border:1px solid var(--border-subtle);
}

/* Wizard Step 2 */
.wizard-intake-grid { display:grid; grid-template-columns:1fr; gap:1.25rem; }
.wizard-intake-grid.has-qa { grid-template-columns:1fr 1fr; }
.wizard-qa-card {
    background:var(--bg-page); border-radius:var(--radius-lg);
    padding:1.25rem; border:1px solid var(--border-subtle);
}
.wizard-elements-section {
    margin-top:1.25rem; background:var(--bg-surface);
    border:1px solid var(--border-subtle); border-radius:var(--radius-lg); overflow:hidden;
}
.wizard-elements-bar {
    display:flex; align-items:center; justify-content:space-between;
    padding:0.875rem 1rem; cursor:pointer; user-select:none;
}
.wizard-elements-bar:hover { background:var(--bg-page); }
.wizard-progress {
    flex:1; max-width:180px; height:6px; background:var(--border-subtle);
    border-radius:3px; overflow:hidden;
}
.wizard-progress-fill {
    height:100%; background:var(--primary); border-radius:3px;
    transition:width 0.3s ease;
}
.wizard-progress-text { font-size:0.75rem; color:var(--text-muted); white-space:nowrap; }
.wizard-elements-body { padding:0 1rem 1rem; }

/* Wizard Step 3 */
.wizard-generate-card {
    max-width:520px; margin:0 auto; text-align:center;
    padding:2rem; background:var(--bg-page); border-radius:var(--radius-lg);
    border:1px solid var(--border-subtle);
}
.wizard-gen-summary {
    margin-bottom:1.25rem; font-size:0.9375rem; color:var(--text-secondary);
    line-height:1.6;
}

/* Option Chips (for checkbox-style fields) */
.option-chips-wrap {
    display:flex; flex-wrap:wrap; gap:0.5rem; padding:0.25rem 0;
}
.option-chip {
    display:inline-flex; align-items:center; padding:0.375rem 0.75rem;
    font-size:0.8125rem; border-radius:20px; cursor:pointer;
    border:1px solid var(--border-subtle); background:var(--bg-page);
    color:var(--text-secondary); transition:all 0.15s; user-select:none;
}
.option-chip:hover { border-color:var(--primary); color:var(--primary); }
.option-chip.selected {
    background:var(--primary); color:#fff; border-color:var(--primary);
}

/* Structured Sub-Fields */
.structured-sub-fields {
    display:flex; flex-direction:column; gap:0.5rem;
}
.sub-field-row {
    display:flex; align-items:center; gap:0.75rem;
}
.sub-field-label {
    min-width:5rem; font-size:0.8125rem; font-weight:500;
    color:var(--text-secondary); white-space:nowrap; flex-shrink:0;
}
.sub-field-input {
    flex:1; padding:0.375rem 0.5rem !important;
    font-size:0.8125rem !important; min-height:auto !important;
}

@media (max-width: 768px) {
    .wizard-intake-grid { grid-template-columns:1fr; }
    .wizard-bar { padding:1rem; }
    .wizard-panel { padding:0 1rem 1rem; }
    .wizard-line { width:24px; }
}

/* ── Main Content ── */
.main-content {
    flex: 1; background: var(--bg-page); min-height: calc(100vh - 64px);
}
.content-container { max-width: 1080px; margin: 0 auto; padding: 3rem 2rem 5rem; }

/* ── Page Header (Hero Area) ── */
.page-header { margin-bottom: 3.5rem; text-align: left; }
.page-header h1 { font-family: var(--font-heading); color: var(--text-primary); }
.page-header p { font-size: 1.125rem; color: var(--text-secondary); max-width: 640px; }

/* ── Workspace Immersive Hero (Claude Style) ── */
.workspace-hero {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    padding: 2rem 0 4rem; max-width: 720px; margin: 0 auto;
}
.greeting { font-family: var(--font-heading); font-size: 2.25rem; color: #1F1D1C; margin-bottom: 0.5rem; letter-spacing: -0.01em; }
.greeting-sub { font-size: 1.125rem; color: var(--text-secondary); margin-bottom: 2.5rem; }

.intent-bar {
    width: 100%; display: flex; align-items: center; gap: 1rem;
    background: var(--bg-surface); border: 1px solid var(--border-strong);
    padding: 0.75rem 0.75rem 0.75rem 1.25rem; border-radius: 1.25rem;
    box-shadow: var(--shadow-soft), 0 12px 24px rgba(45,43,42,0.02);
    cursor: pointer; transition: all var(--transition-base); margin-bottom: 2rem;
}
.intent-bar:hover { box-shadow: var(--shadow-float); border-color: var(--cta-bg); transform: translateY(-1px); }
.intent-icon { color: var(--primary); display: flex; align-items: center; }
.intent-icon svg { width: 22px; height: 22px; }
.intent-text { flex: 1; text-align: left; color: var(--text-muted); font-size: 1.0625rem; font-weight: 400; }
.intent-btn { padding: 0.75rem 1.5rem; border-radius: 0.875rem; font-weight: 600; white-space: nowrap; }

.intent-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; }
.intent-tag {
    background: #EFECE5; border: 1px solid transparent; color: var(--text-secondary);
    padding: 0.5rem 1rem; border-radius: var(--radius-sm); font-size: 0.9375rem;
    cursor: pointer; transition: all var(--transition-fast);
}
.intent-tag:hover { background: #E5E1D8; color: var(--text-primary); }

.workspace-meta {
    display: flex; justify-content: space-around; background: var(--bg-surface);
    border: 1px solid var(--border-subtle); border-radius: 20px;
    padding: 2rem 1rem; margin-bottom: 4rem; box-shadow: 0 4px 12px rgba(45,43,42,0.02);
}
.meta-item {
    flex: 1; text-align: center; border-right: 1px solid var(--border-subtle);
    display: flex; flex-direction: column; gap: 0.5rem; justify-content: center;
}
.meta-item:last-child { border-right: none; }
.meta-label { font-size: 0.875rem; color: var(--text-secondary); }
.meta-value { font-size: 1.75rem; font-family: var(--font-heading); font-weight: 600; color: var(--text-primary); line-height: 1; }



/* ── Buttons (Claude Style) ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.625rem 1.25rem; border-radius: var(--radius-md); font-size: 0.9375rem; font-weight: 500;
    cursor: pointer; transition: all var(--transition-fast); border: 1px solid transparent; outline: none;
    text-decoration: none;
}

.btn-primary { background: var(--cta-bg); color: #fff; border-color: var(--cta-bg); }
.btn-primary:hover { background: var(--cta-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(45,43,42,0.15); }

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

.btn-ghost { background: transparent; color: var(--text-primary); padding: 0.625rem; border: none; }
.btn-ghost:hover { background: var(--bg-surface-hover); border-radius: var(--radius-sm); }

.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ── Form Elements ── */
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; font-size: 0.9375rem; font-weight: 500; color: var(--text-primary); margin-bottom: 0.5rem; }
.form-input {
    width: 100%; padding: 0.75rem 1rem; background: var(--bg-surface);
    border: 1px solid var(--border-strong); border-radius: var(--radius-md);
    color: var(--text-primary); font-family: var(--font-sans); font-size: 0.9375rem;
    transition: all var(--transition-fast); outline: none; box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.form-input:focus { border-color: var(--cta-bg); box-shadow: 0 0 0 3px rgba(45, 43, 42, 0.1); }
.form-input::placeholder { color: var(--text-muted); }

textarea.form-input { min-height: 140px; resize: vertical; line-height: 1.6; }

select.form-input {
    cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236B6865' viewBox='0 0 16 16'%3E%3Cpath d='M4.646 5.646a.5.5 0 0 1 .708 0L8 8.293l2.646-2.647a.5.5 0 0 1 .708.708l-3 3a.5.5 0 0 1-.708 0l-3-3a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 1rem center; padding-right: 2.5rem;
}

/* ── Lists / Tables (Claude Style) ── */
.list-header {
    display: flex; justify-content: space-between; align-items: flex-end;
    margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border-subtle);
}
.list-header h3 { font-size: 1.25rem; font-weight: 600; margin: 0; }

.search-box { position: relative; width: 280px; }
.search-box svg { position: absolute; left: 0.875rem; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); }
.search-box input {
    width: 100%; padding: 0.625rem 1rem 0.625rem 2.25rem; border-radius: var(--radius-md);
    background: var(--bg-surface); border: 1px solid var(--border-strong);
    font-size: 0.9375rem; color: var(--text-primary); outline: none; transition: all var(--transition-fast);
}
.search-box input:focus { border-color: var(--cta-bg); box-shadow: 0 0 0 3px rgba(45, 43, 42, 0.1); }

.list-wrapper { width: 100%; background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); overflow: hidden; }
.list-row {
    display: flex; align-items: center; padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-subtle); transition: background var(--transition-fast); gap: 1rem;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--bg-page); }

.list-icon { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.list-icon svg { width: 18px; height: 18px; }

.list-icon.doc { background: #EEF2F6; color: #647B91; }
.list-icon.pdf { background: #FAEDEC; color: #A75C54; }
.list-icon.ai { background: #F6F0E9; color: #C18B63; }

.list-content { flex: 1; min-width: 0; }
.list-title { font-weight: 500; font-size: 0.9375rem; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 0.5rem; }
.list-meta { font-size: 0.8125rem; color: var(--text-secondary); margin-top: 0.375rem; display: flex; align-items: center; gap: 0.75rem; }
.list-actions { display: flex; gap: 0.5rem; opacity: 0; transition: opacity var(--transition-fast); }
.list-row:hover .list-actions { opacity: 1; }

/* ── Badges ── */
.badge { display: inline-flex; padding: 0.125rem 0.5rem; border-radius: 6px; font-size: 0.75rem; font-weight: 500; letter-spacing: 0.02em; }
.badge-blue { background: #EEF2F6; color: #4A637A; border: 1px solid #D6E3F0; }
.badge-red { background: #FAEDEC; color: #8F4C45; border: 1px solid #F0D4D1; }
.badge-gray { background: #F2EFE9; color: var(--text-secondary); border: 1px solid var(--border-strong); }

/* ── Materials Grid ── */
.materials-filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 2rem; }
.filter-chip {
    padding: 0.5rem 1rem; border-radius: var(--radius-md); background: var(--bg-surface);
    border: 1px solid var(--border-strong); color: var(--text-secondary); font-size: 0.9375rem; font-weight: 500; cursor: pointer; transition: all var(--transition-fast);
}
.filter-chip:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.filter-chip.active { background: var(--cta-bg); border-color: var(--cta-bg); color: #fff; }
.filter-chip .chip-count { margin-left: 0.375rem; opacity: 0.7; font-size: 0.8125rem; }

.materials-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.5rem; }
.material-card {
    padding: 1.5rem; border-radius: var(--radius-lg); background: var(--bg-surface);
    border: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: 1rem;
    transition: all var(--transition-fast);
}
.material-card:hover { box-shadow: var(--shadow-soft); transform: translateY(-2px); border-color: var(--border-strong); }
.material-card .material-header { display: flex; align-items: flex-start; gap: 1rem; }
.material-card .material-title { font-weight: 600; font-size: 1.0625rem; color: var(--text-primary); line-height: 1.3; margin-bottom: 0.375rem; }
.material-card .material-desc { font-size: 0.9375rem; color: var(--text-secondary); line-height: 1.5; }

.material-tags { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: auto; padding-top: 1rem; }
.material-tag { font-size: 0.75rem; color: var(--text-secondary); background: var(--bg-page); padding: 0.25rem 0.625rem; border-radius: 6px; border: 1px solid var(--border-subtle); }

/* ── Templates Grid (AI) ── */
.templates-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.25rem; margin-bottom: 3rem; }
.template-card {
    padding: 1.5rem; border-radius: var(--radius-lg); background: var(--bg-surface);
    border: 1px solid var(--border-subtle); cursor: pointer; transition: all var(--transition-fast);
}
.template-card:hover { border-color: var(--border-strong); background: var(--bg-page); box-shadow: var(--shadow-soft); transform: translateY(-1px); }
.template-card.selected { border-color: var(--cta-bg); background: #FAF9F8; box-shadow: 0 0 0 1px var(--cta-bg); }
.template-card h4 { font-size: 1.0625rem; font-weight: 600; margin-bottom: 0.375rem; color: var(--text-primary); }
.template-card p { font-size: 0.875rem; color: var(--text-secondary); line-height: 1.5; }

.draft-workspace { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.9fr); gap: 1.5rem; }
.draft-main-column, .draft-side-column { min-width: 0; }
.draft-card-subtitle { font-size: 0.8125rem; color: var(--text-secondary); margin-top: 0.25rem; }
.draft-compose-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(260px, 0.9fr); gap: 1rem; align-items: start; }
.draft-intake-panel, .draft-question-panel {
    background: var(--bg-page); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg); padding: 1rem;
}
.draft-textarea, .draft-answer-textarea { min-height: 168px; resize: vertical; }
.draft-action-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem; }
.draft-sources-list { display: flex; flex-direction: column; gap: 0.625rem; margin-top: 1rem; }
.draft-source-row {
    display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
    padding: 0.75rem 0.875rem; border-radius: var(--radius-md); background: var(--bg-surface);
    border: 1px solid var(--border-subtle); font-size: 0.875rem;
}
.draft-source-row strong { color: var(--text-primary); font-weight: 600; }
.draft-source-meta { color: var(--text-secondary); font-size: 0.75rem; margin-top: 0.25rem; }
.draft-source-badge, .draft-status-pill, .draft-badge {
    display: inline-flex; align-items: center; justify-content: center; border-radius: 999px;
    padding: 0.25rem 0.625rem; font-size: 0.75rem; font-weight: 600;
}
.draft-status-pill { background: #F5F0E6; color: #8B5E34; }
.draft-badge.required { background: #FBE9E7; color: #B34D33; }
.draft-badge.optional { background: #EEF2F6; color: #516273; }
.draft-badge.status-filled { background: #E8F4EA; color: #2C7A4B; }
.draft-badge.status-missing { background: #FDF0E6; color: #B35D1F; }
.draft-badge.status-needs_review { background: #FDEBEC; color: #B42318; }
.draft-question-header { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.draft-question-panel h4 { margin: 0; font-size: 1rem; }
.draft-question-copy { color: var(--text-secondary); font-size: 0.9375rem; line-height: 1.6; margin-bottom: 1rem; }
.draft-elements-summary {
    display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem;
    padding: 0.875rem 1rem; border-radius: var(--radius-lg); background: var(--bg-page);
    border: 1px solid var(--border-subtle); color: var(--text-secondary); font-size: 0.875rem;
}
.draft-elements-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.draft-element-card {
    background: var(--bg-page); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
    padding: 1rem; display: flex; flex-direction: column; gap: 0.875rem;
}
.draft-element-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; }
.draft-element-title { font-size: 0.9375rem; font-weight: 600; color: var(--text-primary); }
.draft-element-meta { font-size: 0.75rem; color: var(--text-secondary); }
.draft-element-badges { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; }
.drafts-list { display: flex; flex-direction: column; gap: 0.75rem; }
.draft-list-item {
    padding: 0.875rem 1rem; border-radius: var(--radius-md); border: 1px solid var(--border-subtle);
    background: var(--bg-page); cursor: pointer; transition: all var(--transition-fast);
}
.draft-list-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-soft); }
.draft-list-item.active { border-color: var(--cta-bg); box-shadow: 0 0 0 1px var(--cta-bg); background: #FAF9F8; }
.draft-list-title { font-size: 0.9375rem; font-weight: 600; color: var(--text-primary); margin-bottom: 0.35rem; }
.draft-list-meta { font-size: 0.8125rem; color: var(--text-secondary); line-height: 1.5; }
.draft-result-meta {
    display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem;
    font-size: 0.875rem; color: var(--text-secondary);
}
.draft-result-meta span {
    display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.4rem 0.75rem;
    border-radius: 999px; background: var(--bg-page); border: 1px solid var(--border-subtle);
}
.preview-image-wrap { display: flex; justify-content: center; padding: 1.5rem; background: var(--bg-surface); }
.preview-image-wrap img { max-width: 100%; height: auto; border-radius: var(--radius-md); box-shadow: var(--shadow-soft); }

/* ── Upload Area ── */
.upload-area {
    border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); padding: 4rem 2rem;
    text-align: center; cursor: pointer; background: var(--bg-surface); transition: all var(--transition-fast); margin-bottom: 2rem;
}
.upload-area:hover { background: var(--bg-surface-hover); border-color: var(--text-muted); }
.upload-area svg { width: 36px; height: 36px; color: var(--text-muted); margin-bottom: 1.25rem; }
.upload-area h3 { font-size: 1.125rem; font-weight: 500; color: var(--text-primary); margin-bottom: 0.5rem; }
.upload-area p { color: var(--text-secondary); font-size: 0.9375rem; max-width: 400px; margin: 0 auto; line-height: 1.5; }

/* ── Empty States & Spinners ── */
.loading-state, .empty-state { text-align: center; padding: 4rem 0; color: var(--text-secondary); background: var(--bg-surface); border-radius: var(--radius-lg); border: 1px solid var(--border-subtle); }
.empty-state svg { width: 48px; height: 48px; color: var(--border-strong); margin-bottom: 1.25rem; }
.empty-state h3 { font-weight: 500; font-size: 1.0625rem; margin-bottom: 0.5rem; color: var(--text-primary); }
.empty-state p { font-size: 0.9375rem; }

.spinner { width: 24px; height: 24px; border: 2px solid transparent; border-top-color: var(--text-muted); border-right-color: var(--text-muted); border-radius: 50%; animation: spin 0.6s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── AI Output & Preview Modal ── */
.ai-output-container { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-soft); }
.ai-output-header { display: flex; justify-content: space-between; align-items: center; padding: 1.25rem 1.5rem; background: var(--bg-page); border-bottom: 1px solid var(--border-subtle); }
.ai-output-header h3 { font-size: 1rem; font-weight: 600; margin: 0; }
.ai-output { padding: 2.5rem; font-size: 1rem; line-height: 1.7; color: var(--text-primary); max-height: 60vh; overflow-y: auto; background: var(--bg-surface); font-family: var(--font-heading); }
.ai-output h1 { font-size: 1.5rem; margin: 1.5rem 0 0.75rem; font-weight: 600; }
.ai-output p { margin-bottom: 1rem; }

.modal-overlay {
    position: fixed; inset: 0; background: rgba(45, 43, 42, 0.4); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 2rem;
    opacity: 0; visibility: hidden; transition: opacity var(--transition-fast);
}
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal {
    width: 100%; max-width: 860px; max-height: 85vh; background: var(--bg-surface);
    border-radius: 20px; display: flex; flex-direction: column;
    box-shadow: var(--shadow-float); transform: scale(0.98) translateY(10px); transition: all var(--transition-fast);
    overflow: hidden; border: 1px solid var(--border-subtle);
}
.modal-overlay.show .modal { transform: scale(1) translateY(0); }
.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border-subtle); display: flex; align-items: center; justify-content: space-between; background: var(--bg-page); }
.modal-body { flex: 1; overflow-y: auto; background: var(--bg-page); }

/* ── Login Page ── */
.login-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-page); }
.login-card { width: 100%; max-width: 380px; padding: 3rem; background: var(--bg-surface); border-radius: 24px; box-shadow: var(--shadow-soft); border: 1px solid var(--border-subtle); }
.login-card .logo { text-align: center; margin-bottom: 2rem; color: var(--primary); }
.login-card h1 { font-family: var(--font-heading); font-size: 1.75rem; letter-spacing: -0.02em; text-align: center; margin-bottom: 0.5rem; }
.login-card p { color: var(--text-secondary); margin-bottom: 2rem; text-align: center; }

/* ── Views ── */
.view { display: none; }
.view.active { display: block; animation: fadeView 0.2s ease-out; }
@keyframes fadeView { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ── Toast ── */
.toast-container { position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
    display: flex; align-items: center; gap: 0.625rem; padding: 0.875rem 1.25rem;
    background: var(--text-primary); color: #fff;
    border-radius: var(--radius-md); font-size: 0.9375rem; font-weight: 500;
    box-shadow: 0 8px 16px rgba(45,43,42,0.15); animation: toastUp 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
}
.toast-close { display: none; }
@keyframes toastUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* ── Responsive ── */
/* ── Document Manager ── */
.doc-view-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap;
}
.doc-toolbar {
    display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
}

.breadcrumb { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.375rem; }
.breadcrumb-item {
    font-size: 0.9375rem; color: var(--text-secondary); cursor: pointer;
    transition: color var(--transition-fast);
}
.breadcrumb-item:hover { color: var(--primary); }
.breadcrumb-item.active { color: var(--text-primary); font-weight: 500; pointer-events: none; }
.breadcrumb-sep { color: var(--border-strong); font-size: 0.875rem; }

/* Folder rows */
.list-icon.folder { background: #F5F0E6; color: #C18B63; }
.folder-row { cursor: pointer; }
.folder-row:hover { background: #FBF9F5; }
.folder-row .list-actions { gap: 0.25rem; }

/* ── Chat Layout ── */
.chat-layout {
    display: flex; gap: 0; height: calc(100vh - 64px - 6rem);
    border: 1px solid var(--border-subtle); border-radius: 20px;
    overflow: hidden; background: var(--bg-surface);
}

.chat-sidebar {
    width: 260px; min-width: 260px; padding: 1.25rem;
    border-right: 1px solid var(--border-subtle);
    display: flex; flex-direction: column; overflow-y: auto;
    background: var(--bg-page);
}

.session-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 0.25rem; }
.session-item {
    padding: 0.75rem 1rem; border-radius: var(--radius-md);
    cursor: pointer; transition: all var(--transition-fast);
    display: flex; justify-content: space-between; align-items: center;
}
.session-item:hover { background: var(--bg-surface-hover); }
.session-item.active { background: var(--bg-surface); box-shadow: var(--shadow-soft); }
.session-title { font-size: 0.9375rem; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.session-time { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; margin-left: 0.5rem; }
.session-delete { opacity: 0; color: var(--text-muted); background: none; border: none; cursor: pointer; padding: 2px; transition: all var(--transition-fast); }
.session-item:hover .session-delete { opacity: 1; }
.session-delete:hover { color: var(--danger); }

.chat-main {
    flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative;
}

.chat-welcome {
    flex: 1; display: flex; align-items: center; justify-content: center;
}

.chat-messages {
    flex: 1; overflow-y: auto; padding: 2rem 2rem 1rem; display: flex; flex-direction: column; gap: 1.5rem;
}

.msg-bubble { max-width: 85%; line-height: 1.65; font-size: 1rem; }
.msg-bubble.user {
    align-self: flex-end; background: var(--cta-bg); color: #fff;
    padding: 1rem 1.25rem; border-radius: 18px 18px 4px 18px;
}
.msg-bubble.model {
    align-self: flex-start; background: transparent; color: var(--text-primary);
    padding: 0.5rem 0;
}
.msg-bubble.model p { margin-bottom: 0.75rem; }
.msg-bubble.model h1, .msg-bubble.model h2, .msg-bubble.model h3 {
    margin-top: 1rem; margin-bottom: 0.5rem; font-family: var(--font-heading);
}
.msg-bubble.model code { background: var(--bg-page); padding: 0.125rem 0.375rem; border-radius: 4px; font-size: 0.875rem; }
.msg-bubble.model pre { background: var(--bg-page); padding: 1rem; border-radius: var(--radius-md); overflow-x: auto; margin: 0.75rem 0; }
.msg-bubble.model ul, .msg-bubble.model ol { padding-left: 1.5rem; margin-bottom: 0.75rem; }
.msg-bubble.model li { margin-bottom: 0.25rem; }

/* Streaming cursor */
.msg-streaming::after {
    content: ''; display: inline-block; width: 2px; height: 1.1em;
    background: var(--primary); margin-left: 2px; vertical-align: text-bottom;
    animation: blink 0.8s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.chat-input-bar {
    padding: 1rem 2rem 1.5rem; border-top: 1px solid var(--border-subtle); background: var(--bg-surface);
}
.chat-input-wrapper {
    display: flex; align-items: flex-end; gap: 0.75rem; background: var(--bg-page);
    border: 1px solid var(--border-strong); border-radius: 16px;
    padding: 0.5rem 0.5rem 0.5rem 1.25rem; transition: border-color var(--transition-fast);
}
.chat-input-wrapper:focus-within { border-color: var(--cta-bg); box-shadow: 0 0 0 3px rgba(45,43,42,0.08); }
.chat-input {
    flex: 1; border: none; outline: none; background: transparent; resize: none;
    font-family: var(--font-sans); font-size: 1rem; color: var(--text-primary);
    line-height: 1.5; max-height: 150px; padding: 0.375rem 0;
}
.chat-input::placeholder { color: var(--text-muted); }
.chat-send-btn { border-radius: 12px !important; padding: 0.625rem !important; flex-shrink: 0; }
.chat-send-btn svg { width: 18px; height: 18px; }
.chat-disclaimer { font-size: 0.75rem; color: var(--text-muted); text-align: center; margin-top: 0.5rem; }

/* Attach menu */
.attach-btn { padding: 0.375rem; color: var(--text-secondary); }
.attach-btn:hover { color: var(--primary); }
.attach-menu {
    display: none; position: absolute; bottom: 100%; left: 0; margin-bottom: 8px;
    background: var(--bg-surface); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md); box-shadow: var(--shadow-float);
    min-width: 180px; z-index: 10; overflow: hidden;
}
.attach-menu.show { display: block; }
.attach-menu button {
    display: flex; align-items: center; gap: 0.5rem; width: 100%;
    padding: 0.75rem 1rem; border: none; background: none; cursor: pointer;
    font-size: 0.9375rem; color: var(--text-primary); text-align: left;
    transition: background var(--transition-fast);
}
.attach-menu button:hover { background: var(--bg-surface-hover); }

/* Attached files chips */
.chat-attachments {
    display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0 0 0.75rem;
}
.attach-chip {
    display: inline-flex; align-items: center; gap: 0.375rem;
    background: var(--bg-page); border: 1px solid var(--border-subtle);
    border-radius: 8px; padding: 0.375rem 0.625rem; font-size: 0.8125rem;
    color: var(--text-primary); max-width: 200px;
}
.attach-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip .chip-remove {
    cursor: pointer; color: var(--text-muted); background: none; border: none;
    padding: 0; line-height: 1; font-size: 1rem;
}
.attach-chip .chip-remove:hover { color: var(--danger); }

/* Doc picker items */
.doc-pick-item {
    display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem;
    border-radius: var(--radius-md); cursor: pointer;
    transition: background var(--transition-fast);
}
.doc-pick-item:hover { background: var(--bg-surface-hover); }

/* Tool call status */
.tool-status {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1rem; background: var(--bg-page);
    border-radius: var(--radius-md); font-size: 0.9375rem;
    color: var(--text-secondary);
}
.msg-bubble.model a { color: var(--primary); text-decoration: underline; font-weight: 500; }
.msg-bubble.model a:hover { opacity: 0.8; }

/* Stats container */
.stats-container {
    display: flex; gap: 3rem; padding: 1.5rem 0;
}
.stat-item { text-align: center; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); line-height: 1.2; }
.stat-label { font-size: 0.875rem; color: var(--text-muted); margin-top: 0.25rem; }

/* AI output */
.ai-output { padding: 2rem; font-size: 1rem; line-height: 1.7; }

@media (max-width: 768px) {
    .main-nav { display: none; }
    .top-nav-container > .nav-user { display: none; }
    .main-nav .nav-user { display: flex; }
    .content-container { padding: 2rem 1.5rem; }
    .stats-container { grid-template-columns: 1fr; }
    .materials-grid { grid-template-columns: 1fr; }
    .workspace-meta { flex-direction: column; gap: 1.5rem; padding: 1.5rem; }
    .meta-item { border-right: none; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border-subtle); }
    .meta-item:last-child { border-bottom: none; padding-bottom: 0; }
    .draft-workspace, .draft-compose-grid, .draft-elements-list { grid-template-columns: 1fr; }
    .draft-action-row { flex-direction: column; }
}

body.no-scroll { overflow: hidden; }

.main-content,
.content-container,
.chat-layout,
.chat-main,
.draft-workspace,
.draft-main-column,
.draft-side-column,
.wizard-panel,
.wizard-elements-list,
.materials-grid {
    min-width: 0;
}

.mobile-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-primary);
    box-shadow: none;
    position: relative;
    z-index: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.mobile-menu-toggle svg {
    width: 20px;
    height: 20px;
}

.mobile-nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(45, 43, 42, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base);
    z-index: 140;
}

.mobile-nav-backdrop.open {
    opacity: 1;
    visibility: visible;
}

.chat-mobile-header {
    display: none;
}

.chat-mobile-title {
    flex: 1;
    text-align: center;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.filter-divider {
    width: 1px;
    min-height: 24px;
    background: var(--border-subtle);
    align-self: center;
    flex-shrink: 0;
}

.material-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: #F5F0E6;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.material-icon svg {
    width: 20px;
    height: 20px;
}

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

.material-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
}

.material-meta {
    margin-top: 0.3rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.material-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: auto;
}

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

.glass-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: var(--bg-page);
    border-bottom: 1px solid var(--border-subtle);
}

.card-header h3 {
    margin: 0;
}

.card-body {
    padding: 1.25rem 1.5rem;
    background: var(--bg-surface);
}

.modal-body iframe {
    width: 100%;
    min-height: 70vh;
    border: none;
    background: #fff;
}

.preview-content {
    padding: 1.5rem;
    color: var(--text-primary);
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

.docx-preview-container {
    min-height: 100%;
    padding: 1rem;
    background: var(--bg-surface);
    overflow: auto;
}

.docx-preview-container .docx-wrapper {
    background: transparent !important;
    padding: 0 !important;
}

.tool-status {
    flex-wrap: wrap;
}

.msg-bubble.model {
    overflow-wrap: anywhere;
}

.msg-bubble.model pre {
    max-width: 100%;
}

@media (max-width: 768px) {
    html,
    body {
        overflow-x: hidden;
    }

    .mobile-menu-toggle {
        display: inline-flex;
    }

    .top-nav {
        height: auto;
        min-height: 64px;
        z-index: 200;
    }

    .top-nav-container {
        min-height: 64px;
        padding: 0 1rem;
        justify-content: space-between;
        gap: 0.75rem;
    }

    .nav-brand {
        flex: 1;
        min-width: 0;
    }

    .brand-text {
        font-size: 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-menu-toggle {
        margin-left: auto;
        background: var(--bg-surface);
    }

    .main-nav {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: auto;
        width: min(80vw, 300px);
        padding: 0;
        background: var(--bg-surface);
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        transform: translateX(100%);
        transition: transform var(--transition-base);
        z-index: 180;
        overflow-y: auto;
        border-left: 1px solid var(--border-subtle);
        box-shadow: -12px 0 40px rgba(45, 43, 42, 0.12);
    }

    .main-nav.open {
        transform: translateX(0);
    }

    .main-nav::before {
        content: 'Legal Docs Pro';
        display: block;
        padding: 1.25rem 1.25rem 1rem;
        font-family: var(--font-heading);
        font-size: 1.125rem;
        font-weight: 600;
        color: var(--text-primary);
        border-bottom: 1px solid var(--border-subtle);
        background: var(--bg-page);
        flex-shrink: 0;
    }

    .nav-item {
        display: flex;
        align-items: center;
        padding: 0.95rem 1.25rem;
        margin: 0.125rem 0.75rem;
        border-radius: 12px;
        background: transparent;
        font-size: 1.0625rem;
    }

    .nav-item:first-child {
        margin-top: 0.75rem;
    }

    .nav-item.active {
        padding-bottom: 0.95rem;
        border-bottom: none;
        background: var(--bg-page);
        box-shadow: inset 0 0 0 1px var(--border-subtle);
        color: var(--text-primary);
        font-weight: 600;
    }

    .nav-user {
        position: static;
        width: auto;
        margin-top: auto;
        padding: 1rem 1.25rem;
        border-top: 1px solid var(--border-subtle);
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        background: var(--bg-page);
        box-shadow: none;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        transform: none;
        transition: none;
        z-index: auto;
        flex-shrink: 0;
    }

    .nav-user.open {
        transform: none;
    }

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

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

    .nav-user .btn-logout {
        padding: 0.5rem;
        border-radius: 10px;
        background: var(--bg-surface);
    }

    .profile-panel {
        width: 100%;
        right: 0;
        top: auto;
        bottom: calc(100% + 10px);
    }

    .main-content {
        min-height: calc(100dvh - 64px);
    }

    .content-container {
        padding: 1rem 1rem calc(2rem + env(safe-area-inset-bottom));
    }

    .btn {
        min-height: 44px;
    }

    .workspace-hero {
        padding: 1rem 0 2.5rem;
    }

    .greeting {
        font-size: 1.875rem;
    }

    .greeting-sub,
    .page-header p {
        font-size: 1rem;
    }

    .intent-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
        gap: 0.75rem;
    }

    .intent-text {
        text-align: left;
    }

    .intent-btn {
        width: 100%;
    }

    .workspace-meta {
        margin-bottom: 2rem;
    }

    .doc-view-header,
    .list-header,
    .wizard-panel-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .doc-toolbar {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .doc-toolbar .btn,
    .doc-toolbar .search-box,
    .doc-toolbar .search-box input,
    .list-header .search-box,
    .list-header .search-box input {
        width: 100%;
    }

    #upload-form > div {
        flex-direction: column;
        align-items: stretch !important;
    }

    .upload-area {
        padding: 2.5rem 1rem;
    }

    .list-row {
        flex-wrap: wrap;
        align-items: flex-start;
        padding: 1rem;
        gap: 0.875rem;
    }

    .list-icon {
        width: 44px;
        height: 44px;
    }

    .list-content {
        flex: 1 1 calc(100% - 60px);
    }

    .list-title {
        white-space: normal;
        line-height: 1.45;
    }

    .list-meta {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .list-actions {
        opacity: 1;
        width: 100%;
        justify-content: flex-end;
        gap: 0.625rem;
    }

    .list-actions .btn-ghost {
        min-width: 44px;
        min-height: 44px;
        border-radius: 12px;
        background: var(--bg-page);
    }

    .materials-filters {
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 0.625rem;
        margin: 0 -1rem 1.5rem;
        padding: 0 1rem 0.25rem;
        -webkit-overflow-scrolling: touch;
    }

    .filter-divider {
        display: none;
    }

    .filter-chip {
        flex-shrink: 0;
    }

    .stats-container {
        flex-direction: column;
        gap: 1rem;
    }

    .materials-grid,
    .templates-grid,
    .draft-elements-list {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .material-card {
        padding: 1rem;
    }

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

    .chat-layout {
        display: block;
        height: calc(100dvh - 64px - 2rem);
        min-height: 560px;
        border-radius: 20px;
        overflow: hidden;
    }

    .chat-sidebar,
    .chat-main {
        width: 100%;
        min-width: 0;
        height: 100%;
    }

    .chat-sidebar {
        border-right: none;
        padding: 1rem;
    }

    .chat-layout.mobile-sessions .chat-sidebar {
        display: flex;
    }

    .chat-layout.mobile-sessions .chat-main {
        display: none;
    }

    .chat-layout.mobile-thread .chat-sidebar {
        display: none;
    }

    .chat-layout.mobile-thread .chat-main {
        display: flex;
    }

    .chat-mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        padding: 0.875rem 1rem;
        border-bottom: 1px solid var(--border-subtle);
        background: var(--bg-page);
    }

    .chat-mobile-header .btn {
        min-width: 40px;
        min-height: 40px;
    }

    .chat-welcome {
        overflow-y: auto;
    }

    .chat-welcome > div {
        padding: 2rem 1rem 1.5rem !important;
    }

    .chat-messages {
        padding: 1rem 1rem 0.75rem;
        gap: 1rem;
    }

    .msg-bubble {
        max-width: 92%;
        font-size: 0.95rem;
    }

    .chat-input-bar {
        position: sticky;
        bottom: 0;
        z-index: 5;
        padding: 0.875rem 1rem calc(0.875rem + env(safe-area-inset-bottom));
    }

    .chat-attachments {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 0 0 0.75rem;
        margin: 0 -0.25rem;
        -webkit-overflow-scrolling: touch;
    }

    .attach-chip {
        flex-shrink: 0;
        max-width: none;
    }

    .chat-input-wrapper {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .chat-input {
        font-size: 16px;
    }

    .attach-menu {
        max-width: calc(100vw - 2rem);
    }

    .wizard-bar {
        justify-content: flex-start;
        overflow-x: auto;
        gap: 0.25rem;
        margin: 0 -1rem 0.5rem;
        padding: 1rem 1rem 0.75rem;
        -webkit-overflow-scrolling: touch;
    }

    .wizard-step {
        flex: 0 0 auto;
    }

    .wizard-step span {
        font-size: 0.8125rem;
        white-space: nowrap;
    }

    .wizard-line {
        flex: 0 0 24px;
        width: 24px;
    }

    .wizard-panel {
        padding: 0 0 1rem;
    }

    .drafts-drawer {
        margin-top: 1rem;
        padding: 0.875rem;
    }

    .wizard-elements-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .wizard-elements-bar > div {
        width: 100%;
    }

    .wizard-progress {
        max-width: none;
        width: 100%;
    }

    .draft-elements-summary {
        flex-direction: column;
        align-items: flex-start;
    }

    .draft-element-card {
        padding: 0.875rem;
    }

    .draft-element-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .draft-element-badges {
        justify-content: flex-start;
    }

    .sub-field-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.375rem;
    }

    .sub-field-label {
        min-width: 0;
        white-space: normal;
    }

    .wizard-generate-card {
        max-width: none;
        padding: 1.25rem;
    }

    .card-header {
        flex-direction: column;
        align-items: stretch;
    }

    .card-header > div {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .card-header > div .btn {
        width: 100%;
    }

    .draft-result-meta {
        flex-direction: column;
        align-items: stretch;
    }

    .modal-overlay {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
    }

    .modal,
    #doc-picker-modal .modal,
    #new-folder-modal .modal {
        width: 100vw;
        height: 100dvh;
        max-width: none !important;
        max-height: none;
        border-radius: 0;
        border: none;
    }

    .modal-header {
        position: sticky;
        top: 0;
        z-index: 5;
        padding: 1rem;
    }

    .modal-body {
        min-height: 0;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }

    #doc-picker-modal .modal-body,
    #new-folder-modal .modal-body {
        max-height: none !important;
    }

    #new-folder-modal .modal-body > div:last-child {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .content-container {
        padding-left: 0.875rem;
        padding-right: 0.875rem;
    }

    .greeting {
        font-size: 1.625rem;
    }

    .intent-tags {
        gap: 0.5rem;
    }

    .intent-tag,
    .filter-chip {
        font-size: 0.875rem;
    }

    .chat-layout {
        height: calc(100dvh - 64px - 1.75rem);
        min-height: 520px;
    }

    .chat-messages,
    .chat-input-bar,
    .card-body,
    .wizard-elements-body {
        padding-left: 0.875rem;
        padding-right: 0.875rem;
    }

    .msg-bubble {
        max-width: 96%;
    }

    .wizard-step span {
        font-size: 0.75rem;
    }
}
