/* ==========================================================================
   Lulu — Royco internal comms tool
   Royco brand tokens applied to a productivity webapp surface.
   Source of truth for tokens: ~/.claude/skills/royco-design/colors_and_type.css
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Shippori+Mincho+B1:wght@400;500;600;700&display=swap');

:root {
    /* Royco palette */
    --paper:          #FBF6ED;
    --paper-cream:    #FBF6ED;
    --paper-deep:     #F4ECDD;
    --ink:            #0F0E0D;
    --ink-soft:       #1A1815;
    --ink-black:      #101010;
    --muted:          #83715C;
    --muted-soft:     #A99780;
    --sand:           #D4C5B4;
    --stone:          #B6B3AD;
    --hairline:       #D4C5B4;
    --hairline-cool:  #B6B3AD;
    --hairline-soft:  #E5DDC8;
    --bronze:         #DA913E;
    --bronze-deep:    #83715C;
    --senior:         rgb(206, 247, 209);
    --junior:         rgb(248, 255, 212);

    /* Surfaces */
    --surface:        var(--paper);
    --surface-raised: #FFFEF8;
    --surface-sunken: rgba(212, 197, 180, 0.18);

    /* Type */
    --font-display: 'Shippori Mincho B1', 'Cormorant Garamond', Georgia, serif;
    --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono:    ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, monospace;

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-pill: 999px;

    /* Motion */
    --ease-standard: cubic-bezier(0.2, 0, 0, 1);
    --ease-entry:    cubic-bezier(0, 0, 0, 1);
    --dur-fast: 120ms;
    --dur-med:  220ms;
}

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

html, body {
    height: 100%;
    height: 100dvh; /* dynamic viewport height — prevents iOS Safari URL-bar overflow */
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow: hidden;
    /* Safe area insets for notched phones */
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

button { font-family: inherit; }
.hidden { display: none !important; }

/* Paper + moiré background — present everywhere, very subtle */
body {
    position: relative;
}
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background: url('/static/assets/bg-paper-texture.png') center / cover no-repeat;
    opacity: 0.10;
    pointer-events: none;
    z-index: 0;
}
body::after {
    content: "";
    position: fixed;
    inset: 0;
    background: linear-gradient(
        rgba(251, 246, 237, 0.55) 0%,
        rgba(251, 246, 237, 0.00) 28%,
        rgba(251, 246, 237, 0.00) 72%,
        rgba(251, 246, 237, 0.55) 100%
    );
    pointer-events: none;
    z-index: 0;
}
body > * { position: relative; z-index: 1; }

/* Royco-style typography helpers */
.eyebrow {
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: 11px;
    letter-spacing: 0.14em;
    line-height: 1.2;
    text-transform: uppercase;
    color: var(--bronze);
}
.display {
    font-family: var(--font-display);
    font-weight: 500;
    letter-spacing: -0.05em;
    color: var(--ink);
}

/* --- Top utility bar (lang) --- */
.top-bar {
    position: fixed;
    top: 0;
    right: 0;
    padding: 14px 18px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 12px;
}
.lang-selector {
    display: inline-flex;
    background: var(--surface-raised);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-md);
    padding: 3px;
}
.lang-selector button {
    background: transparent;
    color: var(--muted);
    border: none;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    cursor: pointer;
    border-radius: 6px;
    transition: color var(--dur-fast), background var(--dur-fast);
}
.lang-selector button:hover { color: var(--ink); }
.lang-selector button.active { background: var(--ink); color: var(--paper); }

/* ==========================================================================
   LOGIN SCREEN
   ========================================================================== */
.login-screen {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 1.25rem;
}
.login-mark {
    color: var(--ink);
    margin-bottom: 0.5rem;
}
.login-mark svg { display: block; height: 56px; width: 56px; }
.login-wordmark {
    margin-bottom: 1.25rem;
    color: var(--ink);
}
.login-wordmark img {
    display: block;
    height: 44px;
    width: auto;
}
.login-eyebrow {
    margin-bottom: 0.5rem;
}
.login-screen h1 {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 88px;
    line-height: 1;
    letter-spacing: -0.07em;
    color: var(--ink);
    margin: 0;
}
.login-screen .subtitle {
    color: var(--muted);
    font-style: italic;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    letter-spacing: 0.01em;
}
.login-screen input[type="password"] {
    background: var(--surface-raised);
    border: 1px solid var(--hairline);
    color: var(--ink);
    padding: 14px 18px;
    font-size: 15px;
    width: 340px;
    max-width: 90vw;
    border-radius: var(--radius-md);
    outline: none;
    font-family: inherit;
    transition: border-color var(--dur-fast);
}
.login-screen input[type="password"]:focus { border-color: var(--ink); }
.login-screen input[type="password"]::placeholder { color: var(--muted-soft); }

.login-screen .login-btn {
    background: var(--ink);
    color: var(--paper);
    border: 1px solid var(--ink);
    padding: 14px 36px;
    font-size: 13px;
    letter-spacing: 0.08em;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: opacity var(--dur-fast), transform var(--dur-fast);
}
.login-screen .login-btn:hover { opacity: 0.86; }
.login-screen .login-btn:active { transform: scale(0.985); }
.login-screen .login-btn:disabled { opacity: 0.5; cursor: not-allowed; }

#login-error {
    color: #B23A3A;
    min-height: 1.2em;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
}

.login-footer {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--muted-soft);
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

/* ==========================================================================
   APP LAYOUT — sidebar + main
   ========================================================================== */
.app-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: 100dvh;
}

/* --- Sidebar --- */
.sidebar {
    background: rgba(244, 236, 221, 0.45);
    border-right: 1px solid var(--hairline);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sidebar-head {
    padding: 18px 18px 12px;
    border-bottom: 1px solid var(--hairline-soft);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
}
.sidebar-brand svg { height: 22px; width: 22px; flex-shrink: 0; }
.sidebar-brand .wordmark {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 20px;
    letter-spacing: -0.04em;
}
.sidebar-brand .label {
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
    margin-left: auto;
}

.new-chat-btn {
    background: var(--ink);
    color: var(--paper);
    border: none;
    padding: 11px 14px;
    border-radius: var(--radius-md);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    transition: opacity var(--dur-fast);
}
.new-chat-btn:hover { opacity: 0.86; }
.new-chat-btn .plus {
    font-size: 16px;
    line-height: 1;
    font-weight: 400;
}

.sidebar-section {
    padding: 14px 14px 4px;
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--bronze);
    font-weight: 500;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.chat-list:empty + .chat-list-empty { display: block; }
.chat-list-empty {
    display: none;
    padding: 12px 16px;
    font-size: 12px;
    color: var(--muted-soft);
    font-style: italic;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--ink-soft);
    font-size: 13px;
    line-height: 1.35;
    border: 1px solid transparent;
    transition: background var(--dur-fast), border-color var(--dur-fast);
    position: relative;
}
.chat-item:hover {
    background: var(--surface-raised);
    border-color: var(--hairline-soft);
}
.chat-item.active {
    background: var(--surface-raised);
    border-color: var(--hairline);
}
.chat-item .pin-icon {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
    color: var(--bronze);
    opacity: 0;
}
.chat-item.pinned .pin-icon { opacity: 1; }
.chat-item .chat-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-item .chat-actions {
    display: none;
    gap: 2px;
}
.chat-item:hover .chat-actions { display: flex; }
.chat-item .chat-action-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    padding: 3px;
    cursor: pointer;
    border-radius: 4px;
    line-height: 0;
    transition: color var(--dur-fast), background var(--dur-fast);
}
.chat-item .chat-action-btn:hover { color: var(--ink); background: var(--paper-deep); }
.chat-item .chat-action-btn svg { width: 12px; height: 12px; display: block; }

.sidebar-foot {
    border-top: 1px solid var(--hairline-soft);
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--muted);
}
.sidebar-foot .logout-btn {
    background: transparent;
    border: 1px solid var(--hairline);
    color: var(--muted);
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 500;
    transition: color var(--dur-fast), border-color var(--dur-fast);
}
.sidebar-foot .logout-btn:hover { color: var(--ink); border-color: var(--ink-soft); }

/* --- Main chat area --- */
.main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}
.main-head {
    padding: 16px 24px 14px;
    border-bottom: 1px solid var(--hairline-soft);
    display: flex;
    align-items: baseline;
    gap: 14px;
}
.main-head .display-name {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 28px;
    letter-spacing: -0.05em;
    color: var(--ink);
    line-height: 1;
}
.main-head .current-chat-title {
    color: var(--muted);
    font-size: 13px;
    letter-spacing: 0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

#messages {
    flex: 1;
    overflow-y: auto;
    padding: 28px 24px;
    max-width: 880px;
    margin: 0 auto;
    width: 100%;
}

.welcome {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}
.welcome .display {
    font-size: 56px;
    color: var(--ink);
    margin-bottom: 16px;
}
.welcome p {
    font-size: 14px;
    max-width: 460px;
    margin: 0 auto;
    line-height: 1.7;
}

/* Messages */
.msg {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--surface-raised);
    border: 1px solid var(--hairline-soft);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    box-shadow: 0 1px 2px rgba(15, 14, 13, 0.03);
}
.msg-user {
    background: #FFFFFF;
    border-color: var(--hairline-soft);
}
.msg-lulu {
    background: var(--surface-raised);
    border-color: var(--hairline);
    border-left: 3px solid var(--bronze);
}
.msg-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--bronze);
    font-weight: 500;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--hairline-soft);
}
.msg-user .msg-meta { color: var(--muted); }
.msg-meta .msg-divider {
    flex: 1;
}
.msg-files {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}
.msg-file-tag {
    background: var(--surface-raised);
    border: 1px solid var(--hairline);
    color: var(--ink-soft);
    padding: 3px 9px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-family: var(--font-mono);
}
.msg-text {
    color: var(--ink);
    font-size: 15px;
    line-height: 1.65;
    word-wrap: break-word;
}
.msg-user .msg-text { white-space: pre-wrap; }
.msg-lulu .msg-text { white-space: normal; }
.msg-lulu .msg-text strong { font-weight: 600; color: var(--ink); }
.msg-lulu .msg-text em {
    font-style: italic;
    font-weight: 400;
    color: var(--ink);
}
/* Signature phrases (English Lulu coinages) get the bronze serif treatment ONLY when explicitly tagged */
.msg-lulu .msg-text em.signature,
.msg-lulu .msg-text .lulu-phrase {
    font-family: var(--font-display);
    color: var(--bronze-deep);
    font-weight: 500;
    font-style: italic;
}
.msg-lulu .msg-text code {
    background: var(--surface-sunken);
    padding: 0.1em 0.4em;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.92em;
    color: var(--ink-soft);
}
.msg-lulu .msg-text pre {
    background: var(--surface-raised);
    border: 1px solid var(--hairline);
    padding: 12px 14px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 10px 0;
}
.msg-lulu .msg-text pre code { background: transparent; padding: 0; }
.msg-lulu .msg-text h1,
.msg-lulu .msg-text h2 {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 22px;
    letter-spacing: -0.04em;
    line-height: 1.25;
    color: var(--ink);
    margin: 22px 0 10px;
}
.msg-lulu .msg-text h1:first-child,
.msg-lulu .msg-text h2:first-child,
.msg-lulu .msg-text h3:first-child,
.msg-lulu .msg-text p:first-child { margin-top: 0; }
.msg-lulu .msg-text h3 {
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--bronze);
    font-weight: 500;
    margin: 18px 0 8px;
}
.msg-lulu .msg-text p {
    margin: 0 0 12px;
}
.msg-lulu .msg-text p:last-child { margin-bottom: 0; }
.msg-lulu .msg-text ul,
.msg-lulu .msg-text ol {
    padding-left: 1.5rem;
    margin: 8px 0 14px;
}
.msg-lulu .msg-text ul ul,
.msg-lulu .msg-text ul ol,
.msg-lulu .msg-text ol ul,
.msg-lulu .msg-text ol ol {
    margin: 6px 0;
}
.msg-lulu .msg-text li {
    margin-bottom: 6px;
    line-height: 1.55;
}
.msg-lulu .msg-text li > p { margin: 0; }
.msg-lulu .msg-text ol {
    list-style: decimal;
}
.msg-lulu .msg-text ol li::marker {
    color: var(--bronze);
    font-weight: 600;
}
.msg-lulu .msg-text ul li::marker {
    color: var(--muted);
}
.msg-lulu .msg-text blockquote {
    border-left: 3px solid var(--hairline);
    padding: 4px 0 4px 14px;
    margin: 10px 0;
    color: var(--muted);
    font-style: italic;
}
.msg-lulu .msg-text hr {
    border: none;
    border-top: 1px solid var(--hairline-soft);
    margin: 18px 0;
}
.msg-lulu .msg-text a {
    color: var(--bronze-deep);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
}

/* Glossary terms — Lulu concepts decorated with hover tooltips. */
.lulu-term {
    position: relative;
    border-bottom: 1px dotted var(--bronze);
    cursor: help;
}
.lulu-term:focus { outline: none; }
.lulu-term:focus-visible {
    background: rgba(218, 145, 62, 0.10);
    border-radius: 3px;
}
.lulu-term-tip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    z-index: 60;
    width: max-content;
    max-width: 320px;
    padding: 10px 12px;
    background: var(--surface-raised);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(15, 14, 13, 0.10);
    color: var(--ink);
    font-family: var(--font-sans);
    font-style: normal;
    font-weight: 400;
    font-size: 12.5px;
    line-height: 1.5;
    text-align: left;
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity 120ms ease, transform 120ms ease;
}
.lulu-term-tip strong {
    display: block;
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 13.5px;
    color: var(--ink);
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}
.lulu-term:hover .lulu-term-tip,
.lulu-term:focus-visible .lulu-term-tip {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
/* If the term sits near the right edge of the bubble, flip the tip to align right */
.lulu-term.tip-right .lulu-term-tip {
    left: auto;
    right: 0;
}

.msg-system {
    background: rgba(178, 58, 58, 0.08);
    border: 1px solid rgba(178, 58, 58, 0.3);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    color: #B23A3A;
    font-size: 13px;
}

/* Input form */
.input-form {
    padding: 12px 24px 24px;
    border-top: 1px solid var(--hairline-soft);
    max-width: 920px;
    margin: 0 auto;
    width: 100%;
    background: transparent;
}
#file-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
#file-chips:empty { display: none; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-raised);
    border: 1px solid var(--hairline);
    padding: 5px 6px 5px 10px;
    border-radius: var(--radius-md);
    font-size: 12px;
    max-width: 280px;
}
.chip-type {
    background: var(--ink);
    color: var(--paper);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
}
.chip-name {
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.chip-size { color: var(--muted); font-size: 11px; }
.chip-remove {
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 3px;
}
.chip-remove:hover { color: var(--ink); background: var(--paper-deep); }

.input-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}
#input {
    flex: 1;
    background: var(--surface-raised);
    color: var(--ink);
    border: 1px solid var(--hairline);
    padding: 12px 14px;
    border-radius: var(--radius-md);
    resize: vertical;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.55;
    min-height: 64px;
    max-height: 240px;
    outline: none;
    transition: border-color var(--dur-fast);
}
#input:focus { border-color: var(--ink-soft); }
#input::placeholder { color: var(--muted-soft); }

.input-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 96px;
}
.upload-btn {
    background: var(--surface-raised);
    color: var(--muted);
    border: 1px solid var(--hairline);
    cursor: pointer;
    border-radius: var(--radius-md);
    padding: 8px;
    transition: color var(--dur-fast), border-color var(--dur-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 36px;
}
.upload-btn:hover { color: var(--ink); border-color: var(--ink-soft); }
.upload-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.mic-btn {
    background: var(--surface-raised);
    color: var(--muted);
    border: 1px solid var(--hairline);
    cursor: pointer;
    border-radius: var(--radius-md);
    padding: 8px;
    transition: color var(--dur-fast), border-color var(--dur-fast), background var(--dur-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 36px;
    position: relative;
}
.mic-btn:hover { color: var(--ink); border-color: var(--ink-soft); }
.mic-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.mic-btn .mic-icon-rec {
    display: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #b54730;
    box-shadow: 0 0 0 0 rgba(181, 71, 48, 0.55);
    animation: lulu-rec-pulse 1.2s ease-out infinite;
}
.mic-btn.recording {
    background: rgba(181, 71, 48, 0.08);
    border-color: #b54730;
    color: #b54730;
}
.mic-btn.recording .mic-icon-idle { display: none; }
.mic-btn.recording .mic-icon-rec { display: block; }
.mic-btn.transcribing {
    color: var(--bronze);
    border-color: var(--bronze);
    cursor: progress;
}
.mic-btn.transcribing .mic-icon-idle {
    animation: lulu-spin 1.2s linear infinite;
    transform-origin: center;
}
@keyframes lulu-spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
@keyframes lulu-rec-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(181, 71, 48, 0.55); }
    70%  { box-shadow: 0 0 0 10px rgba(181, 71, 48, 0); }
    100% { box-shadow: 0 0 0 0 rgba(181, 71, 48, 0); }
}

.send-btn {
    background: var(--ink);
    color: var(--paper);
    border: none;
    padding: 0 14px;
    cursor: pointer;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    flex: 1;
    transition: opacity var(--dur-fast);
}
.send-btn:hover { opacity: 0.86; }
.send-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Drop overlay */
#drop-overlay {
    position: fixed;
    inset: 0;
    background: rgba(251, 246, 237, 0.92);
    backdrop-filter: blur(2px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.drop-box {
    border: 2px dashed var(--bronze);
    background: var(--surface-raised);
    color: var(--ink);
    padding: 60px 80px;
    border-radius: var(--radius-md);
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 32px;
    letter-spacing: -0.04em;
}

/* --- Mobile --- */
.sidebar-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--hairline);
    color: var(--muted);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    cursor: pointer;
    line-height: 0;
}
.sidebar-toggle svg { width: 18px; height: 18px; }

@media (max-width: 760px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        inset: 0 30% 0 0;
        max-width: 320px;
        z-index: 90;
        transform: translateX(-100%);
        transition: transform var(--dur-med) var(--ease-standard);
        background: var(--paper);
        box-shadow: 0 0 24px rgba(0, 0, 0, 0.12);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: inline-flex; }
    .main-head { padding: 12px 16px; gap: 10px; }
    .main-head .display-name { font-size: 22px; }
    #messages { padding: 18px 16px; }
    .input-form { padding: 10px 14px max(18px, env(safe-area-inset-bottom)); }
    .input-buttons { width: 70px; }
    .send-btn { font-size: 11px; padding: 0 8px; }
    .mic-btn { flex: 0 0 32px; padding: 6px; }
    .login-screen h1 { font-size: 64px; }
    .top-bar { padding: 8px; }
    .drop-box { padding: 32px 40px; font-size: 22px; }
    /* iOS Safari zooms when input font-size < 16px on focus. Force 16px on mobile. */
    #input,
    .login-screen input[type="password"] {
        font-size: 16px !important;
    }
    /* Card padding tighter on mobile */
    .msg { padding: 14px 16px; margin-bottom: 14px; }
    .msg-text { font-size: 15px; }
    .lang-selector button { padding: 4px 8px; font-size: 10px; }
    .header-actions button { padding: 4px 8px; font-size: 10px; }
    /* Make sure file chips wrap nicely */
    .chip { max-width: calc(100vw - 80px); }
}

/* Backdrop for mobile sidebar */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 14, 13, 0.4);
    z-index: 80;
}
.sidebar-backdrop.show { display: block; }

/* --- Sidebar foot actions (sync + logout) --- */
.sidebar-foot-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}
.sidebar-foot .sync-btn {
    background: transparent;
    border: 1px solid var(--hairline);
    color: var(--muted);
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 500;
    transition: color var(--dur-fast), border-color var(--dur-fast);
}
.sidebar-foot .sync-btn:hover { color: var(--ink); border-color: var(--ink-soft); }

/* --- Sync modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 14, 13, 0.55);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(2px);
}
.modal-card {
    background: var(--surface-raised);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    max-width: 460px;
    width: 100%;
    padding: 28px 28px 24px;
    position: relative;
    box-shadow: 0 20px 60px rgba(15, 14, 13, 0.25);
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
}
.modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: transparent;
    border: 0;
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    transition: color var(--dur-fast), background var(--dur-fast);
}
.modal-close:hover { color: var(--ink); background: var(--paper-deep); }
.modal-card h2 {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 22px;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
    color: var(--ink);
}
.modal-card .modal-body {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
    margin-bottom: 16px;
}
.modal-primary {
    background: var(--ink);
    color: var(--paper);
    border: 0;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 500;
    transition: opacity var(--dur-fast), transform var(--dur-fast);
}
.modal-primary:hover { opacity: 0.86; }
.modal-primary:active { transform: scale(0.985); }
.modal-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.sync-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--hairline-soft);
    margin-bottom: 18px;
}
.sync-tab {
    background: transparent;
    border: 0;
    padding: 9px 4px;
    margin-right: 12px;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color var(--dur-fast), border-color var(--dur-fast);
}
.sync-tab:hover { color: var(--ink); }
.sync-tab.active {
    color: var(--ink);
    border-bottom-color: var(--ink);
}
.sync-pane { display: flex; flex-direction: column; gap: 10px; }
.sync-code {
    font-family: var(--font-mono);
    font-size: 32px;
    letter-spacing: 0.18em;
    text-align: center;
    padding: 18px 12px;
    background: var(--paper-deep);
    border: 1px dashed var(--hairline);
    border-radius: var(--radius-md);
    color: var(--ink);
    user-select: all;
}
.sync-countdown {
    text-align: center;
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    min-height: 14px;
}
#sync-code-input {
    width: 100%;
    padding: 14px 12px;
    font-family: var(--font-mono);
    font-size: 24px;
    letter-spacing: 0.18em;
    text-align: center;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-md);
    background: var(--paper);
    color: var(--ink);
    outline: none;
    transition: border-color var(--dur-fast);
}
#sync-code-input:focus { border-color: var(--ink); }
.sync-msg {
    font-size: 12px;
    color: var(--muted);
    min-height: 16px;
}
.sync-msg-ok { color: #2c7a3f; }
.sync-msg-error { color: #b54730; }
