:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --ink: #1f2933;
    --ink-soft: #5b6672;
    --line: #e2e6ea;
    --brand: #0b2740;
    --accent: #1d6fe0;
    --platform: #6b3fd1;
    --danger: #c92f3c;
    --danger-soft: #fde8ea;
    --ok: #1f9d57;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    color: var(--ink);
    background: var(--bg);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; background: #eef1f4; padding: .1em .35em; border-radius: 4px; font-size: .92em; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    height: 56px; padding: 0 24px;
    background: var(--brand); color: #fff;
}
.brand { color: #fff; font-weight: 600; font-size: 1.05rem; letter-spacing: .2px; }
.brand:hover { text-decoration: none; }
.brand-accent { color: #7fb2ff; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topnav { display: flex; align-items: center; gap: 16px; }
.topnav a { color: #cdd7e2; font-size: .9rem; }
.topnav a:hover { color: #fff; text-decoration: underline; }
.user { color: #cdd7e2; font-size: .9rem; }
.inline-form { margin: 0; }
.link-button { background: none; border: none; color: #cdd7e2; cursor: pointer; font: inherit; padding: 0; }
.link-button:hover { color: #fff; text-decoration: underline; }

.content { flex: 1; }
.page { max-width: 1040px; margin: 0 auto; padding: 32px 24px 64px; }

.page-title { font-size: 1.55rem; margin: 0 0 4px; display: flex; align-items: center; gap: 12px; }
.page-subtitle { color: var(--ink-soft); margin: 0 0 24px; }
.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }

.breadcrumb { color: var(--ink-soft); font-size: .9rem; margin-bottom: 12px; }
.breadcrumb .sep { margin: 0 6px; color: #b6c0ca; }

.badge { display: inline-block; font-size: .72rem; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; }
.badge-platform { background: #efe9fb; color: var(--platform); }

/* Version lifecycle badges */
.badge-release { background: #d5f2e3; color: #1a7a4a; }
.badge-candidate { background: #fdeecb; color: #8a5a00; }
.badge-yanked { background: #f8d7da; color: #a81f2b; }
.badge-superseded { background: #e7e9ee; color: #5b6472; }
.badge-attested { background: #d5f2e3; color: #1a7a4a; }
.badge-attest-pending { background: #e7e9ee; color: #5b6472; }
.badge-attest-failed { background: #f8d7da; color: #a81f2b; }
.badge-unmerged { background: #fde2c8; color: #9a4a10; }
.badges-cell { display: flex; flex-wrap: wrap; gap: 4px; }

.notice { background: #eef4ff; border: 1px solid #cddcf7; color: #1d4e8f; padding: 10px 14px; border-radius: var(--radius); margin: 0 0 16px; }
.fetch-cmd { display: block; margin-top: 4px; color: #5b6472; font-size: .78rem; white-space: nowrap; overflow-x: auto; }
.inline-form { display: inline; }
.inline-form .reason { width: 130px; padding: 4px 8px; font-size: .82rem; border: 1px solid var(--line); border-radius: 6px; margin-right: 4px; }
.btn-primary-sm { background: #1a7a4a; color: #fff; border-color: #1a7a4a; padding: 5px 12px; font-size: .85rem; }
.btn-primary-sm:hover { background: #156038; }
.btn-warn-sm { background: #fff; color: #8a5a00; border-color: #e6c983; padding: 5px 12px; font-size: .85rem; }
.btn-warn-sm:hover { background: #fdeecb; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.group-card {
    display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px; box-shadow: var(--shadow); color: var(--ink); transition: border-color .12s, transform .12s;
}
.group-card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.group-card.is-platform { border-left: 4px solid var(--platform); }
.group-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.group-name { font-weight: 600; font-size: 1.1rem; }
.group-stats { display: flex; gap: 16px; color: var(--ink-soft); font-size: .9rem; }
.group-stats strong { color: var(--ink); }
.group-when { margin-top: 10px; color: #98a3ae; font-size: .82rem; }

.grid { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.grid th, .grid td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.grid thead th { background: #f8fafc; color: var(--ink-soft); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .3px; }
.grid tbody tr:last-child td { border-bottom: none; }
.grid tbody tr:hover { background: #f8fafc; }
.grid .num { text-align: right; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.strong-link { font-weight: 600; }
.row-action { text-align: right; }

.search { display: flex; gap: 8px; margin-bottom: 20px; }
.search input { flex: 0 1 320px; }

.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 40px; text-align: center; color: var(--ink-soft); }

input { font: inherit; padding: 9px 11px; border: 1px solid #cbd3db; border-radius: 8px; background: #fff; color: var(--ink); }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29, 111, 224, .15); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #185cba; }
.btn-secondary { background: #fff; color: var(--ink); border-color: #cbd3db; }
.btn-secondary:hover { background: #f1f4f7; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a81f2b; }
.btn-danger-sm { background: #fff; color: var(--danger); border-color: #e7b9bd; padding: 5px 12px; font-size: .85rem; }
.btn-danger-sm:hover { background: var(--danger-soft); }
.btn-block { width: 100%; }

.alert { border-radius: 8px; padding: 11px 14px; margin-bottom: 16px; font-size: .92rem; }
.alert-error { background: var(--danger-soft); color: #8f2530; border: 1px solid #f0c2c7; }

.type-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin-top: 8px; }
@media (max-width: 540px) { .type-grid { grid-template-columns: 1fr; } }
.type-card {
    display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 32px 28px; box-shadow: var(--shadow); color: var(--ink);
    transition: border-color .15s, transform .15s, box-shadow .15s;
}
.type-card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(16,24,40,.12); }
.type-card.is-domain { border-top: 4px solid #1d5fbe; }
.type-card.is-capability { border-top: 4px solid #1a7a4a; }
.type-card-label { font-size: 1.35rem; font-weight: 700; margin-bottom: 10px; }
.type-card.is-domain .type-card-label { color: #1d5fbe; }
.type-card.is-capability .type-card-label { color: #1a7a4a; }
.type-card-desc { color: var(--ink-soft); font-size: .93rem; line-height: 1.55; }

.badge-domain { background: #ddeaff; color: #1d5fbe; }
.badge-capability { background: #d5f2e3; color: #1a7a4a; }

.howto-heading { font-size: 1.15rem; font-weight: 700; margin: 40px 0 4px; }
.howto-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 12px; }
@media (max-width: 860px) { .howto-grid { grid-template-columns: 1fr; } }
.howto-card {
    display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 18px 18px 16px; box-shadow: var(--shadow); color: var(--ink);
    border-top: 3px solid var(--accent);
    transition: border-color .15s, transform .15s, box-shadow .15s;
}
.howto-card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 4px 14px rgba(16,24,40,.14); }
.howto-icon {
    width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem; line-height: 1; border-radius: 9px; background: #eef4ff; margin-bottom: 12px;
}
.howto-title { font-size: 1rem; font-weight: 600; margin-bottom: 5px; letter-spacing: -.01em; }
.howto-desc { color: var(--ink-soft); font-size: .82rem; line-height: 1.5; flex: 1; }
.howto-go { color: var(--accent); font-size: .82rem; font-weight: 600; margin-top: 14px; }

.login-page { min-height: calc(100vh - 56px); display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 32px; }
.login-brand { font-size: 1.3rem; font-weight: 600; color: var(--brand); }
.login-brand .brand-accent { color: var(--accent); }
.login-sub { color: var(--ink-soft); margin: 6px 0 22px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; color: var(--ink-soft); }
.field input { color: var(--ink); }

.danger-card { background: var(--surface); border: 1px solid #f0c2c7; border-top: 4px solid var(--danger); border-radius: var(--radius); padding: 28px; max-width: 620px; box-shadow: var(--shadow); }
.danger-title { margin: 0 0 14px; color: #8f2530; font-size: 1.3rem; }
.danger-card .warn { color: #8f2530; background: var(--danger-soft); border-radius: 8px; padding: 10px 12px; }
.danger-form { margin-top: 18px; display: flex; flex-direction: column; gap: 16px; }
.danger-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* Catalog Raw Feeds page */
.prose { max-width: 780px; }
.prose p { margin: 0 0 12px; }
.section-title { margin: 28px 0 4px; font-size: 1.05rem; color: var(--brand); }
.section-note { margin: 0 0 12px; color: var(--ink-soft); max-width: 780px; }
.feed-list { list-style: none; margin: 0 0 8px; padding: 0; max-width: 780px; }
.feed-list li { display: flex; align-items: baseline; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.feed-list li:last-child { border-bottom: none; }
.feed-kind { color: var(--ink-soft); font-size: .88rem; }

/* Rendered Markdown (DocView) */
.markdown-body { max-width: 820px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 28px; box-shadow: var(--shadow); }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { color: var(--brand); line-height: 1.25; margin: 1.4em 0 .5em; }
.markdown-body h1 { font-size: 1.5rem; margin-top: 0; }
.markdown-body h2 { font-size: 1.25rem; }
.markdown-body h3 { font-size: 1.08rem; }
.markdown-body p { margin: 0 0 12px; }
.markdown-body ul, .markdown-body ol { margin: 0 0 12px; padding-left: 1.5em; }
.markdown-body li { margin: 3px 0; }
.markdown-body blockquote { margin: 0 0 12px; padding: 4px 14px; border-left: 3px solid var(--accent); color: var(--ink-soft); background: #f8fafc; border-radius: 0 6px 6px 0; }
.markdown-body pre { background: #0b2740; color: #e6edf3; padding: 14px 16px; border-radius: 8px; overflow-x: auto; margin: 0 0 12px; }
.markdown-body pre code { background: none; padding: 0; color: inherit; font-size: .88rem; }
.markdown-body hr { border: none; border-top: 1px solid var(--line); margin: 20px 0; }
.markdown-body a { color: var(--accent); }
