:root {
    color-scheme: light;
    --ink: #18242c;
    --muted: #5f7280;
    --line: #d8e3ea;
    --panel: #ffffff;
    --soft: #f5f8fa;
    --accent: #1779ba;
    --accent-dark: #0d5f91;
    --green: #198754;
    --shadow: 0 16px 40px rgba(30, 52, 70, 0.10);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 0;
    background: linear-gradient(180deg, #eef5f8 0%, #ffffff 34%, #f5f8fa 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);
}

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

.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 {
    overflow-wrap: anywhere;
}

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

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

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

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

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

.tool-layout {
    display: grid;
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
    gap: 18px;
    align-items: start;
}

.tool-layout > *,
.panel,
.table-stage {
    min-width: 0;
}

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

.panel {
    padding: 20px;
}

.panel-head p:last-child {
    margin-bottom: 0;
}

.full-label,
.import-grid label,
.control-row label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

input[type="text"],
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
    padding: 10px 12px;
}

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

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

.toggle-row label {
    display: inline-flex;
    gap: 7px;
    align-items: center;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--soft);
    color: var(--ink);
    font-size: 0.9rem;
}

button {
    border: 1px solid #bfd0da;
    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);
}

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

.table-stage {
    min-height: 360px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

#previewTitle {
    margin: 0 0 12px;
    font-size: 1.2rem;
}

.table-scroll {
    overflow-x: auto;
    max-width: 100%;
}

.made-table {
    width: 100%;
    min-width: 420px;
    border-collapse: collapse;
    table-layout: fixed;
    background: #fff;
}

.made-table.no-border,
.made-table.no-border th,
.made-table.no-border td {
    border-color: transparent;
}

.made-table th,
.made-table td {
    border: 1px solid #b9c9d3;
    min-width: 92px;
    padding: 10px;
    vertical-align: top;
    overflow-wrap: anywhere;
}

.made-table.compact th,
.made-table.compact td {
    padding: 6px 8px;
    font-size: 0.9rem;
}

.made-table th {
    background: #edf6fb;
    color: #123044;
    font-weight: 700;
}

.made-table [contenteditable="true"] {
    outline: 2px solid transparent;
    border-radius: 4px;
}

.made-table [contenteditable="true"]:focus {
    outline-color: rgba(23, 121, 186, 0.32);
    background: #f7fbff;
}

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

.related-tools {
    margin-top: 18px;
}

.tool-links {
    display: grid;
    grid-template-columns: repeat(5, 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;
}

.app-comment-section {
    margin-top: 18px;
}

.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,
    .info-grid {
        grid-template-columns: 1fr;
    }

    .tool-links {
        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;
    }

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

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

    .made-table {
        min-width: 360px;
    }
}
