:root {
    --bg: #f4f5f7;
    --surface: #fff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --primary: #2563eb;
    --primary-text: #fff;
    --radius: 10px;

    --draft: #9ca3af;
    --ready: #2563eb;
    --in_progress: #7c3aed;
    --needs_input: #d97706;
    --review: #0891b2;
    --failed: #dc2626;
    --done: #16a34a;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111318;
        --surface: #1b1e25;
        --text: #e5e7eb;
        --muted: #9ca3af;
        --border: #2d323c;
        --primary: #3b82f6;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--primary); text-decoration: none; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .875em; }
h1 { font-size: 1.5rem; margin: .25rem 0 .75rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }

.container { max-width: 760px; margin: 0 auto; padding: 1rem; }
.muted { color: var(--muted); font-weight: normal; }

/* --- horní lišta ---------------------------------------------------- */
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; justify-content: space-between; align-items: center;
    padding: .75rem 1rem; background: #1f2937; color: #fff;
}
.topbar a { color: #fff; }
.topbar .brand { font-weight: 600; }
.topbar nav { display: flex; gap: 1rem; align-items: center; font-size: .9rem; }
.topbar .muted { color: #9ca3af; }

.breadcrumb { margin: 0; font-size: .875rem; color: var(--muted); }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }

/* --- karty ---------------------------------------------------------- */
.card {
    display: block; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem; margin-bottom: .75rem; color: inherit;
}
.card-link:active { transform: scale(.99); }
.card-attention { border-left: 4px solid var(--needs_input); }
.card-title { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.card-meta, .badges { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .5rem; font-size: .875rem; }
details.card > summary { cursor: pointer; font-weight: 600; }
details.card[open] > summary { margin-bottom: .75rem; }
.section-head { display: flex; justify-content: space-between; align-items: center; }

/* --- stavy ---------------------------------------------------------- */
.badge {
    display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; white-space: nowrap;
    background: var(--border); color: var(--text);
}
.badge-draft { background: var(--draft); color: #fff; }
.badge-ready { background: var(--ready); color: #fff; }
.badge-in_progress { background: var(--in_progress); color: #fff; }
.badge-needs_input, .badge-attention { background: var(--needs_input); color: #fff; }
.badge-review { background: var(--review); color: #fff; }
.badge-failed, .badge-high { background: var(--failed); color: #fff; }
.badge-done { background: var(--done); color: #fff; }

.progress { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--muted); }
.progress-bar { width: 80px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: var(--done); }

.callout { border-radius: var(--radius); padding: 1rem; margin: 1rem 0; background: var(--surface); border: 1px solid var(--border); }
.callout-info { border-color: var(--in_progress); }
.callout-error { border-color: var(--failed); }
.callout-attention { border: 2px solid var(--needs_input); }
.callout-review { border: 2px solid var(--review); }

.agent-banner { padding: .6rem .9rem; border-radius: var(--radius); background: var(--in_progress); color: #fff; margin-bottom: .75rem; font-size: .9rem; }
.agent-banner a { color: #fff; text-decoration: underline; }
.agent-banner .muted { color: #ddd6fe; }
.agent-dead { background: var(--failed); }

.filters { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .5rem; margin-bottom: .5rem; -webkit-overflow-scrolling: touch; }
.filters a { white-space: nowrap; padding: .3rem .75rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: .85rem; color: var(--text); }
.filters a.active { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }

/* --- formuláře ------------------------------------------------------ */
label { display: block; font-weight: 600; margin: .9rem 0 .3rem; font-size: .9rem; }
label:first-child { margin-top: 0; }
input[type=text], input[type=password], textarea, select {
    width: 100%; padding: .65rem .75rem; font: inherit; color: inherit;
    background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.hint { font-size: .8rem; color: var(--muted); margin: .3rem 0 0; }
.field-error { color: var(--failed); font-size: .85rem; margin: .3rem 0 0; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

.btn {
    display: inline-block; padding: .6rem 1rem; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer;
    border: 1px solid var(--border); background: var(--surface); color: var(--text); text-align: center;
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-block { width: 100%; margin-top: 1.25rem; }
.btn-small { padding: .3rem .7rem; font-size: .85rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.actions.secondary { align-items: center; font-size: .85rem; }
form.inline { display: inline; }
.callout form .btn { margin-top: .5rem; }

.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.flash-success { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }

.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.login { max-width: 360px; margin: 10vh auto 0; }
.login h1 { text-align: center; }

/* --- obsah epicu ---------------------------------------------------- */
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown p, .markdown ul, .markdown ol { margin: .5rem 0; }
.markdown pre, pre.log { background: var(--bg); padding: .75rem; border-radius: 8px; overflow-x: auto; }
.markdown img { max-width: 100%; }
.markdown ul:has(input[type=checkbox]) { list-style: none; padding-left: .25rem; }
.markdown input[type=checkbox] { margin-right: .4rem; }
pre.log { max-height: 50vh; white-space: pre-wrap; word-break: break-word; font-size: .78rem; }

.question { padding: .75rem 0; border-top: 1px solid var(--border); }
.question:first-of-type { border-top: 0; }
.question textarea { margin-top: .5rem; }
.answer { margin-top: .4rem; padding-left: .75rem; border-left: 3px solid var(--done); }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.gallery .file { grid-column: 1 / -1; font-size: .9rem; }
.upload { display: flex; gap: .5rem; align-items: center; margin-top: .75rem; flex-wrap: wrap; font-size: .85rem; }
.commits { padding-left: 1.2rem; font-size: .85rem; }
dl.meta { display: grid; grid-template-columns: auto 1fr; gap: .25rem .75rem; margin: 0 0 .75rem; font-size: .9rem; }
dl.meta dt { color: var(--muted); }
dl.meta dd { margin: 0; word-break: break-all; }

@media (max-width: 480px) {
    .row { grid-template-columns: 1fr; }
    .actions .btn { flex: 1 1 auto; }
}
