:root {
    --bg-page: #f0f9ff;
    --bg-surface: rgba(255, 255, 255, 0.9);
    --bg-elevated: #ffffff;
    --text-main: #0c4a6e;
    --text-muted: #25638a;
    --primary: #0ea5e9;
    --primary-strong: #0284c7;
    --accent: #f97316;
    --accent-strong: #ea580c;
    --border: #bfe6fb;
    --shadow: 0 16px 40px rgba(2, 132, 199, 0.14);
    --focus-ring: rgba(249, 115, 22, 0.38);
    --result-bg: linear-gradient(160deg, #e0f2fe, #f0f9ff);
}

[data-theme="dark"] {
    --bg-page: #041022;
    --bg-surface: rgba(10, 26, 47, 0.86);
    --bg-elevated: #0f2744;
    --text-main: #e0f2fe;
    --text-muted: #b7d8ee;
    --primary: #38bdf8;
    --primary-strong: #0ea5e9;
    --accent: #fb923c;
    --accent-strong: #f97316;
    --border: #1f456f;
    --shadow: 0 20px 50px rgba(0, 0, 0, 0.34);
    --focus-ring: rgba(56, 189, 248, 0.45);
    --result-bg: linear-gradient(160deg, #0d2d4f, #113559);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    max-width: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    padding: 20px 14px 32px;
    font-family: 'Work Sans', sans-serif;
    line-height: 1.65;
    color: var(--text-main);
    background: radial-gradient(circle at 10% 10%, rgba(56, 189, 248, 0.18), transparent 40%),
                radial-gradient(circle at 90% 30%, rgba(14, 165, 233, 0.14), transparent 45%),
                var(--bg-page);
    transition: background-color 0.25s ease, color 0.25s ease;
    -webkit-text-size-adjust: 100%;
}

h1,
h2,
h3,
p,
li,
summary,
th,
td {
    overflow-wrap: break-word;
}

.aurora-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: -1;
}

.blob {
    position: absolute;
    border-radius: 999px;
    filter: blur(50px);
    opacity: 0.48;
    animation: drift 10s ease-in-out infinite alternate;
}

.blob-one {
    width: 360px;
    height: 360px;
    background: #7dd3fc;
    top: -80px;
    left: -60px;
}

.blob-two {
    width: 420px;
    height: 420px;
    background: #38bdf8;
    top: 30%;
    right: -110px;
    animation-delay: 1.2s;
}

.blob-three {
    width: 340px;
    height: 340px;
    background: #fdba74;
    bottom: -110px;
    left: 40%;
    animation-delay: 2s;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--bg-surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
}

.hero {
    padding: 26px 20px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.16), rgba(249, 115, 22, 0.1));
    border: 1px solid var(--border);
}

.eyebrow {
    margin: 0 0 6px;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--primary-strong);
}

.hero h1 {
    margin: 0;
    font-family: 'Outfit', sans-serif;
    font-size: clamp(1.85rem, 4vw, 2.75rem);
    line-height: 1.15;
}

.brand-note {
    max-width: 760px;
    margin: 12px 0 0;
    color: var(--text-muted);
    font-size: 1.05rem;
}

.jump-links {
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.jump-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--primary-strong);
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.jump-links a:hover {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.jump-links a:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--focus-ring);
}

.hero-points {
    margin-top: 20px;
    display: grid;
    gap: 14px;
}

.point-card {
    margin: 0;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    display: grid;
    grid-template-columns: 38px 1fr;
    gap: 12px;
    align-items: start;
}

.point-card svg {
    width: 28px;
    height: 28px;
    fill: var(--primary-strong);
}

.point-card h3 {
    margin: 0 0 4px;
    font-size: 1.04rem;
    font-family: 'Outfit', sans-serif;
}

.point-card p {
    margin: 0;
    color: var(--text-muted);
}

main {
    margin-top: 20px;
    display: grid;
    gap: 18px;
    min-width: 0;
}

main > * {
    min-width: 0;
}

.seo-section,
.input-section,
.result-section,
.quick-guide article {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    background: var(--bg-elevated);
}

.seo-section h2,
.input-section h2,
.result-section h2 {
    margin: 0 0 10px;
    font-family: 'Outfit', sans-serif;
    color: var(--primary-strong);
}

.lead {
    margin: 0 0 12px;
}

.what-you-learn,
.result-hints ul,
.prep-grid ul {
    margin: 0;
    padding-left: 18px;
}

.quick-guide {
    display: grid;
    gap: 12px;
    min-width: 0;
}

.quick-guide h3 {
    margin: 0 0 4px;
    font-size: 1rem;
    font-family: 'Outfit', sans-serif;
    color: var(--primary-strong);
}

.quick-guide p {
    margin: 0;
    color: var(--text-muted);
}

.calculator-grid {
    display: grid;
    gap: 16px;
    min-width: 0;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.form-group input[type="date"],
.form-group input[type="time"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background-color: var(--bg-elevated);
    color: var(--text-main);
    font-family: 'Work Sans', sans-serif;
    font-size: 16px;
    font-weight: 400;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.time-picker {
    position: relative;
    z-index: 3;
}

.time-trigger {
    width: 100%;
    min-height: 50px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-elevated);
    color: var(--text-main);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.time-trigger:hover {
    border-color: var(--accent);
}

.time-trigger:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--focus-ring);
}

.time-trigger-value {
    font-family: 'Work Sans', sans-serif;
    font-size: 16px;
    font-weight: 400;
    letter-spacing: 0;
    color: var(--text-main);
}

.time-trigger-icon {
    width: 10px;
    height: 10px;
    border-right: 2px solid var(--text-main);
    border-bottom: 2px solid var(--text-main);
    transform: rotate(45deg) translateY(-2px);
    transition: transform 0.2s ease;
}

.time-picker.is-open .time-trigger {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--focus-ring);
}

.time-picker.is-open .time-trigger-icon {
    transform: rotate(-135deg) translateY(-1px);
}

.time-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-elevated);
    box-shadow: 0 18px 36px rgba(2, 26, 59, 0.18);
    padding: 10px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 1px minmax(0, 1fr);
    gap: 10px;
}

.time-panel[hidden] {
    display: none !important;
}

.time-column {
    min-width: 0;
}

.time-column-label {
    display: block;
    margin: 0 0 8px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--primary-strong);
    text-align: center;
}

.time-column-divider {
    background: var(--border);
    border-radius: 1px;
}

.time-options {
    max-height: 210px;
    overflow-y: auto;
    padding-right: 2px;
}

.time-option {
    width: 100%;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    text-align: center;
    padding: 8px 10px;
    cursor: pointer;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.time-option:hover {
    background: rgba(14, 165, 233, 0.12);
}

.time-option.is-selected {
    background: rgba(14, 165, 233, 0.22);
    color: #04558b;
}

.time-options::-webkit-scrollbar {
    width: 8px;
}

.time-options::-webkit-scrollbar-thumb {
    background: rgba(14, 165, 233, 0.35);
    border-radius: 999px;
}

.form-group input[type="time"].native-time-input {
    position: absolute;
    width: 1px;
    height: 1px;
    min-width: 1px;
    padding: 0;
    border: 0;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}

.form-group input[type="date"]:focus-visible,
.form-group input[type="time"]:focus-visible,
.form-group input[type="number"]:focus-visible,
.form-group select:focus-visible,
.cta-button:focus-visible,
#language-select:focus-visible,
#theme-toggle:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--focus-ring);
}

.radio-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.radio-group input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.radio-group label {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 999px;
    min-height: 40px;
    padding: 8px 14px;
    background: var(--bg-elevated);
    color: var(--text-main);
    cursor: pointer;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.22s ease;
}

.radio-group input[type="radio"]:focus-visible + label {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--focus-ring);
}

.radio-group input[type="radio"]:checked + label {
    border-color: var(--primary);
    color: #ffffff;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
}

.cta-button {
    width: 100%;
    border: 0;
    border-radius: 10px;
    min-height: 46px;
    padding: 14px 16px;
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(140deg, var(--accent), var(--accent-strong));
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.cta-button:hover {
    filter: brightness(1.02);
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(249, 115, 22, 0.24);
}

.result-display {
    padding: 18px;
    border-radius: 12px;
    border: 1px solid var(--border);
    text-align: center;
    font-size: 1.08rem;
    font-weight: 600;
    background: var(--result-bg);
}

.result-display p {
    margin: 0;
}

.result-time {
    margin-top: 8px;
    display: block;
    font-size: 1.2rem;
    font-family: 'Outfit', sans-serif;
}

.result-breakdown {
    margin-top: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
}

.result-error {
    color: #b91c1c;
    font-weight: 700;
}

.result-hints {
    margin-top: 14px;
    border-top: 1px dashed var(--border);
    padding-top: 12px;
}

.result-hints h3,
.prep-grid h3 {
    margin: 0 0 8px;
    font-family: 'Outfit', sans-serif;
    font-size: 1.02rem;
}

.prep-grid {
    display: grid;
    gap: 12px;
    min-width: 0;
}

.prep-grid article {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    background: var(--bg-surface);
}

.prep-grid article h3 a {
    color: var(--primary-strong);
    text-decoration: none;
}

.prep-grid article h3 a:hover,
.prep-grid article h3 a:focus-visible {
    text-decoration: underline;
}

.buffer-table-wrap {
    margin-top: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-surface);
    padding: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.buffer-table-wrap h3 {
    margin: 0 0 8px;
    font-family: 'Outfit', sans-serif;
    font-size: 1.02rem;
}

.buffer-table {
    width: 100%;
    min-width: 520px;
    border-collapse: collapse;
    table-layout: auto;
    font-size: 0.94rem;
}

.buffer-table .col-type {
    width: 32%;
}

.buffer-table .col-buffer {
    width: 22%;
}

.buffer-table .col-notes {
    width: 46%;
}

.buffer-table caption {
    caption-side: top;
    text-align: left;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-muted);
}

.buffer-table th,
.buffer-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
    line-height: 1.5;
}

.buffer-table th {
    font-family: 'Outfit', sans-serif;
    color: var(--primary-strong);
}

.buffer-table tbody tr:last-child td {
    border-bottom: 0;
}

.seo-section ol {
    margin-top: 0;
    padding-left: 18px;
}

.faq-list details {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 10px;
    background-color: var(--bg-surface);
}

.faq-list summary {
    cursor: pointer;
    font-weight: 700;
}

.faq-list p {
    margin: 8px 0 0;
    color: var(--text-muted);
}

footer {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.icon-attribution {
    margin: 8px 0 0;
    font-size: 0.85rem;
}

.icon-attribution a {
    color: var(--text-muted);
}

.icon-attribution a:hover,
.icon-attribution a:focus-visible {
    color: var(--primary-strong);
}

.friend-links {
    margin-top: 10px;
}

.friend-links-title {
    margin: 0 0 6px;
    font-size: 0.88rem;
    letter-spacing: 0.02em;
}

.friend-links-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 8px 14px;
    justify-content: center;
    flex-wrap: wrap;
}

.friend-links-list a {
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 1px dashed transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.friend-links-list a:hover,
.friend-links-list a:focus-visible {
    color: var(--primary-strong);
    border-bottom-color: var(--primary-strong);
}

.footer-controls {
    margin-top: 8px;
    display: inline-flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.language-switcher,
.theme-switcher {
    display: inline-flex;
    gap: 10px;
    align-items: center;
}

#language-select {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-elevated);
    color: var(--text-main);
    min-height: 34px;
    padding: 4px 10px;
    font-family: 'Work Sans', sans-serif;
    font-size: 0.9rem;
}

#theme-toggle {
    width: 40px;
    height: 22px;
    appearance: none;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #ffffff;
    position: relative;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#theme-toggle::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-strong);
    transition: transform 0.2s ease;
}

#theme-toggle:checked {
    background: #08233f;
}

#theme-toggle:checked::after {
    transform: translateX(18px);
    background: var(--accent);
}

@keyframes drift {
    0% {
        transform: translateY(0) scale(1);
    }
    100% {
        transform: translateY(-18px) scale(1.08);
    }
}

@media (min-width: 768px) {
    body {
        padding: 26px;
    }

    .container {
        padding: 24px;
    }

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

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

    .calculator-grid {
        grid-template-columns: 1.1fr 0.9fr;
    }

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

@media (max-width: 767px) {
    body {
        padding: 12px 10px 24px;
    }

    .container {
        padding: 12px;
        border-radius: 16px;
    }

    .hero {
        padding: 18px 14px;
        border-radius: 14px;
    }

    .hero h1 {
        font-size: clamp(1.55rem, 7.8vw, 2rem);
    }

    .brand-note {
        font-size: 0.98rem;
        line-height: 1.55;
    }

    .jump-links {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .jump-links a {
        width: 100%;
        font-size: 0.86rem;
        padding: 8px 10px;
    }

    main {
        gap: 14px;
    }

    .seo-section,
    .input-section,
    .result-section,
    .quick-guide article {
        padding: 14px;
        border-radius: 12px;
    }

    .point-card {
        grid-template-columns: 30px 1fr;
        padding: 12px;
        gap: 10px;
    }

    .point-card svg {
        width: 24px;
        height: 24px;
    }

    .radio-group {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .radio-group label {
        width: 100%;
        text-align: center;
    }

    .time-picker {
        z-index: 6;
    }

    .time-trigger {
        min-height: 46px;
        padding: 8px 12px;
    }

    .time-trigger-value {
        font-size: 1rem;
    }

    .time-panel {
        padding: 8px;
        gap: 8px;
    }

    .time-options {
        max-height: 180px;
    }

    .time-option {
        font-size: 0.98rem;
        padding: 7px 8px;
    }

    .result-display {
        padding: 14px;
        font-size: 1rem;
    }

    .result-time {
        font-size: 1.08rem;
    }

    .buffer-table {
        min-width: 520px;
        font-size: 0.9rem;
    }

    .footer-controls,
    .theme-switcher,
    .language-switcher {
        flex-wrap: wrap;
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}
