:root {
    --bg: #faf9f6;
    --surface: #ffffff;
    --surface-soft: #f3f6f7;
    --text: #18212b;
    --muted: #6d7680;
    --line: #e4e7e9;
    --accent: #315f69;
    --accent-hover: #254c54;
    --accent-soft: #e9f0f1;
    --warm-soft: #f5f1e8;
    --shadow: 0 12px 32px rgba(20, 31, 38, 0.06);
    --radius: 18px;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "Hiragino Sans",
        "Yu Gothic",
        "Meiryo",
        sans-serif;
    line-height: 1.7;
}

.site-header {
    background: rgba(250, 249, 246, 0.96);
    border-bottom: 1px solid var(--line);
}

.site-brand {
    color: var(--text);
    font-family:
        Georgia,
        "Times New Roman",
        "Yu Mincho",
        serif;
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-decoration: none;
}

.site-brand:hover {
    color: var(--accent);
}

.page-shell {
    min-height: 70vh;
}

.hero {
    max-width: 780px;
    margin: 0 auto 3.5rem;
    text-align: center;
}

.hero-title {
    margin-bottom: 1rem;
    font-family:
        Georgia,
        "Times New Roman",
        "Yu Mincho",
        serif;
    font-size: clamp(1.9rem, 4vw, 3rem);
    font-weight: 500;
    line-height: 1.35;
    letter-spacing: -0.015em;
}

.hero-text {
    max-width: 650px;
    margin: 0 auto;
    color: var(--muted);
    font-size: 1rem;
}

.artwork-card {
    height: 100%;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}


.artwork-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    padding: 1.25rem;
    background: #f1f1ef;
    overflow: hidden;
}

.artwork-frame img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 180ms ease;
}


.rating-area {
    padding: 1.1rem 1.2rem 1.3rem;
}

.rating-input-group {
    overflow: hidden;
    border: 1px solid #cfd5d8;
    border-radius: 12px;
    background: var(--surface);
}

.rating-field-error[hidden] {
    display: none !important;
}

/* Field-specific validation appears directly below the corresponding score. */
.rating-field-error {
    margin: 0.55rem 0 0;
    color: #8a3026;
    font-size: 0.86rem;
    line-height: 1.5;
}

.rating-input-group.is-invalid,
.rating-input-group.is-invalid:focus-within {
    border-color: #a74436;
}

.rating-input {
    min-height: 50px;
    background: transparent;
    border: 0;
    box-shadow: none !important;
    font-size: 1.05rem;
}

.rating-input:focus {
    background: transparent;
}

/* The placeholder explains the 1–10 score range. */
.rating-input::placeholder {
    color: var(--muted);
    opacity: 0.65;
    font-weight: 400;
}

.rating-input-group:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(49, 95, 105, 0.12);
}

.submit-area {
    margin-top: 3rem;
    text-align: center;
}

.primary-action {
    min-width: min(360px, 100%);
    padding: 0.9rem 2rem;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 999px;
    color: #fff;
    font-weight: 600;
    transition:
        background 160ms ease,
        transform 160ms ease;
}

.primary-action:hover,
.primary-action:focus {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
    transform: translateY(-1px);
}

.primary-action:disabled {
    opacity: 0.65;
    transform: none;
}

.results-header {
    max-width: 760px;
    margin: 0 auto 3.5rem;
    text-align: center;
}

.results-title {
    font-family:
        Georgia,
        "Times New Roman",
        serif;
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 500;
}

.result-section {
    padding: 2rem;
    border-radius: 24px;
}

.result-section-recommended {
    background: #F4DBC1;
}

.result-section-contrasting {
    background: #D1E8F5;
}

.result-section-title {
    margin-bottom: 1.75rem;
    font-family:
        Georgia,
        "Times New Roman",
        "Yu Mincho",
        serif;
    font-size: clamp(1.4rem, 3vw, 1.9rem);
    font-weight: 500;
}

.result-col {
    width: 20%;
}

.result-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid rgba(24, 33, 43, 0.08);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(20, 31, 38, 0.05);
}

.result-image-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    padding: 0.75rem;
    background: #f1f1ef;
    overflow: hidden;
}

.result-image-frame img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.result-card-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: 1rem;
}

.result-title {
    margin-bottom: 0.4rem;
    font-family:
        Georgia,
        "Times New Roman",
        serif;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
}

.result-creator {
    min-height: 2.6em;
    margin-bottom: 0.75rem;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.4;
}

.result-museum {
    margin-top: auto;
    margin-bottom: 0.9rem;
    font-size: 0.82rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.external-link {
    display: inline-block;
    width: 100%;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--accent);
    border-radius: 10px;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
}

.external-link:hover {
    background: var(--accent);
    color: #fff;
}

.survey-panel {
    max-width: 860px;
    margin: 4rem auto 0;
    padding: 2rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.secondary-action {
    display: inline-block;
    padding: 0.75rem 1.3rem;
    border: 1px solid #b9c0c4;
    border-radius: 999px;
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
}

.secondary-action:hover {
    background: var(--surface-soft);
    color: var(--text);
}

.site-footer {
    margin-top: 5rem;
    background: var(--surface);
    border-top: 1px solid var(--line);
}

.footer-inner {
    padding: 2rem 0;
    color: var(--muted);
    font-size: 0.88rem;
    text-align: center;
}

.footer-link {
    color: var(--accent);
    text-decoration: none;
}

.footer-link:hover {
    text-decoration: underline;
}

/* Loading overlay */

.loading-overlay {
    position: fixed;
    z-index: 2000;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(250, 249, 246, 0.9);
    backdrop-filter: blur(4px);
}

.loading-overlay.is-visible {
    display: flex;
}

.loading-panel {
    width: min(520px, 100%);
    padding: 2.5rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow);
    text-align: center;
}

.loading-spinner {
    width: 38px;
    height: 38px;
    margin: 0 auto 1.5rem;
    border: 3px solid #dbe2e4;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-title {
    margin-bottom: 0.75rem;
    font-family:
        Georgia,
        "Times New Roman",
        "Yu Mincho",
        serif;
    font-size: 1.4rem;
}

.loading-text {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

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

/* Responsive */

@media (max-width: 991.98px) {
    .result-col {
        width: 50%;
    }

    .result-section {
        padding: 1.5rem;
    }
}

@media (max-width: 575.98px) {
    .hero {
        margin-bottom: 2.5rem;
    }

    .artwork-frame {
        padding: 1rem;
    }

    .result-col {
        width: 100%;
    }

    .result-section {
        padding: 1rem;
        border-radius: 18px;
    }

    .survey-panel {
        padding: 1.5rem;
    }
}

/* Language controls: compact and usable on narrow screens. */
.language-switch-button {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0.25rem 0.125rem;
  font: inherit;
  font-size: 0.875rem;
  opacity: 0.7;
  cursor: pointer;
}
.language-switch-button[aria-pressed="true"] {
  font-weight: 700;
  opacity: 1;
  text-decoration: underline;
  text-underline-offset: 0.25rem;
}
.language-switch-button:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

/* Keep native numeric validation without visible increment/decrement buttons. */
.rating-input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}
.rating-input[type="number"]::-webkit-inner-spin-button,
.rating-input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Male face input uses a portrait frame; preserve aspect ratio without cropping. */
.male-face-site .artwork-frame { aspect-ratio: 3 / 4; }
.mode-mark { font-size:.8rem; letter-spacing:.03em; color:var(--muted); margin-left:1.25rem; }
@media (max-width:520px){ .mode-mark{ display:block; margin-left:0; } }

/* One-to-ten rating layout */
.rating-input { min-width: 0; }
.rating-suffix {
    border: 0;
    background: transparent;
    color: var(--muted);
    padding-inline: 0.9rem;
}
.rating-scale-help {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.35rem 0.75rem;
    color: var(--muted);
    font-size: 0.77rem;
    margin: 0.55rem 0 0;
}
.scale-separator { opacity: 0.45; }

/* Discrete 1–10 slider. Each card starts explicitly unselected. */
.rating-score-display {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.35rem;
    margin: 0.25rem 0 0.4rem;
}
.rating-score-number {
    min-width: 1.55em;
    color: var(--accent);
    font-size: 2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    text-align: right;
}
.rating-score-unit { color: var(--muted); font-size: 0.92rem; }
.rating-slider {
    display: block;
    width: 100%;
    height: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    touch-action: auto;
    --slider-progress: 44.444%;
}
.rating-slider::-webkit-slider-runnable-track {
    height: 8px;
    border-radius: 999px;
    background: #dfe6e8;
}
.rating-slider.is-rated::-webkit-slider-runnable-track {
    background: linear-gradient(to right,
        var(--accent) 0%, var(--accent) var(--slider-progress),
        #dfe6e8 var(--slider-progress), #dfe6e8 100%);
}
.rating-slider::-moz-range-track {
    height: 8px;
    border-radius: 999px;
    background: #dfe6e8;
}
.rating-slider.is-rated::-moz-range-progress {
    height: 8px;
    border-radius: 999px;
    background: var(--accent);
}
.rating-slider::-webkit-slider-thumb {
    width: 26px;
    height: 26px;
    margin-top: -9px;
    border: 3px solid var(--accent);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 6px rgba(20,31,38,.15);
    appearance: none;
    -webkit-appearance: none;
}
.rating-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border: 3px solid var(--accent);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 6px rgba(20,31,38,.15);
}
.rating-slider:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.rating-slider-ticks {
    display: flex;
    justify-content: space-between;
    gap: 0;
    padding-inline: 13px;
    margin-top: -2px;
    color: var(--muted);
    font-size: 0.76rem;
    font-variant-numeric: tabular-nums;
    user-select: none;
    pointer-events: none;
}
.rating-slider-tick {
    position: relative;
    width: 0;
    overflow: visible;
    display: flex;
    justify-content: center;
    white-space: nowrap;
    padding-top: 6px;
}
.rating-slider-tick::before {
    position: absolute;
    top: 0;
    width: 1px;
    height: 5px;
    background: #b6c4c8;
    content: '';
}
.rating-slider-footer { margin-top: 1.75rem; }
.rating-scale-help { margin-top: 0; }
.rating-progress {
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--muted);
}
.rating-noscript {
    margin-top: 1rem;
    color: #8a3026;
    text-align: center;
}
@media (max-width: 380px) {
    .rating-area { padding: 0.9rem; }
    .rating-scale-help { font-size: 0.73rem; }
}
