:root {
    --bg: #f4f7f6;
    --panel: #ffffff;
    --ink: #1f2a36;
    --muted: #5b6b7c;
    --line: #e2e8f0;
    --accent: #2f74ff;
    --accent-dark: #1f57cc;
    --company: #2c3e50;
    --gross: #bdc3c7;
    --net: #f39c12;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f6 100%);
    color: var(--ink);
}

.page {
    max-width: 860px;
    margin: 0 auto;
    padding: 32px 20px 48px;
}

.hero {
    text-align: center;
    margin-bottom: 28px;
}

.hero-eyebrow {
    display: inline-block;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent-dark);
    font-size: 0.85rem;
    margin-bottom: 8px;
    text-decoration: none;
}

.hero-eyebrow:hover {
    text-decoration: underline;
}

.hero h1 {
    font-size: 1.8rem;
    margin: 0 0 10px;
}

.hero-sub {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.card {
    background: var(--panel);
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
    border: 1px solid var(--line);
    padding: 24px;
}

.input-card {
    margin-bottom: 24px;
}

.input-section label {
    display: block;
    font-weight: 700;
    margin-bottom: 10px;
}

.input-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.option-group {
    display: grid;
    gap: 10px;
    padding: 8px 12px;
    background: #f8fafc;
    border: 1px solid #dbe4f0;
    border-radius: 8px;
}

.option-button {
    position: relative;
}

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

.option-button label {
    display: grid;
    place-items: center;
    width: 100%;
    padding: 6px 0;
    border: 1px solid #cbd5f5;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.88rem;
    color: #334155;
    cursor: pointer;
    background: #fff;
    transition: all 0.2s ease;
}

.option-button input:checked + label {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent-dark);
    box-shadow: 0 6px 12px rgba(47, 116, 255, 0.25);
}

.option-button label:hover {
    border-color: var(--accent);
}

.input-row {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.input-row input {
    flex: 1;
    border: 1px solid #cbd5f5;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 1rem;
}

.input-row button {
    border: none;
    background: var(--accent);
    color: #fff;
    padding: 0 18px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.input-row button:hover {
    background: var(--accent-dark);
}

.results-section {
    margin-bottom: 24px;
}

.results-section h2 {
    margin: 0 0 10px;
    font-size: 1.2rem;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 8px;
}

.chart-card {
    margin-bottom: 20px;
}

.takehome-rate-card {
    margin-bottom: 20px;
}

.takehome-rate-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.takehome-rate-row h3 {
    margin: 0;
}

.takehome-rate-row .amount {
    font-weight: 700;
    color: #b42318;
}

.chart-card h3 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 20px;
}

.chart-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding: 20px 0 10px;
}

.chart-column {
    display: flex;
    gap: 30px;
    align-items: flex-end;
    height: 280px;
    border-bottom: 2px solid #cbd5e1;
    padding-bottom: 6px;
}

.chart-bar-container {
    width: 90px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 100%;
    text-align: center;
}

.chart-bar-container::before {
    content: attr(data-label);
    position: absolute;
    bottom: -34px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.78rem;
    color: var(--muted);
    width: 120px;
}

.chart-bar-fill,
.chart-bar-stacked {
    width: 100%;
    transition: height 0.6s ease-out;
    transform-origin: bottom;
}

.chart-bar-fill {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    border-radius: 6px 6px 0 0;
    position: relative;
    overflow: hidden;
    animation: grow 0.8s ease-out;
}

.chart-bar-container.company-cost .chart-bar-fill {
    background: var(--company);
}

.chart-bar-container.gross-income .chart-bar-fill {
    background: var(--gross);
    color: #2d3748;
}

.chart-bar-container.net-income .chart-bar-fill {
    background: var(--net);
}

.chart-bar-value-inner {
    font-size: 0.8rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.chart-bar-stacked {
    border: 2px dashed #49566a;
    border-bottom: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 6px;
    animation: grow 0.8s ease-out;
}

.chart-bar-stacked + .chart-bar-stacked,
.chart-bar-stacked + .chart-bar-fill {
    margin-top: -2px;
}

.gross-income .chart-bar-stacked {
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}

.net-income .chart-bar-stacked:first-of-type {
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}

.net-income .chart-bar-stacked + .chart-bar-stacked {
    border-top: 2px dashed #49566a;
    border-radius: 0;
}

.net-income .chart-bar-fill {
    border-top: none;
}

.stacked-bar-value-inner {
    font-size: 0.7rem;
    font-weight: 700;
    color: #1f2937;
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.9);
}

.stacked-label-line {
    position: absolute;
    right: -24px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 1px;
    background: #475569;
    pointer-events: none;
}

.stacked-label-text {
    position: absolute;
    left: calc(100% + 4px);
    top: 50%;
    transform: translateY(-50%);
    background: #f1f5f9;
    color: #1f2937;
    border: 1px solid #cbd5e1;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.72rem;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
    pointer-events: none;
}

.is-capturing .chart-bar-fill,
.is-capturing .chart-bar-stacked {
    animation: none !important;
    transition: none !important;
    transform: none !important;
}

@keyframes grow {
    from { transform: scaleY(0); }
    to { transform: scaleY(1); }
}

.deductions-card h3 {
    margin-top: 0;
}

.deduction-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px dashed #cbd5e1;
    font-size: 0.95rem;
}

.deduction-item:last-child {
    border-bottom: none;
}

.deduction-item .amount {
    font-weight: 700;
    color: #b42318;
}

.share-section {
    text-align: center;
    margin-bottom: 24px;
}

.share-section h3 {
    margin-bottom: 12px;
}

.share-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.share-buttons button {
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

#share-twitter {
    background: #111827;
}

#share-facebook {
    background: #1877f2;
}

#copy-link {
    background: #334155;
}

#copy-link.is-copied {
    background: #16a34a;
}

#save-image {
    background: #16a34a;
}

.share-copy-box {
    margin: 16px auto 0;
    max-width: 720px;
    border: 1px solid #dbe4f0;
    border-radius: 10px;
    background: #ffffff;
    padding: 14px;
    text-align: left;
}

.share-copy-box h4 {
    margin: 0 0 10px;
    font-size: 1rem;
}

.share-copy-options {
    display: grid;
    gap: 10px;
    margin-bottom: 10px;
}

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

.share-copy-option-title {
    margin: 0;
    width: 72px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #334155;
}

.share-copy-option-buttons {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
}

.share-copy-option {
    position: relative;
}

.share-copy-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.share-copy-option label {
    display: inline-block;
    padding: 6px 12px;
    border: 1px solid #cbd5f5;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #334155;
    cursor: pointer;
    background: #fff;
    transition: all 0.2s ease;
}

.share-copy-option input:checked + label {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent-dark);
    box-shadow: 0 4px 10px rgba(47, 116, 255, 0.2);
}

.share-copy-option label:hover {
    border-color: var(--accent);
}

.share-copy-textarea {
    width: 100%;
    min-height: 84px;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.92rem;
    line-height: 1.5;
    color: #1f2937;
    background: #f8fafc;
    resize: vertical;
}

.share-copy-actions {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
}

#copy-share-text {
    border: none;
    padding: 10px 14px;
    border-radius: 8px;
    color: #fff;
    background: #0f766e;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

#copy-share-text.is-copied {
    background: #16a34a;
}

.calculation-details-section h3 {
    margin-top: 0;
    margin-bottom: 12px;
}

.calculation-details-section p,
.calculation-details-section ul {
    font-size: 0.92rem;
    color: var(--muted);
}

.calculation-details-section ul {
    padding-left: 18px;
}

.faq-section {
    margin-top: 20px;
}

.faq-section h3 {
    margin-top: 0;
    margin-bottom: 12px;
}

.faq-list {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
}

.faq-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    padding: 10px 12px;
}

.faq-item summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--ink);
    list-style-position: inside;
}

.faq-item[open] summary {
    margin-bottom: 8px;
}

.faq-item p {
    margin: 0;
    font-size: 0.92rem;
    color: var(--muted);
}

.site-footer {
    text-align: center;
    color: #94a3b8;
    font-size: 0.85rem;
    margin-top: 30px;
}

@media (max-width: 720px) {
    .hero h1 {
        font-size: 1.5rem;
    }

    .input-row {
        flex-direction: column;
    }

    .share-copy-option-title {
        width: 100%;
    }

    .chart-wrapper {
        overflow: visible;
        padding: 20px 0 32px;
    }

    .chart-column {
        --bar-width: clamp(40px, 14vw, 60px);
        --bar-gap: clamp(4px, 1.5vw, 10px);
        --label-width: clamp(68px, 22vw, 92px);
        --edge-pad: 6px;
        --label-line: clamp(8px, 2.6vw, 12px);
        width: 100%;
        gap: var(--bar-gap);
        height: 240px;
        justify-content: space-between;
        padding-left: var(--edge-pad);
        padding-right: calc(var(--label-width) + var(--edge-pad));
    }

    .chart-bar-container {
        width: var(--bar-width);
    }

    .chart-bar-container::before {
        width: clamp(68px, 22vw, 88px);
        font-size: 0.68rem;
        bottom: -40px;
    }

    .stacked-label-line {
        width: var(--label-line);
        right: calc(-1 * var(--label-line));
    }

    .stacked-label-text {
        font-size: clamp(0.6rem, 2.6vw, 0.7rem);
        white-space: normal;
        width: var(--label-width);
        max-width: var(--label-width);
        line-height: 1.2;
        left: calc(100% + 2px);
    }
}
