:root {
    color-scheme: light;
    --background: #f2f3f8;
    --surface: #ffffff;
    --ink: #202230;
    --muted: #8a8d9c;
    --line: #d9dce6;
    --accent: #7b35f2;
    --accent-strong: #4d23e8;
    --pink: #ec0b69;
    --soft-pink: #fff0f7;
    --soft-blue: #eef7ff;
    --error-bg: #fff0ed;
    --error-text: #8a2118;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--background);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    letter-spacing: 0;
    overflow-x: hidden;
}

.page-shell {
    width: min(100%, 420px);
    margin: 0 auto;
    min-height: 100vh;
    padding: 0 0 22px;
    background: #f7f7fb;
    box-shadow: 0 18px 60px rgba(36, 39, 65, 0.16);
}

.label {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.app-header {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 96px;
    padding: 10px 18px;
    background: linear-gradient(110deg, #e30a68 0%, #8a25f3 54%, #4228f5 100%);
    color: #fff;
}

.heart-icon {
    position: relative;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 8px;
}

.header-logo {
    width: 76px;
    height: 76px;
    flex: 0 0 auto;
    border-radius: 8px;
    object-fit: cover;
}

.heart-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #ec0b69, #8a2df3);
}

.heart-icon::before {
    color: #fff;
    font-size: 22px;
    line-height: 1;
    content: "♡";
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1;
}

h2 {
    margin-bottom: 0;
    font-size: 1.12rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.lookup-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 0 18px 0;
    background: transparent;
    border: 0;
    border-radius: 0;
}

.person-card {
    overflow: visible;
    position: relative;
    margin-top: 0;
    background: var(--surface);
    border: 0;
    border-radius: 0 0 12px 12px;
}

.person-card:first-child {
    margin-top: 0;
    z-index: 3;
}

.person-card:nth-of-type(2) {
    z-index: 2;
}

.person-card-top {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 58px;
    padding: 6px 24px;
    background: linear-gradient(110deg, #ffe1ee 0%, #efdfff 55%, #f6e4ff 100%);
}

.person-card:nth-of-type(2) .person-card-top {
    background: linear-gradient(110deg, #e0f7ff 0%, #e3e9ff 55%, #ddf2e9 100%);
}

.toggle-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 12px;
    min-height: 50px;
    margin: 0;
    padding: 0 22px;
    background: #f5f0fb;
    color: var(--ink);
    font-size: 0.86rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.person-card:nth-of-type(2) .toggle-row {
    background: #f5f0fb;
}

.toggle-row input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.toggle-visual {
    position: relative;
    width: 30px;
    height: 18px;
    background: #d7d9df;
    border-radius: 999px;
}

.toggle-visual::after {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(21, 24, 35, 0.2);
    content: "";
    transition: transform 160ms ease;
}

.toggle-row input:checked + .toggle-visual {
    background: var(--accent);
}

.toggle-row input:checked + .toggle-visual::after {
    transform: translateX(12px);
}

.person-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 34px 24px 28px;
    background: var(--surface);
}

label {
    display: grid;
    position: relative;
    gap: 8px;
    min-width: 0;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

select,
input[type="text"],
button {
    width: 100%;
    min-height: 48px;
    border-radius: 8px;
    font: inherit;
}

select,
input[type="text"] {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    padding: 0 12px;
    box-shadow: 0 1px 4px rgba(31, 35, 48, 0.08);
    min-width: 0;
    text-overflow: ellipsis;
}

select.is-placeholder {
    color: rgba(138, 141, 156, 0.68);
}

select option {
    color: var(--ink);
}

.not-listed-field[hidden] {
    display: none;
}

.ts-wrapper.js-enhanced-select {
    min-width: 0;
    position: relative;
    z-index: 20;
}

.ts-wrapper.js-enhanced-select.dropdown-active,
label.is-select-open,
label:has(.ts-wrapper.js-enhanced-select.dropdown-active) {
    z-index: 10000;
}

.ts-wrapper.js-enhanced-select.single .ts-control {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    min-height: 48px;
    height: 48px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(31, 35, 48, 0.08);
    color: var(--ink);
    font: inherit;
    padding: 12px;
}

.ts-wrapper.js-enhanced-select .ts-control input {
    flex: 0 1 auto;
    min-width: 0;
    caret-color: transparent;
    font: inherit;
}

.ts-wrapper.js-enhanced-select .ts-control::after {
    border-color: var(--muted) transparent transparent;
}

.ts-wrapper.js-enhanced-select.single .ts-control .item {
    flex: 1 1 auto;
    min-width: 0;
    max-width: calc(100% - 18px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ts-wrapper.js-enhanced-select.single.has-items .ts-control input {
    flex: 0 0 2px;
    width: 2px !important;
}

.ts-wrapper.js-enhanced-select .option {
    overflow-wrap: anywhere;
}

.ts-wrapper.js-enhanced-select .option.is-not-listed-option {
    border-bottom: 1px solid var(--line);
    background: #f4f5f8;
    color: var(--muted);
    font-weight: 700;
}

.ts-wrapper.js-enhanced-select .option.is-not-listed-option.active,
.ts-wrapper.js-enhanced-select .option.is-not-listed-option:hover {
    background: #eceef4;
    color: var(--ink);
}

.ts-wrapper.js-enhanced-select .ts-dropdown {
    border-color: var(--line);
    border-radius: 8px;
    font: inherit;
    z-index: 10001;
}

.ts-wrapper.js-enhanced-select .ts-control input::placeholder {
    color: rgba(138, 141, 156, 0.68);
}

button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 64px;
    margin-top: -4px;
    border: 0;
    background: linear-gradient(110deg, #ec0b69 0%, #892df3 55%, #4328f5 100%);
    color: #fff;
    padding: 0 18px;
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.04em;
    box-shadow: 0 12px 28px rgba(85, 41, 225, 0.34);
}

button:hover,
button:focus-visible {
    filter: brightness(0.96);
}

button:disabled {
    cursor: wait;
    filter: saturate(0.9) brightness(0.95);
}

.thinking-icon {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 2px solid rgba(255, 255, 255, 0.55);
    border-top-color: #fff;
    border-radius: 50%;
    color: transparent;
    animation: thinking-spin 800ms linear infinite;
}

@keyframes thinking-spin {
    to {
        transform: rotate(360deg);
    }
}

.result,
.notice {
    margin: 24px 18px 0;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow-wrap: anywhere;
}

.notice.error {
    background: var(--error-bg);
    border-color: #e8b8b1;
    color: var(--error-text);
}

.result-box {
    margin: 24px 0 0;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.result-code {
    margin-bottom: 8px;
    color: var(--accent);
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 700;
    line-height: 1;
}

.result-detail,
.result-note {
    margin-bottom: 0;
    overflow-wrap: anywhere;
    font-size: 1.15rem;
    line-height: 1.5;
}

.result-detail {
    color: var(--ink);
    font-weight: 700;
}

.result-note {
    margin-top: 12px;
    color: var(--muted);
}

.result-popup {
    border-radius: 8px;
    color: var(--ink);
}

.popup-show {
    animation: popup-rise 180ms ease-out;
}

.popup-hide {
    animation: popup-fade 140ms ease-in;
}

.popup-pair {
    margin-bottom: 14px;
    color: var(--muted);
    font-weight: 700;
}

.popup-code {
    margin-bottom: 8px;
    color: var(--accent);
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
}

.popup-detail {
    color: var(--ink);
    font-weight: 700;
    line-height: 1.5;
}

.popup-birth-name {
    margin-bottom: 14px;
    color: var(--muted);
    font-weight: 700;
    line-height: 1.5;
}

.popup-note {
    margin-top: 12px;
    color: var(--muted);
    line-height: 1.5;
}

.result-popup-button {
    border-radius: 8px;
    background: linear-gradient(110deg, #ec0b69 0%, #892df3 55%, #4328f5 100%) !important;
}

@keyframes popup-rise {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes popup-fade {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.98);
    }
}

@media (min-width: 560px) {
    .page-shell {
        width: min(100% - 32px, 760px);
        margin-block: 24px;
        min-height: auto;
        border-radius: 8px;
        overflow: visible;
    }

    .lookup-form {
        padding-inline: 24px;
    }

    .person-card {
        border-radius: 8px;
    }

    .person-fields {
        padding-inline: 32px;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .result,
    .notice {
        margin-inline: 24px;
    }
}

@media (min-width: 900px) {
    .page-shell {
        width: min(100% - 48px, 980px);
    }

    .person-fields {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        padding-block: 32px;
    }

    .lookup-form {
        gap: 22px;
    }
}

@media (max-width: 360px) {
    .person-fields {
        grid-template-columns: 1fr;
        padding-inline: 22px;
    }

    .app-header,
    .person-card-top,
    .toggle-row {
        padding-inline: 16px;
    }

    .lookup-form {
        padding-inline: 12px;
    }

    .result,
    .notice {
        margin-inline: 12px;
        padding: 18px;
    }
}
