/* --- "Focus & Transparency" Design System --- */
:root {
    /* --- Color Palette: Monochrome & Functional --- */
    /* Base - UIの90%を構成 */
    --white: #FFFFFF;
    --gray-50: #F9FAFB;   /* 背景用: 極めて薄いグレー */
    --gray-100: #F3F4F6;  /* 二次背景: 薄いグレー */
    --gray-200: #E5E7EB;  /* 境界線（必要最小限） */
    --gray-300: #D1D5DB;  /* 無効状態など */
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;  /* セカンダリテキスト */
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;  /* メインテキスト */
    --gray-900: #111827;  /* 見出し */

    /* Functional Colors - アクションと状態のみ */
    --brand-color: #DB2777;        /* Action: Pink-600 */
    --brand-color-hover: #BE185D;  /* Pink-700 */
    --brand-color-subtle: #FDF2F8; /* Pink-50 (背景用) */
    
    --success-color: #059669;      /* Emerald-600 */
    --success-bg: #ECFDF5;         /* Emerald-50 */
    
    --danger-color: #DC2626;       /* Red-600 */
    --danger-bg: #FEF2F2;          /* Red-50 */
    
    --warning-color: #D97706;      /* Amber-600 */
    --warning-bg: #FFFBEB;         /* Amber-50 */

    /* --- Typography --- */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    
    /* Scale: 4段階 + Caption */
    --text-caption: 0.75rem;   /* 12px */
    --text-sm: 0.875rem;       /* 14px */
    --text-base: 1rem;         /* 16px */
    --text-lg: 1.25rem;        /* 20px */
    --text-xl: 1.875rem;       /* 30px - Page Titles */

    --weight-regular: 400;
    --weight-medium: 500;
    --weight-bold: 600;        /* 太すぎないボールド */

    --leading-tight: 1.25;
    --leading-normal: 1.6;     /* 本文用: 可読性最大化 */

    /* --- Spacing: "呼吸する余白" --- */
    --space-1: 0.25rem;  /* 4px */
    --space-2: 0.5rem;   /* 8px */
    --space-3: 0.75rem;  /* 12px */
    --space-4: 1rem;     /* 16px */
    --space-6: 1.5rem;   /* 24px */
    --space-8: 2rem;     /* 32px */
    --space-12: 3rem;    /* 48px */
    --space-16: 4rem;    /* 64px */

    /* --- Effects --- */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;   /* 8px: 標準 */
    --radius-lg: 0.75rem;  /* 12px: カード */
    --radius-full: 9999px; /* ピル状の最大丸み */

    /* "透明性"のあるシャドウ: 境界線代わりの淡い影 */
    --shadow-subtle: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-dropdown: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    
    --focus-ring: 0 0 0 2px var(--white), 0 0 0 4px var(--brand-color);
    
    /* Touch Target */
    --touch-min: 44px;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--gray-800);
    background-color: var(--gray-50); /* わずかにグレーにして白のカードを浮かび上がらせる */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    color: inherit;
}

/* --- Layout --- */
.container {
    width: 100%;
    max-width: 1024px; /* 視線移動を抑えるため幅を制限 */
    margin: 0 auto;
    padding: 0 var(--space-4);
}

@media (min-width: 768px) {
    .container {
        padding: 0 var(--space-8);
    }
}

.main-content {
    flex: 1;
    padding: var(--space-8) 0 var(--space-16);
    width: 100%;
}

/* --- Header --- */
.header {
    background-color: var(--white);
    /* ボーダーではなく、ごく薄いシャドウで分離 */
    box-shadow: var(--shadow-subtle); 
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-content {
    height: 4rem; /* 64px */
    display: flex;
    align-items: center;
    justify-content: space-between;
}

@media (min-width: 1024px) {
    .header .container {
        max-width: 1200px; /* PC表示でヘッダー内の余白を拡張 */
    }
}

.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
}

@media (min-width: 768px) {
    .header-bar {
        flex: 0 0 auto;
    }
}

.header-title {
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);
    color: var(--gray-900);
    letter-spacing: -0.025em;
    margin: 0;
}

/* Navigation */
.header-nav {
    display: none; /* Mobile default: hidden or handled by JS */
}

@media (min-width: 768px) {
    .header-nav,
    .header-nav.is-open {
        display: flex;
        flex-direction: row;
        position: static;
        top: auto;
        left: auto;
        right: auto;
        background-color: transparent;
        padding: 0;
        box-shadow: none;
        border-top: none;
        gap: var(--space-6);
        width: auto;
        align-items: center;
    }

    .header-nav.is-open .nav-links,
    .nav-links {
        display: flex;
        flex-direction: row;
        width: auto;
        gap: var(--space-1);
    }

    .header-nav.is-open .nav-link,
    .nav-link {
        display: inline-block;
        width: auto;
        padding: var(--space-2) var(--space-4);
        border-radius: var(--radius-md);
        font-size: var(--text-sm);
        font-weight: var(--weight-medium);
        color: var(--gray-500);
        transition: all 0.2s ease;
    }

    .nav-link:hover {
        color: var(--gray-900);
        background-color: var(--gray-100);
    }

    .nav-link.active {
        color: var(--brand-color);
        background-color: var(--brand-color-subtle);
    }
    
    .header-nav.is-open .nav-meta,
    .nav-meta {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: var(--space-4);
        padding-left: var(--space-6);
        border-left: 1px solid var(--gray-200);
        padding-top: 0;
        border-top: none;
        width: auto;
    }
    
    .nav-email {
        font-size: var(--text-caption);
        color: var(--gray-500);
    }
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--touch-min);
    height: var(--touch-min);
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--gray-600);
    padding: 0;
}

@media (min-width: 768px) {
    .menu-toggle { display: none; }
}

/* Fix: Add Menu Icon Styles */
.menu-icon {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 20px;
    height: 14px;
}

.menu-icon span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--gray-800);
    border-radius: 2px;
}

/* Mobile Menu Drawer */
/* Define base drawer styles only for mobile */
@media (max-width: 767.98px) {
    .header-nav.is-open {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--white);
        padding: var(--space-4);
        box-shadow: var(--shadow-dropdown);
        border-top: 1px solid var(--gray-100);
        gap: var(--space-4);
        z-index: 40; /* Ensure it's above content */
    }
}

/* Wrap specific mobile drawer styles to avoid conflict/leakage */
@media (max-width: 767.98px) {
    .header-nav.is-open .nav-links {
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    .header-nav.is-open .nav-link {
        padding: var(--space-3) var(--space-4);
        width: 100%;
        display: block;
    }

    .header-nav.is-open .nav-meta {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        gap: var(--space-4);
        padding-top: var(--space-4);
        border-top: 1px solid var(--gray-100);
    }
}

/* --- Cards: "Transparent & Focus" --- */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    /* ボーダーなし、控えめなシャドウで浮き上がらせる */
    box-shadow: var(--shadow-card);
    padding: var(--space-6);
    margin-bottom: var(--space-8);
    transition: box-shadow 0.2s ease;
}

@media (min-width: 768px) {
    .card {
        padding: var(--space-12); /* 余白を大幅に増やす */
    }
}

.card-header {
    font-size: var(--text-xl);
    font-weight: var(--weight-bold);
    color: var(--gray-900);
    margin-bottom: var(--space-8);
    /* ボーダーラインを削除し、余白で区切りを表現 */
    border-bottom: none; 
    padding-bottom: 0;
    letter-spacing: -0.025em;
}

/* --- Buttons: Flat & Functional --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    line-height: 1.4;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: var(--touch-min);
    border: none; /* フラットデザイン */
    box-shadow: none; /* 影なし */
}

.btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Primary: Brand Color - アクション誘導 */
.btn-primary {
    background-color: var(--brand-color);
    color: var(--white);
}

.btn-primary:hover {
    background-color: var(--brand-color-hover);
    /* ホバー時も影はつけず、色変化のみ */
}

/* Secondary: Ghost/Outline style for transparency */
.btn-secondary {
    background-color: transparent;
    color: var(--gray-600);
    /* ボーダーではなく背景色で表現する場合もありだが、ここでは控えめなボーダーを使用 */
    border: 1px solid var(--gray-200); 
}

.btn-secondary:hover {
    background-color: var(--gray-50);
    color: var(--gray-900);
    border-color: var(--gray-300);
}

/* Danger */
.btn-danger {
    background-color: var(--danger-bg);
    color: var(--danger-color);
}

.btn-danger:hover {
    background-color: #FEE2E2; /* Red-100 */
}

.btn-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    margin-top: var(--space-8);
}

@media (min-width: 768px) {
    .btn-group {
        flex-direction: row;
        justify-content: flex-start; /* 左揃えで視線の流れを止めない */
    }
}

/* --- Forms: Clean & Minimal --- */
.form-group {
    margin-bottom: var(--space-8); /* 余白を広く */
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--gray-700);
    margin-bottom: var(--space-2);
}

.form-input,
.form-select,
.form-file {
    display: block;
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-base);
    color: var(--gray-900);
    background-color: var(--white);
    border: 1px solid var(--gray-200); /* 薄いボーダー */
    border-radius: var(--radius-md);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    appearance: none;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--brand-color);
    box-shadow: 0 0 0 3px var(--brand-color-subtle); /* 柔らかいグロウ効果 */
}

.form-hint {
    display: block;
    margin-top: var(--space-2);
    font-size: var(--text-caption);
    color: var(--gray-500);
}

/* File input styling override */
.form-file {
    padding: var(--space-2);
    font-size: var(--text-sm);
}

.form-file::file-selector-button {
    margin-right: var(--space-4);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-sm);
    border: none;
    background-color: var(--gray-100);
    color: var(--gray-700);
    cursor: pointer;
    transition: background 0.2s;
}

.form-file::file-selector-button:hover {
    background-color: var(--gray-200);
}

/* --- Progress Bar --- */
.progress-container {
    margin: var(--space-8) 0;
}

.progress-bar-wrapper {
    width: 100%;
    height: 0.5rem; /* 8px - 薄く洗練させる */
    background-color: var(--gray-100);
    border-radius: var(--radius-full); /* 丸み */
    overflow: hidden;
    margin-bottom: var(--space-4);
}

.progress-bar {
    height: 100%;
    background-color: var(--brand-color);
    transition: width 0.4s ease;
}

/* Progress bar text hidden inside bar, shown below for cleaner look */
.progress-bar span {
    display: none; 
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-sm);
    color: var(--gray-600);
    margin-bottom: var(--space-6);
}

/* Detail Card within Progress */
.progress-detail {
    background-color: var(--gray-50);
    border-radius: var(--radius-md);
    padding: var(--space-6);
    margin-top: var(--space-6);
    border: 1px solid var(--gray-100); /* ほとんど見えない境界 */
}

.progress-detail-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--gray-900);
}

.progress-detail-message {
    font-size: var(--text-sm);
    color: var(--gray-600);
}

/* --- Alerts & States --- */
.alert {
    padding: var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    margin-bottom: var(--space-6);
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}

.alert-success {
    background-color: var(--success-bg);
    color: var(--success-color);
}

.alert-danger {
    background-color: var(--danger-bg);
    color: var(--danger-color);
}

.alert-warning {
    background-color: var(--warning-bg);
    color: var(--warning-color);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: var(--text-caption);
    font-weight: var(--weight-medium);
    line-height: 1;
}

.badge-light {
    background-color: var(--gray-100);
    color: var(--gray-700);
}

/* --- Tables --- */
.table-responsive {
    overflow-x: auto;
    margin-bottom: var(--space-8);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.table th {
    text-align: left;
    padding: var(--space-3) var(--space-4);
    color: var(--gray-500);
    font-weight: var(--weight-medium);
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}

.table td {
    padding: var(--space-4);
    color: var(--gray-800);
    border-bottom: 1px solid var(--gray-100); /* 行間のみ薄く */
}

/* --- Error Report Styles --- */
.error-summary {
    padding: var(--space-4);
    background-color: var(--danger-bg);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--danger-color);
    font-weight: var(--weight-medium);
    margin-bottom: var(--space-6);
}

.error-count {
    background-color: var(--white);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: var(--text-caption);
    font-weight: var(--weight-bold);
}

.error-item {
    border-bottom: 1px solid var(--gray-200);
    padding: var(--space-4) 0;
}

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

.error-item-header {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
}

.error-number {
    color: var(--danger-color);
    font-weight: var(--weight-medium);
}

.error-item-details {
    padding-left: var(--space-4);
    border-left: 2px solid var(--gray-200); /* インデント線 */
    margin-left: var(--space-2);
}

.error-field, .error-reason {
    font-size: var(--text-sm);
    color: var(--gray-600);
    margin-top: var(--space-1);
}

/* Screenshot Thumbnail */
.screenshot-thumbnail-container {
    margin-top: var(--space-3);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: inline-block;
}

.screenshot-thumbnail {
    height: 80px;
    width: auto;
    display: block;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.screenshot-thumbnail:hover {
    opacity: 1;
}

/* --- Modal --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.4); /* Dimmed background */
    backdrop-filter: blur(2px); /* すりガラス効果 */
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-dropdown);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    padding: var(--space-6);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--gray-100);
}

.modal-title {
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);
    color: var(--gray-900);
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--gray-400);
    cursor: pointer;
    padding: var(--space-2);
}

.modal-body {
    padding: var(--space-6);
}

.modal-footer {
    padding: var(--space-6);
    background-color: var(--gray-50);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-4);
}

/* Screenshot Modal specifics */
.screenshot-modal {
    background-color: rgba(0,0,0,0.8);
}

.screenshot-modal-content {
    background: transparent;
    box-shadow: none;
    display: flex;
    justify-content: center;
    position: relative;
}

.screenshot-modal-image {
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--radius-sm);
}

.screenshot-modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    color: var(--white);
}

/* --- Login Page Specifics --- */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--gray-50);
    padding: var(--space-4);
}

.login-card {
    background: var(--white);
    width: 100%;
    max-width: 400px;
    padding: var(--space-8) var(--space-6);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

.login-title {
    text-align: center;
    font-size: var(--text-xl);
    font-weight: var(--weight-bold);
    color: var(--gray-900);
    margin-bottom: var(--space-2);
}

.login-subtitle {
    text-align: center;
    color: var(--gray-500);
    font-size: var(--text-sm);
    margin-bottom: var(--space-8);
}

/* --- Utility --- */
.hidden { display: none !important; }
.btn-block { display: flex; width: 100%; }
.text-center { text-align: center; }
.text-muted { color: var(--gray-500); }
.mt-1 { margin-top: var(--space-2); }
.mt-2 { margin-top: var(--space-4); }
.mb-1 { margin-bottom: var(--space-2); }
.mb-2 { margin-bottom: var(--space-4); }
