/**
 * KIOK - Complete Stylesheet
 * Concept: Nostalgia × Modern (Apple-like Spacing & Clarity)
 * Generated with Gemini, integrated by Claude
 */

/* =============================================
   1. DESIGN SYSTEM - Core Variables
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=Noto+Sans+JP:wght@400;600;700&display=swap');

:root {
    --primary-900: #1a252f;
    --primary-700: #2c3e50;
    --primary-500: #34495e;
    --accent-500: #3498db;
    --accent-600: #2980b9;
    --success: #27ae60;
    --warning: #f39c12;
    --danger:  #e74c3c;
    --sepia-light: #fdf6e3;
    --sepia-medium: #eee8d5;
    --sepia-dark: #b58900;
    --bg-main: #f8f9fa;
    --bg-card: #ffffff;
    --bg-overlay: rgba(0, 0, 0, 0.45);
    --text-main: #2d3436;
    --text-muted: #636e72;
    --text-light: #b2bec3;
    --text-on-accent: #ffffff;
    --border-light: #dfe6e9;
    --border-medium: #ced4da;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.12);
    --ff-main: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
    --fs-xs: 0.75rem;
    --fs-sm: 0.875rem;
    --fs-base: 1rem;
    --fs-md: 1.125rem;
    --fs-lg: 1.25rem;
    --fs-xl: 1.5rem;
    --fs-2xl: 2rem;
    --lh-tight: 1.25;
    --lh-normal: 1.5;
    --lh-relaxed: 1.75;
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;
    --space-8: 4rem;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: var(--ff-main);
    font-size: var(--fs-base);
    line-height: var(--lh-normal);
    color: var(--text-main);
    background-color: var(--bg-main);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}
:focus-visible { outline: 2px solid var(--accent-500); outline-offset: 2px; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }


/* =============================================
   2. HEADER
   ============================================= */

.header {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 56px;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 var(--space-4);
    z-index: 1100;
    background-color: rgba(26, 37, 47, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-sm);
}
.header-left { display: flex; align-items: center; gap: var(--space-3); color: white; }
.logo { display: flex; align-items: center; font-weight: 700; font-size: var(--fs-lg); letter-spacing: -0.02em; }
.logo-img { height: 28px; width: auto; }
.logo-icon { display: inline-block; margin-right: 4px; font-style: normal; }
.header-left:hover .logo-icon { animation: pin-bounce 0.5s ease-in-out 2; }
@keyframes pin-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.tagline { font-size: var(--fs-xs); opacity: 0.7; font-weight: 400; border-left: 1px solid rgba(255,255,255,0.3); padding-left: var(--space-3); color: white; }
.header-right { display: flex; align-items: center; gap: var(--space-4); }

.search-bar { position: relative; display: flex; align-items: center; }
.search-bar input {
    width: 40px; height: 36px; padding: 0 12px 0 32px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.1) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="white" viewBox="0 0 16 16"><path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z"/></svg>') no-repeat 10px center;
    color: white; cursor: pointer;
    transition: width var(--transition-normal), background-color var(--transition-fast);
    outline: none; font-size: var(--fs-sm);
}
.search-bar input::placeholder { color: transparent; }
.search-bar input:focus { width: 240px; background-color: rgba(255,255,255,0.2); cursor: text; }
.search-bar input:focus::placeholder { color: rgba(255,255,255,0.6); }
.search-bar button { display: none; }

.lang-toggle, .btn-login, .btn-logout {
    font-size: var(--fs-sm); color: white; background: none; border: none;
    opacity: 0.8; cursor: pointer; transition: opacity var(--transition-fast);
}
.lang-toggle:hover, .btn-login:hover, .btn-logout:hover { opacity: 1; }
.btn-settings { background: none; border: none; cursor: pointer; font-size: 18px; opacity: 0.7; padding: 4px; }
.btn-settings:hover { opacity: 1; }
.user-name { font-size: var(--fs-sm); color: white; opacity: 0.9; }

.btn-add {
    background-color: white; color: var(--primary-900);
    padding: var(--space-2) var(--space-4); border-radius: var(--radius-full);
    font-weight: 700; font-size: var(--fs-sm); border: none; cursor: pointer;
    box-shadow: var(--shadow-sm); transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    white-space: nowrap;
}
.btn-add:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); background-color: var(--sepia-light); }


/* =============================================
   3. CONTROL BAR
   ============================================= */

.control-bar {
    position: fixed; bottom: var(--space-6); left: 50%; transform: translateX(-50%);
    width: 90%; max-width: 600px; height: 64px; z-index: 900;
    background-color: rgba(255,255,255,0.85);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--sepia-medium); border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
    display: flex; align-items: center; padding: 0 var(--space-6); gap: var(--space-4);
}
.control-bar-inner { display: flex; align-items: center; gap: var(--space-4); width: 100%; }
.era-display { font-family: 'Inter', sans-serif; font-weight: 700; font-size: var(--fs-sm); color: var(--primary-700); min-width: 60px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.era-value { font-weight: 700; color: var(--primary-900); font-size: var(--fs-md); }

.era-slider {
    -webkit-appearance: none; flex: 1; height: 4px;
    background: var(--sepia-medium); border-radius: var(--radius-full); outline: none; cursor: pointer;
}
.era-slider::-webkit-slider-thumb {
    -webkit-appearance: none; width: 24px; height: 24px;
    background-color: var(--bg-card); border: 2px solid var(--accent-500);
    border-radius: 50%; box-shadow: var(--shadow-md);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.era-slider::-webkit-slider-thumb:hover { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(52,152,219,0.1); }
.era-slider::-webkit-slider-thumb:active { transform: scale(0.95); background-color: var(--accent-500); }
.era-slider::-moz-range-thumb { width: 24px; height: 24px; background-color: var(--bg-card); border: 2px solid var(--accent-500); border-radius: 50%; box-shadow: var(--shadow-md); cursor: pointer; }
.era-range-label { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--text-muted); padding: 2px 4px 0; }
.pin-era-badge { display: inline-block; margin-top: var(--space-2); padding: 4px 12px; background: var(--primary-50); color: var(--primary-700); border-radius: var(--radius-full); font-size: var(--fs-sm); font-weight: 600; }
.collective-era-summary { display: flex; align-items: center; gap: var(--space-3); padding: 10px 14px; background: var(--primary-50); border-radius: var(--radius-md); margin-bottom: var(--space-2); }
.collective-era-span { font-size: var(--fs-md); font-weight: 700; color: var(--primary-700); }
.collective-era-count { font-size: var(--fs-xs); color: var(--text-muted); }
.collective-era-empty { padding: 12px; background: var(--bg-secondary); border-radius: var(--radius-md); color: var(--text-muted); font-size: var(--fs-sm); text-align: center; margin-bottom: var(--space-2); }
.collective-era-details { display: flex; flex-direction: column; gap: 4px; margin-bottom: var(--space-2); }
.collective-era-item { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; background: var(--bg-secondary); border-radius: var(--radius-sm); font-size: var(--fs-sm); }
.collective-era-who { font-size: var(--fs-xs); color: var(--text-muted); }
.collective-era-hint { font-size: var(--fs-xs); color: var(--text-muted); font-style: italic; padding-top: var(--space-1); }
.owner-pin-notice { padding: 10px 14px; background: var(--bg-secondary); border-radius: var(--radius-md); color: var(--text-muted); font-size: var(--fs-sm); text-align: center; border-left: 3px solid var(--primary-300); }


/* =============================================
   4. MAP
   ============================================= */

#map { position: fixed; top: 56px; left: 0; width: 100%; height: calc(100vh - 56px); }
#map.create-mode { cursor: crosshair; }


/* =============================================
   5. CREATE MODE BANNER
   ============================================= */

.create-mode-banner {
    display: none; position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
    background: var(--accent-500); color: white;
    padding: var(--space-3) var(--space-5); border-radius: var(--radius-full);
    font-size: var(--fs-sm); font-weight: 600; z-index: 1500;
    box-shadow: var(--shadow-lg); animation: slideDown 0.3s ease;
}
.create-mode-banner.active { display: flex; align-items: center; gap: var(--space-3); }
.create-mode-banner button { background: rgba(255,255,255,0.2); border: none; color: white; padding: var(--space-1) var(--space-3); border-radius: var(--radius-full); cursor: pointer; font-size: var(--fs-xs); }
@keyframes slideDown { from { top: 50px; opacity: 0; } to { top: 70px; opacity: 1; } }


/* =============================================
   6. LEGEND
   ============================================= */

.legend { position: fixed; bottom: 110px; left: var(--space-3); background: rgba(255,255,255,0.9); backdrop-filter: blur(8px); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); box-shadow: var(--shadow-md); z-index: 800; font-size: var(--fs-xs); }
.legend-title { font-weight: 600; margin-bottom: var(--space-2); color: var(--primary-700); }
.legend-item { display: flex; align-items: center; gap: var(--space-2); margin: var(--space-1) 0; color: var(--text-muted); }


/* =============================================
   7. MODALS
   ============================================= */

.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--bg-overlay); z-index: 2000;
    justify-content: center; align-items: center; backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }

.modal {
    background-color: var(--bg-card); width: 100%; max-width: 480px; max-height: 85vh;
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column; overflow: hidden;
    animation: modal-slide-up var(--transition-normal);
}
.modal-sm { max-width: 400px; }
@keyframes modal-slide-up { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header { padding: var(--space-5) var(--space-5) var(--space-3); display: flex; justify-content: space-between; align-items: flex-start; position: sticky; top: 0; background: var(--bg-card); z-index: 1; }
.modal-title { font-size: var(--fs-xl); font-weight: 700; color: var(--primary-900); }
.modal-subtitle { font-size: var(--fs-sm); color: var(--text-muted); margin-top: var(--space-1); }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-light); line-height: 1; padding: var(--space-1); transition: color var(--transition-fast); }
.modal-close:hover { color: var(--text-main); }
.modal-body { padding: 0 var(--space-5) var(--space-5); overflow-y: auto; flex: 1; }


/* =============================================
   8. STATUS BADGES
   ============================================= */

.status-badge { display: inline-block; padding: 2px 10px; border-radius: var(--radius-full); font-size: var(--fs-xs); font-weight: 600; }
.status-badge.voting { background: var(--warning); color: var(--primary-900); }
.status-badge.confirmed { background: var(--success); color: white; }


/* =============================================
   9. VOTE SECTION
   ============================================= */

.vote-section { background-color: var(--sepia-light); margin: var(--space-3) 0; padding: var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--sepia-medium); }
.vote-question { font-size: var(--fs-sm); color: var(--text-main); margin-bottom: var(--space-3); text-align: center; }
.vote-buttons { display: flex; gap: var(--space-3); margin-bottom: var(--space-3); }
.vote-btn { flex: 1; height: 44px; border: none; border-radius: var(--radius-md); font-weight: 600; font-size: var(--fs-sm); cursor: pointer; transition: transform var(--transition-fast); }
.vote-btn.agree { background: var(--success); color: white; }
.vote-btn.disagree { background: var(--danger); color: white; }
.vote-btn:active { transform: scale(0.95); }
.vote-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.vote-progress { display: flex; align-items: center; gap: var(--space-3); }
.progress-bar { flex: 1; height: 6px; background: var(--border-light); border-radius: var(--radius-full); overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--success), #2ecc71); border-radius: var(--radius-full); transition: width 0.3s; }
.progress-text { font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; }


/* =============================================
   10. SECTIONS
   ============================================= */

.section { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--border-light); }
.section:first-child { margin-top: var(--space-4); padding-top: 0; border-top: none; }
.section-title { font-size: var(--fs-sm); font-weight: 600; color: var(--primary-700); margin-bottom: var(--space-3); display: flex; align-items: center; gap: var(--space-2); }

.memory-range-box { background: var(--bg-main); border-radius: var(--radius-md); padding: var(--space-4); position: relative; }
.memory-range-box.confirmed { background: rgba(39,174,96,0.08); }
.memory-range-box.voting { background: rgba(243,156,18,0.08); }
.range-display { display: flex; align-items: center; gap: var(--space-3); font-size: var(--fs-sm); font-weight: 600; color: var(--primary-700); font-family: 'Inter', sans-serif; }
.range-line { flex: 1; height: 4px; background: var(--accent-500); border-radius: var(--radius-full); box-shadow: 0 0 8px rgba(52,152,219,0.3); }
.range-status { font-size: var(--fs-xs); color: var(--text-muted); margin-top: var(--space-2); }
.range-note { font-size: var(--fs-xs); color: var(--text-muted); margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px dashed var(--border-light); line-height: var(--lh-relaxed); }

.attr-item { display: flex; align-items: center; padding: var(--space-2) 0; font-size: var(--fs-sm); }
.attr-icon { width: 20px; color: var(--success); font-size: var(--fs-xs); }
.attr-text { flex: 1; color: var(--text-main); }
.no-data { color: var(--text-light); font-size: var(--fs-sm); padding: var(--space-2) 0; }

.thread-item { padding: var(--space-4); background: var(--bg-main); border-radius: var(--radius-md); margin-bottom: var(--space-3); border-left: 4px solid var(--sepia-medium); cursor: pointer; transition: all var(--transition-normal) cubic-bezier(0.4,0,0.2,1); }
.thread-item:hover { background: white; transform: translateX(4px); border-left-color: var(--accent-500); box-shadow: var(--shadow-md); }
.thread-title { font-weight: 600; color: var(--primary-700); font-size: var(--fs-sm); }
.thread-meta { font-size: var(--fs-xs); color: var(--text-muted); margin-top: var(--space-1); }

.comment { padding: var(--space-3) 0; border-bottom: 1px solid var(--border-light); }
.comment:last-child { border-bottom: none; }
.comment-author { font-weight: 600; color: var(--accent-500); font-size: var(--fs-sm); }
.comment-text { margin-top: var(--space-2); color: var(--text-main); line-height: var(--lh-relaxed); font-size: var(--fs-sm); }
.comment-actions { margin-top: var(--space-2); font-size: var(--fs-xs); color: var(--text-muted); }
.comment-actions span { margin-right: var(--space-3); cursor: pointer; transition: color var(--transition-fast); }
.comment-actions span:hover { color: var(--accent-500); }

.footer-actions { display: flex; justify-content: space-around; margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--border-light); }
.footer-actions .action-btn { font-size: var(--fs-xs); color: var(--text-muted); background: none; border: none; cursor: pointer; text-decoration: underline; transition: color var(--transition-fast); }
.footer-actions .action-btn:hover { color: var(--danger); }


/* =============================================
   11. FORMS
   ============================================= */

.form-group { margin-bottom: var(--space-4); }
.form-label { display: block; font-weight: 700; font-size: var(--fs-sm); color: var(--primary-900); margin-bottom: var(--space-2); }
.form-input, .form-select, .form-textarea {
    width: 100%; padding: var(--space-3); border: 1px solid var(--border-medium);
    border-radius: var(--radius-md); font-size: var(--fs-sm); background-color: var(--bg-main);
    transition: border-color var(--transition-fast), background-color var(--transition-fast);
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent-500); background-color: white; outline: none; box-shadow: 0 0 0 3px rgba(52,152,219,0.1); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: var(--fs-xs); color: var(--text-muted); margin-top: var(--space-1); }
.form-error { color: var(--danger); font-size: var(--fs-xs); margin-top: var(--space-1); }
.form-row { display: flex; gap: var(--space-3); }
.form-row .form-group { flex: 1; }

.guidelines { background-color: #fff9db; border: 1px solid var(--warning); border-radius: var(--radius-md); padding: var(--space-4); margin-bottom: var(--space-4); display: flex; gap: var(--space-3); font-size: var(--fs-sm); }
.guidelines-title { font-weight: 600; color: var(--primary-700); margin-bottom: var(--space-2); }
.guidelines ul { margin-left: 18px; color: var(--primary-700); line-height: var(--lh-relaxed); }

.confidence-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); margin-top: var(--space-2); }
.confidence-option {
    cursor: pointer; padding: var(--space-3); text-align: center;
    border: 2px solid var(--border-light); border-radius: var(--radius-md);
    transition: transform 0.4s cubic-bezier(0.175,0.885,0.32,1.275), border-color var(--transition-normal), box-shadow var(--transition-normal);
}
.confidence-option input { display: none; }
.confidence-icon { font-size: 20px; display: block; margin-bottom: var(--space-1); }
.confidence-text strong { display: block; font-size: var(--fs-xs); color: var(--primary-700); }
.confidence-text span { font-size: var(--fs-xs); color: var(--text-muted); }
.confidence-option.selected { border-color: var(--accent-500); background-color: rgba(52,152,219,0.05); transform: scale(1.05) translateY(-4px); box-shadow: 0 8px 16px rgba(52,152,219,0.15); }


/* =============================================
   12. ACTION BUTTONS
   ============================================= */

.action-btn { padding: var(--space-2) var(--space-4); border: 1px solid var(--border-light); border-radius: var(--radius-full); background: white; cursor: pointer; font-size: var(--fs-xs); transition: all var(--transition-fast); color: var(--text-muted); }
.action-btn:hover { border-color: var(--accent-500); color: var(--accent-500); }
.action-btn.primary { background: var(--primary-900); color: white; border-color: var(--primary-900); position: relative; overflow: hidden; }
.action-btn.primary:hover { opacity: 0.9; }
.action-btn.primary::after { content: ""; position: absolute; top: 50%; left: 50%; width: 0; height: 0; background: rgba(255,255,255,0.2); border-radius: 50%; transform: translate(-50%,-50%); transition: width 0.6s ease-out, height 0.6s ease-out; }
.action-btn.primary:active::after { width: 300px; height: 300px; }
.action-btn.full { width: 100%; margin-top: var(--space-3); }
.action-btn.danger { color: var(--danger); border-color: var(--danger); }
.action-btn.danger:hover { background: var(--danger); color: white; }
.action-row { display: flex; gap: var(--space-2); margin-top: var(--space-3); flex-wrap: wrap; }

/* Era Picker Chips */
/* Era Timeline Range Selector */
.era-timeline { margin-top: var(--space-3); user-select: none; }
.era-timeline-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; margin-bottom: 4px; padding: 0 2px; }
.era-timeline-track { position: relative; height: 40px; background: var(--bg-main); border: 1px solid var(--border-medium); border-radius: var(--radius-md); cursor: crosshair; overflow: hidden; }
.era-timeline-fill { position: absolute; top: 0; height: 100%; background: linear-gradient(135deg, rgba(52,152,219,0.25), rgba(52,152,219,0.4)); border-left: 3px solid var(--accent-500); border-right: 3px solid var(--accent-500); pointer-events: none; transition: opacity 0.15s; }
.era-timeline-handle { position: absolute; top: 50%; width: 16px; height: 28px; background: var(--accent-500); border: 2px solid white; border-radius: 4px; transform: translate(-50%, -50%); cursor: ew-resize; z-index: 2; box-shadow: 0 1px 4px rgba(0,0,0,0.2); }
.era-timeline-handle:hover { background: var(--accent-600); transform: translate(-50%, -50%) scaleY(1.1); }
.era-timeline-ticks { position: absolute; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; }
.era-timeline-tick { position: absolute; top: 0; width: 1px; height: 100%; background: var(--border-light); }
.era-timeline-tick-label { position: absolute; bottom: 2px; font-size: 9px; color: var(--text-light); transform: translateX(-50%); }
.era-timeline-range-text { text-align: center; margin-top: var(--space-2); font-size: var(--fs-sm); font-weight: 700; color: var(--accent-500); }
.era-timeline-range-text span { background: rgba(52,152,219,0.1); padding: 2px 12px; border-radius: var(--radius-full); }

/* Profile/Settings Modal */
.profile-section { margin-bottom: var(--space-4); }
.profile-section-title { font-weight: 700; font-size: var(--fs-sm); margin-bottom: var(--space-2); color: var(--primary-700); }
.profile-city-list { list-style: none; padding: 0; margin: 0; }
.profile-city-item { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) 0; border-bottom: 1px solid var(--border-light); }
.profile-city-item:last-child { border-bottom: none; }


/* =============================================
   13. AUTH MODALS
   ============================================= */

.auth-form { display: flex; flex-direction: column; gap: var(--space-4); }
.auth-input {
    width: 100%; height: 48px; padding: 0 var(--space-4);
    border: 1px solid var(--border-medium); border-radius: var(--radius-md);
    background-color: var(--bg-main); font-size: var(--fs-base); transition: all var(--transition-fast);
}
.auth-input:focus { border-color: var(--accent-500); background-color: white; outline: none; box-shadow: 0 0 0 3px rgba(52,152,219,0.1); }

.btn-auth-submit {
    width: 100%; height: 52px; margin-top: var(--space-2);
    background-color: var(--primary-700); color: white; border: none;
    border-radius: var(--radius-full); font-weight: 700; font-size: var(--fs-base);
    cursor: pointer; transition: transform var(--transition-fast), background-color var(--transition-fast);
}
.btn-auth-submit:hover { background-color: var(--primary-900); transform: translateY(-1px); }

.auth-divider { display: flex; align-items: center; margin: var(--space-6) 0; color: var(--text-light); font-size: var(--fs-xs); }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background-color: var(--border-light); }
.auth-divider span { padding: 0 var(--space-3); }

.btn-social { width: 100%; height: 48px; display: flex; align-items: center; justify-content: center; gap: var(--space-3); background-color: white; border: 1px solid var(--border-medium); border-radius: var(--radius-full); font-size: var(--fs-sm); color: var(--text-muted); cursor: not-allowed; opacity: 0.6; filter: grayscale(1); margin-bottom: var(--space-3); }

/* Favorite Cities Section */
.fav-cities-section { margin-top: var(--space-2); padding: var(--space-4); background: var(--bg-main); border-radius: var(--radius-md); border: 1px solid var(--border-light); }
.fav-cities-title { font-weight: 700; font-size: var(--fs-sm); color: var(--primary-900); margin-bottom: var(--space-1); }
.fav-cities-hint { font-size: var(--fs-xs); color: var(--text-muted); margin-bottom: var(--space-3); }
.fav-city-row { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); position: relative; }
.fav-city-num { font-weight: 700; font-size: var(--fs-sm); color: var(--accent-500); min-width: 20px; }
.fav-city-input { flex: 1; height: 40px !important; font-size: var(--fs-sm) !important; }
.fav-city-status { font-size: var(--fs-xs); min-width: 20px; }
.fav-city-suggestions { position: absolute; top: 100%; left: 28px; right: 28px; background: white; border: 1px solid var(--border-medium); border-radius: var(--radius-md); box-shadow: var(--shadow-md); z-index: 10; max-height: 150px; overflow-y: auto; }
.fav-city-suggestion { padding: var(--space-2) var(--space-3); cursor: pointer; font-size: var(--fs-sm); }
.fav-city-suggestion:hover { background: var(--bg-main); }
.fav-city-remove { background: none; border: none; color: var(--danger); font-size: 18px; cursor: pointer; padding: 0 4px; line-height: 1; opacity: 0.6; }
.fav-city-remove:hover { opacity: 1; }
.btn-add-city { background: none; border: 1px dashed var(--border-medium); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); font-size: var(--fs-xs); color: var(--text-muted); cursor: pointer; width: 100%; transition: all var(--transition-fast); }
.btn-add-city:hover { border-color: var(--accent-500); color: var(--accent-500); }

.auth-switch { text-align: center; margin-top: var(--space-5); font-size: var(--fs-sm); color: var(--text-muted); }
.auth-switch a { color: var(--accent-500); text-decoration: none; font-weight: 600; margin-left: var(--space-1); }
.auth-switch a:hover { text-decoration: underline; }
.auth-forgot { text-align: right; margin: -0.5rem 0 0.75rem; }
.auth-forgot a { color: var(--text-muted); font-size: var(--fs-xs); text-decoration: none; }
.auth-forgot a:hover { color: var(--accent-500); text-decoration: underline; }


/* =============================================
   14. TOAST
   ============================================= */

/* Footer */
.site-footer { position: fixed; bottom: 0; left: 0; right: 0; background: rgba(26,26,46,0.85); backdrop-filter: blur(8px); color: rgba(255,255,255,0.7); font-size: 11px; padding: 6px 16px; display: flex; align-items: center; justify-content: center; gap: 6px; z-index: 900; flex-wrap: wrap; }
.site-footer a { color: rgba(255,255,255,0.85); text-decoration: none; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.footer-sep { color: rgba(255,255,255,0.3); }
.footer-copy { color: rgba(255,255,255,0.5); }

.toast-container { position: fixed; top: 20px; right: 20px; z-index: 3000; }
.toast { background: var(--primary-900); color: white; padding: var(--space-3) var(--space-5); border-radius: var(--radius-md); margin-bottom: var(--space-2); font-size: var(--fs-sm); box-shadow: var(--shadow-lg); animation: toast-in 0.3s ease; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); color: var(--primary-900); }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }


/* =============================================
   15. MAP MARKERS
   ============================================= */

.custom-marker { display: flex; align-items: center; justify-content: center; font-size: 22px; background: none !important; border: none !important; }
.marker-voting { filter: grayscale(50%) opacity(0.7); }
.marker-confirmed { filter: none; }
.temp-marker { font-size: 28px; animation: marker-drop 0.5s cubic-bezier(0.175,0.885,0.32,1.275); }
@keyframes marker-drop { 0% { transform: translateY(-50px); opacity: 0; } 60% { transform: translateY(5px); } 80% { transform: translateY(-3px); } 100% { transform: translateY(0); opacity: 1; } }

.nearby-pin-item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--border-light); border-radius: var(--radius-md); margin-bottom: var(--space-2); cursor: pointer; transition: all var(--transition-fast); }
.nearby-pin-item:hover { background: var(--bg-main); border-color: var(--accent-500); }

/* Map Context Menu */
.map-context-menu {
    position: fixed; z-index: 10000;
    background: white; border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
    min-width: 200px; overflow: hidden;
    animation: ctx-pop 0.15s ease-out;
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
}
@keyframes ctx-pop { 0% { opacity: 0; transform: scale(0.92); } 100% { opacity: 1; transform: scale(1); } }
.map-ctx-item {
    padding: 12px 16px; cursor: pointer;
    font-size: 14px; font-weight: 500; color: var(--text-main);
    display: flex; align-items: center; gap: 8px;
    transition: background 0.12s;
}
.map-ctx-item:hover { background: var(--bg-main); }
.map-ctx-item:first-child { padding-top: 14px; }
.map-ctx-item:active { background: rgba(52,152,219,0.1); }
.map-ctx-coord {
    padding: 8px 16px 10px; font-size: 11px;
    color: var(--text-light); border-top: 1px solid var(--border-light);
    font-variant-numeric: tabular-nums;
}


/* =============================================
   16. SKELETON LOADING
   ============================================= */

.skeleton { background: linear-gradient(90deg, var(--sepia-light) 25%, var(--sepia-medium) 50%, var(--sepia-light) 75%); background-size: 200% 100%; animation: loading-shimmer 2s infinite; border-radius: var(--radius-sm); }
@keyframes loading-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }


/* =============================================
   17. TOOLTIPS
   ============================================= */

[data-tooltip] { position: relative; }
[data-tooltip]::before { content: attr(data-tooltip); position: absolute; bottom: 125%; left: 50%; transform: translateX(-50%) translateY(10px); padding: 6px 10px; background: var(--primary-900); color: white; font-size: var(--fs-xs); border-radius: var(--radius-sm); white-space: nowrap; opacity: 0; visibility: hidden; transition: all var(--transition-normal); pointer-events: none; }
[data-tooltip]:hover::before { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }


/* =============================================
   18. SCROLLBAR
   ============================================= */

.modal-body::-webkit-scrollbar { width: 4px; }
.modal-body::-webkit-scrollbar-track { background: transparent; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border-medium); border-radius: var(--radius-full); }
.modal-body::-webkit-scrollbar-thumb:hover { background: var(--text-light); }


/* =============================================
   19. RESPONSIVE - Tablet
   ============================================= */

@media (max-width: 1024px) { .search-bar input:focus { width: 200px; } }


/* =============================================
   20. RESPONSIVE - Mobile
   ============================================= */

@media (max-width: 768px) {
    body { font-size: 14px; }

    /* iOS Safari 100vh 対策 */
    :root { --vh: 1vh; }

    .header { height: 52px; padding: 0 var(--space-3); }
    .tagline { display: none; }
    .logo { font-size: var(--fs-base); }
    .logo-img { height: 24px; }
    .header-right { gap: var(--space-2); }

    /* 検索バー */
    .search-bar input:focus {
        width: 140px; position: absolute; right: 0; top: 50%;
        transform: translateY(-50%); z-index: 10;
        background-color: var(--primary-900);
    }

    /* ユーザーメニュー（ログイン時のオーバーフロー防止） */
    #userMenu {
        gap: var(--space-1);
        max-width: 50vw;
        overflow: hidden;
    }
    .user-name {
        max-width: 60px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: var(--fs-xs);
    }
    .btn-logout { font-size: var(--fs-xs); }

    /* マップ */
    #map { top: 52px; height: calc(100vh - 52px); height: calc(var(--vh, 1vh) * 100 - 52px); }

    /* コントロールバー（フッターと重ならないように） */
    .control-bar {
        bottom: 40px;
        width: calc(100% - 24px);
        height: 52px;
        padding: 0 var(--space-4);
        gap: var(--space-2);
    }
    .era-display { font-size: var(--fs-xs); min-width: 40px; }
    .era-value { font-size: var(--fs-sm); }
    .era-range-label { font-size: 10px; }

    /* 凡例 */
    .legend { bottom: 100px; }

    /* フッター */
    .site-footer {
        padding: 4px 12px;
        font-size: 10px;
        gap: 4px;
    }

    /* モーダル（ボトムシート） */
    .modal {
        position: fixed; bottom: 0; left: 0; right: 0;
        max-width: 100%; width: 100%;
        max-height: 90vh;
        max-height: calc(var(--vh, 1vh) * 90);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        animation: bottom-sheet-up 0.3s cubic-bezier(0.25,1,0.5,1);
    }
    @keyframes bottom-sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
    .modal::before {
        content: ""; display: block; width: 36px; height: 4px;
        background: var(--border-medium); border-radius: var(--radius-full);
        margin: 12px auto;
    }
    .modal-header { padding: var(--space-3) var(--space-4) var(--space-2); }
    .modal-body { padding: 0 var(--space-4) var(--space-4); }
    .modal-title { font-size: var(--fs-lg); }

    /* タッチターゲット最低48px */
    .vote-btn, .action-btn.primary, .auth-input, .btn-auth-submit { min-height: 48px; }
    .confidence-options { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; gap: 0; }
    .create-mode-banner { top: 62px; font-size: var(--fs-xs); }

    /* スレッド・コメントのタップ領域改善 */
    .thread-item { padding: var(--space-4) var(--space-3); }
    .comment-actions span { padding: var(--space-2); margin-right: var(--space-1); }

    /* ディスピュート・メモリーボタンのタップ改善 */
    .memory-btn, .dispute-btn { padding: 12px 16px; font-size: var(--fs-sm); }

    /* フォームのズーム防止（iOS） */
    .form-input, .form-select, .form-textarea, .auth-input, .fav-city-input {
        font-size: 16px !important;
    }

    /* Toast位置をモバイル向けに */
    .toast-container { top: auto; bottom: 100px; right: var(--space-3); left: var(--space-3); }
    .toast { text-align: center; }
}


/* =============================================
   21. RESPONSIVE - Small Mobile
   ============================================= */

@media (max-width: 480px) {
    .header-right { gap: var(--space-1); }
    .btn-add { padding: var(--space-2) var(--space-3); font-size: var(--fs-xs); }
    .btn-add span.full-text { display: none; }
    .lang-toggle { display: none; }

    /* 検索バーを小さく */
    .search-bar input { width: 36px; }
    .search-bar input:focus { width: 120px; }

    /* ユーザー名を非表示に */
    .user-name { display: none; }

    /* コントロールバーの年代表示を最小限に */
    .era-range-label span:nth-child(2) { display: none; }

    /* 記憶追加ボタンのテキスト短縮 */
    .btn-add { padding: var(--space-2); font-size: 12px; }
}


/* =============================================
   22. MAP SEARCH BAR
   ============================================= */

.map-search-container {
  position: fixed;
  top: 75px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  width: 90%;
  max-width: 480px;
}
.map-search-bar {
  display: flex;
  align-items: center;
  background: white;
  border-radius: var(--radius-full);
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  padding: 6px 16px;
  gap: 8px;
}
.map-search-bar input {
  flex: 1;
  border: none;
  outline: none;
  font-size: var(--fs-sm);
  font-family: var(--ff-main);
  background: transparent;
  padding: 8px 0;
}
.map-search-icon { font-size: 1rem; opacity: 0.5; }
.map-search-clear {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
}
.map-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  margin-top: 4px;
  max-height: 240px;
  overflow-y: auto;
}
.map-search-result-item {
  padding: 10px 16px;
  cursor: pointer;
  font-size: var(--fs-sm);
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s;
}
.map-search-result-item:hover { background: var(--sepia-bg); }
.map-search-result-item:last-child { border-bottom: none; }

@media (max-width: 768px) {
  .map-search-container { top: 58px; width: 95%; }
}


/* =============================================
   23. COLOR PIN MARKERS
   ============================================= */

.color-pin-marker {
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: white;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.color-pin-marker.confirmed {
  width: 28px;
  height: 28px;
  opacity: 1;
}
.color-pin-marker.pending {
  width: 22px;
  height: 22px;
  opacity: 0.7;
  border-style: dashed;
}


/* =============================================
   24. LEGEND - Color Version
   ============================================= */

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
}
.legend-confirmed { border: 2px solid white; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.legend-voting { border: 2px dashed white; box-shadow: 0 1px 3px rgba(0,0,0,0.3); opacity: 0.7; }


/* =============================================
   25. DISPUTE BUTTONS
   ============================================= */

.dispute-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.dispute-btn {
  padding: 10px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  background: white;
  font-size: var(--fs-xs);
  font-family: var(--ff-main);
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-main);
  white-space: nowrap;
}
.dispute-btn:hover {
  background: #fef3f2;
  border-color: #f87171;
  color: #dc2626;
}
.dispute-btn:active {
  transform: scale(0.97);
}


/* =============================================
   26. BIRTH YEAR SECTION
   ============================================= */

.birth-year-section {
  margin-top: var(--space-2);
  padding: var(--space-4);
  background: var(--bg-main);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}
.birth-year-title {
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--primary-900);
  margin-bottom: var(--space-1);
}
.birth-year-hint {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}
.birth-year-select {
  height: 44px !important;
  font-size: var(--fs-sm) !important;
}
.age-slider-section {
  margin-bottom: var(--space-3);
}


/* =============================================
   27. MEMORY RESPONSE BUTTONS (Unified Vote + Dispute)
   ============================================= */

.memory-response-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: var(--space-3);
}
.memory-btn {
  padding: 10px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  background: white;
  font-size: var(--fs-xs);
  font-family: var(--ff-main);
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-main);
  white-space: nowrap;
}
.memory-btn.agree {
  border-color: var(--success);
  color: var(--success);
  font-weight: 600;
}
.memory-btn.agree:hover {
  background: rgba(39,174,96,0.1);
}
.memory-btn.dispute:hover {
  background: #fef3f2;
  border-color: #f87171;
  color: #dc2626;
}
.memory-btn:active {
  transform: scale(0.97);
}
.memory-btn.cancel {
  border-color: var(--text-muted);
  color: var(--text-muted);
  font-size: var(--fs-xs);
}
.memory-btn.cancel:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: #fef3f2;
}
.my-vote-display {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.my-vote-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--primary-700);
  padding: 8px 16px;
  background: var(--bg-main);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
}


/* =============================================
   28. LIFE STAGE CHIPS
   ============================================= */

.life-stage-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.life-stage-chip {
  padding: 8px 14px;
  border: 1.5px solid var(--border-medium);
  border-radius: var(--radius-full);
  background: white;
  font-size: var(--fs-xs);
  font-family: var(--ff-main);
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-main);
  white-space: nowrap;
}
.life-stage-chip:hover {
  border-color: var(--accent-500);
  color: var(--accent-500);
  background: rgba(52,152,219,0.05);
}
.life-stage-chip.selected {
  border-color: var(--accent-500);
  background: var(--accent-500);
  color: white;
  font-weight: 600;
}
.life-stage-chip:active {
  transform: scale(0.97);
}
.vote-stage-picker {
  margin-top: var(--space-3);
  padding: var(--space-3);
  background: var(--sepia-light);
  border-radius: var(--radius-md);
  border: 1px solid var(--sepia-medium);
}
.memory-timespan-summary {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--accent-500);
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: rgba(52,152,219,0.08);
  border-radius: var(--radius-md);
  text-align: center;
}


/* =============================================
   29. LOCATION SUGGESTIONS
   ============================================= */

.location-suggestion-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3);
  background: var(--bg-main);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  border: 1px solid var(--border-light);
  gap: var(--space-2);
}
.suggestion-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.suggestion-user {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--primary-700);
}
.suggestion-coords {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.suggestion-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}
.suggestion-count {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--accent-500);
  white-space: nowrap;
}
.suggestion-supported {
  font-size: var(--fs-xs);
  color: var(--success);
  font-weight: 600;
}
.memory-btn.suggest {
  border-color: var(--accent-500);
  color: var(--accent-500);
  font-weight: 600;
}
.memory-btn.suggest:hover {
  background: rgba(52,152,219,0.1);
}