:root{
  --color-primary: #2E7D32;   /* 深緑：安心・誠実 */
  --color-secondary: #29B6F6; /* スカイブルー：透明感 */
  --color-bg: #F3F7F4;
  --color-text: #333333;      /* チャコールグレー */
  --color-muted: #A5D6A7;     /* ライトグリーン：補助 */
  --color-humble: #888888;

  --radius-xl: 1rem;
  --radius-2xl: 1.25rem;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 6px 18px rgba(0,0,0,.12);
  --gap: 1rem;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--color-bg);
    color: var(--color-text);
}

/* ====== Header ====== */
header {
    background: #fff;
    border-bottom: 1px solid var(--color-muted);
    padding: .75rem 1rem;
    display: flex;
    justify-content: center;
}
header a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
}
header a:hover {
    color: var(--color-secondary);
}

/* ====== 小さめ端末の微調整 ====== */
@media (max-width: 480px) {
    header a {
        font-size: 1rem;
    }

    .footer {
        padding: .9rem 1rem 1.1rem;
    }
}

header .brand{
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    text-decoration: none;
    color: inherit;
}

.brand_icon{
    width: 24px;
    height: 24px;
    display: block; /* 余白防止 */
}

/* メイン余白（カードとの距離を確保） */
main { padding: .75rem 0 1.25rem; }

/* ====== Footer ====== */
.footer {
    background: #fff;
    border-top: 1px solid var(--color-muted);
    padding: 1rem 1rem 1.25rem;
    margin-top: 2rem;
    color: #666;
}
.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem 1.25rem;
    justify-content: center;
    margin: 0 0 .5rem;
}
.footer-links p {
    margin: 0;
}

.footer a {
    color: var(--color-text);
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

.footer a:hover {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.footer .fa {
    margin-right: .4rem;
}

.footer-copy {
    text-align: center;
    margin-top: .5rem;
}

.footer-copy p {
    margin: 0;
}

/* ====== Error message（ベースのまま整える） ====== */
#error-message {
    max-width: 1080px;
    margin: 1rem auto;
    background: #fff;
    border: 1px solid var(--color-muted);
    border-radius: var(--radius-xl);
    padding: .75rem 1rem;
    box-shadow: var(--shadow-sm);
}
.error-list {
    list-style: none;
    margin: 0;
    padding: 0;

}
.error-list li {
    text-align: left;
    color: #b94a48;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

.page-wrapper {
    max-width: 1080px;
    margin: 0 auto;
    padding: 1rem;
}

/* ページタイトル */
.page-titlewrap {
    margin: .5rem 0 1rem;
    padding: 0 .25rem;
}

.page_title {
    font-size: 1.5rem;
    line-height: 1.3;
    margin: 0 0 .25rem;
}

.page_subtitle {
    color: #666;
    margin: 0;
}

.section {
    background: #fff;
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-sm);
    padding: 1rem;
    margin-bottom: 1rem;
}

.section--inputs {
    /* not sticky on any device */
}

.form--grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gap);
}

@media (min-width: 960px) {
    .form--grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.form_field label {
    display: block;
    font-size: .9rem;
    margin-bottom: .25rem;
    color: #333;
}
/*
.form_submit-row {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    margin-top: .25rem;
}
*/
.input_with_suffix {
    position: relative;
}

.input_with_suffix input {
    width: 100%;
    padding: .75rem 2.5rem .75rem .75rem;
    border: 1px solid #ddd;
    border-radius: .75rem;
    outline: none;
}

.input_with_suffix .suffix {
    position: absolute;
    right: .5rem;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
    font-size: .9rem;
}

.form_actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .5rem;
    grid-column: 1 / -1;
}

.btn {
    border: 1px solid #ddd;
    background: #fff;
    padding: .6rem .9rem;
    border-radius: .8rem;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

.btn--primary {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.btn--secondary {
    background: var(--color-secondary);
    color: #fff;
    border-color: var(--color-secondary);
}

.btn--ghost {
    background: #fff;
}

.btn--text {
    background: transparent;
    border-color: transparent;
    color: #666;
}

.btn--lg {
    padding: .8rem 1.25rem;
    font-size: 1.05rem;
}

@media (max-width: 480px) {
    .btn--lg { width: 100%; }
}

.section--graph {
    padding: 0;
    overflow: hidden;
}

.graph_header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    padding: .75rem 1rem;
    border-bottom: 1px solid #eee;
    background: #fff;
}

.graph_tabs {
    display: flex;
    gap: .5rem;
}

.tab {
    border: 1px solid #e5e5e5;
    padding: .45rem .8rem;
    border-radius: 999px;
    background: #fff;
    cursor: pointer;
}

.tab.is-active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.graph_legend {
    display: flex;
    gap: 1rem;
    align-items: center;
    color: #555;
    font-size: .9rem;
}

.legend_item {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}

.legend_dot {
    width: .7rem;
    height: .7rem;
    border-radius: 50%;
    background: var(--color-secondary);
    display: inline-block;
}

.legend_dot--muted {
    background: var(--color-muted);
}

.graph_area {
    padding: 0.5rem;
    min-height: 260px;
    background: #fff;
}

.graph_placeholder {
    height: 420px;
    /*
    border-radius: var(--radius-xl);
    border: 2px dashed #ddd;
    */
    display: grid;
    place-items: center;
    color: #777;
}

.section--summary {}

.summary_grid {
    display: grid;
    gap: var(--gap);
    grid-template-columns: 1fr;
}

@media (min-width: 720px) {
    .summary_grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.summary_card {
    background: #fff;
    border: 1px solid #cbd5d0;
    border-radius: var(--radius-xl);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

.summary_label {
    color: #555;
    font-size: .9rem;
    margin-bottom: .2rem;
}

.summary_value {
    font-size: 1.6rem;
    font-weight: 700;
}

.summary_value .unit {
    font-size: .9rem;
    color: #666;
    margin-left: .2rem;
}

.summary_actions {
    margin-top: .75rem;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

/* modal */
.modal[aria-hidden="true"] {
    display: none;
}

.modal[aria-hidden="false"] {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    z-index: 50;
}

.modal_backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .28);
}

.modal_dialog {
    position: relative;
    background: #fff;
    width: min(680px, 92vw);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    max-height: calc(100vh - 24px);
    display: flex;
    flex-direction: column;
}

.modal_header,
.modal_footer {
    padding: .75rem 1rem;
}

.modal_header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #eee;
    padding-right: 2.5rem;
}

.modal_body {
    padding: 1rem;
    overflow: auto;
    -webkit-overflow-scrolling: touch; /* iOS 慣性スクロール */
}

/* × ボタンをヘッダー右上に重ねる（ヒット領域広め） */
.modal_header .icon_btn {
    position: absolute;
    top: .5rem;
    right: .5rem;
    width: 2rem;
    height: 2rem;
    display: grid;
    place-items: center;
    line-height: 1;
    border-radius: .5rem;
}

/* 触り心地少し向上（任意） */
.modal_header .icon_btn:hover {
    background: rgba(0,0,0,.04);
}
.modal_header .icon_btn:active {
    background: rgba(0,0,0,.08);
}

/* スマホはさらに押しやすく（任意） */
@media (max-width: 480px) {
    .modal_header .icon_btn {
        top: .4rem;
        right: .4rem;
        width: 2.25rem;
        height: 2.25rem;
    }
}

.icon_btn {
    border: none;
    background: transparent;
    font-size: 1.2rem;
    cursor: pointer;
}

.helper_text {
    color: #777;
    font-size: .9rem;
    margin-top: .5rem;
}

/* === 積立ルール：1行レイアウトに寄せる（上書き/追加） === */
#contrib_rules_wrapper {
    overflow-x: auto;         /* はみ出す場合は横スクロール（小画面対策） */
}

.contrib_rule_row {
    display: grid;
    grid-auto-flow: column;   /* 並べた順に横並び */
    grid-auto-columns: max-content;
    align-items: center;
    gap: .5rem;
    padding: .4rem .5rem;     /* コンパクトに */
    border: 1px solid rgba(0,0,0,.08);
    border-radius: var(--radius-xl);
    background: #fff;
    box-shadow: var(--shadow-sm);
    white-space: nowrap;      /* 折り返さない */
}

.contrib_rule_row label {
    margin: 0 .25rem 0 0;     /* ラベルを小さめに横置き */
    font-size: .8rem;
    color: var(--color-primary);
}

.contrib_rule_row input.rule_start,
.contrib_rule_row input.rule_amount {
    width: 6.5rem;
    padding: .35rem .45rem;
    font-size: .9rem;
    border: 1px solid rgba(0,0,0,.12);
    border-radius: .5rem;
}

@media (max-width: 480px) {
    .contrib_rule_row {
        gap: .3rem;
        font-size: .8rem;
    }

    .contrib_rule_row input.rule_start {
        width: 2rem;
        padding: .2rem .3rem;
    }

    .contrib_rule_row input.rule_amount {
        width: 3.5rem;
    }
}

.remove_rule_btn {
    /* border: 1px solid rgba(0,0,0,.12); */
    border: none;
    background: #fff;
    padding: .25rem .45rem;
    border-radius: .5rem;
    line-height: 1;
    cursor: pointer;
}

/* 追加ボタンも控えめに */
#add_rule_btn {
    margin-top: .5rem;
    border: 1px solid var(--color-secondary);
    background: rgba(109,140,119,.06);
    color: var(--color-secondary);
    padding: .35rem .7rem;
    border-radius: var(--radius-xl);
    cursor: pointer;
}

/* モーダルヘッダー内で説明を収める */
.modal_header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    flex-wrap: wrap; /* 説明を2段目に回せるように */
}

/* 折りたたみ説明 */
.modal_help {
    margin-left: auto;        /* タイトル右寄せ */
    font-size: .9rem;
}
.modal_help > summary {
    cursor: pointer;
    list-style: none;
    outline: none;
    color: var(--color-secondary);
}
/*
.modal_help > summary::-webkit-details-marker { display: none; }
.modal_help[open] > summary {
    color: var(--color-text);
}*/

/* 開いたときの本文 */
.modal_help ul {
    margin: .4rem 0 0;
    padding-left: 1.1rem;
    color: var(--color-text);
}
.modal_help li {
    margin: .2rem 0;
    line-height: 1.5;
    font-size: .7rem;
    color: var(--color-humble);
}

/* スマホで詰める */
@media (max-width: 480px) {
    .modal_help { width: 100%; margin-left: 0; }
    .modal_help ul { padding-left: 1rem; }
}
