/* Sociální sítě — one stylesheet, light and dark by the system setting. */

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --border: #dfe3e8;
    --text: #1b2330;
    --muted: #5d6b7c;
    --accent: #2f6fde;
    --accent-text: #ffffff;
    --ok: #1f8a4c;
    --ok-bg: #e3f5ea;
    --bad: #c4352b;
    --bad-bg: #fce8e6;
    --warn: #a66300;
    --warn-bg: #fff2d9;
    --plan: #2f6fde;
    --plan-bg: #e5eefc;
    --busy: #7a4cc2;
    --busy-bg: #efe7fb;
    --radius: 10px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1318;
        --surface: #171c23;
        --surface-2: #1f262f;
        --border: #2b343f;
        --text: #e6ebf1;
        --muted: #93a1b1;
        --accent: #5b92f0;
        --accent-text: #0f1318;
        --ok: #4cc27f;
        --ok-bg: #16301f;
        --bad: #f0746a;
        --bad-bg: #3a1c1a;
        --warn: #f0b24c;
        --warn-bg: #3a2c12;
        --plan: #7aa7f5;
        --plan-bg: #18263d;
        --busy: #b294ea;
        --busy-bg: #2a2140;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 var(--font);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 17px; margin: 0 0 12px; }
code, pre { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.faint { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad); }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ top bar */

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar__inner { max-width: 1200px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; }
.brandmark { font-weight: 700; color: var(--text); white-space: nowrap; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.is-active { color: var(--text); background: var(--surface-2); font-weight: 600; }
.env-badge { background: var(--warn-bg); color: var(--warn); padding: 2px 8px; border-radius: 6px; font-size: 12px; }

.usermenu { position: relative; }
.usermenu summary {
    list-style: none; cursor: pointer; width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-weight: 700;
}
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu__list {
    position: absolute; right: 0; top: 42px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 8px; min-width: 240px; box-shadow: 0 8px 24px rgba(0, 0, 0, .15);
    display: flex; flex-direction: column; gap: 4px;
}
.usermenu__who { display: flex; flex-direction: column; padding: 6px 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.usermenu__list a, .usermenu__list button {
    padding: 6px 8px; border-radius: 6px; color: var(--text); background: none; border: 0; text-align: left; font: inherit; cursor: pointer;
}
.usermenu__list a:hover, .usermenu__list button:hover { background: var(--surface-2); text-decoration: none; }

/* ------------------------------------------------------------------ layout */

.main { max-width: 1200px; margin: 0 auto; padding: 24px 16px 64px; }
.main--bare { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.section { margin-top: 28px; }
.section--alert h2 { color: var(--bad); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row input[type=text], .row select { flex: 1; min-width: 200px; }
.inline { display: inline; margin: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-bottom: 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card--link { color: var(--text); display: block; }
.card--link:hover { border-color: var(--accent); text-decoration: none; }
.card__head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.narrow { max-width: 720px; }
.empty { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 24px; text-align: center; }
.empty .actions { justify-content: center; }
ul.plain { list-style: none; margin: 0; padding: 0; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; max-width: 460px; }
.auth-card h1 { margin-bottom: 12px; }
.detail { white-space: pre-wrap; background: var(--surface-2); padding: 10px; border-radius: 6px; }

/* ------------------------------------------------------------------ controls */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px;
    border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
    font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn--small { min-height: 32px; padding: 0 10px; font-size: 14px; }
.btn--quiet { background: transparent; }
.btn--danger { color: var(--bad); }
.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }
.link:hover { text-decoration: underline; }

input[type=text], input[type=date], input[type=datetime-local], select, textarea {
    width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; padding: 8px 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; line-height: 1.5; }
.filter { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter select, .filter input { width: auto; }
.filter label { display: flex; gap: 6px; align-items: center; color: var(--muted); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.is-active { color: var(--text); border-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.pager { display: flex; gap: 8px; margin-top: 16px; }

/* ------------------------------------------------------------------ badges */

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge--bad { background: var(--bad-bg); color: var(--bad); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--plan { background: var(--plan-bg); color: var(--plan); }
.badge--busy { background: var(--busy-bg); color: var(--busy); }
.tag { font-size: 12px; font-weight: 600; color: var(--muted); }

.flashes { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 10px 14px; border-radius: 8px; background: var(--ok-bg); color: var(--ok); }
.flash--error { background: var(--bad-bg); color: var(--bad); }
.token { background: var(--surface); color: var(--text); padding: 8px; border-radius: 6px; user-select: all; white-space: pre-wrap; word-break: break-all; }

/* ------------------------------------------------------------------ post lists */

.post-list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.day-head { padding: 8px 14px; background: var(--surface-2); font-size: 13px; font-weight: 600; color: var(--muted); }
.post-row { display: grid; grid-template-columns: 70px 1fr auto; gap: 12px; padding: 12px 14px; color: var(--text); border-top: 1px solid var(--border); align-items: center; }
.post-row:first-child { border-top: 0; }
.post-row:hover { background: var(--surface-2); text-decoration: none; }
.post-row__when { display: flex; flex-direction: column; font-size: 14px; }
.post-row__meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.post-row__text { display: block; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.post-row__targets { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.net { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.net--ok { background: var(--ok-bg); color: var(--ok); }
.net--bad { background: var(--bad-bg); color: var(--bad); }
.net--plan { background: var(--plan-bg); color: var(--plan); }
.net--busy { background: var(--busy-bg); color: var(--busy); }

/* ------------------------------------------------------------------ editor */

.problems { background: var(--bad-bg); color: var(--bad); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; }
.problems ul { margin: 6px 0 0; padding-left: 20px; }
.editor__grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.accounts { display: flex; flex-direction: column; gap: 6px; }
.account { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; flex-wrap: wrap; }
.account:hover { border-color: var(--accent); }
.account.is-disabled { opacity: .6; cursor: not-allowed; }
.account input { width: 18px; height: 18px; }
.account__note { margin-left: auto; font-size: 13px; color: var(--muted); }
.account__note.is-problem { color: var(--bad); }
.net-name { font-weight: 600; }
.item { margin-bottom: 14px; }
.item__head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.item__title { font-weight: 600; font-size: 14px; }
.counts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; min-height: 22px; }
.count { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-variant-numeric: tabular-nums; }
.count--near { background: var(--warn-bg); color: var(--warn); }
.count--over { background: var(--bad-bg); color: var(--bad); }
.count--note { font-weight: 400; }
.media-preview img, .media-preview video { width: 100%; max-height: 420px; object-fit: contain; border-radius: 8px; background: var(--surface-2); display: block; }
.media-info { font-size: 14px; font-weight: 600; margin: 8px 0; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.buttons { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.blockers { color: var(--bad); font-size: 13px; padding-left: 18px; margin: 12px 0 0; }

/* ------------------------------------------------------------------ detail and stats */

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.thread-item { padding: 10px 0; border-top: 1px solid var(--border); }
.thread-item:first-of-type { border-top: 0; }
.thread-item__text { white-space: normal; word-wrap: break-word; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: 10px 12px; text-align: left; border-top: 1px solid var(--border); vertical-align: top; }
.table th { background: var(--surface-2); font-size: 13px; color: var(--muted); font-weight: 600; border-top: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; }
.tile__label { color: var(--muted); font-size: 13px; }
.tile__value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bars { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.bars__row { display: grid; grid-template-columns: 80px 1fr 220px; gap: 10px; align-items: center; font-size: 13px; }
.bars__track { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bars__fill { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bars__value { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ small screens */

@media (max-width: 860px) {
    .editor__grid, .detail-grid { grid-template-columns: 1fr; }
    .topbar__inner { flex-wrap: wrap; }
    .nav { order: 3; flex-basis: 100%; }
    .post-row { grid-template-columns: 56px 1fr; }
    .post-row__targets { grid-column: 2; justify-content: flex-start; }
    .table { display: block; overflow-x: auto; }
    .bars__row { grid-template-columns: 60px 1fr; }
    .bars__value { grid-column: 2; }
}
