@import url("https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap");

:root {
        --bg: #f6f4f1;
        --surface: rgba(255, 255, 255, 0.9);
        --text: #0f172a;
        --muted: #5b6475;
        --line: rgba(15, 23, 42, 0.08);
        --primary: #1f3a8a;
        --primary-strong: #1e2f6f;
        --secondary: #eef2f7;
        --accent: #2563eb;
        --shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
      }

* {
        box-sizing: border-box;
      }

body {
        margin: 0;
        font-family: "Space Grotesk", "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
        color: var(--text);
        background:
          radial-gradient(1200px 600px at 10% -10%, rgba(37, 99, 235, 0.16), transparent 55%),
          radial-gradient(900px 500px at 90% -20%, rgba(30, 58, 138, 0.16), transparent 55%),
          linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
        line-height: 1.6;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
      }

main {
        flex: 1;
      }

a {
        color: inherit;
      }

.container {
        width: min(1080px, 100% - 2rem);
        margin-inline: auto;
      }

.site-header {
        padding: 1rem 0;
        border-bottom: 1px solid var(--line);
        background: rgba(255, 255, 255, 0.86);
        backdrop-filter: blur(10px);
        position: sticky;
        top: 0;
      }

.header-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
      }

.brand {
        position: relative;
        display: inline-block;
        padding-bottom: 0.9rem;
        font-weight: 700;
        letter-spacing: 0.02em;
      }

.brand img {
        width: clamp(8.5rem, 22vw, 10.5rem);
        height: auto;
        object-fit: contain;
        display: block;
      }

.brand-text small {
        position: absolute;
        left: 44%;
        top: calc(100% - 0.95rem);
        transform: translateX(-50%);
        font-weight: 500;
        color: var(--muted);
        font-size: 0.8rem;
        line-height: 1;
      }

.lang-switch {
        display: inline-flex;
        gap: 8px;
        align-items: center;
        font-size: 12px;
        color: #6c757d;
      }

.lang-switch a {
        text-decoration: none;
        color: #495057;
      }

.lang-switch .lang-current {
        font-weight: 700;
        color: #343a40;
      }

.button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.4rem;
        text-decoration: none;
        border-radius: 0.7rem;
        padding: 0.62rem 1rem;
        font-weight: 600;
        transition: transform 160ms ease, box-shadow 160ms ease;
      }

.button.primary {
        background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
        color: #ffffff;
        border: 1px solid rgba(30, 58, 138, 0.35);
      }

.button.primary:hover,
.button.primary:focus-visible {
        background: linear-gradient(135deg, #1e2f6f 0%, #1d4ed8 100%);
        transform: translateY(-1px);
        box-shadow: 0 10px 22px rgba(30, 58, 138, 0.25);
      }

.button.secondary {
        background: var(--secondary);
        color: #1f2937;
      }

.site-footer {
        padding: 1.2rem 0 1.8rem;
        border-top: 1px solid var(--line);
        color: var(--muted);
        font-size: 0.9rem;
      }

.footer-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.8rem;
        flex-wrap: wrap;
      }

.footer-links {
        display: flex;
        flex-wrap: wrap;
        gap: 0.9rem;
      }

.site-header { z-index: 1; }
      .calculator-main { padding: 2rem 0 3rem; }
      .back-link { color: var(--primary); }
      h1 { font-size: clamp(1.7rem, 5vw, 2.5rem); margin-bottom: .5rem; }
      .intro, .hint { color: var(--muted); }
      .panel { background: var(--surface); border: 1px solid var(--line); border-radius: .9rem; padding: clamp(1rem, 3vw, 2rem); margin-top: 1.5rem; box-shadow: var(--shadow); }
      .fields { display: grid; grid-template-columns: 2fr 1fr; gap: 1.25rem; }
      label { display: block; font-weight: 600; margin-bottom: .4rem; }
      input { width: 100%; min-width: 0; font: inherit; padding: .75rem; border: 1px solid #a5afbf; border-radius: .5rem; background: white; color: var(--text); }
      input[aria-invalid=true] { border-color: #b42318; }
      :focus-visible { outline: 3px solid #2563eb; outline-offset: 3px; }
      .hint { font-size: .9rem; margin: .5rem 0 0; }
      .actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.25rem; }
      button { font: inherit; cursor: pointer; }
      .button.secondary { border: 1px solid #a5afbf; }
      #error { color: #a51d16; margin-bottom: 0; }
      #error:empty { display: none; }
      .math { font-family: Cambria, 'Times New Roman', serif; font-size: 1.3rem; overflow-wrap: anywhere; }
      .math var, table var { font-style: italic; }
      h2 { font-size: 1.25rem; margin-top: 0; }
      .table-scroll { overflow-x: auto; border: 1px solid #d9e0eb; border-radius: .6rem; margin-top: 1rem; }
      table { border-collapse: collapse; width: 100%; text-align: center; font-variant-numeric: tabular-nums; }
      caption { text-align: left; padding: .75rem 1rem; color: var(--muted); }
      th, td { padding: .8rem 1rem; white-space: nowrap; }
      thead { background: #eef2f7; }
      tbody th { text-align: left; }
      tbody tr + tr { border-top: 1px solid var(--line); }
      .remainder-cell { border-left: 2px solid #a5afbf; }
      .result-row { border-top: 2px solid #1f3a8a; font-weight: 700; background: #eff6ff; color: #1f3a8a; }
      .answers { display: flex; flex-wrap: wrap; gap: 1rem; margin: 1.5rem 0; }
      .answers > div { flex: 1; padding: 1rem; background: #eef2f7; border-radius: .6rem; }
      dt { color: var(--muted); }
      dd { margin: .25rem 0 0; }
      .explanation { padding-left: 1.5rem; }
      .explanation li { margin: .5rem 0; }
      [hidden] { display: none !important; }
      @media(max-width: 600px) { .fields { grid-template-columns: 1fr; } th, td { padding: .7rem; } }
