/* Smart FSM documentation: layout, light and dark theme, components. No libraries. */
:root {
    --brand: #2ca58d; --brand-dark: #1f8a75; --brand-soft: #e6f6f2; --navy: #0a2342;
    --bg: #f5f8fb; --surface: #ffffff; --text: #1c2434; --muted: #5d6878; --border: #e2e8f0; --code-bg: #0f1b2d; --code-text: #e6edf6;
    --tip: #1f8a75; --tip-bg: #e9f7f3; --note: #1d5fa8; --note-bg: #eaf3fd; --warn: #a15c00; --warn-bg: #fff4e0; --danger: #b3261e; --danger-bg: #fdecea;
    --shadow: 0 1px 2px rgba(10, 35, 66, .06), 0 8px 24px rgba(10, 35, 66, .06);
    --header-h: 64px; --side-w: 290px;
}
:root[data-theme="dark"] {
    --bg: #0c1522; --surface: #111e30; --text: #e5ecf5; --muted: #9fb0c4; --border: #22344d; --brand-soft: #113a33; --code-bg: #08111d;
    --tip-bg: #0f2f2a; --note-bg: #10263f; --warn-bg: #33250c; --danger-bg: #3a1613; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; font: 16px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--brand-dark); text-decoration-thickness: 1px; text-underline-offset: 2px; }
:root[data-theme="dark"] a { color: #5fd2b9; }
img { max-width: 100%; height: auto; }
code, pre, kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
:not(pre) > code { background: var(--brand-soft); color: var(--brand-dark); padding: .1em .4em; border-radius: 5px; word-break: break-word; }
:root[data-theme="dark"] :not(pre) > code { color: #8fe3cf; }
kbd { background: var(--surface); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 0 .4em; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--brand); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 60%, transparent); outline-offset: 2px; border-radius: 4px; }

/* header */
.topbar { position: sticky; top: 0; z-index: 50; height: var(--header-h); display: flex; align-items: center; gap: 14px; padding: 0 22px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; }
.topbar .brand img { height: 34px; width: auto; }
:root[data-theme="dark"] .topbar .brand img { filter: brightness(0) invert(1); }
.topbar .ver { font-size: .72rem; font-weight: 700; background: var(--brand-soft); color: var(--brand-dark); padding: 2px 9px; border-radius: 20px; }
.topbar .spacer { flex: 1; }
.search { position: relative; width: min(420px, 38vw); }
.search input { width: 100%; font: inherit; font-size: .92rem; padding: 9px 40px 9px 38px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); }
.search svg { position: absolute; left: 11px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); color: var(--muted); }
.search kbd { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font-size: .7rem; color: var(--muted); }
.results { position: absolute; top: calc(100% + 8px); left: 0; right: 0; max-height: 60vh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: none; }
.results.open { display: block; }
.results a { display: block; padding: 9px 12px; border-radius: 8px; text-decoration: none; color: var(--text); }
.results a:hover, .results a.on { background: var(--brand-soft); }
.results b { display: block; font-size: .92rem; }
.results small { color: var(--muted); display: block; line-height: 1.4; }
.results mark { background: #ffe8a3; color: #000; border-radius: 3px; }
.results .none { padding: 14px; color: var(--muted); font-size: .92rem; }
.iconbtn { border: 1px solid var(--border); background: var(--surface); color: var(--text); width: 38px; height: 38px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.iconbtn:hover { border-color: var(--brand); }
.iconbtn svg { width: 18px; height: 18px; }
.menu-btn { display: none; }
.btn { display: inline-block; text-decoration: none; background: var(--brand); color: #fff !important; font-weight: 600; font-size: .9rem; padding: 8px 16px; border-radius: 10px; }
.btn:hover { background: var(--brand-dark); }
.btn.ghost { background: transparent; color: var(--brand-dark) !important; border: 1px solid var(--border); }

/* shell */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); max-width: 1640px; margin: 0 auto; }
.sidebar { position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); overflow-y: auto; padding: 22px 14px 40px 22px; border-right: 1px solid var(--border); scrollbar-width: thin; }
.sidebar .group { margin-bottom: 18px; }
.sidebar .glabel { font-size: .7rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); padding: 0 10px 6px; }
.sidebar a { display: flex; align-items: center; gap: 9px; padding: 6px 10px; margin: 1px 0; color: var(--text); text-decoration: none; font-size: .92rem; border-radius: 8px; border-left: 3px solid transparent; }
.sidebar a:hover { background: var(--brand-soft); }
.sidebar a.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; border-left-color: var(--brand); }
:root[data-theme="dark"] .sidebar a.active { color: #8fe3cf; }
.sidebar a.hide { display: none; }
.sidebar a .n { margin-left: auto; font-size: .68rem; color: var(--muted); }

main { min-width: 0; padding: 32px 40px 80px; display: grid; grid-template-columns: minmax(0, 860px) 220px; gap: 36px; justify-content: center; }
.content { min-width: 0; }
.toc { position: sticky; top: calc(var(--header-h) + 28px); align-self: start; max-height: calc(100vh - var(--header-h) - 60px); overflow: auto; font-size: .85rem; }
.toc b { display: block; font-size: .7rem; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.toc a { display: block; padding: 3px 0 3px 12px; color: var(--muted); text-decoration: none; border-left: 2px solid var(--border); }
.toc a:hover { color: var(--text); }
.toc a.active { color: var(--brand-dark); border-left-color: var(--brand); font-weight: 700; }
:root[data-theme="dark"] .toc a.active { color: #8fe3cf; }
@media (max-width: 1320px) { main { grid-template-columns: minmax(0, 860px); } .toc { display: none; } }

/* sections */
.doc-section { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 34px 38px 30px; margin-bottom: 28px; }
.doc-section > h2 { margin: 0 0 6px; font-size: 1.75rem; line-height: 1.25; letter-spacing: -.01em; }
.eyebrow { font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--brand); margin-bottom: 4px; }
.lead { color: var(--muted); font-size: 1.04rem; margin: 6px 0 22px; }
h3 { font-size: 1.15rem; margin: 30px 0 8px; line-height: 1.35; }
h4 { font-size: .98rem; margin: 22px 0 6px; }
h2 .anchor, h3 .anchor { opacity: 0; margin-left: 8px; text-decoration: none; font-weight: 400; color: var(--muted); }
h2:hover .anchor, h3:hover .anchor { opacity: 1; }
p { margin: 0 0 12px; }
ul, ol { padding-left: 1.3rem; margin: 0 0 14px; }
li { margin: 4px 0; }
.where { font-size: .9rem; color: var(--muted); border-left: 3px solid var(--brand); padding: 2px 0 2px 12px; margin: 14px 0; }
.where b { color: var(--text); }
hr { border: 0; border-top: 1px solid var(--border); margin: 26px 0; }

/* tables */
.tablewrap { overflow-x: auto; margin: 12px 0 18px; border: 1px solid var(--border); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { text-align: left; vertical-align: top; padding: 10px 14px; border-bottom: 1px solid var(--border); }
th { background: var(--bg); font-size: .76rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td:first-child { font-weight: 600; min-width: 140px; }
.tablewrap.plain td:first-child { font-weight: 400; }

/* callouts */
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px; margin: 16px 0; border: 1px solid transparent; }
.callout > b { flex: none; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; padding-top: 3px; min-width: 64px; }
.callout > div > :last-child { margin-bottom: 0; }
.callout.tip { background: var(--tip-bg); border-color: color-mix(in srgb, var(--tip) 30%, transparent); } .callout.tip > b { color: var(--tip); }
.callout.note { background: var(--note-bg); border-color: color-mix(in srgb, var(--note) 30%, transparent); } .callout.note > b { color: var(--note); }
.callout.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, transparent); } .callout.warn > b { color: var(--warn); }
.callout.danger { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 35%, transparent); } .callout.danger > b { color: var(--danger); }
:root[data-theme="dark"] .callout.warn > b { color: #f2b45b; } :root[data-theme="dark"] .callout.note > b { color: #7db7f5; } :root[data-theme="dark"] .callout.danger > b { color: #ff9a92; }

/* steps */
ol.steps { list-style: none; counter-reset: step; padding: 0; margin: 14px 0 18px; }
ol.steps > li { counter-increment: step; position: relative; padding: 2px 0 14px 50px; margin: 0; min-height: 40px; }
ol.steps > li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; }
ol.steps > li::after { content: ""; position: absolute; left: 16px; top: 38px; bottom: 4px; width: 2px; background: var(--border); }
ol.steps > li:last-child::after { display: none; }
ol.steps > li > strong:first-child { display: block; font-size: 1.02rem; margin-bottom: 2px; }

/* code */
.codebox { position: relative; margin: 12px 0 16px; }
pre { background: var(--code-bg); color: var(--code-text); padding: 16px 18px; border-radius: 12px; overflow-x: auto; margin: 0; line-height: 1.55; }
.copy { position: absolute; top: 8px; right: 8px; border: 1px solid rgba(255, 255, 255, .2); background: rgba(255, 255, 255, .08); color: #cfe0f5; font: inherit; font-size: .75rem; padding: 3px 10px; border-radius: 7px; cursor: pointer; }
.copy:hover { background: rgba(255, 255, 255, .18); }

/* figures */
figure { margin: 16px 0 22px; }
figure img { display: block; width: 100%; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); cursor: zoom-in; background: #fff; }
figure.narrow img { max-width: 640px; margin-inline: auto; }
figcaption { font-size: .85rem; color: var(--muted); text-align: center; margin-top: 8px; }
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(5, 12, 22, .88); display: none; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }

/* cards and chips */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 16px 0 6px; }
.card { display: block; text-decoration: none; color: inherit; border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; background: var(--bg); transition: border-color .15s, transform .15s; }
a.card:hover { border-color: var(--brand); transform: translateY(-2px); }
.card b { display: block; margin-bottom: 4px; }
.card span { color: var(--muted); font-size: .9rem; line-height: 1.5; display: block; }
.card .ico { width: 36px; height: 36px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-dark); display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.card .ico svg { width: 19px; height: 19px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; }
.chip { font-size: .8rem; font-weight: 600; padding: 3px 11px; border-radius: 20px; background: var(--brand-soft); color: var(--brand-dark); }
.chip.grey { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.hero { background: linear-gradient(135deg, #0a2342 0%, #0d3b5a 55%, #14735f 100%); color: #fff; border-radius: 18px; padding: 38px 38px 34px; margin-bottom: 28px; position: relative; overflow: hidden; }
.hero h1 { margin: 0 0 8px; font-size: 2.1rem; line-height: 1.2; letter-spacing: -.02em; }
.hero p { color: rgba(255, 255, 255, .85); max-width: 640px; margin-bottom: 18px; }
.hero .btn { background: #fff; color: var(--navy) !important; }
.hero .btn.ghost { background: transparent; color: #fff !important; border-color: rgba(255, 255, 255, .4); }
.hero .chips .chip { background: rgba(255, 255, 255, .14); color: #fff; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 16px; margin: 10px 0 16px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
footer { text-align: center; color: var(--muted); font-size: .88rem; padding: 10px 0 40px; }
.back-top { position: fixed; right: 22px; bottom: 22px; display: none; }
.back-top.show { display: inline-flex; }

/* small screens */
@media (max-width: 980px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: fixed; z-index: 60; top: var(--header-h); left: 0; bottom: 0; width: min(88vw, 330px); height: auto; background: var(--surface); transform: translateX(-102%); transition: transform .2s; box-shadow: var(--shadow); }
    body.menu-open .sidebar { transform: none; }
    body.menu-open::after { content: ""; position: fixed; inset: var(--header-h) 0 0 0; background: rgba(5, 12, 22, .45); z-index: 55; }
    .menu-btn { display: inline-flex; }
    main { padding: 20px 14px 60px; }
    .doc-section { padding: 24px 18px 20px; border-radius: 14px; }
    .hero { padding: 26px 20px; } .hero h1 { font-size: 1.6rem; }
    .search { width: auto; flex: 1; }
    .topbar .ver, .topbar .btn { display: none; }
    .kv { grid-template-columns: 1fr; }
}
@media print {
    .topbar, .sidebar, .toc, .back-top, .copy { display: none !important; }
    .shell, main { display: block; padding: 0; }
    .doc-section { box-shadow: none; border: 0; padding: 0 0 12px; break-inside: avoid-page; }
    body { background: #fff; color: #000; font-size: 11pt; }
    a { color: #000; }
}
