/* ─────────────────────────────────────────────────────────────────────────
   AsentioCloud — Modern (white default + neutral grays + indigo accent).
   Variable names preserved (--ink-*, --paper-*, --amber-*) dla zgodnosci z reszta
   stylow i kodu — tylko WARTOSCI zmienione. Nie dotykac nazw.
   ───────────────────────────────────────────────────────────────────────── */

@import url("/public/grain.css");

/* Default = LIGHT (modern white). data-theme="dark" overrides ponizej. */
:root, [data-theme="light"] {
    /* Surface palette (od jasnej do ciemnej w skali jasnej) */
    --ink-0: #ffffff;          /* main background */
    --ink-1: #fafafa;           /* sidebar / panel bg */
    --ink-2: #ffffff;           /* card bg */
    --ink-3: #f3f4f6;           /* hover / muted bg */
    --ink-4: #e5e7eb;           /* borders / dividers */
    --ink-5: #d1d5db;           /* strong borders */
    --ink-6: #9ca3af;           /* disabled */

    /* Text */
    --paper-0: #0f172a;          /* headings / primary */
    --paper-1: #1f2937;          /* body */
    --paper-2: #4b5563;          /* secondary */
    --paper-3: #6b7280;          /* meta / h3 */
    --paper-mute: #9ca3af;       /* placeholders */

    /* Accent — indigo (zamiast amber). Nazwy --amber-* zachowane. */
    --amber: #4f46e5;
    --amber-bright: #6366f1;
    --amber-soft: rgba(79, 70, 229, 0.08);
    --amber-glow: rgba(79, 70, 229, 0.20);
    --vermilion: #ef4444;        /* czerwony */
    --moss: #10b981;             /* emerald */
    --moss-soft: rgba(16, 185, 129, 0.10);
    --slate: #64748b;
    --rust: #dc2626;             /* destructive */

    /* Status */
    --ok: #10b981;
    --warn: #f59e0b;
    --danger: #dc2626;

    /* Layout */
    --sidebar-w: 320px;
    --topbar-h: 56px;
    --right-w: 280px;

    /* Typography — nowoczesny sans, bez serifow */
    --font-display: "Inter", "Söhne", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
    --font-body: "Inter", "Söhne", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
    --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

    /* Effects */
    --grain-opacity: 0;
    --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-pop: 0 10px 25px -5px rgba(15, 23, 42, 0.10), 0 8px 10px -6px rgba(15, 23, 42, 0.05);
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --hairline: rgba(15, 23, 42, 0.06);
    --hairline-strong: rgba(15, 23, 42, 0.12);

    --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 280ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark theme — modern charcoal (zero amber). */
[data-theme="dark"] {
    --ink-0: #0a0a0b;
    --ink-1: #111113;
    --ink-2: #1a1a1d;
    --ink-3: #232328;
    --ink-4: #2e2e35;
    --ink-5: #3f3f48;
    --ink-6: #6b6b75;

    --paper-0: #fafafa;
    --paper-1: #e5e7eb;
    --paper-2: #9ca3af;
    --paper-3: #6b7280;
    --paper-mute: #4b5563;

    --amber: #6366f1;
    --amber-bright: #818cf8;
    --amber-soft: rgba(99, 102, 241, 0.12);
    --amber-glow: rgba(129, 140, 248, 0.25);

    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-pop: 0 24px 48px -16px rgba(0, 0, 0, 0.6), 0 4px 12px rgba(0, 0, 0, 0.4);

    --hairline: rgba(255, 255, 255, 0.06);
    --hairline-strong: rgba(255, 255, 255, 0.14);

    --grain-opacity: 0;
}

[data-theme="dark"] body {
    background: var(--ink-0);
}

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

html, body {
    height: 100%;
    background: var(--ink-0);
    color: var(--paper-1);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    font-feature-settings: "ss01", "cv11";
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body {
    background: var(--ink-0);
    overflow: hidden;
}

#main {
    height: 100%;
}

/* Grain overlay disabled in modern theme. */
body::before { display: none; }

/* ─── Typography ───────────────────────────────────────────────────────── */

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--paper-0);
}

h1 { font-size: 22px; line-height: 1.2; }
h2 { font-size: 17px; }
h3 { font-size: 12px; font-family: var(--font-mono); font-weight: 500; text-transform: uppercase; letter-spacing: 0.12em; color: var(--paper-3); }

a {
    color: var(--amber-bright);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover { color: var(--paper-0); }

code, pre, .mono {
    font-family: var(--font-mono);
    font-size: 0.92em;
}

/* ─── Buttons ──────────────────────────────────────────────────────────── */

button, .btn {
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.01em;
    background: var(--amber);
    color: var(--ink-0);
    border: none;
    padding: 9px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15) inset, 0 1px 0 rgba(255, 255, 255, 0.2) inset;
}

button:hover, .btn:hover {
    background: var(--amber-bright);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--amber-glow), 0 0 0 1px rgba(0, 0, 0, 0.15) inset;
}
button:active, .btn:active { transform: translateY(0); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-secondary {
    background: var(--ink-3);
    color: var(--paper-1);
    box-shadow: 0 0 0 1px var(--hairline-strong) inset;
}
.btn-secondary:hover {
    background: var(--ink-4);
    color: var(--paper-0);
    box-shadow: 0 0 0 1px var(--paper-3) inset, 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-ghost {
    background: transparent;
    color: var(--paper-2);
    box-shadow: none;
    padding: 6px 10px;
}
.btn-ghost:hover {
    background: var(--ink-2);
    color: var(--paper-0);
    transform: none;
    box-shadow: none;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--paper-2);
    box-shadow: none;
}
.btn-icon:hover { background: var(--ink-2); color: var(--paper-0); transform: none; box-shadow: none; }

.btn-danger { background: var(--danger); color: var(--paper-0); }
.btn-danger:hover { background: #d44535; }

/* ─── Inputs ───────────────────────────────────────────────────────────── */

input[type="text"], input[type="password"], input[type="url"], input[type="email"],
input[type="search"], textarea, select {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--paper-0);
    background: var(--ink-1);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--radius);
    padding: 10px 12px;
    width: 100%;
    transition: border-color var(--transition), box-shadow var(--transition);
    caret-color: var(--amber);
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--amber);
    box-shadow: 0 0 0 3px var(--amber-soft);
}
input::placeholder, textarea::placeholder { color: var(--paper-mute); }

label {
    display: block;
    font-size: 11px;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--paper-3);
    margin-bottom: 6px;
}

/* ─── App shell ────────────────────────────────────────────────────────── */

.app-root { height: 100%; }

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    height: 100%;
}

.sidebar {
    background: linear-gradient(180deg, var(--ink-1) 0%, var(--ink-0) 100%);
    border-right: 1px solid var(--hairline);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-brand {
    height: var(--topbar-h);
    padding: 0 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--hairline);
}

.brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: linear-gradient(135deg, var(--amber) 0%, var(--vermilion) 100%);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4) inset, 0 4px 12px var(--amber-soft);
    display: grid;
    place-items: center;
    color: var(--ink-0);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
}

.brand-name {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 500;
    color: var(--paper-0);
    letter-spacing: -0.01em;
}
.brand-tag {
    font-family: var(--font-mono);
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--paper-3);
    margin-top: 1px;
}

.sidebar-search {
    padding: 12px 14px;
    border-bottom: 1px solid var(--hairline);
}
.sidebar-search input {
    background: var(--ink-2);
    border: 1px solid transparent;
    padding: 7px 12px;
    font-size: 13px;
    border-radius: var(--radius);
}
.sidebar-search input:focus {
    background: var(--ink-1);
    border-color: var(--hairline-strong);
    box-shadow: 0 0 0 3px var(--amber-soft);
}

.sidebar-section {
    padding: 14px 14px 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sidebar-section h3 {
    font-size: 10.5px;
}

.sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px 12px;
}

.sidebar-foot {
    padding: 10px 14px;
    border-top: 1px solid var(--hairline);
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--ink-1);
}

/* Conversation/Space row */
.row {
    display: grid;
    grid-template-columns: 36px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition);
}
.row:hover { background: var(--ink-2); }
.row.active {
    background: var(--ink-3);
    box-shadow: inset 2px 0 0 var(--amber);
}

.row-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14px;
    color: var(--ink-0);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

.row-content { min-width: 0; }
.row-title {
    font-size: 14px;
    color: var(--paper-0);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}
.row-sub {
    font-size: 12px;
    color: var(--paper-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 1px;
}
.row-time {
    font-size: 10.5px;
    font-family: var(--font-mono);
    color: var(--paper-mute);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.row-active-glow {
    color: var(--amber);
    font-weight: 600;
}

/* ─── Main pane ────────────────────────────────────────────────────────── */

.main {
    display: grid;
    grid-template-rows: var(--topbar-h) 1fr;
    overflow: hidden;
    background: var(--ink-0);
}

.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 22px;
    border-bottom: 1px solid var(--hairline);
    background: linear-gradient(180deg, var(--ink-1) 0%, var(--ink-0) 100%);
}

.topbar-title {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}
.topbar-title strong {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 500;
    color: var(--paper-0);
}
.topbar-title small {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--paper-3);
}

.topbar-grow { flex: 1; }

.topbar-actions { display: flex; gap: 6px; align-items: center; }

.viewport {
    overflow-y: auto;
    padding: 24px 28px;
}

/* Right sidebar (room details) */
.with-right {
    display: grid;
    grid-template-columns: 1fr 320px;
    height: 100%;
    overflow: hidden;
}
.right-panel {
    border-left: 1px solid var(--hairline);
    background: linear-gradient(180deg, var(--ink-1) 0%, var(--ink-0) 100%);
    overflow-y: auto;
    padding: 18px 16px;
}
.right-panel section { margin-bottom: 24px; }
.right-panel h3 { margin-bottom: 10px; }

.member {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: var(--radius);
}
.member:hover { background: var(--ink-2); }
.member .av {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: grid; place-items: center;
    font-family: var(--font-display); font-weight: 600;
    color: var(--ink-0);
}
.member .name { font-size: 13px; color: var(--paper-0); }
.member .sub { font-size: 11px; color: var(--paper-3); font-family: var(--font-mono); }
/* Akcje na czlonku (np. Wyrzuc) — widoczne dopiero na hover, zeby lista
   nie byla wizualnie zaszumiona. Dotyk: zawsze widoczne (focus-within). */
.member .member-action {
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}
.member:hover .member-action,
.member:focus-within .member-action {
    opacity: 1;
    pointer-events: auto;
}

/* Pending invite row — wyblakly. Cancel button widoczny tylko on hover. */
.member-invite { opacity: 0.7; }
.member-invite:hover { opacity: 1; }
.member-invite .cancel-invite {
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}
.member-invite:hover .cancel-invite,
.member-invite:focus-within .cancel-invite {
    opacity: 1;
    pointer-events: auto;
}

.shared-thumb {
    display: grid;
    grid-template-columns: 32px 1fr;
    gap: 10px;
    align-items: center;
    padding: 6px 8px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition);
}
.shared-thumb:hover { background: var(--ink-2); }
.shared-thumb .icon { font-size: 22px; text-align: center; }
.shared-thumb .name { font-size: 12px; color: var(--paper-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shared-thumb .meta { font-size: 10.5px; color: var(--paper-3); font-family: var(--font-mono); }

/* Tabs */
.tab-bar {
    display: flex;
    background: var(--ink-2);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--radius);
    padding: 3px;
    gap: 2px;
}
.tab-bar .tab {
    flex: 1 1 0;
    min-width: 0;
    background: transparent;
    color: var(--paper-3);
    border: none;
    padding: 8px 6px;
    font-size: 12px;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-radius: 5px;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    box-shadow: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tab-bar .tab:hover { color: var(--paper-1); transform: none; box-shadow: none; }
.tab-bar .tab.active {
    background: var(--ink-0);
    color: var(--amber-bright);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 0 0 1px var(--hairline);
    transform: none;
}

/* Image lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 9998;
    display: grid;
    place-items: center;
    cursor: zoom-out;
    animation: fade-in 180ms cubic-bezier(0.4, 0, 0.2, 1);
}
.lightbox-img {
    max-width: 92vw;
    max-height: 88vh;
    border-radius: var(--radius);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.8);
    cursor: default;
    object-fit: contain;
}
.lightbox-loading {
    color: var(--paper-1);
    display: flex;
    align-items: center;
}
.lightbox-toolbar {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10001;
}

/* Modal — wspólna struktura dla popupów (true overlay) */
.modal-backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 9, 7, 0.78);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fade-in 180ms cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    padding: 40px 20px;
}
.modal {
    background: linear-gradient(180deg, var(--ink-2), var(--ink-1));
    border: 1px solid var(--hairline-strong);
    border-radius: var(--radius-xl);
    padding: 28px 32px;
    width: 100%;
    min-width: 320px;
    max-width: 520px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    box-shadow: var(--shadow-pop);
    margin: auto;
    position: relative;
    z-index: 10000;
}

/* App layout — pozwol fixed overlay-om wyjsc poza app-shell */
html, body { overflow: hidden !important; }
.app-root { position: relative; height: 100%; }
.app-shell { position: relative; }

/* ─── Login screen ─────────────────────────────────────────────────────── */

.login-screen {
    height: 100%;
    display: grid;
    place-items: center;
    background:
        radial-gradient(800px 400px at 30% 20%, var(--amber-soft), transparent 60%),
        var(--ink-0);
    position: relative;
}

.login-screen::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(to right, rgba(232, 222, 198, 0.04) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(232, 222, 198, 0.04) 1px, transparent 1px);
    background-size: 64px 64px;
    pointer-events: none;
    mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
}

.login-card {
    position: relative;
    width: 420px;
    background: linear-gradient(180deg, var(--ink-2) 0%, var(--ink-1) 100%);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--radius-xl);
    padding: 32px;
    box-shadow: var(--shadow-pop);
    z-index: 1;
}

.login-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}
.login-header .brand-mark {
    width: 40px; height: 40px; border-radius: 10px; font-size: 22px;
}
.login-title {
    display: flex; flex-direction: column;
}
.login-title h1 {
    font-size: 22px;
    color: var(--paper-0);
    margin: 0;
}
.login-title small {
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--paper-3);
    margin-top: 2px;
}

.login-card .field { margin-bottom: 16px; }
.login-card .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.login-card button[type="submit"], .login-card .btn-primary { width: 100%; padding: 11px 16px; font-size: 14px; }

.login-meta {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--hairline);
    font-size: 12px;
    color: var(--paper-3);
    text-align: center;
}

.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
}
.alert-error {
    background: rgba(192, 57, 43, 0.1);
    color: #f3a89e;
    border: 1px solid rgba(192, 57, 43, 0.3);
}
.alert-warn {
    background: var(--amber-soft);
    color: var(--amber-bright);
    border: 1px solid var(--amber);
}

/* ─── Chat / room view ─────────────────────────────────────────────────── */

.chat {
    display: grid;
    grid-template-rows: 1fr auto;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.msg-hover { position: relative; }
.msg-toolbar {
    position: absolute;
    top: -8px;
    right: 8px;
    display: none;
    gap: 2px;
    padding: 3px;
    background: var(--ink-2);
    border: 1px solid var(--ink-3);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 5;
}
.msg-hover:hover .msg-toolbar { display: flex; }
.msg-tool {
    background: transparent;
    border: 0;
    color: var(--paper-1);
    padding: 4px 7px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
}
.msg-tool:hover { background: var(--ink-3); }
.msg-reactions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 4px;
}
.reaction-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--ink-3);
    border: 1px solid var(--ink-2);
    border-radius: 12px;
    font-size: 12px;
}
.reaction-count { color: var(--muted); font-size: 11px; }

/* Liczniki w zakladkach (Uczestnicy (4), Pliki (10), itd) — odstep od tekstu. */
.tab-bar .tab .count { margin-left: 6px; opacity: 0.65; font-weight: 400; }
.edited-marker {
    margin-left: 6px;
    color: var(--muted);
    font-size: 11px;
    font-style: italic;
}
.edit-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: rgba(204, 142, 53, 0.08);
    border-bottom: 1px solid var(--amber);
    font-size: 12px;
}

.unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    border-radius: 9px;
    background: var(--amber);
    color: var(--ink-1);
    font-size: 11px;
    font-weight: 600;
    margin-left: 6px;
}
.unread-badge.highlight { background: var(--rust); color: white; }

.chat-drop-active {
    outline: 2px dashed var(--amber-bright);
    outline-offset: -8px;
    background: rgba(204, 142, 53, 0.04);
}

.with-right { min-height: 0; overflow: hidden; }
.chat-only { display: contents; }
.composer { flex-shrink: 0; }

.timeline {
    overflow-y: auto;
    padding: 24px 32px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scroll-behavior: smooth;
}

.timeline-empty {
    flex: 1;
    display: grid;
    place-items: center;
    color: var(--paper-3);
    text-align: center;
    padding: 40px;
}
.timeline-empty .glyph {
    font-family: var(--font-display);
    font-size: 56px;
    color: var(--paper-mute);
    margin-bottom: 12px;
}

.day-divider {
    text-align: center;
    margin: 14px 0 8px;
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--paper-mute);
    position: relative;
}
.day-divider::before, .day-divider::after {
    content: "";
    position: absolute;
    top: 50%;
    width: calc(50% - 80px);
    height: 1px;
    background: var(--hairline);
}
.day-divider::before { left: 0; }
.day-divider::after { right: 0; }

.msg {
    display: grid;
    grid-template-columns: 36px 1fr;
    gap: 12px;
    padding: 6px 8px;
    border-radius: var(--radius);
}
.msg:hover { background: var(--ink-1); }

/* Wlasna wiadomosc — chmurka po prawej, ciepla amber palette zeby odsunac od cudzych. */
.msg.msg-self {
    grid-template-columns: 1fr 36px;
}
.msg.msg-self > .msg-avatar { grid-column: 2; grid-row: 1 / span 2; }
.msg.msg-self .msg-bubble {
    grid-column: 1;
    background: linear-gradient(135deg, rgba(217, 152, 73, 0.18), rgba(217, 152, 73, 0.10));
    border: 1px solid rgba(217, 152, 73, 0.35);
    border-radius: 14px 14px 4px 14px;
    padding: 6px 12px 8px;
    max-width: 78%;
    margin-left: auto;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}
.msg.msg-self .msg-meta { justify-content: flex-end; }
.msg.msg-self:hover { background: transparent; }
.msg.msg-self .msg-toolbar { left: auto; right: 52px; }

/* Typing indicator — 3 male kropki obok nicka, animowane. */
.typing-dots {
    display: inline-flex;
    gap: 2px;
    align-items: center;
}
.typing-dots > span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--moss);
    animation: typing-bounce 1s infinite ease-in-out;
}
.typing-dots > span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots > span:nth-child(3) { animation-delay: 0.30s; }
@keyframes typing-bounce {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-2px); }
}

/* Cudza — chmurka po lewej, neutralny ink. */
.msg:not(.msg-self) .msg-bubble {
    background: var(--ink-2);
    border: 1px solid var(--hairline);
    border-radius: 4px 14px 14px 14px;
    padding: 6px 12px 8px;
    max-width: 78%;
}

.msg-avatar {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: grid; place-items: center;
    font-family: var(--font-display); font-weight: 600;
    color: var(--ink-0);
    grid-row: span 2;
}
.msg-avatar.spacer { background: transparent; visibility: hidden; }

.msg-meta {
    display: flex; align-items: baseline; gap: 8px;
}
.msg-author {
    font-weight: 600;
    color: var(--paper-0);
    font-size: 14px;
}
.msg-time {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--paper-mute);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.msg-body {
    font-size: 14px;
    color: var(--paper-1);
    word-break: break-word;
}
.md-content > *:first-child { margin-top: 0; }
.md-content > *:last-child  { margin-bottom: 0; }
.md-content p { margin: 4px 0; }
.md-content pre {
    background: var(--ink-2);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--radius);
    padding: 8px 10px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 12.5px;
    margin: 6px 0;
}
.md-content code {
    background: var(--ink-2);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 12.5px;
}
.md-content pre code { background: transparent; padding: 0; }
.md-content blockquote {
    margin: 6px 0;
    padding: 4px 10px;
    border-left: 3px solid var(--hairline-strong);
    color: var(--paper-2);
}
.md-content ul, .md-content ol { margin: 4px 0; padding-left: 22px; }
.md-content ul ul, .md-content ul ol,
.md-content ol ul, .md-content ol ol { margin: 2px 0; padding-left: 20px; }
.md-content li { margin: 1px 0; }
.md-content ul { list-style: disc; }
.md-content ul ul { list-style: circle; }
.md-content ul ul ul { list-style: square; }
.md-content ol { list-style: decimal; }
.md-content a { color: var(--amber-bright); text-decoration: underline; }
.md-content h1, .md-content h2, .md-content h3 { margin: 8px 0 4px; }
.md-content table { border-collapse: collapse; margin: 6px 0; }
.md-content th, .md-content td {
    border: 1px solid var(--hairline-strong);
    padding: 3px 8px;
    font-size: 13px;
}

.msg-body p { margin: 2px 0; }

.msg-attachment {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--ink-2);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--radius);
    margin-top: 6px;
    cursor: pointer;
    transition: border-color var(--transition);
}

.msg-image {
    display: block;
    max-width: 360px;
    max-height: 320px;
    border-radius: var(--radius);
    margin-top: 6px;
    cursor: pointer;
    border: 1px solid var(--hairline);
    background: var(--ink-2);
    object-fit: cover;
    transition: transform var(--transition);
}
.msg-image:hover {
    transform: scale(1.01);
    border-color: var(--amber);
}

/* Compose pending attachment preview (przed wyslaniem) */
.compose-preview {
    background: var(--ink-1);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.compose-preview .thumb {
    width: 56px; height: 56px;
    border-radius: var(--radius);
    object-fit: cover;
    background: var(--ink-2);
    display: grid; place-items: center;
    font-size: 22px;
}
.compose-preview img.thumb { object-fit: cover; }
.compose-preview .meta { flex: 1; min-width: 0; }
.compose-preview .name { font-size: 13px; color: var(--paper-0); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-preview .size { font-size: 11px; color: var(--paper-3); font-family: var(--font-mono); }
.compose-preview .remove {
    background: transparent; border: none; color: var(--paper-3);
    cursor: pointer; padding: 4px 8px;
    box-shadow: none;
}
.compose-preview .remove:hover { color: var(--danger); transform: none; box-shadow: none; }
.msg-attachment:hover { border-color: var(--amber); }
.msg-attachment .a-icon { font-size: 18px; }
.msg-attachment .a-name { font-size: 13px; color: var(--paper-0); }
.msg-attachment .a-size { font-size: 11px; color: var(--paper-3); margin-left: 6px; font-family: var(--font-mono); }

.msg-system {
    text-align: center;
    font-size: 12px;
    color: var(--paper-3);
    padding: 4px 12px;
    margin: 6px 0;
}

/* Composer */
.composer {
    border-top: 1px solid var(--hairline);
    padding: 14px 24px 18px;
    background: linear-gradient(180deg, var(--ink-0) 0%, var(--ink-1) 100%);
}

.composer-box {
    background: var(--ink-2);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--radius-lg);
    padding: 8px 8px 8px 14px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: end;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.composer-box:focus-within {
    border-color: var(--amber);
    box-shadow: 0 0 0 3px var(--amber-soft);
}

.composer textarea {
    background: transparent;
    border: none;
    padding: 8px 4px;
    resize: none;
    min-height: 22px;
    max-height: 140px;
    font-size: 14px;
    line-height: 1.5;
}
.composer textarea:focus { box-shadow: none; }

.composer-actions { display: flex; gap: 4px; }

.composer-attach-list {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-bottom: 8px;
}
.composer-attach-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--ink-3);
    border: 1px solid var(--hairline-strong);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    color: var(--paper-1);
}
.composer-attach-pill button {
    background: none; border: none; color: var(--paper-3);
    padding: 0; width: 16px; height: 16px;
    cursor: pointer; box-shadow: none;
}
.composer-attach-pill button:hover { color: var(--paper-0); transform: none; box-shadow: none; }

/* ─── Files / space view ───────────────────────────────────────────────── */

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 18px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--paper-3);
}
.breadcrumb a { color: var(--paper-2); }
.breadcrumb a:hover { color: var(--amber-bright); }
.breadcrumb .sep { color: var(--paper-mute); }

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}
.toolbar h2 { flex: 1; }

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

.file-card {
    position: relative;
    background: linear-gradient(180deg, var(--ink-2) 0%, var(--ink-1) 100%);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--radius);
    padding: 14px 14px 12px;
    cursor: pointer;
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
}
.file-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--hairline-strong), transparent);
}
.file-card:hover {
    border-color: var(--amber);
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}

.file-card .icon {
    font-size: 36px;
    width: 100%;
    text-align: center;
    padding: 14px 0 8px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

.file-card .name {
    font-size: 13px;
    color: var(--paper-0);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}
.file-card .meta {
    font-size: 10.5px;
    font-family: var(--font-mono);
    color: var(--paper-3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: flex;
    justify-content: space-between;
}

.folder-card { background: linear-gradient(180deg, var(--ink-3) 0%, var(--ink-2) 100%); }

/* Dropzone */
.dropzone {
    border: 1px dashed var(--hairline-strong);
    border-radius: var(--radius-lg);
    padding: 28px;
    text-align: center;
    color: var(--paper-3);
    margin-bottom: 16px;
    transition: border-color var(--transition), background var(--transition);
}
.dropzone.active { border-color: var(--amber); background: var(--amber-soft); color: var(--amber-bright); }

/* ─── Avatar colors (deterministic) ─────────────────────────────────────── */

.av-1 { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.av-2 { background: linear-gradient(135deg, #10b981, #059669); }
.av-3 { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.av-4 { background: linear-gradient(135deg, #f43f5e, #be123c); }
.av-5 { background: linear-gradient(135deg, #f59e0b, #d97706); }
.av-6 { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.av-7 { background: linear-gradient(135deg, #ec4899, #be185d); }
.av-8 { background: linear-gradient(135deg, #14b8a6, #0f766e); }

/* ─── Misc ─────────────────────────────────────────────────────────────── */

.muted { color: var(--paper-3); font-size: 12px; }
.dim   { color: var(--paper-mute); }

.empty {
    text-align: center;
    color: var(--paper-3);
    padding: 60px 24px;
}
.empty .glyph { font-family: var(--font-display); font-size: 56px; color: var(--paper-mute); }
.empty h3 { color: var(--paper-2); margin: 8px 0 4px; }

.tag-pill {
    display: inline-block;
    padding: 2px 9px;
    background: var(--ink-3);
    border: 1px solid var(--hairline-strong);
    border-radius: 999px;
    font-size: 11px;
    margin-right: 4px;
    color: var(--paper-2);
    font-family: var(--font-mono);
}

.kbd {
    font-family: var(--font-mono);
    font-size: 10.5px;
    padding: 1px 6px;
    background: var(--ink-3);
    border: 1px solid var(--hairline-strong);
    border-radius: 4px;
    color: var(--paper-2);
}

/* Toast */
.toast-wrap {
    position: fixed;
    top: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 200;
}
.toast {
    background: var(--ink-2);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--radius);
    padding: 12px 16px;
    min-width: 280px;
    max-width: 380px;
    box-shadow: var(--shadow-pop);
    animation: toast-in 220ms cubic-bezier(0.4, 0, 0.2, 1);
}
.toast.error { border-left: 3px solid var(--danger); }
.toast.ok    { border-left: 3px solid var(--ok); }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fade-in 220ms cubic-bezier(0.4, 0, 0.2, 1); }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--ink-4);
    border-radius: 999px;
    border: 2px solid var(--ink-0);
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-5); }

/* Spinner */
.spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid var(--paper-mute);
    border-top-color: var(--amber);
    border-radius: 50%;
    animation: spin 720ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Progress */
.progress {
    height: 3px;
    background: var(--ink-3);
    border-radius: 999px;
    overflow: hidden;
}
.progress > div {
    height: 100%;
    background: linear-gradient(90deg, var(--amber), var(--amber-bright));
    transition: width 280ms ease;
}

/* Responsive */
@media (max-width: 920px) {
    .app-shell { grid-template-columns: 80px 1fr; }
    .sidebar-brand .brand-name, .row-content, .row-time, .sidebar-search, .sidebar-section { display: none; }
    .row { grid-template-columns: 36px; justify-content: center; }
}
