body {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #ffffff;
    --text: #111111;
    --muted: #444444;
    --subtle: #555555;
    --border: #dddddd;
    --border-2: #e5e5e5;
    --input-border: #cccccc;
    --link: #111111;
    --button-bg: #111111;
    --button-bg-hover: #333333;
    --button-text: #ffffff;
    --badge-bg: #111111;
    --badge-alt-bg: #333333;
    --danger: #c62828;
    --theme-toggle-bg: transparent;
    --theme-toggle-border: #dddddd;
    --theme-toggle-hover: #111111;
    --theme-toggle-text: #111111;
}

body.theme-dark {
    --bg: #000000;
    --surface: #000000;
    --surface-2: #000000;
    --text: #e8edf5;
    --muted: #b2bccb;
    --subtle: #9aa6b6;
    --border: #2a3340;
    --border-2: #253041;
    --input-border: #3a4557;
    --link: #e8edf5;
    --button-bg: #e8edf5;
    --button-bg-hover: #ffffff;
    --button-text: #111111;
    --badge-bg: #e8edf5;
    --badge-alt-bg: #cfd7e4;
    --danger: #ff7a7a;
    --theme-toggle-bg: transparent;
    --theme-toggle-border: #2a3340;
    --theme-toggle-hover: #e8edf5;
    --theme-toggle-text: #e8edf5;
    color-scheme: dark;
}

html,
body {
    margin: 0;
    min-height: 100vh;
    padding: 28px 18px;
    box-sizing: border-box;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg) !important;
}

html {
    background: var(--bg) !important;
}

* {
    box-sizing: border-box;
}

.page {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--surface);
    min-height: calc(100vh - 56px);
}

body.about-page .content-card {
    margin-bottom: 16px;
}

body.help-page {
    scroll-behavior: smooth;
}

body.about-page .card-body {
    padding: 18px 20px;
}

.header,
.card {
    border: 1px solid var(--border);
    background: var(--surface);
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
    padding: 14px 16px;
}

.top-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin: 0;
    padding: 0;
}

.top-nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.top-nav-aside {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    margin-left: auto;
}

.top-nav-visual {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}

.site-nav {
    margin: 0 auto 14px;
    max-width: 1200px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    background: var(--surface);
}

.top-nav a {
    color: var(--link);
    text-decoration: none;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.top-nav a:hover {
    text-decoration: underline;
}

.theme-toggle {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--link);
    padding: 0;
    font: inherit;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    text-decoration: underline;
}

.theme-toggle:hover {
    color: var(--link);
}

.nav-logo {
    display: block;
    width: 120px;
    max-width: 120px;
    height: auto;
    object-fit: contain;
}

.error-header {
    border-color: #d32f2f;
}

.header h1 {
    margin: 0 0 6px;
    font-size: 22px;
    line-height: 1.2;
}

.header p {
    margin: 0;
    color: var(--muted);
}

.header-copy {
    min-width: 0;
}

.page-header-logo {
    display: block;
    width: 84px;
    max-width: 84px;
    height: auto;
    object-fit: contain;
    flex-shrink: 0;
}

.result-grid,
.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.stack {
    display: grid;
    gap: 16px;
    align-content: start;
}

.card {
    overflow: hidden;
}

.error-card {
    border-color: var(--danger);
}

.card-head {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.card-head h2,
.card-head h3 {
    margin: 0;
    font-size: 15px;
    line-height: 1.25;
}

.card-head h3.danger-title {
    color: var(--danger);
}

.card-body {
    padding: 14px;
}

.info-list,
.options,
.note-list {
    display: grid;
    gap: 0;
}

.info-row,
.option,
.list-item,
.note {
    padding: 7px 0;
    border-bottom: 1px solid var(--border-2);
}

.info-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.label {
    color: var(--subtle);
    flex-shrink: 0;
    font-size: 13px;
}

.value {
    color: var(--text);
    font-weight: 600;
    text-align: right;
}

.option .desc,
.list-item,
.note,
.empty-state {
    color: var(--text);
    line-height: 1.4;
}

.full-code-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.full-code-value {
    flex: 1;
    min-width: 0;
    padding: 8px 0;
    color: var(--text);
    font-weight: 700;
    word-break: break-word;
}

.copy-btn {
    appearance: none;
    border: 1px solid var(--button-bg);
    background: var(--button-bg);
    color: var(--button-text);
    border-radius: 999px;
    padding: 8px 14px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.copy-btn:hover {
    background: var(--button-bg-hover);
}

.copy-btn:active {
    transform: translateY(1px);
}

.badge {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    color: var(--button-text);
    background: var(--badge-bg);
}

.badge.alt {
    background: var(--badge-alt-bg);
}

.footer-link {
    display: inline-block;
    margin-top: 4px;
    color: var(--link);
    text-decoration: none;
    font-weight: 600;
}

.footer-link,
.page-links {
    display: none;
}

.footer-link:hover {
    text-decoration: underline;
}

.content-card {
    margin-bottom: 16px;
}

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

.help-content {
    display: grid;
    gap: 16px;
}

.help-show-all {
    display: inline-block;
    margin-bottom: 12px;
    color: var(--link);
    font-weight: 700;
    text-decoration: none;
}

.help-show-all:hover {
    text-decoration: underline;
}

.help-sidebar {
    position: sticky;
    top: 14px;
}

.help-nav {
    display: grid;
    gap: 8px;
}

.help-nav a {
    display: block;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--link);
    text-decoration: none;
    font-weight: 700;
    line-height: 1.35;
}

.help-nav a:hover {
    border-color: var(--border-2);
    background: var(--surface-2);
    text-decoration: none;
}

.help-nav a.is-active {
    border-color: var(--border);
    background: var(--surface-2);
}

.help-section {
    scroll-margin-top: 16px;
}

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

.content-hero {
    width: 180px;
    height: 180px;
    object-fit: contain;
    border: 1px solid var(--border);
    background: var(--surface);
}

.help-figure {
    display: block;
    width: min(100%, 720px);
    height: auto;
    margin: 0 auto;
    padding: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
}

.help-image {
    display: block;
    width: auto;
    max-width: min(100%, 640px);
    height: auto;
    margin: 0 auto;
    padding: 0;
    border: 0;
    background: transparent;
    object-fit: contain;
}

.content-text p {
    margin: 0 0 12px;
    color: var(--text);
    line-height: 1.55;
}

.markdown-content > :first-child {
    margin-top: 0;
}

.markdown-content > :last-child {
    margin-bottom: 0;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    margin: 0 0 12px;
    line-height: 1.2;
}

.markdown-content h2 {
    margin-top: 22px;
    font-size: 18px;
}

.markdown-content ul,
.markdown-content ol {
    margin: 0 0 12px 20px;
    padding: 0;
}

.markdown-content li {
    margin: 0 0 6px;
    line-height: 1.5;
}

.markdown-content code {
    padding: 1px 5px;
    border: 1px solid var(--border-2);
    border-radius: 6px;
    background: var(--surface-2);
    font-family: Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.95em;
}

.markdown-content blockquote {
    margin: 0 0 12px;
    padding: 10px 14px;
    border-left: 3px solid var(--border);
    background: var(--surface-2);
    color: var(--muted);
}

.markdown-content img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 16px 0 0;
    padding: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
}

.search-form {
    display: grid;
    gap: 14px;
}

.field {
    display: grid;
    gap: 6px;
}

.field label {
    color: var(--muted);
    font-weight: 500;
}

.field input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--input-border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    outline: none;
}

.field input:focus {
    border-color: var(--link);
}

.hint {
    color: var(--subtle);
    font-size: 13px;
    line-height: 1.4;
}

.actions {
    display: flex;
    gap: 10px;
    margin-top: 2px;
}

.submit-btn {
    appearance: none;
    border: 1px solid var(--button-bg);
    padding: 10px 16px;
    border-radius: 999px;
    color: var(--button-text);
    font-weight: 600;
    background: var(--button-bg);
    cursor: pointer;
}

.submit-btn:hover {
    background: var(--button-bg-hover);
}

@media (max-width: 920px) {
    .grid,
    .result-grid {
        grid-template-columns: 1fr;
    }

    .help-layout {
        grid-template-columns: 1fr;
    }

    .help-sidebar {
        position: static;
    }

    .info-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .value {
        text-align: left;
    }

    .full-code-row {
        flex-direction: column;
        align-items: stretch;
    }

    .content-layout {
        grid-template-columns: 1fr;
    }

    .content-hero {
        width: 140px;
        height: 140px;
    }

    .header {
        align-items: flex-start;
    }

    .page-header-logo {
        width: 64px;
        max-width: 64px;
    }

    .top-nav {
        align-items: flex-start;
    }

    .top-nav-aside {
        align-items: flex-start;
        margin-left: 0;
    }

    .top-nav-visual {
        justify-content: flex-start;
    }
}
