/* ========================================
   イエミル (IeMiru) - メインスタイル
   ======================================== */

/* ── リセット & ベース ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #1e40af;
    --primary-dark: #1e3a8a;
    --primary-light: #dbeafe;
    --primary-50: #eff6ff;
    --accent: #f59e0b;
    --accent-dark: #d97706;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --success: #16a34a;
    --success-light: #f0fdf4;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --text: #1e293b;
    --text-sub: #64748b;
    --bg: #f1f5f9;
    --white: #ffffff;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
}

html { font-size: 16px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { opacity: 0.85; }

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

/* ── コンテナ ── */
.container { max-width: 640px; margin: 0 auto; padding: 20px 16px; }

/* ── ヘッダー ── */
.header {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 16px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.header-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: var(--primary);
    font-size: 1.1rem;
}
.logo-icon { font-size: 1.4rem; }
.desktop-nav { display: none; }
.desktop-nav a {
    color: var(--text-sub);
    font-size: 0.85rem;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}
.desktop-nav a:hover { background: var(--primary-50); color: var(--primary); }

/* ハンバーガー */
.hamburger {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}
.hamburger span {
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: 0.3s;
}

/* モバイルナビ */
.mobile-nav {
    display: none;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 8px 16px 16px;
}
.mobile-nav.open { display: block; }
.mobile-nav a {
    display: block;
    padding: 12px 16px;
    color: var(--text);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
}
.mobile-nav a:hover { background: var(--primary-50); }

/* ── メインコンテンツ ── */
.main-content {
    min-height: calc(100vh - 56px - 60px - 80px);
    padding-bottom: 80px;
}

/* ── ボトムナビ ── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 6px 0 env(safe-area-inset-bottom, 6px);
    z-index: 100;
}
.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 8px;
    color: var(--text-sub);
    font-size: 0.7rem;
    min-width: 56px;
}
.bottom-nav-item:hover, .bottom-nav-item.active { color: var(--primary); }
.bottom-nav-icon { font-size: 1.3rem; }
.bottom-nav-label { font-weight: 500; }

/* ── フッター ── */
.footer {
    text-align: center;
    padding: 20px 16px 100px;
    color: var(--text-sub);
    font-size: 0.8rem;
}
.disclaimer {
    color: var(--danger);
    font-size: 0.75rem;
    margin-bottom: 8px;
}

/* ── ボタン ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}
.btn-primary {
    background: var(--primary);
    color: var(--white);
}
.btn-primary:hover { background: var(--primary-dark); color: var(--white); }
.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-50); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; }

/* ── フォーム ── */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 6px;
    color: var(--text);
}
.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    color: var(--text);
    background: var(--white);
    transition: border-color 0.2s;
    -webkit-appearance: none;
}
.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}
.form-input::placeholder { color: #94a3b8; }
select.form-input { cursor: pointer; }
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.form-hint {
    font-size: 0.8rem;
    color: var(--text-sub);
    margin-top: 4px;
}

/* ── アラート ── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 20px;
}
.alert-danger {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid #fecaca;
}
.alert-success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid #bbf7d0;
}

/* ── 認証画面 ── */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
}
.auth-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 32px 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}
.auth-logo {
    text-align: center;
    margin-bottom: 28px;
}
.auth-logo h1 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-top: 8px;
}
.auth-subtitle {
    color: var(--text-sub);
    font-size: 0.9rem;
    margin-top: 4px;
}
.auth-footer {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    text-align: center;
}
.auth-footer p {
    color: var(--text-sub);
    font-size: 0.85rem;
    margin-bottom: 12px;
}

/* ── ラジオカード ── */
.radio-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.radio-card { cursor: pointer; }
.radio-card input { display: none; }
.radio-card-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 8px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
}
.radio-card input:checked + .radio-card-inner {
    border-color: var(--primary);
    background: var(--primary-50);
    color: var(--primary);
}

/* ── ヒーロー ── */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    color: var(--white);
    border-radius: var(--radius);
    padding: 28px 24px;
    margin-bottom: 24px;
}
.hero h1 { font-size: 1.3rem; margin-bottom: 4px; }
.hero p { opacity: 0.9; font-size: 0.9rem; }

/* ── アクションカード ── */
.action-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}
.action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px 12px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    color: var(--text);
}
.action-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); color: var(--text); }
.action-card-primary {
    background: var(--primary);
    color: var(--white);
}
.action-card-primary:hover { color: var(--white); }
.action-icon { font-size: 1.8rem; }
.action-label { font-weight: 700; font-size: 0.9rem; }
.action-desc { font-size: 0.75rem; opacity: 0.75; }

/* ── セクション ── */
.section { margin-bottom: 28px; }
.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
    padding-left: 4px;
}

/* ── 結果カード ── */
.result-card {
    display: block;
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    color: var(--text);
    transition: box-shadow 0.2s;
}
.result-card:hover { box-shadow: var(--shadow-lg); color: var(--text); }
.result-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.result-card-body { margin-bottom: 8px; }
.result-location { font-size: 0.9rem; color: var(--text-sub); }
.result-price { font-size: 1.4rem; font-weight: 700; color: var(--primary); }
.result-date { font-size: 0.8rem; color: var(--text-sub); }

/* ── バッジ ── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-mansion { background: #dbeafe; color: #1e40af; }
.badge-house { background: #dcfce7; color: #16a34a; }
.badge-land { background: #fef3c7; color: #d97706; }

/* ── 精度バッジ ── */
.confidence { font-size: 0.8rem; font-weight: 600; }
.confidence-high { color: var(--success); }
.confidence-medium { color: var(--warning); }
.confidence-low { color: var(--danger); }

/* ── 機能グリッド ── */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.feature-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px 12px;
    text-align: center;
    box-shadow: var(--shadow);
    color: var(--text);
    transition: transform 0.2s;
}
.feature-card:hover { transform: translateY(-2px); color: var(--text); }
.feature-icon { font-size: 1.6rem; }
.feature-name { font-weight: 600; font-size: 0.85rem; }

/* ── 空の状態 ── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.empty-state h2 { font-size: 1.1rem; margin-bottom: 8px; }
.empty-state p { color: var(--text-sub); font-size: 0.9rem; }

/* ── テキスト ── */
.text-center { text-align: center; }
.text-sub { color: var(--text-sub); }

/* ── トースト ── */
.toast {
    position: fixed;
    top: 72px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: var(--text);
    color: var(--white);
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s;
    pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── ローディング ── */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}
.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 査定結果ヒーロー ── */
.result-hero {
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    color: var(--white);
    border-radius: var(--radius);
    padding: 32px 24px;
    text-align: center;
    margin-bottom: 24px;
}
.result-hero-badge { margin-bottom: 12px; }
.result-hero-label { font-size: 0.9rem; opacity: 0.85; margin-bottom: 4px; }
.result-hero-price { font-size: 2.2rem; font-weight: 800; margin-bottom: 8px; }
.result-hero-sqm { font-size: 0.9rem; opacity: 0.8; }
.confidence-box {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.15);
}
.confidence-label { font-weight: 600; font-size: 0.9rem; }
.confidence-desc { font-size: 0.8rem; opacity: 0.85; margin-top: 4px; }

/* ── 詳細カード ── */
.detail-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.detail-row:last-child { border-bottom: none; }
.detail-row-total { background: var(--primary-50); font-weight: 700; }
.detail-label { color: var(--text-sub); font-size: 0.85rem; }
.detail-value { font-weight: 600; font-size: 0.9rem; }
.factor-up { color: var(--success); }
.factor-down { color: var(--danger); }

/* ── 結果メタ情報 ── */
.result-meta {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-sub);
    margin-top: 4px;
}

/* ── KPI カード ── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}
.kpi-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px 12px;
    text-align: center;
    box-shadow: var(--shadow);
}
.kpi-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
}
.kpi-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-sub);
    margin-top: 4px;
}

/* ── パイプライン ── */
.pipeline-bar {
    display: flex;
    border-radius: var(--radius-sm);
    overflow: hidden;
    height: 36px;
    margin-bottom: 8px;
}
.pipeline-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--white);
    transition: width 0.3s;
}
.pipeline-active { background: var(--primary); }
.pipeline-contracted { background: var(--success); }
.pipeline-declined { background: #94a3b8; }
.pipeline-legend {
    display: flex;
    gap: 16px;
    font-size: 0.8rem;
    color: var(--text-sub);
}
.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}
.dot-active { background: var(--primary); }
.dot-contracted { background: var(--success); }
.dot-declined { background: #94a3b8; }

/* ── ステータスバッジ ── */
.badge-status-primary { background: var(--primary-light); color: var(--primary); }
.badge-status-success { background: var(--success-light); color: var(--success); }
.badge-status-gray { background: #f1f5f9; color: #64748b; }

/* ── フォームセクション ── */
.form-section {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.form-section-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-light);
}

/* ── レスポンシブ ── */
@media (min-width: 769px) {
    .hamburger { display: none; }
    .desktop-nav { display: flex; gap: 4px; }
    .bottom-nav { display: none; }
    .main-content { padding-bottom: 20px; }
    .footer { padding-bottom: 20px; }
}

@media (max-width: 480px) {
    .action-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .action-card { padding: 14px 8px; }
    .feature-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .form-row { grid-template-columns: 1fr; }
    .radio-group { grid-template-columns: repeat(3, 1fr); gap: 6px; }
}

/* ── PWA インストールバナー ── */
#pwa-install-banner {
    position: fixed;
    bottom: -200px;
    left: 0;
    right: 0;
    z-index: 9999;
    padding: 0 12px 12px;
    transition: bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
#pwa-install-banner.show {
    bottom: 68px;
}
@media (min-width: 769px) {
    #pwa-install-banner.show { bottom: 12px; }
}
.pwa-banner-inner {
    max-width: 480px;
    margin: 0 auto;
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    padding: 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}
.pwa-banner-icon {
    flex-shrink: 0;
}
.pwa-banner-icon img {
    display: block;
    box-shadow: var(--shadow);
}
.pwa-banner-text {
    flex: 1;
    min-width: 0;
}
.pwa-banner-text strong {
    display: block;
    font-size: 0.95rem;
    color: var(--text);
    margin-bottom: 2px;
}
.pwa-banner-text p {
    font-size: 0.8rem;
    color: var(--text-sub);
    line-height: 1.5;
    margin: 0;
}
.pwa-banner-actions {
    display: flex;
    gap: 8px;
    width: 100%;
}
.pwa-btn-install {
    flex: 1;
    padding: 10px 0;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}
.pwa-btn-install:hover {
    background: var(--primary-dark);
}
.pwa-btn-dismiss {
    padding: 10px 16px;
    background: none;
    color: var(--text-sub);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.85rem;
    cursor: pointer;
}
.pwa-btn-dismiss:hover {
    background: var(--bg);
}
.pwa-ios-step {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    text-align: center;
    font-size: 0.7rem;
    line-height: 18px;
    font-weight: 700;
}
.pwa-ios-share {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    text-align: center;
    font-size: 0.85rem;
    line-height: 22px;
    vertical-align: middle;
}
