:root {
    --bg: #0f172a;
    --bg-soft: #1e293b;
    --panel: #ffffff;
    --panel-alt: #f8fafc;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --ok: #16a34a;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--panel-alt);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Topbar ---------- */
.topbar {
    background: var(--bg);
    color: #e2e8f0;
    box-shadow: var(--shadow);
}
.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
    height: 58px;
    display: flex;
    align-items: center;
    gap: 24px;
}
.brand {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}
.brand:hover { text-decoration: none; }
.brand-mark { color: #60a5fa; font-size: 1.3rem; }
.nav { display: flex; gap: 18px; }
.nav a { color: #cbd5e1; font-weight: 500; }
.nav a:hover { color: #fff; text-decoration: none; }
.user-area { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.user-name { color: #f1f5f9; font-weight: 600; }
.link-muted { color: #94a3b8; font-size: .9rem; }

/* ---------- Layout ---------- */
.container {
    max-width: 1100px;
    margin: 28px auto;
    padding: 0 20px;
}
.footer {
    max-width: 1100px;
    margin: 40px auto 24px;
    padding: 0 20px;
    color: var(--muted);
    font-size: .85rem;
}
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}
.page-head h1 { margin: 0; font-size: 1.6rem; }
.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 860px) {
    .grid { grid-template-columns: 1fr; }
}

/* ---------- Panels ---------- */
.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}
.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 14px;
}
.panel-head h2 { margin: 0; font-size: 1.15rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }

/* ---------- Dropzone ---------- */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: var(--panel-alt);
    padding: 26px 18px;
    text-align: center;
    transition: border-color .15s, background .15s;
    cursor: default;
}
.dropzone.dragover {
    border-color: var(--primary);
    background: #eff6ff;
}
.dz-icon { font-size: 1.8rem; color: var(--primary); }
.dropzone p { margin: 6px 0; }
.link-btn {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    padding: 0;
    font: inherit;
    text-decoration: underline;
}

/* ---------- Progress ---------- */
.upload-progress { margin-top: 14px; }
.progress-name { font-size: .88rem; margin-bottom: 4px; word-break: break-all; }
.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    width: 0;
    background: var(--primary);
    transition: width .12s linear;
}
.progress-meta { text-align: right; font-size: .8rem; color: var(--muted); margin-top: 2px; }

/* ---------- Item list ---------- */
.item-list { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-alt);
}
.item-text { align-items: flex-start; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; word-break: break-all; }
.item-meta { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.text-content {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .88rem;
    max-height: 220px;
    overflow: auto;
}
.empty { color: var(--muted); text-align: center; padding: 18px; }
.hidden { display: none; }

/* ---------- Text form ---------- */
.text-form { display: flex; flex-direction: column; gap: 10px; }
.textarea {
    width: 100%;
    resize: vertical;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .9rem;
}
.textarea:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.text-form-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--panel-alt); text-decoration: none; }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: #fecaca; background: #fff; }
.btn-danger:hover { background: #fef2f2; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.inline-form { display: inline; margin: 0; }

/* ---------- Auth / forms ---------- */
.auth-card {
    max-width: 440px;
    margin: 40px auto;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
}
.auth-card h1 { margin-top: 0; font-size: 1.4rem; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 5px; }
.input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
}
.input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.field-check .check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.field-check input { width: 16px; height: 16px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* ---------- Table ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table th { font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.row-actions { display: flex; gap: 6px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-off { background: #f1f5f9; color: #64748b; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-size: .92rem; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.validation-summary { color: var(--danger); font-size: .88rem; margin-bottom: 12px; }
.validation-summary ul { margin: 0; padding-left: 18px; }
.validation-summary:empty { display: none; }

/* ---------- Share bar ---------- */
.share-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    background: #fff;
    min-width: 200px;
}
.select:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.share-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    background: #eff6ff;
    color: #1d4ed8;
}
.owner-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    background: #f1f5f9;
    color: #475569;
}

/* ---------- Connection badge ---------- */
.conn-badge { font-size: .8rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.conn-on { background: #dcfce7; color: #166534; }
.conn-off { background: #f1f5f9; color: #94a3b8; }
