:root {
    color-scheme: light;
    --ink: #17242d;
    --muted: #5d717f;
    --line: #d8e4ec;
    --panel: #ffffff;
    --soft: #f4f8fb;
    --accent: #2f6389;
    --accent-dark: #204a67;
    --green: #198754;
    --warn: #946400;
    --shadow: 0 16px 40px rgba(28, 50, 68, 0.10);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 0;
    background: linear-gradient(180deg, #edf5fb 0%, #ffffff 35%, #f6f9fb 100%);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif;
    line-height: 1.7;
}

a {
    color: var(--accent-dark);
}

button,
input,
select,
textarea {
    max-width: 100%;
    font: inherit;
}

.site-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 44px;
}

.hero {
    padding: 28px 0 22px;
}

.series-label,
.section-kicker,
.ad-label {
    margin: 0 0 8px;
    color: var(--accent-dark);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

h1,
h2,
h3,
p,
li,
pre {
    overflow-wrap: anywhere;
}

h1 {
    margin: 0;
    font-size: clamp(2rem, 5vw, 3.45rem);
    line-height: 1.12;
}

h2 {
    margin: 0 0 10px;
    font-size: 1.35rem;
}

h3 {
    margin: 0 0 8px;
    font-size: 1rem;
}

.subtitle {
    margin: 12px 0 0;
    font-size: 1.08rem;
    font-weight: 700;
}

.lead {
    max-width: 840px;
    margin: 12px 0 0;
}

.note,
.status-line {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.panel,
.site-return-link,
.mothership-link {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.tool-layout,
.result-grid,
.info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
}

.tool-layout > *,
.result-grid > *,
.info-grid > *,
.panel {
    min-width: 0;
}

.panel {
    padding: 20px;
}

.text-label {
    display: grid;
    gap: 6px;
    margin-top: 14px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
    padding: 11px 12px;
}

textarea {
    min-height: 340px;
    resize: vertical;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

button {
    border: 1px solid #bad0df;
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
    padding: 9px 12px;
    cursor: pointer;
}

button:hover,
button:focus-visible {
    border-color: var(--accent);
    outline: none;
}

.primary-button,
.save-button {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    font-weight: 700;
}

.save-button {
    border-color: var(--green);
    background: var(--green);
}

.quiet-button {
    color: var(--muted);
}

.copy-fallback {
    min-height: 120px;
    margin-top: 12px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.86rem;
    white-space: pre;
}

.copy-fallback[hidden] {
    display: none;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.stats-grid div {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--soft);
    text-align: center;
}

.stats-grid strong,
.stats-grid span {
    display: block;
}

.stats-grid strong {
    color: var(--accent-dark);
    font-size: 1.4rem;
}

.stats-grid span {
    color: var(--muted);
    font-size: 0.82rem;
}

.result-grid,
.related-tools,
.app-comment-section {
    margin-top: 18px;
}

.result-list {
    margin: 0;
    padding-left: 1.25rem;
}

.result-list li + li {
    margin-top: 6px;
}

.tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    background: #eaf3f9;
    color: var(--accent-dark);
    font-size: 0.78rem;
    font-weight: 700;
}

.tag.warn {
    background: #fff4d8;
    color: var(--warn);
}

.detail-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.element-panel {
    margin-top: 18px;
}

.element-filter {
    display: grid;
    grid-template-columns: minmax(220px, 340px) minmax(0, 1fr);
    gap: 14px;
    align-items: end;
    margin-top: 12px;
}

.class-examples {
    min-height: 48px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--soft);
    color: var(--muted);
}

.element-groups {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 16px;
}

.element-list {
    display: grid;
    gap: 8px;
}

.element-card {
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fbfd;
}

.element-card strong,
.element-card span {
    display: block;
}

.element-card code {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.element-meta {
    margin-top: 5px;
    color: var(--muted);
    font-size: 0.86rem;
}

.element-text {
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.84rem;
}

pre {
    max-height: 300px;
    overflow: auto;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fbfd;
    color: var(--ink);
    white-space: pre-wrap;
}

.ad-row {
    margin: 18px 0;
    min-height: 250px;
    padding: 12px;
    border: 1px dashed #cbd7df;
    border-radius: 8px;
    background: rgba(255,255,255,0.7);
}

.tool-links {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.tool-links a {
    display: block;
    min-height: 96px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    text-decoration: none;
}

.tool-links a:hover,
.tool-links a:focus-visible {
    border-color: var(--accent);
    outline: none;
}

.tool-links strong,
.tool-links span {
    display: block;
}

.tool-links span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.88rem;
}

.site-return-link,
.mothership-link {
    max-width: 560px;
    margin: 18px auto 0;
    padding: 14px;
    text-align: center;
}

.site-return-link span,
.mothership-link span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.site-return-link a,
.mothership-link a {
    display: inline-block;
    margin-top: 4px;
    font-weight: 700;
}

.site-return-link p,
.mothership-link p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.86rem;
}

.lab-footer {
    margin-top: 22px;
    color: var(--muted);
    text-align: center;
    font-size: 0.86rem;
}

.app-comments,
.app-comment-form-section {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
}

@media (max-width: 900px) {
    .tool-layout,
    .result-grid,
    .info-grid,
    .detail-columns,
    .element-filter,
    .element-groups {
        grid-template-columns: 1fr;
    }

    .tool-links {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .site-shell {
        width: min(100% - 20px, 100%);
        padding-top: 20px;
    }

    .panel {
        padding: 14px;
    }

    textarea {
        min-height: 250px;
    }

    .action-row button {
        flex: 1 1 140px;
    }

    .tool-links {
        grid-template-columns: 1fr;
    }
}
