/* ===== CSS Variables & Design Tokens ===== */
:root {
    --primary: #FF6B00;
    --primary-light: #FF8C33;
    --primary-dark: #E05500;
    --navy: #1B2A4A;
    --navy-light: #2D4470;
    --navy-dark: #0F1A30;
    --white: #FFFFFF;
    --gray-50: #F8F9FA;
    --gray-100: #F1F3F5;
    --gray-200: #E9ECEF;
    --gray-300: #DEE2E6;
    --gray-400: #ADB5BD;
    --gray-500: #6C757D;
    --gray-600: #495057;
    --gray-700: #343A40;
    --gray-800: #212529;
    --accent-green: #10B981;
    --accent-red: #EF4444;
    --bg: var(--white);
    --bg-card: var(--white);
    --bg-section: var(--gray-50);
    --text: var(--gray-800);
    --text-muted: var(--gray-500);
    --border: var(--gray-200);
    --shadow: 0 4px 24px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font-main: 'Noto Sans JP', sans-serif;
    --font-display: 'Outfit', 'Noto Sans JP', sans-serif;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg: #0D1117;
    --bg-card: #161B22;
    --bg-section: #0D1117;
    --text: #E6EDF3;
    --text-muted: #8B949E;
    --border: #30363D;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.4);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
    font-family: var(--font-main);
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    overflow-x: hidden;
    transition: background var(--transition), color var(--transition);
}
img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-light); }

.container { max-width: 800px; margin: 0 auto; padding: 0 20px; }
.highlight { color: var(--primary); }
.required { color: var(--accent-red); font-size: 0.8em; }

/* ===== Dark Mode Toggle ===== */
.dark-mode-toggle {
    position: fixed; top: 16px; right: 16px; z-index: 1000;
    width: 48px; height: 48px; border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg-card);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    box-shadow: var(--shadow);
    transition: all var(--transition);
}
.dark-mode-toggle:hover { transform: scale(1.1); box-shadow: var(--shadow-lg); }

/* ===== Header ===== */
.header {
    position: sticky; top: 0; z-index: 100;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
[data-theme="dark"] .header { background: rgba(13,17,23,0.85); }
.header-inner {
    max-width: 800px; margin: 0 auto; padding: 12px 20px;
    display: flex; align-items: center; justify-content: space-between;
}
.logo-area { display: flex; align-items: center; gap: 10px; }
.logo-img { width: 40px; height: 40px; border-radius: 10px; }
.app-title {
    font-family: var(--font-display); font-size: 1.3rem; font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text; line-height: 1.2;
}
.app-subtitle { font-size: 0.65rem; color: var(--text-muted); font-weight: 500; }
.nav-link-btn {
    padding: 8px 16px; border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white) !important; font-size: 0.8rem; font-weight: 600;
    transition: all var(--transition); white-space: nowrap;
}
.nav-link-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(255,107,0,0.4); }

/* ===== Hero ===== */
.hero-section {
    position: relative; min-height: 85vh;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.hero-bg-img {
    position: absolute; inset: 0; width: 100%; height: 100%;
    object-fit: cover; z-index: 0;
}
.hero-overlay {
    position: absolute; inset: 0; z-index: 1;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 40%, rgba(255, 255, 255, 0.8) 90%, var(--bg) 100%);
}
[data-theme="dark"] .hero-overlay {
    background: linear-gradient(180deg, rgba(13,17,23,0.3) 0%, rgba(13,17,23,0.1) 40%, rgba(13,17,23,0.8) 90%, var(--bg) 100%);
}
.hero-content { 
    position: relative; z-index: 2; text-align: center; 
    padding: 60px 20px 40px; /* 作業員を隠さないように位置を調整 */
}
[data-theme="dark"] .hero-content {
    background: transparent;
}
.hero-badge {
    display: inline-block; padding: 6px 18px; border-radius: 50px;
    background: rgba(255,107,0,0.2); border: 1px solid rgba(255,107,0,0.3);
    color: var(--primary-light); font-size: 0.85rem; font-weight: 600;
    margin-bottom: 20px; animation: fadeInUp 0.6s ease forwards;
}
.hero-title {
    font-family: var(--font-display); font-size: clamp(1.8rem, 5vw, 2.8rem);
    font-weight: 800; color: #0000ff; line-height: 1.6; margin-bottom: 24px;
    animation: fadeInUp 0.6s 0.1s ease forwards; opacity: 0;
    text-align: center;
}

/* 文字の背景だけをご指定の色にする設定（文字ぎりぎり） */
.hero-title span.title-bg {
    background: rgba(255, 255, 240, 0.9); /* #fffff0 */
    padding: 2px 8px;
    border-radius: 4px;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
    box-shadow: 5px 0 0 rgba(255, 255, 240, 0.9), -5px 0 0 rgba(255, 255, 240, 0.9);
}

.hero-title .highlight { color: #0000ff; }
[data-theme="dark"] .hero-title span.title-bg { 
    background: rgba(40, 40, 40, 0.9);
    box-shadow: 5px 0 0 rgba(40, 40, 40, 0.9), -5px 0 0 rgba(40, 40, 40, 0.9);
}
[data-theme="dark"] .hero-title { color: #5555ff; }
[data-theme="dark"] .hero-title .highlight { color: #5555ff; }

.hero-description {
    color: var(--white); font-size: clamp(0.85rem, 2.5vw, 1rem);
    font-weight: 500;
    max-width: 540px; margin: 0 auto 28px;
    animation: fadeInUp 0.6s 0.2s ease forwards; opacity: 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
[data-theme="dark"] .hero-description { color: rgba(255,255,255,0.9); }
.hero-cta {
    display: inline-block; padding: 16px 36px; border-radius: 60px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white) !important; font-size: 1.05rem; font-weight: 700;
    box-shadow: 0 6px 24px rgba(255,107,0,0.4);
    transition: all var(--transition);
    animation: fadeInUp 0.6s 0.3s ease forwards; opacity: 0;
}
.hero-cta:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 10px 32px rgba(255,107,0,0.5); }
.hero-scroll-indicator {
    position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%); z-index: 2;
    color: var(--navy-light); font-size: 0.8rem; font-weight: 600; animation: bounce 2s infinite;
}
[data-theme="dark"] .hero-scroll-indicator { color: rgba(255,255,255,0.5); }

/* Moving Clouds Animation */
.hero-bg-img {
    animation: zoomOut 20s infinite alternate linear;
}
@keyframes zoomOut {
    from { transform: scale(1.1); }
    to { transform: scale(1); }
}

/* ===== Steps ===== */
.steps-section { padding: 80px 0; background: var(--bg-section); }
.section-title {
    text-align: center; font-family: var(--font-display);
    font-size: clamp(1.5rem, 4vw, 2rem); font-weight: 800; margin-bottom: 12px;
}
.section-desc { text-align: center; color: var(--text-muted); margin-bottom: 40px; }
.steps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-top: 40px; }
.step-card {
    background: var(--bg-card); border-radius: var(--radius); padding: 32px 24px;
    text-align: center; border: 1px solid var(--border);
    box-shadow: var(--shadow); transition: all var(--transition);
    position: relative; overflow: hidden;
    animation: fadeInUp 0.5s var(--delay) ease forwards; opacity: 0;
}
.step-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); }
.step-number {
    position: absolute; top: -10px; right: -10px;
    width: 60px; height: 60px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white); font-family: var(--font-display);
    font-size: 1.5rem; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    opacity: 0.15;
}
.step-icon { font-size: 2.5rem; margin-bottom: 16px; }
.step-card h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; }
.step-card p { font-size: 0.85rem; color: var(--text-muted); }

/* ===== Mode Tabs ===== */
.mode-tabs {
    display: flex; gap: 4px; margin-bottom: 24px;
    background: var(--bg-card); border-radius: var(--radius);
    padding: 4px; border: 1px solid var(--border);
}
.mode-tab {
    flex: 1; padding: 12px 16px; border: none; border-radius: 12px;
    background: transparent; color: var(--text-muted);
    font-size: 0.9rem; font-weight: 600; cursor: pointer;
    font-family: var(--font-main); transition: all var(--transition);
}
.mode-tab.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white); box-shadow: 0 2px 8px rgba(255,107,0,0.3);
}
.mode-panel { display: none; }
.mode-panel.active { display: block; animation: fadeInUp 0.3s ease; }

/* ===== Manual Items Grid ===== */
.manual-items-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}
.manual-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px; border-radius: var(--radius-sm);
    background: var(--bg-card); border: 1px solid var(--border);
    transition: all var(--transition);
}
.manual-item:hover { border-color: var(--primary); }
.manual-item.has-count { border-color: var(--primary); background: rgba(255,107,0,0.05); }
.manual-item-name { font-size: 0.85rem; font-weight: 500; white-space: nowrap; }
.manual-item-vol { font-size: 0.65rem; color: var(--text-muted); }
.manual-item-left { display: flex; flex-direction: column; gap: 1px; }
.manual-item-count {
    display: flex; align-items: center; gap: 6px;
}
.manual-item-count button {
    width: 28px; height: 28px; border-radius: 50%;
    border: 1px solid var(--border); background: var(--bg);
    color: var(--text); cursor: pointer; font-size: 1rem;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition); font-family: var(--font-main);
}
.manual-item-count button:hover { border-color: var(--primary); color: var(--primary); }
.manual-item-count span {
    min-width: 20px; text-align: center;
    font-weight: 700; font-size: 0.95rem;
}

/* ===== Upload ===== */
.upload-section { padding: 80px 0; }
.api-key-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px; margin-bottom: 24px;
    box-shadow: var(--shadow);
}
.api-key-card h3 { font-size: 1rem; margin-bottom: 8px; }
.api-key-card p { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 12px; }
.api-key-input-group { display: flex; gap: 10px; }
.api-key-input {
    flex: 1; padding: 12px 16px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg);
    color: var(--text); font-size: 0.9rem;
    transition: border var(--transition);
}
.api-key-input:focus { outline: none; border-color: var(--primary); }
.api-key-note { font-size: 0.7rem; color: var(--text-muted); margin-top: 8px; }

.upload-dropzone {
    border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 48px 24px; text-align: center; cursor: pointer;
    transition: all var(--transition); background: var(--bg-card);
}
.upload-dropzone:hover, .upload-dropzone.dragover {
    border-color: var(--primary); background: rgba(255,107,0,0.05);
}
.dropzone-icon { font-size: 3rem; margin-bottom: 12px; }
.dropzone-text { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.dropzone-or { color: var(--text-muted); font-size: 0.8rem; margin-bottom: 16px; }
.upload-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.preview-area { margin-top: 24px; }
.preview-area h3 { font-size: 1rem; margin-bottom: 12px; }
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; margin-bottom: 16px; }
.preview-item {
    position: relative; aspect-ratio: 1; border-radius: var(--radius-sm);
    overflow: hidden; border: 2px solid var(--border);
}
.preview-item img { width: 100%; height: 100%; object-fit: cover; }
.preview-remove {
    position: absolute; top: 4px; right: 4px;
    width: 28px; height: 28px; border-radius: 50%;
    background: rgba(0,0,0,0.6); color: white; border: none;
    cursor: pointer; font-size: 0.8rem;
    display: flex; align-items: center; justify-content: center;
}
.preview-actions { display: flex; justify-content: center; gap: 12px; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 12px 24px; border-radius: var(--radius-sm);
    font-size: 0.9rem; font-weight: 600; border: none;
    cursor: pointer; transition: all var(--transition);
    font-family: var(--font-main);
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(255,107,0,0.4); }
.btn-secondary { background: var(--navy); color: var(--white); }
.btn-secondary:hover { background: var(--navy-light); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-accent { background: linear-gradient(135deg, var(--accent-green), #059669); color: var(--white); }
.btn-accent:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(16,185,129,0.4); }
.btn-lg { padding: 14px 32px; font-size: 1rem; }
.btn-xl { padding: 18px 40px; font-size: 1.1rem; border-radius: 60px; }

.analyze-btn { width: 100%; justify-content: center; border-radius: 60px; padding: 16px; font-size: 1.05rem; }

/* ===== Loading ===== */
.loading-area { padding: 60px 0; text-align: center; }
.spinner {
    width: 48px; height: 48px; border: 4px solid var(--border);
    border-top-color: var(--primary); border-radius: 50%;
    animation: spin 0.8s linear infinite; margin: 0 auto 16px;
}
.loading-text { font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
.loading-sub { font-size: 0.8rem; color: var(--text-muted); }

/* ===== Results ===== */
.result-section { padding: 60px 0; background: var(--bg-section); }
.result-card {
    background: var(--bg-card); border-radius: var(--radius);
    padding: 24px; margin-bottom: 20px;
    border: 1px solid var(--border); box-shadow: var(--shadow);
    animation: fadeInUp 0.5s ease forwards;
}
.result-card-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }

.item-list-content { display: flex; flex-wrap: wrap; gap: 8px; }
.item-tag {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 50px;
    background: rgba(255,107,0,0.1); border: 1px solid rgba(255,107,0,0.2);
    font-size: 0.85rem; font-weight: 500;
}
.item-tag .item-vol { font-size: 0.75rem; color: var(--text-muted); }

.total-volume-bar {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 16px; padding: 12px 16px; border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--navy), var(--navy-light));
    color: var(--white); font-weight: 600;
}
.total-volume-value { font-family: var(--font-display); font-size: 1.3rem; font-weight: 800; }

.truck-suggestions { display: flex; flex-direction: column; gap: 16px; }
.truck-option {
    border: 2px solid var(--border); border-radius: var(--radius);
    padding: 20px; transition: all var(--transition);
    position: relative; overflow: hidden;
}
.truck-option:first-child { border-color: var(--primary); }
.truck-option:first-child::before {
    content: '💡 おすすめ'; position: absolute; top: 0; right: 0;
    padding: 4px 14px; border-radius: 0 0 0 var(--radius-sm);
    background: var(--primary); color: var(--white);
    font-size: 0.75rem; font-weight: 700;
}
.truck-name { font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
.truck-count { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 12px; }
.truck-prices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.price-item {
    text-align: center; padding: 10px 8px; border-radius: var(--radius-xs);
    background: var(--bg-section); border: 1px solid var(--border);
}
.price-label { font-size: 0.7rem; color: var(--text-muted); display: block; margin-bottom: 4px; }
.price-calc { font-size: 0.7rem; color: var(--text-muted); display: block; margin-bottom: 2px; }
.price-value { font-family: var(--font-display); font-size: 1rem; font-weight: 800; color: var(--primary); }

.quote-trigger-area { text-align: center; margin-top: 32px; }
.quote-trigger-btn { animation: pulse 2s infinite; }

/* ===== Quote Form ===== */
.quote-form-section { padding: 60px 0; }
.quote-form { background: var(--bg-card); border-radius: var(--radius); padding: 32px; border: 1px solid var(--border); box-shadow: var(--shadow); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label { font-size: 0.85rem; font-weight: 600; }
.form-group input, .form-group select {
    padding: 12px 16px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg);
    color: var(--text); font-size: 0.9rem; font-family: var(--font-main);
    transition: border var(--transition);
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--primary); }

.estimate-preview {
    margin-top: 24px; padding: 20px; border-radius: var(--radius-sm);
    background: var(--bg-section); border: 1px solid var(--border);
}
.estimate-preview h4 { font-size: 0.95rem; margin-bottom: 12px; }
.estimate-preview-text { font-size: 0.8rem; white-space: pre-wrap; line-height: 1.8; }
.form-actions { margin-top: 24px; text-align: center; }

/* ===== Footer ===== */
.footer {
    padding: 40px 0; background: var(--navy-dark);
    color: rgba(255,255,255,0.7); text-align: center;
}
.footer-content { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.footer-brand { display: flex; align-items: center; gap: 8px; }
.footer-logo { width: 32px; height: 32px; border-radius: 8px; }
.footer-app-name { color: var(--white); font-weight: 700; font-family: var(--font-display); }
.footer-link {
    padding: 8px 20px; border-radius: var(--radius-sm);
    background: rgba(255,107,0,0.2); color: var(--primary-light) !important;
    font-weight: 600; font-size: 0.85rem;
}
.footer-link:hover { background: rgba(255,107,0,0.3); }
.footer-copyright { font-size: 0.75rem; }

/* ===== Modal ===== */
.modal-overlay {
    position: fixed; inset: 0; z-index: 2000;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-content {
    background: var(--bg-card); border-radius: var(--radius);
    padding: 40px; text-align: center; max-width: 400px; width: 100%;
    box-shadow: var(--shadow-lg); animation: fadeInUp 0.3s ease;
}
.modal-icon { font-size: 3rem; margin-bottom: 12px; }
.modal-content h3 { font-size: 1.3rem; margin-bottom: 8px; }
.modal-content p { color: var(--text-muted); margin-bottom: 24px; font-size: 0.9rem; }

/* ===== Animations ===== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-8px); }
}
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
    50% { box-shadow: 0 0 0 12px rgba(16,185,129,0); }
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    .header-inner { padding: 10px 16px; }
    .logo-img { width: 32px; height: 32px; }
    .app-title { font-size: 1.1rem; }
    .nav-link-btn { padding: 6px 12px; font-size: 0.75rem; }
    .dark-mode-toggle { width: 40px; height: 40px; top: 12px; right: 12px; font-size: 1.1rem; }
    .hero-section { min-height: 75vh; }
    .steps-section, .upload-section, .result-section, .quote-form-section { padding: 48px 0; }
    .form-grid { grid-template-columns: 1fr; }
    .truck-prices { grid-template-columns: 1fr; }
    .quote-form { padding: 20px; }
    .upload-dropzone { padding: 32px 16px; }
    .api-key-input-group { flex-direction: column; }
}
