:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #1d2433;
    --muted: #6b7280;
    --border: #e2e5ea;
    --primary: #1d4ed8;
    --primary-dark: #1e40af;
    --danger: #b91c1c;
    --green: #15803d;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 1.25rem; }

/* ---------- Top bar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; min-height: 60px; gap: 1rem; }
.brand { font-weight: 700; font-size: 1.05rem; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: .55rem; }
.brand-logo { height: 26px; width: auto; display: block; }
.brand .badge {
    background: var(--primary); color: #fff; font-size: .68rem; font-weight: 600;
    padding: .15rem .45rem; border-radius: 999px; vertical-align: middle; margin-left: .3rem;
    text-transform: uppercase; letter-spacing: .04em;
}
.topnav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.topnav a { color: var(--muted); text-decoration: none; font-size: .95rem; }
.topnav a:hover { color: var(--text); }

/* ---------- Layout ---------- */
.page-main { flex: 1; padding: 2rem 1.25rem 3rem; }
.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem; padding: 1rem 0; background: var(--surface); }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 1.5rem; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem 1.5rem; margin-bottom: 1.25rem;
}
.card h2 { margin-top: 0; font-size: 1.1rem; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.card-link { display: block; text-decoration: none; color: var(--text); transition: border-color .15s, transform .15s; margin-bottom: 0; }
.card-link:hover { border-color: var(--primary); transform: translateY(-2px); }
.card-link h2 { margin: 0 0 .25rem; font-size: 1.05rem; }

.hero { padding: 1.5rem 0 2rem; }
.hero h1 { margin: 0 0 .4rem; font-size: 1.9rem; }
.hero p { margin: 0; color: var(--muted); max-width: 46rem; }

/* ---------- Table ---------- */
.table-card { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: .7rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: #fafbfc; }
tr:last-child td { border-bottom: none; }
.actions-col { white-space: nowrap; }

/* ---------- Chips & badges ---------- */
.chip {
    display: inline-block; font-size: .72rem; font-weight: 600; padding: .12rem .5rem;
    border-radius: 999px; background: #fef3c7; color: #92400e;
}
.chip-blue { background: #dbeafe; color: #1e40af; }
.chip-green { background: #dcfce7; color: var(--green); }
.chip-gray { background: #e5e7eb; color: #4b5563; }

.muted { color: var(--muted); font-size: .88rem; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block; padding: .5rem 1rem; font-size: .92rem; font-weight: 500;
    border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
    color: var(--text); text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s;
}
.btn:hover { background: #f3f4f6; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: .28rem .6rem; font-size: .82rem; }
.btn-block { width: 100%; }
.inline-form { display: inline; }
.linklike {
    background: none; border: none; padding: 0; font: inherit; font-size: .95rem;
    color: var(--muted); cursor: pointer;
}
.linklike:hover { color: var(--text); }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: .9rem; margin: 1.1rem 0 .35rem; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; font-size: .95rem; margin: .8rem 0; }
input[type="text"], input[type="email"], input[type="password"], input[type="file"] {
    width: 100%; padding: .55rem .75rem; font-size: .95rem; border: 1px solid var(--border);
    border-radius: 8px; background: var(--surface); color: var(--text);
}
input:focus, trix-editor:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
.hint { color: var(--muted); font-size: .84rem; margin: .35rem 0 0; }
.field-error { color: var(--danger); font-size: .85rem; margin: .3rem 0 0; }
.form-actions { margin-top: 1.5rem; display: flex; gap: .6rem; }

.slug-row { display: flex; align-items: stretch; }
.slug-prefix {
    display: flex; align-items: center; padding: 0 .6rem; background: #f3f4f6;
    border: 1px solid var(--border); border-right: none; border-radius: 8px 0 0 8px;
    color: var(--muted); font-size: .88rem; white-space: nowrap;
}
.slug-row input { border-radius: 0 8px 8px 0; }

.mode-fieldset { border: 1px solid var(--border); border-radius: 8px; padding: .4rem 1rem .6rem; margin-top: 1.25rem; }
.mode-fieldset legend { font-weight: 600; font-size: .9rem; padding: 0 .4rem; }

trix-editor { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; min-height: 260px; }
trix-toolbar .trix-button-group { background: var(--surface); }
trix-editor img { max-width: 100%; height: auto; }
trix-editor figure.attachment--preview:hover { outline: 2px dashed var(--primary); outline-offset: 2px; cursor: pointer; }

.image-size-bar {
    display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
    margin-bottom: .5rem; font-size: .85rem; color: var(--muted);
}

/* ---------- Alerts ---------- */
.alert { padding: .8rem 1.1rem; border-radius: 8px; margin-bottom: 1.25rem; font-size: .93rem; }
.alert-success { background: #dcfce7; color: #14532d; border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #7f1d1d; border: 1px solid #fecaca; }
.alert-error ul { margin: 0; padding-left: 1.2rem; }

/* ---------- Public doc page ---------- */
.doc h1 { font-size: 1.8rem; margin: .5rem 0 1.25rem; }
.doc-content { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem 1.75rem; }
.doc-content img { max-width: 100%; height: auto; border-radius: 6px; }
.doc-files { margin-top: 1.5rem; }
.doc-files h2 { font-size: 1.15rem; }

.file-list { list-style: none; padding: 0; margin: .5rem 0 1rem; }
.file-list li {
    display: flex; align-items: center; gap: .75rem; padding: .55rem .25rem;
    border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.file-list li:last-child { border-bottom: none; }
.file-list a { color: var(--primary); text-decoration: none; word-break: break-all; }
.file-list a:hover { text-decoration: underline; }
.file-list form { margin-left: auto; }

.upload-form { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-top: .75rem; }
.upload-form input[type="file"] { flex: 1; min-width: 220px; width: auto; }

.public-url-card { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.public-url-card code { background: #f3f4f6; padding: .25rem .5rem; border-radius: 6px; word-break: break-all; }

/* ---------- PDF-as-page ---------- */
.pdf-page { height: 100vh; }
.pdf-main { flex: 1; display: flex; }
.pdf-frame { flex: 1; width: 100%; border: none; }

/* ---------- Auth ---------- */
.auth-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 1.3rem; margin-top: 0; }
.auth-logo { height: 48px; width: auto; display: block; margin: .25rem auto 1rem; }

/* ---------- QR dialog ---------- */
.qr-dialog { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; text-align: center; max-width: 340px; }
.qr-dialog::backdrop { background: rgba(15, 23, 42, .5); }
.qr-dialog h2 { margin-top: 0; }
#qr-box { display: flex; justify-content: center; margin: 1rem 0; }
.dialog-actions { display: flex; gap: .6rem; justify-content: center; }

.empty-state { text-align: center; color: var(--muted); padding: 2.5rem 1.5rem; }

code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; }
