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

:root {
    --primary: #6c5ce7;
    --primary-dark: #5f4dd8;
    --secondary: #00cec9;
    --success: #00b894;
    --danger: #ff7675;
    --warning: #fdcb6e;
    --dark: #2d3436;
    --gray: #636e72;
    --light-gray: #dfe6e9;
    --bg: #f5f6fa;
    --white: #ffffff;
}

body {
    font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
    background: var(--bg);
    color: var(--dark);
    line-height: 1.6;
    /* iOSでのスクロールバウンス対策 */
    overscroll-behavior-y: none;
}

.hidden {
    display: none !important;
}

/* ===== レイアウト ===== */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden; /* コンテナ全体はスクロールさせない */
}

/* サイドバー（PC） */
.sidebar {
    width: 280px;
    background: var(--white);
    border-right: 1px solid var(--light-gray);
    display: flex;
    flex-direction: column;
    padding: 24px;
    flex-shrink: 0; /* 縮小しない */
}

.logo-area {
    margin-bottom: 32px;
}

.logo-area h2 {
    font-size: 28px;
    color: var(--primary);
    font-weight: 700;
}

.tagline {
    font-size: 13px;
    color: var(--gray);
    margin-top: 4px;
}

.nav-links {
    flex: 1;
}

.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 8px;
    border: none;
    background: transparent;
    border-radius: 12px;
    cursor: pointer;
    font-size: 15px;
    color: var(--dark);
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--bg);
}

.nav-item.active {
    background: var(--primary);
    color: var(--white);
}

.nav-item .material-icons-round {
    font-size: 20px;
}

.profile-mini {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg);
    border-radius: 12px;
    margin-top: 16px;
    cursor: pointer;
}

.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: bold;
    overflow: hidden;
    flex-shrink: 0;
}

.avatar-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-text strong {
    font-size: 14px;
    display: block;
}

.profile-text small {
    font-size: 12px;
    color: var(--gray);
}

.logout-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    color: var(--danger);
    text-decoration: none;
    border-radius: 8px;
    margin-top: 8px;
    transition: background 0.2s;
}

.logout-link:hover {
    background: rgba(255, 118, 117, 0.1);
}

/* モバイルヘッダー */
.mobile-header {
    display: none; /* PCでは非表示 */
    background: var(--white);
    border-bottom: 1px solid var(--light-gray);
    padding: 12px 16px;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    flex-shrink: 0;
    z-index: 10;
}

.header-logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.icon-link {
    color: var(--dark);
    display: flex;
    padding: 8px;
}

/* メインコンテンツ */
.main-content {
    flex: 1;
    overflow-y: auto; /* ここだけスクロール */
    padding: 32px;
    background: var(--bg);
    position: relative;
    width: 100%;
}

.content-wrapper {
    max-width: 1200px;
    margin: 0 auto;
}

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

.page-header h1 {
    font-size: 32px;
    font-weight: 700;
}

/* ボタン */
.primary-btn {
    background: var(--primary);
    color: var(--white);
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    white-space: nowrap;
}

.primary-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.primary-btn:active {
    transform: translateY(0);
}

.submit-btn {
    width: 100%;
    background: var(--primary);
    color: var(--white);
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.submit-btn:hover {
    background: var(--primary-dark);
}

.delete-btn {
    width: 100%;
    background: var(--danger);
    color: var(--white);
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.delete-btn:hover {
    background: #e74c3c;
    transform: translateY(-1px);
}

/* カテゴリーフィルター */
.category-filter {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.filter-chip {
    padding: 8px 16px;
    border-radius: 20px;
    border: 2px solid var(--light-gray);
    background: var(--white);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    white-space: nowrap;
}

.filter-chip:hover {
    border-color: var(--primary);
}

.filter-chip.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* 連絡先グリッド */
.contacts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.contact-card {
    background: var(--white);
    border-radius: 16px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.contact-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    border-color: var(--primary);
}

.contact-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.contact-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 24px;
    font-weight: bold;
    overflow: hidden;
    flex-shrink: 0;
}

.contact-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.contact-info h3 {
    font-size: 18px;
    margin-bottom: 4px;
}

.contact-info p {
    font-size: 13px;
    color: var(--gray);
}

.contact-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--gray);
}

.detail-row .material-icons-round {
    font-size: 18px;
}

.category-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-top: 12px;
    margin-right: 6px;
}

.category-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
}

.category-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 0;
}

.category-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.category-checkbox input[type="checkbox"] {
    display: none;
}

.checkbox-label {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    color: white;
    transition: all 0.2s;
    border: 3px solid transparent;
    opacity: 0.5;
}

.category-checkbox input[type="checkbox"]:checked + .checkbox-label {
    opacity: 1;
    border-color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transform: scale(1.05);
}

.category-checkbox:hover .checkbox-label {
    opacity: 0.8;
    transform: translateY(-2px);
}

/* カテゴリーリスト */
.categories-list {
    display: grid;
    gap: 16px;
}

.category-item {
    background: var(--white);
    padding: 20px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.category-color {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    flex-shrink: 0;
}

.category-item h3 {
    flex: 1;
    font-size: 18px;
}

.category-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: var(--light-gray);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--gray);
    color: var(--white);
    transform: translateY(-2px);
}

.icon-btn.delete {
    background: rgba(255, 118, 117, 0.1);
    color: var(--danger);
}

.icon-btn.delete:hover {
    background: var(--danger);
    color: var(--white);
}

.danger-btn {
    background: var(--danger);
    color: var(--white);
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.danger-btn:hover {
    background: #e74c3c;
    transform: translateY(-2px);
}

/* モーダル */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: var(--white);
    border-radius: 20px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    /* モバイルでのスクロール慣性 */
    -webkit-overflow-scrolling: touch;
}

.modal-content.large {
    max-width: 900px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid var(--light-gray);
    position: sticky;
    top: 0;
    background: var(--white);
    z-index: 5;
}

.modal-header h3 {
    font-size: 24px;
}

.close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray);
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.close-btn:hover {
    background: var(--light-gray);
}

.modal-body {
    padding: 24px;
}

/* フォーム */
.input-group {
    margin-bottom: 20px;
}

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

.input-group input,
.input-group textarea,
.input-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--light-gray);
    border-radius: 12px;
    font-size: 16px; /* iOSでのズーム防止 */
    transition: border 0.2s;
    appearance: none; /* iOSのデフォルトスタイル解除 */
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.input-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* 連絡先詳細 */
.contact-detail-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--light-gray);
}

.contact-detail-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 40px;
    font-weight: bold;
    overflow: hidden;
    flex-shrink: 0;
}

.contact-detail-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.contact-detail-info h2 {
    font-size: 28px;
    margin-bottom: 8px;
}

.contact-detail-info p {
    color: var(--gray);
    font-size: 15px;
}

.detail-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--light-gray);
    overflow-x: auto;
    padding-bottom: 4px;
}

.tab-btn {
    padding: 12px 24px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    color: var(--gray);
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.info-item {
    background: var(--bg);
    padding: 16px;
    border-radius: 12px;
}

.info-item label {
    display: block;
    font-size: 13px;
    color: var(--gray);
    margin-bottom: 4px;
    font-weight: 600;
}

.info-item p {
    font-size: 15px;
    color: var(--dark);
    word-break: break-all;
}

/* レーダーチャート */
#radar-chart, #detail-radar-chart {
    display: block;
    max-width: 500px;
    width: 100%;
    height: auto;
    margin: 0 auto 32px;
}

.evaluation-sliders {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.slider-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.slider-item label {
    font-size: 13px;
    font-weight: 600;
}

.slider-item input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 5px;
    background: var(--light-gray);
    outline: none;
    -webkit-appearance: none;
}

.slider-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
}

.slider-item input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
}

.slider-value {
    text-align: center;
    font-weight: 600;
    color: var(--primary);
}

/* ボトムナビゲーション（モバイル） */
.bottom-nav {
    display: none;
    background: var(--white);
    border-top: 1px solid var(--light-gray);
    padding: 8px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: 60px;
}

.nav-icon {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0 8px;
    color: var(--gray);
    transition: color 0.2s;
}

.nav-icon.active {
    color: var(--primary);
}

.nav-icon .label {
    font-size: 11px;
}

/* 認証画面 */
.auth-container {
    display: flex;
    min-height: 100vh;
}

.auth-visual {
    flex: 1;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--white);
}

.visual-content {
    max-width: 500px;
}

.app-logo-large {
    font-size: 48px;
    font-weight: 700;
    display: block;
    margin-bottom: 24px;
}

.visual-content h1 {
    font-size: 48px;
    line-height: 1.2;
    margin-bottom: 24px;
}

.visual-content p {
    font-size: 18px;
    opacity: 0.9;
    line-height: 1.8;
}

.auth-form-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: var(--bg);
}

.auth-card {
    background: var(--white);
    padding: 48px;
    border-radius: 24px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 4px 24px rgba(0,0,0,0.1);
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header h2 {
    font-size: 32px;
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--gray);
    font-size: 15px;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.input-with-icon .material-icons-round {
    position: absolute;
    left: 12px;
    color: var(--gray);
    /* アイコンを垂直中央に固定 */
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none; /* クリックを通過させる */
    z-index: 2;
}

.input-with-icon input {
    padding-left: 44px; /* アイコンの分スペースを確保 */
    width: 100%;
    height: 48px; /* 高さを明示 */
}

.auth-btn {
    width: 100%;
    background: var(--primary);
    color: var(--white);
    border: none;
    padding: 16px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}

.auth-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.auth-footer {
    text-align: center;
    margin-top: 32px;
}

.auth-footer p {
    color: var(--gray);
    font-size: 14px;
    margin-bottom: 12px;
}

.sub-btn {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
}

.sub-btn:hover {
    text-decoration: underline;
}

.avatar-section {
    text-align: center;
    margin-bottom: 32px;
}

.avatar-upload {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 3px dashed var(--light-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.2s;
}

.avatar-upload:hover {
    border-color: var(--primary);
}

.avatar-upload img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--gray);
}

.upload-placeholder .icon {
    font-size: 32px;
}

.avatar-hint {
    font-size: 13px;
    color: var(--gray);
}

.badge {
    background: var(--danger);
    color: var(--white);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.color-picker {
    display: flex;
    align-items: center;
    gap: 12px;
}

.color-picker input[type="color"] {
    width: 60px;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    padding: 0;
}

/* レスポンシブ */
@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
    
    .mobile-only {
        display: flex !important;
    }
    
    .bottom-nav {
        display: flex !important;
    }
    
    /* 重要：スマホでは縦並びにする */
    .app-container {
        flex-direction: column;
    }
    
    .main-content {
        padding: 16px;
        padding-bottom: 80px; /* ボトムナビの高さ分を確保 */
        width: 100%;
    }
    
    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    
    .page-header > div {
        width: 100%;
    }
    
    .page-header h1 {
        font-size: 24px;
    }
    
    .danger-btn, .primary-btn {
        flex: 1;
        width: 100%;
    }
    
    .contacts-grid {
        grid-template-columns: 1fr; /* 1列表示 */
    }
    
    /* 認証画面のスマホ対応 */
    .auth-container {
        flex-direction: column;
    }
    
    .auth-visual {
        min-height: 30vh;
        padding: 24px;
        flex: none; /* 高さを指定値に固定 */
    }
    
    .visual-content h1 {
        font-size: 28px;
    }
    
    .app-logo-large {
        font-size: 32px;
        margin-bottom: 12px;
    }
    
    .visual-content p {
        font-size: 14px;
    }
    
    .auth-form-wrapper {
        padding: 24px 16px;
    }
    
    .auth-card {
        padding: 32px 24px;
        box-shadow: none; /* スマホでは影を消してフラットに */
    }
    
    .contact-detail-header {
        flex-direction: column;
        text-align: center;
    }
    
    .modal-content {
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
}