:root {
    --tg-ink: #172033;
    --tg-muted: #596579;
    --tg-border: #dbe2ec;
    --tg-soft: #f4f7fb;
    --tg-panel: #ffffff;
    --tg-accent: #ef4444;
    --tg-accent-dark: #c92f2f;
    --tg-focus: #2563eb;
    --tg-shadow: 0 22px 60px rgba(20, 31, 52, 0.12);
    --tg-radius: 24px;
}

.type-generator-page {
    color: var(--tg-ink);
}

body.type-generator-page main.container {
    box-sizing: border-box;
    width: min(1180px, calc(100% - 32px));
    margin-right: auto;
    margin-left: auto;
    padding: 46px 0 72px;
}

.tg-hero {
    display: grid;
    gap: 24px;
}

.tg-heading {
    max-width: 820px;
}

body.type-generator-page .tg-heading h1 {
    margin: 0;
    color: #111827;
    font-size: clamp(2.55rem, 5.4vw, 4.25rem);
    line-height: 0.98;
    letter-spacing: -0.055em;
}

.tg-heading .lead {
    max-width: 760px;
    margin: 18px 0 0;
    color: var(--tg-muted);
    font-size: clamp(1rem, 2vw, 1.18rem);
    line-height: 1.7;
}

.tg-app {
    display: grid;
    grid-template-columns: minmax(320px, 0.88fr) minmax(420px, 1.12fr);
    min-height: 610px;
    overflow: hidden;
    border: 1px solid var(--tg-border);
    border-radius: 30px;
    background: var(--tg-panel);
    box-shadow: var(--tg-shadow);
}

.tg-controls {
    padding: 28px;
    border-right: 1px solid var(--tg-border);
    background: linear-gradient(180deg, #ffffff 0%, #f7f9fc 100%);
}

.tg-control-group + .tg-control-group {
    margin-top: 24px;
}

.tg-control-label,
.tg-controls legend {
    display: block;
    margin-bottom: 10px;
    color: #273247;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

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

.tg-mode-button {
    min-height: 58px;
    padding: 10px 12px;
    border: 1px solid #ccd5e2;
    border-radius: 14px;
    background: #ffffff;
    color: #2b364b;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 750;
    line-height: 1.25;
    text-align: left;
    cursor: pointer;
    transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.tg-mode-button:hover {
    border-color: #9ca9ba;
    transform: translateY(-1px);
}

.tg-mode-button[aria-pressed="true"] {
    border-color: #111827;
    background: #111827;
    color: #ffffff;
}

.tg-seed-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 9px;
}

.tg-seed-row input {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: #ffffff;
    color: var(--tg-ink);
    font: inherit;
}

.tg-secondary-button,
.tg-link-button,
.tg-reset-button {
    min-height: 46px;
    padding: 10px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: #ffffff;
    color: #273247;
    font: inherit;
    font-weight: 750;
    cursor: pointer;
    transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.tg-secondary-button:hover,
.tg-link-button:hover,
.tg-reset-button:hover {
    border-color: #929fb1;
    background: #f8fafc;
    transform: translateY(-1px);
}

.tg-toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid #d9e0ea;
    border-radius: 12px;
    background: #ffffff;
    color: #334155;
    font-weight: 650;
    cursor: pointer;
}

.tg-toggle-row input {
    width: 19px;
    height: 19px;
    accent-color: #111827;
}

.tg-types-details {
    border-top: 1px solid #e4e9f0;
    padding-top: 18px;
}

.tg-types-details summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 44px;
    color: #273247;
    font-weight: 800;
    cursor: pointer;
    list-style: none;
}

.tg-types-details summary::-webkit-details-marker {
    display: none;
}

.tg-types-details summary::after {
    content: "+";
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 50%;
    background: #e9eef6;
    font-size: 1.15rem;
}

.tg-types-details[open] summary::after {
    content: "−";
}

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

.tg-type-option {
    position: relative;
}

.tg-type-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.tg-type-option label {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 8px 7px;
    border: 1px solid #cfd8e5;
    border-radius: 11px;
    background: #ffffff;
    color: #3b4658;
    font-size: 0.79rem;
    font-weight: 780;
    cursor: pointer;
    transition: border-color 150ms ease, background 150ms ease, color 150ms ease, opacity 150ms ease;
}

.tg-type-option input:checked + label {
    border-color: var(--type-color, #64748b);
    background: color-mix(in srgb, var(--type-color, #64748b) 15%, #ffffff);
    color: #172033;
}

.tg-type-option input:not(:checked) + label {
    opacity: 0.48;
    text-decoration: line-through;
}

.tg-type-actions {
    display: flex;
    gap: 8px;
    margin-top: 11px;
}

.tg-type-actions button {
    min-height: 40px;
    padding: 7px 11px;
    border: 0;
    background: transparent;
    color: #475569;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 750;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.tg-pool-note {
    margin: 12px 0 0;
    color: var(--tg-muted);
    font-size: 0.86rem;
    line-height: 1.5;
}

.tg-primary-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    margin-top: 24px;
}

.tg-generate-button {
    min-height: 54px;
    padding: 13px 18px;
    border: 0;
    border-radius: 14px;
    background: var(--tg-accent);
    color: #ffffff;
    font: inherit;
    font-size: 1rem;
    font-weight: 850;
    cursor: pointer;
    box-shadow: 0 12px 25px rgba(239, 68, 68, 0.22);
    transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.tg-generate-button:hover:not(:disabled) {
    background: var(--tg-accent-dark);
    transform: translateY(-1px);
    box-shadow: 0 15px 28px rgba(201, 47, 47, 0.25);
}

.tg-generate-button:disabled {
    opacity: 0.48;
    cursor: not-allowed;
    box-shadow: none;
}

.tg-inline-status {
    min-height: 22px;
    margin: 12px 0 0;
    color: #9f2d2d;
    font-size: 0.86rem;
    font-weight: 650;
    line-height: 1.45;
}

.tg-inline-status + .tg-control-group {
    margin-top: 18px;
}

.tg-output {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    padding: 34px;
    background:
        radial-gradient(circle at 85% 15%, rgba(255, 255, 255, 0.92), transparent 34%),
        linear-gradient(145deg, #edf2f8 0%, #f8fafc 100%);
}

.tg-fallback-notice {
    display: none;
    margin: 0 0 14px;
    padding: 10px 12px;
    border: 1px solid #f4cf75;
    border-radius: 12px;
    background: #fff7dc;
    color: #765311;
    font-size: 0.85rem;
    line-height: 1.5;
}

.tg-fallback-notice.is-visible {
    display: block;
}

.tg-wheel-stage {
    display: none;
    align-items: center;
    justify-content: center;
    min-height: 250px;
    margin-bottom: 18px;
}

.tg-wheel-stage.is-visible {
    display: flex;
}

.tg-wheel-wrap {
    position: relative;
    width: min(250px, 68vw);
    aspect-ratio: 1;
}

.tg-wheel {
    position: relative;
    width: 100%;
    height: 100%;
    border: 9px solid #ffffff;
    border-radius: 50%;
    background: conic-gradient(#94a3b8 0deg 360deg);
    box-shadow: 0 20px 44px rgba(28, 39, 61, 0.2), inset 0 0 0 2px rgba(23, 32, 51, 0.12);
    transform: rotate(var(--tg-wheel-rotation, 0deg));
    transition: transform 1.75s cubic-bezier(0.16, 0.72, 0.23, 1);
}

.tg-wheel::after {
    content: "";
    position: absolute;
    inset: 37%;
    border: 7px solid #ffffff;
    border-radius: 50%;
    background: #172033;
    box-shadow: 0 7px 18px rgba(0, 0, 0, 0.18);
}

.tg-wheel-pointer {
    position: absolute;
    z-index: 2;
    top: -5px;
    left: 50%;
    width: 0;
    height: 0;
    border-right: 16px solid transparent;
    border-left: 16px solid transparent;
    border-top: 29px solid #172033;
    transform: translateX(-50%);
    filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.2));
}

.tg-wheel-label {
    position: absolute;
    z-index: 3;
    inset: 50% auto auto 50%;
    width: 98px;
    color: #ffffff;
    font-size: 0.82rem;
    font-weight: 850;
    line-height: 1.1;
    text-align: center;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.tg-result-card {
    position: relative;
    overflow: hidden;
    min-height: 330px;
    padding: 28px;
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: var(--tg-radius);
    background: linear-gradient(135deg, var(--tg-primary, #ee8130), var(--tg-secondary, #cc6020));
    color: var(--tg-result-text, #ffffff);
    box-shadow: 0 20px 50px rgba(25, 35, 55, 0.18);
}

.tg-result-card::before,
.tg-result-card::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
}

.tg-result-card::before {
    width: 260px;
    height: 260px;
    top: -115px;
    right: -75px;
}

.tg-result-card::after {
    width: 150px;
    height: 150px;
    bottom: -85px;
    left: -45px;
}

.tg-result-inner {
    position: relative;
    z-index: 1;
}

.tg-result-mode {
    display: inline-flex;
    min-height: 30px;
    align-items: center;
    padding: 5px 10px;
    border: 1px solid rgba(255, 255, 255, 0.38);
    border-radius: 999px;
    background: rgba(17, 24, 39, 0.18);
    color: inherit;
    font-size: 0.74rem;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tg-result-title {
    margin: 22px 0 8px;
    font-size: clamp(2.15rem, 5vw, 4rem);
    line-height: 1;
    letter-spacing: -0.055em;
}

.tg-result-classification {
    max-width: 640px;
    margin: 0;
    color: inherit;
    font-size: 1rem;
    font-weight: 650;
    line-height: 1.55;
    opacity: 0.92;
}

.tg-result-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 25px;
}

.tg-result-detail {
    min-width: 0;
    padding: 13px 14px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 14px;
    background: rgba(17, 24, 39, 0.15);
    backdrop-filter: blur(7px);
}

.tg-result-detail strong {
    display: block;
    margin-bottom: 5px;
    font-size: 0.73rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    opacity: 0.78;
}

.tg-result-detail span {
    display: block;
    font-size: 0.9rem;
    font-weight: 680;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.tg-output-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
}

.tg-output-actions #resultActionsHost {
    flex: 1 1 auto;
    min-width: 0;
}

.tg-output-actions .result-actions {
    margin: 0;
}

.tg-output-actions .ra-btn,
.tg-link-button {
    min-height: 44px;
}

.tg-history {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid #dbe2ec;
}

.tg-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.tg-history h2 {
    margin: 0;
    color: #293548;
    font-size: 1rem;
    letter-spacing: -0.02em;
}

.tg-history-clear {
    border: 0;
    background: transparent;
    color: #64748b;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 750;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.tg-history-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.tg-history-item {
    display: block;
    min-height: 48px;
    padding: 9px 11px;
    border: 1px solid #d7dee8;
    border-radius: 11px;
    background: #ffffff;
    color: #334155;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 730;
    line-height: 1.35;
    text-align: left;
    cursor: pointer;
}

.tg-history-item:hover {
    border-color: #99a6b7;
}

.tg-history-empty {
    grid-column: 1 / -1;
    margin: 0;
    color: #758195;
    font-size: 0.84rem;
}

.tg-section {
    margin-top: 72px;
}

.tg-section h2 {
    max-width: 860px;
    margin: 0;
    color: #172033;
    font-size: clamp(1.75rem, 3vw, 2.7rem);
    line-height: 1.1;
    letter-spacing: -0.04em;
}

.tg-section > p,
.tg-section .tg-intro {
    max-width: 850px;
    color: var(--tg-muted);
    font-size: 1rem;
    line-height: 1.78;
}

.tg-mode-explainer {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-top: 26px;
}

.tg-explainer-item {
    padding: 20px;
    border-top: 3px solid var(--item-accent, #64748b);
    background: #ffffff;
    box-shadow: 0 10px 28px rgba(24, 34, 54, 0.07);
}

.tg-explainer-item h3 {
    margin: 0 0 10px;
    color: #1d293d;
    font-size: 1.08rem;
}

.tg-explainer-item p {
    margin: 0;
    color: var(--tg-muted);
    font-size: 0.92rem;
    line-height: 1.65;
}

.tg-two-column {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 36px;
    margin-top: 26px;
}

.tg-two-column h3 {
    margin: 0 0 9px;
    color: #273247;
    font-size: 1.08rem;
}

.tg-two-column p,
.tg-two-column li {
    color: var(--tg-muted);
    line-height: 1.72;
}

.tg-two-column ul {
    margin: 12px 0 0;
    padding-left: 20px;
}

.tg-rule-list {
    display: grid;
    gap: 0;
    margin-top: 24px;
    border-top: 1px solid var(--tg-border);
}

.tg-rule {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr);
    gap: 24px;
    padding: 23px 0;
    border-bottom: 1px solid var(--tg-border);
}

.tg-rule h3 {
    margin: 0;
    color: #263248;
    font-size: 1rem;
}

.tg-rule p {
    margin: 0;
    color: var(--tg-muted);
    line-height: 1.72;
}

.tg-type-reference {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 9px;
    margin-top: 24px;
}

.tg-type-reference span {
    display: flex;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border: 1px solid color-mix(in srgb, var(--type-color) 56%, #d7dee8);
    border-radius: 12px;
    background: color-mix(in srgb, var(--type-color) 14%, #ffffff);
    color: #202b3e;
    font-size: 0.86rem;
    font-weight: 820;
}

.tg-related-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-top: 24px;
}

.tg-related-card {
    display: block;
    min-height: 155px;
    padding: 20px;
    border: 1px solid var(--tg-border);
    border-radius: 18px;
    background: #ffffff;
    color: inherit;
    text-decoration: none;
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.tg-related-card:hover {
    border-color: #aeb9c8;
    transform: translateY(-3px);
    box-shadow: 0 14px 30px rgba(22, 32, 51, 0.1);
}

.tg-related-card h3 {
    margin: 0 0 8px;
    color: #1e293b;
    font-size: 1.04rem;
}

.tg-related-card p {
    margin: 0;
    color: var(--tg-muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

.tg-faq-list {
    display: grid;
    gap: 0;
    margin-top: 22px;
    border-top: 1px solid var(--tg-border);
}

.tg-faq-list details {
    border-bottom: 1px solid var(--tg-border);
}

.tg-faq-list summary {
    min-height: 60px;
    padding: 18px 42px 18px 0;
    color: #263248;
    font-weight: 820;
    cursor: pointer;
}

.tg-faq-list details p {
    max-width: 850px;
    margin: -4px 0 20px;
    color: var(--tg-muted);
    line-height: 1.72;
}

.tg-mode-button:focus-visible,
.tg-secondary-button:focus-visible,
.tg-link-button:focus-visible,
.tg-reset-button:focus-visible,
.tg-generate-button:focus-visible,
.tg-history-item:focus-visible,
.tg-history-clear:focus-visible,
.tg-type-option input:focus-visible + label,
.tg-seed-row input:focus-visible,
.tg-types-details summary:focus-visible,
.tg-faq-list summary:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--tg-focus) 52%, transparent);
    outline-offset: 3px;
}

@media (max-width: 980px) {
    .tg-app {
        grid-template-columns: 1fr;
    }

    .tg-controls {
        border-right: 0;
        border-bottom: 1px solid var(--tg-border);
    }

    .tg-mode-explainer,
    .tg-related-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .tg-type-reference {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 680px) {
    body.type-generator-page main.container {
        width: min(100% - 20px, 1180px);
        padding-top: 28px;
    }

    body.type-generator-page .tg-heading h1 {
        font-size: clamp(2.2rem, 13vw, 3.45rem);
    }

    .tg-app {
        min-height: 0;
        border-radius: 22px;
    }

    .tg-controls,
    .tg-output {
        padding: 20px;
    }

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

    .tg-mode-button {
        min-height: 62px;
        font-size: 0.86rem;
    }

    .tg-seed-row {
        grid-template-columns: 1fr;
    }

    .tg-type-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .tg-type-option label {
        min-height: 44px;
        font-size: 0.73rem;
    }

    .tg-primary-row {
        grid-template-columns: 1fr;
    }

    .tg-generate-button,
    .tg-reset-button {
        min-height: 50px;
    }

    .tg-result-card {
        min-height: 355px;
        padding: 22px;
    }

    .tg-result-title {
        font-size: clamp(2.05rem, 12vw, 3.2rem);
    }

    .tg-result-grid {
        grid-template-columns: 1fr;
    }

    .tg-output-actions {
        align-items: stretch;
    }

    .tg-output-actions #resultActionsHost,
    .tg-link-button {
        width: 100%;
    }

    .tg-output-actions .result-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .tg-output-actions .ra-btn,
    .tg-link-button {
        width: 100%;
    }

    .tg-history-list,
    .tg-mode-explainer,
    .tg-related-grid,
    .tg-two-column {
        grid-template-columns: 1fr;
    }

    .tg-rule {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .tg-type-reference {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .tg-section {
        margin-top: 58px;
    }
}

@media (max-width: 390px) {
    .tg-controls,
    .tg-output {
        padding: 16px;
    }

    .tg-type-grid,
    .tg-type-reference {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    .tg-wheel,
    .tg-mode-button,
    .tg-secondary-button,
    .tg-link-button,
    .tg-reset-button,
    .tg-generate-button,
    .tg-related-card {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
