.jmg-tool {
    --jmg-ink: #18212f;
    --jmg-muted: #5f6b7a;
    --jmg-line: #d9e0e8;
    --jmg-soft: #f5f7fa;
    --jmg-panel: #ffffff;
    --jmg-accent: #c93f32;
    --jmg-accent-dark: #9f2f26;
    --jmg-gold: #b98a2f;
    color: var(--jmg-ink);
    font-family: inherit;
    margin: 28px auto;
    max-width: 860px;
}

.jmg-tool * {
    box-sizing: border-box;
}

.jmg-tool .jmg-shell {
    background: var(--jmg-panel);
    border: 1px solid var(--jmg-line);
    border-radius: 8px;
    box-shadow: 0 18px 40px rgba(24, 33, 47, 0.12);
    overflow: hidden;
}

.jmg-tool .jmg-header {
    background: linear-gradient(135deg, #fffaf2 0%, #f7f9fb 52%, #eef5f2 100%);
    border-bottom: 1px solid var(--jmg-line);
    padding: 32px;
}

.jmg-tool .jmg-kicker {
    color: var(--jmg-accent);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0;
    margin: 0 0 8px;
    text-transform: uppercase;
}

.jmg-tool .jmg-title {
    color: var(--jmg-ink);
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.12;
    margin: 0 0 14px;
}

.jmg-tool .jmg-description {
    color: var(--jmg-muted);
    font-size: 16px;
    line-height: 1.65;
    margin: 0;
    max-width: 700px;
}

.jmg-tool .jmg-tabs {
    display: flex;
    gap: 8px;
    padding: 20px 24px 0;
}

.jmg-tool .jmg-tab {
    appearance: none;
    background: var(--jmg-soft);
    border: 1px solid var(--jmg-line);
    border-radius: 8px 8px 0 0;
    color: var(--jmg-muted);
    cursor: pointer;
    flex: 1 1 0;
    font: inherit;
    font-weight: 700;
    line-height: 1.25;
    min-height: 48px;
    padding: 12px 14px;
}

.jmg-tool .jmg-tab.is-active {
    background: var(--jmg-panel);
    border-bottom-color: var(--jmg-panel);
    color: var(--jmg-accent-dark);
}

.jmg-tool .jmg-grid {
    align-items: start !important;
    display: grid;
    column-gap: 24px;
    grid-auto-rows: auto;
    row-gap: 18px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    padding: 24px;
}

.jmg-tool [hidden] {
    display: none !important;
}

.jmg-tool .jmg-panel {
    align-self: start !important;
    background: var(--jmg-panel);
    border: 1px solid var(--jmg-line);
    border-radius: 8px;
    height: auto !important;
    min-height: 0 !important;
    padding: 22px;
}

.jmg-tool .jmg-result {
    align-self: start !important;
    background: transparent;
    border: 0;
    grid-column: 1 / -1;
    height: auto !important;
    min-height: 0 !important;
    padding: 0;
}

.jmg-tool .jmg-output {
    display: grid;
    gap: 22px;
}

.jmg-tool .jmg-main-answer,
.jmg-tool .jmg-result > .jmg-empty {
    background: var(--jmg-panel);
    border: 1px solid var(--jmg-line);
    border-radius: 8px;
    margin: 0;
    padding: 22px;
}

.jmg-tool .jmg-tab-panel {
    margin: 0 0 18px;
}

.jmg-tool .jmg-field {
    display: block;
    margin: 0 0 18px;
}

.jmg-tool .jmg-label {
    color: var(--jmg-ink);
    display: block;
    font-size: 14px;
    font-weight: 700;
    margin: 0 0 8px;
}

.jmg-tool .jmg-select,
.jmg-tool .jmg-input {
    background: #fff;
    border: 1px solid #cbd5df;
    border-radius: 6px;
    color: var(--jmg-ink);
    font: inherit;
    min-height: 46px;
    padding: 10px 12px;
    width: 100%;
}

.jmg-tool .jmg-select:focus,
.jmg-tool .jmg-input:focus {
    border-color: var(--jmg-accent);
    box-shadow: 0 0 0 3px rgba(201, 63, 50, 0.16);
    outline: none;
}

.jmg-tool .jmg-help {
    color: var(--jmg-muted);
    font-size: 13px;
    line-height: 1.5;
    margin: -8px 0 18px;
}

.jmg-tool .jmg-generate {
    appearance: none;
    background: var(--jmg-accent);
    border: 1px solid var(--jmg-accent);
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    min-height: 48px;
    padding: 12px 18px;
    width: 100%;
}

.jmg-tool .jmg-generate:hover,
.jmg-tool .jmg-generate:focus {
    background: var(--jmg-accent-dark);
    border-color: var(--jmg-accent-dark);
}

.jmg-tool .jmg-style-guide {
    align-self: start !important;
    background: #f7faf8;
    border: 1px solid var(--jmg-line);
    border-radius: 18px;
    margin-top: 0;
    padding: 16px 18px;
}

.jmg-tool .jmg-style-guide-kicker {
    color: var(--jmg-accent-dark);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.03em;
    line-height: 1.3;
    margin: 0 0 6px;
    text-transform: uppercase;
}

.jmg-tool .jmg-style-guide-title {
    color: var(--jmg-ink);
    font-size: 18px;
    font-weight: 800;
    line-height: 1.3;
    margin: 0;
}

.jmg-tool .jmg-style-guide-body {
    display: grid;
    gap: 12px 18px;
    grid-template-columns: 1fr;
}

.jmg-tool .jmg-style-guide-copy {
    display: grid;
    gap: 8px;
}

.jmg-tool .jmg-style-guide-text,
.jmg-tool .jmg-style-guide-note {
    color: var(--jmg-muted);
    font-size: 13px;
    line-height: 1.55;
    margin: 0;
}

.jmg-tool .jmg-style-guide-note {
    margin-top: 0;
}

.jmg-tool .jmg-style-guide strong {
    color: var(--jmg-ink);
}

.jmg-tool .jmg-empty {
    color: var(--jmg-muted);
    font-size: 16px;
    line-height: 1.6;
    margin: 0;
}

.jmg-tool .jmg-result-card {
    display: grid;
    gap: 18px;
    height: auto !important;
    min-height: 0 !important;
    width: 100%;
}

.jmg-tool .jmg-main-result-layout {
    align-items: start;
    display: grid;
    gap: 20px;
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
}

.jmg-tool .jmg-result-primary,
.jmg-tool .jmg-result-support {
    display: grid;
    gap: 18px;
}

.jmg-tool .jmg-style-label {
    color: var(--jmg-muted);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 -8px;
    text-transform: uppercase;
}

.jmg-tool .jmg-pending-title {
    color: var(--jmg-accent-dark);
    font-size: 20px;
    font-weight: 800;
    line-height: 1.3;
    margin: 0;
}

.jmg-tool .jmg-japanese {
    color: var(--jmg-ink);
    font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
    font-size: clamp(42px, 7vw, 72px);
    font-weight: 700;
    line-height: 1.15;
    margin: 0;
    overflow-wrap: anywhere;
}

.jmg-tool .jmg-result-card.is-pending .jmg-japanese {
    color: var(--jmg-muted);
    font-family: inherit;
    font-size: 17px;
    font-weight: 700;
}

.jmg-tool .jmg-result-card.is-free-result .jmg-japanese {
    font-size: clamp(38px, 6vw, 64px);
    line-height: 1.2;
    overflow-wrap: normal;
    word-break: keep-all;
}

.jmg-tool .jmg-romaji {
    color: var(--jmg-accent-dark);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.35;
    margin: -8px 0 0;
}

.jmg-tool .jmg-meaning {
    color: var(--jmg-muted);
    font-size: 15px;
    line-height: 1.6;
    margin: 0;
}

.jmg-tool .jmg-style-meta {
    color: var(--jmg-muted);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.45;
    margin: -4px 0 0;
}

.jmg-tool .jmg-copy-row,
.jmg-tool .jmg-alt-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.jmg-tool .jmg-copy-row {
    margin: -4px 0 0;
}

.jmg-tool .jmg-alt-actions {
    margin-top: 10px;
}

.jmg-tool .jmg-copy-btn {
    appearance: none;
    background: #fff;
    border: 1px solid var(--jmg-line);
    border-radius: 999px;
    color: var(--jmg-accent-dark);
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
    min-height: 32px;
    padding: 7px 12px;
}

.jmg-tool .jmg-copy-btn:hover,
.jmg-tool .jmg-copy-btn:focus {
    background: #fff7ed;
    border-color: var(--jmg-accent);
    outline: none;
}

.jmg-tool .jmg-alt-listen-btn {
    appearance: none;
    background: #fff;
    border: 1px solid rgba(179, 38, 30, 0.25);
    border-radius: 999px;
    color: #b3261e;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
    min-height: 32px;
    padding: 7px 12px;
}

.jmg-tool .jmg-alt-listen-btn:hover,
.jmg-tool .jmg-alt-listen-btn:focus,
.jmg-tool .jmg-alt-listen-btn.is-playing {
    background: #fff7ed;
    border-color: var(--jmg-accent);
    outline: none;
}

.jmg-tool .jmg-audio {
    background: #f7faf8;
    border: 1px solid var(--jmg-line);
    border-radius: 8px;
    display: grid;
    gap: 8px;
    margin: -2px 0 0;
    padding: 10px 12px;
}

.jmg-tool .jmg-audio-label {
    color: var(--jmg-accent-dark);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.03em;
    line-height: 1.3;
    text-transform: uppercase;
}

.jmg-tool .jmg-audio audio {
    display: block;
    height: 36px;
    width: 100%;
}

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

.jmg-tool .jmg-score {
    background: var(--jmg-soft);
    border: 1px solid var(--jmg-line);
    border-radius: 8px;
    padding: 12px;
}

.jmg-tool .jmg-score-name {
    color: var(--jmg-muted);
    display: block;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 6px;
}

.jmg-tool .jmg-score-value {
    color: var(--jmg-gold);
    display: block;
    font-size: 24px;
    font-weight: 800;
    line-height: 1;
}

.jmg-tool .jmg-note {
    background: #fffaf2;
    border-left: 4px solid var(--jmg-gold);
    color: var(--jmg-ink);
    font-size: 14px;
    line-height: 1.65;
    margin: 0;
    padding: 12px 14px;
}

.jmg-tool .jmg-free-style-guide {
    display: grid;
    gap: 8px;
}

.jmg-tool .jmg-free-style-guide p {
    margin: 0;
}

.jmg-tool .jmg-alt-section {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}

.jmg-tool .jmg-alt-title {
    color: var(--jmg-ink);
    font-size: 22px;
    font-weight: 800;
    line-height: 1.35;
    margin: 0 0 16px;
}

.jmg-tool .jmg-alt-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.jmg-tool .jmg-alt-card {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 18px;
    padding: 16px 18px;
}

.jmg-tool .jmg-alt-label {
    color: #b3261e;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.03em;
    line-height: 1.3;
    margin: 0;
    text-transform: uppercase;
}

.jmg-tool .jmg-alt-japanese {
    color: #111827;
    font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
    font-size: clamp(30px, 5vw, 44px);
    font-weight: 800;
    line-height: 1.25;
    margin: 6px 0 0;
    overflow-wrap: anywhere;
}

.jmg-tool .jmg-alt-romaji {
    color: #9f1d15;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.35;
    margin: 6px 0 0;
}

.jmg-tool .jmg-alt-meaning {
    color: #4b5563;
    font-size: 14px;
    line-height: 1.55;
    margin: 4px 0 0;
}

.jmg-tool .jmg-alt-note {
    background: #fff7ed;
    border-radius: 12px;
    color: #7c2d12;
    font-size: 12px;
    line-height: 1.45;
    margin: 8px 0 0;
    padding: 8px 10px;
}

.jmg-tool .jmg-action-row {
    align-items: stretch;
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1.2fr) minmax(220px, 0.8fr);
}

.jmg-tool .jmg-action-row .jmg-related-slot:empty {
    display: none;
}

.jmg-tool .jmg-action-row .jmg-related-slot:empty + .jmg-share {
    grid-column: 1 / -1;
}

.jmg-tool .jmg-related {
    background: #f7faf8;
    border: 1px solid var(--jmg-line);
    border-radius: 8px;
    padding: 14px 16px;
}

.jmg-tool .jmg-related-kicker {
    color: var(--jmg-accent-dark);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.03em;
    line-height: 1.3;
    margin: 0 0 6px;
    text-transform: uppercase;
}

.jmg-tool .jmg-related-link {
    color: var(--jmg-ink);
    display: inline-block;
    font-size: 16px;
    font-weight: 800;
    line-height: 1.35;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.jmg-tool .jmg-related-link:hover,
.jmg-tool .jmg-related-link:focus {
    color: var(--jmg-accent-dark);
}

.jmg-tool .jmg-related-desc {
    color: var(--jmg-muted);
    font-size: 13px;
    line-height: 1.5;
    margin: 8px 0 0;
}

.jmg-tool .jmg-share {
    align-items: center;
    background: #f8f8fa;
    border: 1px solid var(--jmg-line);
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 16px;
}

.jmg-tool .jmg-x-btn {
    appearance: none;
    background: #111827;
    border: 1px solid #111827;
    border-radius: 999px;
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.2;
    min-height: 36px;
    padding: 9px 14px;
}

.jmg-tool .jmg-x-btn:hover,
.jmg-tool .jmg-x-btn:focus {
    background: #2f3948;
    border-color: #2f3948;
    outline: none;
}

.jmg-tool .jmg-disclaimer {
    border-top: 1px solid var(--jmg-line);
    color: var(--jmg-muted);
    font-size: 13px;
    line-height: 1.6;
    margin: 0;
    padding: 18px 24px 24px;
}

@media (max-width: 720px) {
    .jmg-tool {
        margin: 20px auto;
    }

    .jmg-tool .jmg-header {
        padding: 24px 18px;
    }

    .jmg-tool .jmg-tabs {
        flex-direction: column;
        padding: 16px 16px 0;
    }

    .jmg-tool .jmg-tab {
        border-radius: 8px;
    }

    .jmg-tool .jmg-grid {
        grid-template-columns: 1fr;
        padding: 16px;
    }

    .jmg-tool .jmg-main-result-layout {
        grid-template-columns: 1fr;
    }

    .jmg-tool .jmg-panel,
    .jmg-tool .jmg-main-answer,
    .jmg-tool .jmg-result > .jmg-empty {
        padding: 18px;
    }
}

@media (max-width: 640px) {
    .jmg-tool .jmg-style-guide-body {
        grid-template-columns: 1fr;
    }

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

    .jmg-tool .jmg-action-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 460px) {
    .jmg-tool .jmg-score-grid {
        grid-template-columns: 1fr;
    }

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

.jmg-tool .jmg-alt-section {
    border-top: none !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
}

.jmg-tool .jmg-alt-title {
    margin-top: 0 !important;
    margin-bottom: 16px !important;
}

.jmg-tool .jmg-grid {
    column-gap: 24px !important;
    padding: 16px 24px 20px !important;
    row-gap: 12px !important;
}

.jmg-tool .jmg-main-answer {
    margin-top: 0 !important;
}

.jmg-tool .jmg-output {
    gap: 18px !important;
}

.jmg-tool .jmg-main-answer {
    grid-column: 1 / -1;
    margin-top: 0 !important;
    padding-top: 0 !important;
}

.jmg-tool .jmg-result {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

.jmg-tool .jmg-result-card {
    margin-top: 0 !important;
}

.jmg-tool .jmg-panel {
    margin-bottom: 0 !important;
}

.jmg-tool .jmg-style-guide {
    margin-bottom: 0 !important;
}

.jmg-tool .jmg-grid {
    padding-top: 12px !important;
    row-gap: 8px !important;
}

.jmg-tool .jmg-debug-status {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    color: #6b7280;
    font-size: 12px;
    line-height: 1.45;
    margin: 0;
    padding: 7px 10px;
}
