:root {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-2: #273449;
    --border: #334155;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --accent: #38bdf8;
    --accent-strong: #0ea5e9;
    --success: #22c55e;
    --warning: #fbbf24;
    --danger: #f87171;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

.wrap {
    max-width: 1180px;
    margin: 0 auto;
    padding: 32px 20px 64px;
}

.hero {
    margin-bottom: 28px;
}

.hero h1 {
    font-size: 1.9rem;
    line-height: 1.2;
    margin: 0 0 8px;
}

.hero p {
    color: var(--muted);
    margin: 0;
    max-width: 70ch;
}

.hero .tag {
    display: inline-block;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px 10px;
    margin-bottom: 12px;
}

.os-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 18px;
    margin-bottom: 20px;
}

.os-tabs {
    display: inline-flex;
    gap: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px;
}

.os-tab {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 600;
    padding: 8px 18px;
    border-radius: 7px;
    cursor: pointer;
}

.os-tab:hover {
    color: var(--text);
}

.os-tab.active {
    background: var(--accent);
    color: #08263a;
}

.os-bar .note {
    margin: 10px 0 0;
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.column {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
}

.card h2 {
    font-size: 1rem;
    margin: 0;
}

.group-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.note {
    color: var(--muted);
    font-size: 0.82rem;
    margin: 2px 0 0;
}

.link-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 2px 0;
    white-space: nowrap;
}

.link-btn:hover,
.link-btn:focus-visible {
    color: var(--accent-strong);
    text-decoration: underline;
}

.items {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
}

.item:hover {
    background: var(--surface-2);
}

.item[hidden] {
    display: none;
}

.item input[type="checkbox"] {
    margin: 3px 0 0;
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
    flex: none;
    cursor: pointer;
}

.item-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.item-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.item-desc {
    color: var(--muted);
    font-size: 0.78rem;
}

.badge {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0 5px;
    line-height: 1.5;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.toolbar .count {
    color: var(--muted);
    font-size: 0.82rem;
    margin-right: auto;
}

button.action {
    background: var(--accent);
    color: #08263a;
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

button.action:hover:not(:disabled) {
    background: var(--accent-strong);
}

button.action.secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

button.action.secondary:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

button.action:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.switch {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--muted);
    cursor: pointer;
}

.switch input {
    accent-color: var(--warning);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

select {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.85rem;
}

pre#preview {
    background: #0b1220;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    margin: 0;
    max-height: 62vh;
    overflow: auto;
    font-family: var(--mono);
    font-size: 0.76rem;
    line-height: 1.5;
    color: #cbd5e1;
    white-space: pre;
}

.preview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.preview-head h2 {
    font-size: 1rem;
    margin: 0;
}

.sticky {
    position: sticky;
    top: 20px;
}

ul.safe {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 12px;
}

ul.safe li {
    font-size: 0.82rem;
    color: var(--muted);
    padding-left: 18px;
    position: relative;
}

ul.safe li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success);
}

.warning {
    border-left: 3px solid var(--warning);
    background: rgba(251, 191, 36, 0.08);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 14px;
}

.steps {
    margin: 10px 0 0;
    padding-left: 20px;
    color: var(--muted);
    font-size: 0.82rem;
}

.steps li {
    margin-bottom: 4px;
}

.steps code,
code.inline {
    font-family: var(--mono);
    background: #0b1220;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 0.78rem;
    color: var(--accent);
    word-break: break-all;
}

#toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translate(-50%, 20px);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 0.82rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 20;
}

#toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

footer {
    margin-top: 32px;
    color: var(--muted);
    font-size: 0.78rem;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .sticky {
        position: static;
    }

    pre#preview {
        max-height: 40vh;
    }
}

@media (max-width: 520px) {
    .wrap {
        padding: 20px 14px 48px;
    }

    .hero h1 {
        font-size: 1.5rem;
    }

    ul.safe {
        grid-template-columns: minmax(0, 1fr);
    }
}
