@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@700;800&display=swap');

/* ===========================
   カルクル - 共通スタイル
   =========================== */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --bg: #eef2f7;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --header-height: 72px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
    background: var(--bg);
    color: var(--text);
    padding-top: calc(var(--header-height) + 16px);
}

/* ===========================
   固定ヘッダー
   =========================== */

.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--primary);
    color: white;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.app-header-inner {
    max-width: 720px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}

/* ===========================
   ロゴ＋キャッチコピー
   =========================== */

.logo-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-decoration: none;
    gap: 1px;
    flex-shrink: 0;
}

.logo-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: white;
    line-height: 1.1;
}

.logo-tagline {
    font-size: 13px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.85);
    letter-spacing: 0.04em;
    line-height: 1.3;
    white-space: nowrap;
}

/* ===========================
   PC ナビ
   =========================== */

.app-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-link {
    display: inline-block;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 14px;
    right: 14px;
    height: 1.5px;
    background: rgba(255, 255, 255, 0.85);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.nav-link:hover::after,
.nav-link.active::after {
    transform: scaleX(1);
}

/* ===========================
   ハンバーガーボタン（スマホのみ）
   =========================== */

.nav-toggle {
    display: none;
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: white;
    font-size: 18px;
    line-height: 1;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    transition: background 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.nav-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: none;
    box-shadow: none;
}

/* ===========================
   スマホ サイドドロワー（モバイルのみ表示）
   =========================== */

/* 半透明オーバーレイ */
.menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1100;
}

/* ドロワー本体 */
.mobile-drawer {
    display: none;
    position: fixed;
    top: 0;
    right: -80%;
    width: 80%;
    max-width: 320px;
    height: 100vh;
    background: var(--surface);
    transition: right 0.3s ease;
    z-index: 1200;
    overflow-y: auto;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
}

/* ドロワーヘッダー */
.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--primary);
    color: white;
    position: sticky;
    top: 0;
    z-index: 1;
}

.drawer-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    font-weight: 800;
    color: white;
    letter-spacing: 0.02em;
}

.drawer-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 4px;
    transition: background 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.drawer-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: none;
    box-shadow: none;
}

.drawer-body {
    padding: 16px 20px 32px;
}

/* ドロワー内カテゴリ */
.nav-cat {
    margin-bottom: 20px;
}

.nav-cat:last-child {
    margin-bottom: 0;
}

.nav-cat-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.mobile-drawer .nav-link {
    display: block;
    padding: 11px 14px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    border-radius: 6px;
    margin-bottom: 2px;
    transition: background 0.15s, color 0.15s;
    position: relative;
}

.mobile-drawer .nav-link::after {
    display: none;
}

.mobile-drawer .nav-link:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.mobile-drawer .nav-link:active {
    background: #bfdbfe;
    color: var(--primary-dark);
}

/* ===========================
   メインカード
   =========================== */

.app-card {
    background: var(--surface);
    border-radius: 16px;
    max-width: 720px;
    margin: 16px auto;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

/* ===========================
   2カラムレイアウト (PC 900px+)
   =========================== */

@media (min-width: 900px) {
    .app-header-inner {
        max-width: 1000px;
    }

    .app-card {
        max-width: 1000px;
    }

    .footer {
        max-width: 1000px;
    }

    .app-card.has-cols {
        display: grid;
        grid-template-columns: 5fr 7fr;
        gap: 0 36px;
        align-items: start;
    }

    .side-info {
        position: sticky;
        top: calc(var(--header-height) + 20px);
        z-index: 1;
    }

    .side-info h1 {
        font-size: 22px;
        margin-bottom: 12px;
        line-height: 1.4;
    }

    .side-info h2 {
        font-size: 16px;
        margin: 16px 0 6px;
        color: var(--text);
    }

    .side-info p,
    .side-info .note {
        font-size: 14px;
        line-height: 1.8;
        color: var(--text-muted);
    }

    /* ツール・履歴・解説は全幅 */
    .app-card.has-cols > .tools,
    .app-card.has-cols > .history-section,
    .app-card.has-cols > .explain-section {
        grid-column: 1 / -1;
    }
}

/* ===========================
   入力セクション
   =========================== */

.input-section {
    background: #f8fafc;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.input-group {
    margin-bottom: 15px;
}

.input-group:last-child {
    margin-bottom: 0;
}

label {
    display: block;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 600;
}

input {
    width: 100%;
    padding: 15px;
    font-size: 18px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.3s, box-shadow 0.3s;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ===========================
   ボタン
   =========================== */

.button-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.button-grid.button-full {
    grid-template-columns: 1fr;
}

button {
    padding: 16px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: var(--primary);
    color: white;
}

button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

button:active {
    transform: translateY(0);
    box-shadow: none;
}

/* ボタンカラーバリエーション（青系統一） */
.btn-discount { background: #2563eb; }
.btn-discount:hover { background: #1d4ed8; }
.btn-reverse { background: #3b82f6; }
.btn-reverse:hover { background: #2563eb; }
.btn-increase { background: #2563eb; }
.btn-increase:hover { background: #1d4ed8; }
.btn-decrease { background: #3b82f6; }
.btn-decrease:hover { background: #2563eb; }
.btn-tax-in { background: #1e40af; }
.btn-tax-in:hover { background: #1e3a8a; }
.btn-tax-out { background: #1e40af; }
.btn-tax-out:hover { background: #1e3a8a; }

/* ===========================
   結果セクション
   =========================== */

.result-section {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: white;
    border-radius: 16px;
    padding: 32px 24px;
    margin-bottom: 20px;
    text-align: center;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow:
        0 8px 24px rgba(37, 99, 235, 0.3),
        0 2px 8px rgba(37, 99, 235, 0.15);
}

.result-label {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 10px;
}

.result-value {
    font-size: 48px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.result-detail {
    font-size: 14px;
    opacity: 0.85;
}

/* シンプルページ用結果表示 */
.tool-result:not(:empty) {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    text-align: center;
    font-size: 22px;
    font-weight: 800;
    line-height: 1.7;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
}

/* ===========================
   計算履歴
   =========================== */

.history-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.history-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.clear-btn {
    padding: 8px 16px;
    font-size: 12px;
    background: var(--border);
    color: var(--text-muted);
    border-radius: 6px;
}

.clear-btn:hover {
    background: #cbd5e1;
    box-shadow: none;
    transform: none;
}

.history-list {
    background: #f8fafc;
    border-radius: 8px;
    padding: 15px;
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    padding: 12px;
    background: var(--surface);
    border-radius: 6px;
    margin-bottom: 10px;
    font-size: 14px;
    border: 1px solid var(--border);
}

.history-item:last-child {
    margin-bottom: 0;
}

.history-calc {
    color: var(--text-muted);
    margin-bottom: 5px;
}

.history-result {
    font-weight: 600;
    color: var(--text);
    font-size: 16px;
}

.empty-history {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
    font-size: 14px;
}

/* ===========================
   解説・FAQ セクション
   =========================== */

.explain-section {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.explain-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 10px;
}

.explain-subtitle {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin: 16px 0 8px;
}

.explain-body {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.7;
    margin: 0 0 10px;
}

.explain-list {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.7;
    padding-left: 20px;
    margin: 0 0 10px;
}

.explain-list li {
    margin-bottom: 6px;
}

.faq-list {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0;
}

.faq-list dt {
    font-weight: 700;
    color: var(--text);
    margin-top: 12px;
}

.faq-list dd {
    margin-left: 0;
    line-height: 1.7;
    padding-left: 12px;
    border-left: 2px solid var(--border);
    margin-top: 4px;
}

/* ===========================
   下部導線（関連ツール）
   =========================== */

.tools {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.tools-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.tool-link {
    display: block;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #f8fafc;
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}

.tool-link:hover {
    background: #eef2ff;
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.12);
}

/* 「すべての計算ツールを見る」リンク */
.all-tools-link {
    grid-column: 1 / -1;
    display: block;
    margin-top: 4px;
    padding: 10px 16px;
    border: 1.5px solid var(--primary);
    border-radius: 8px;
    color: var(--primary);
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
    text-align: center;
    background: transparent;
    transition: background 0.2s, color 0.2s;
}

.all-tools-link:hover {
    background: var(--primary);
    color: white;
    transform: none;
    box-shadow: none;
}

/* ===========================
   フッター
   =========================== */

.footer {
    max-width: 720px;
    margin: 22px auto 28px;
    padding: 0 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

.footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

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

.footer-links {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

/* ===========================
   タイポグラフィ統一
   =========================== */

.app-card h1 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 14px;
    line-height: 1.4;
}

.app-card h2 {
    font-size: 20px;
    font-weight: 700;
    margin: 22px 0 10px;
    line-height: 1.4;
}

.app-card h3 {
    font-size: 17px;
    font-weight: 600;
    margin: 16px 0 8px;
    line-height: 1.5;
}

.app-card p {
    font-size: 15px;
    line-height: 1.85;
    margin-bottom: 12px;
    color: #222;
}

.app-card ul,
.app-card ol {
    font-size: 15px;
    line-height: 1.85;
    padding-left: 22px;
    margin-bottom: 14px;
    color: #222;
}

/* コンテンツセクション（解説・FAQ） */
.content-section {
    margin-top: 22px;
    padding-top: 22px;
    border-top: 1px solid var(--border);
}

.content-section h2 {
    font-size: 20px;
    font-weight: 700;
    margin: 22px 0 10px;
    line-height: 1.4;
    color: var(--text);
}

.content-section h2:first-child {
    margin-top: 0;
}

.content-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 18px 0 8px;
    color: var(--text);
}

.content-section p {
    font-size: 15px;
    line-height: 1.85;
    margin-bottom: 12px;
    color: #333;
}

.content-section ul,
.content-section ol {
    font-size: 15px;
    line-height: 1.85;
    padding-left: 22px;
    margin-bottom: 14px;
    color: #333;
}

.content-section li {
    margin-bottom: 6px;
}

.content-section dl dt {
    font-weight: 700;
    color: var(--text-main);
    margin-top: 14px;
}
.content-section dl dd {
    margin: 4px 0 0 0;
    color: var(--text-sub);
    line-height: 1.7;
}

.example-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin: 12px 0 16px;
}
.example-table th,
.example-table td {
    border: 1px solid var(--border);
    padding: 8px 10px;
    text-align: center;
}
.example-table th {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
}
.example-table tbody tr:nth-child(even) {
    background: #fafafa;
}

.app-card .card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin: 14px 0;
}

.app-card .muted {
    color: var(--text-muted);
    font-size: 12px;
}

.app-card .note {
    margin-top: 10px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.7;
}

/* ===========================
   早見表テーブル
   =========================== */

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin-bottom: 16px;
}

.data-table thead th {
    background: var(--primary);
    color: white;
    font-weight: 600;
    padding: 10px 8px;
    text-align: right;
    font-size: 12px;
    white-space: nowrap;
}

.data-table thead th:first-child {
    border-radius: 8px 0 0 0;
    text-align: center;
}

.data-table thead th:last-child {
    border-radius: 0 8px 0 0;
}

.data-table tbody td {
    padding: 10px 8px;
    text-align: right;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table tbody td:first-child {
    font-weight: 700;
    color: var(--primary);
    text-align: center;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

/* ===========================
   スマホ (max 899px)
   =========================== */

@media (max-width: 899px) {
    /* ヘッダー高さ・1行レイアウト */
    .app-header {
        height: var(--header-height);
    }

    .app-header-inner {
        flex-direction: row;
        align-items: center;
        height: 100%;
        padding: 0 16px;
    }

    /* body padding-top はグローバルルールで設定済み（重複のため省略） */

    /* ハンバーガーボタン表示 */
    .nav-toggle {
        display: flex;
    }

    /* PC ナビ非表示（ドロワーが代替） */
    .app-nav {
        display: none;
    }

    /* オーバーレイ表示（開閉はbody.nav-openで制御） */
    .menu-overlay {
        display: block;
    }

    /* ドロワー表示（開閉はbody.nav-openで制御） */
    .mobile-drawer {
        display: block;
    }

    /* メニューオープン時 */
    body.nav-open {
        overflow: hidden;
    }

    body.nav-open .menu-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    body.nav-open .mobile-drawer {
        right: 0;
    }

    /* カード */
    .app-card {
        margin: 8px 8px;
        padding: 20px 20px;
        border-radius: 12px;
    }

    .button-grid {
        grid-template-columns: 1fr;
    }

    .tools-grid {
        grid-template-columns: 1fr;
    }

    .result-value {
        font-size: 36px;
    }

    /* スマホ時のタイポグラフィ縮小 */
    .app-card h1 {
        font-size: 22px;
    }

    .app-card h2,
    .content-section h2 {
        font-size: 18px;
    }

    .app-card h3,
    .content-section h3 {
        font-size: 15px;
    }

    .app-card p,
    .app-card ul,
    .app-card ol,
    .content-section p,
    .content-section ul,
    .content-section ol {
        font-size: 14px;
    }

    .data-table {
        font-size: 12px;
    }

    .data-table thead th,
    .data-table tbody td {
        padding: 8px 6px;
    }

    .footer {
        margin: 16px 12px 24px;
    }
}

/* タグライン: 768px以下は非表示 */
@media (max-width: 768px) {
    .logo-tagline {
        display: none;
    }
}

