/* ============================
   ペアチャ - モダン・クリーンCSS
   ============================ */

:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --accent: #ec4899;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --transition: 0.2s ease;
    --mood-bg: #ffffff;
    --mood-accent: #6c757d;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }

.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* ---- Header ---- */
.site-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: #fff;
    padding: 12px 0;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
    position: sticky;
    top: 0;
    z-index: 100;
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; }
.site-title { font-size: 1.4rem; font-weight: 800; letter-spacing: 0.02em; }
.site-title a { color: #fff; }
.site-title a:hover { opacity: 0.9; }
.site-nav a { color: rgba(255,255,255,0.9); font-size: 0.9rem; margin-left: 16px; }
.site-nav a:hover { color: #fff; }

/* ---- Main ---- */
.main-content { padding: 24px 0 60px; }

/* ---- Footer ---- */
.site-footer { text-align: center; padding: 20px; color: var(--text-muted); font-size: 0.8rem; border-top: 1px solid var(--border); }

/* ---- Card ---- */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    gap: 6px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #db2777; color: #fff; }
.btn-outline { background: transparent; border: 2px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 0.85rem; }
.btn-block { display: flex; width: 100%; }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.9rem; color: var(--text); }
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: border-color var(--transition);
    background: var(--surface);
    color: var(--text);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.form-error { color: var(--danger); font-size: 0.85rem; margin-bottom: 12px; font-weight: 500; }

/* ---- Sex badge ---- */
.sex-male { color: #3b82f6; }
.sex-female { color: #ec4899; }
.sex-secret { color: var(--text-muted); }
.sex-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}
.sex-badge.sex-male { background: #eff6ff; }
.sex-badge.sex-female { background: #fdf2f8; }
.sex-badge.sex-secret { background: #f1f5f9; }

/* ---- Tags ---- */
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    background: #f1f5f9;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* ---- Tag selector (form) ---- */
.tag-selector { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-selector label {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border: 2px solid var(--border);
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
    font-weight: 500;
}
.tag-selector label:hover { border-color: var(--primary-light); }
.tag-selector input { display: none; }
.tag-selector input:checked + span { color: var(--primary); }
.tag-selector label:has(input:checked) { border-color: var(--primary); background: rgba(99,102,241,0.08); }

/* ---- Mood color selector ---- */
.mood-selector { display: flex; flex-wrap: wrap; gap: 10px; }
.mood-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.85rem;
}
.mood-option:hover { border-color: var(--primary-light); }
.mood-option input { display: none; }
.mood-option:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.mood-swatch {
    width: 24px; height: 24px;
    border-radius: 50%;
    border: 2px solid rgba(0,0,0,0.1);
}

/* ---- Genre grid (top page) ---- */
.genre-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin: 24px 0;
}
.genre-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 16px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: all var(--transition);
    text-align: center;
    text-decoration: none;
    color: var(--text);
}
.genre-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); color: var(--text); }
.genre-card .genre-name { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.genre-card .genre-count { font-size: 0.8rem; color: var(--text-muted); }
.genre-card .genre-count strong { color: var(--primary); font-size: 1.2rem; }

/* ---- Room list table (PC) ---- */
.room-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.room-table th {
    background: var(--bg);
    padding: 10px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: left;
    border-bottom: 2px solid var(--border);
}
.room-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    vertical-align: middle;
}
.room-table tr:hover td { background: rgba(99,102,241,0.03); }
.room-table .mood-stripe {
    width: 4px;
    border-radius: 2px;
    padding: 0;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}
.status-waiting { background: #dcfce7; color: #16a34a; }
.status-full { background: #fee2e2; color: #dc2626; }

/* ---- Room list mobile ---- */
.room-cards { display: flex; flex-direction: column; gap: 10px; }
.room-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    border-left: 4px solid var(--mood-accent);
    transition: all var(--transition);
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
}
.room-card:hover { box-shadow: var(--shadow-lg); }
.room-card-body { flex: 1; min-width: 0; }
.room-card-name { font-weight: 700; font-size: 0.95rem; }
.room-card-meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.room-card-msg { font-size: 0.85rem; margin-top: 6px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-card-status { flex-shrink: 0; }

/* ---- Filter bar ---- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
    padding: 14px 18px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.filter-bar select { padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.85rem; }
.filter-bar .filter-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }

/* ---- Pagination ---- */
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 24px; }
.pagination a, .pagination span {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
}
.pagination a { background: var(--surface); box-shadow: var(--shadow); }
.pagination a:hover { background: var(--primary); color: #fff; }
.pagination .current { background: var(--primary); color: #fff; }

/* ---- Chat room (LINE風) ---- */
.chat-wrapper {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 70px);
    max-width: 800px;
    margin: 0 auto;
}

/* Header */
.chat-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 10;
}
.chat-header-info { display: flex; align-items: center; gap: 10px; }
.chat-header-info h2 { font-size: 1rem; font-weight: 700; line-height: 1.2; }
.chat-header-sub { font-size: 0.75rem; color: var(--text-muted); }
.chat-partner-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 0.9rem;
    flex-shrink: 0;
}
.chat-actions { display: flex; gap: 4px; flex-wrap: wrap; }

/* Peek indicator */
.peek-indicator { font-size: 0.75rem; color: var(--text-muted); }
.peek-eye { font-size: 0.7rem; margin-right: 1px; }

/* Message area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px 16px;
    background: var(--mood-bg);
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: background 0.3s ease;
}
.line-chat-bg { background: #7494c0; }

/* Date separator */
.line-date-sep {
    text-align: center;
    margin: 16px 0 12px;
}
.line-date-sep span {
    display: inline-block;
    padding: 4px 14px;
    background: rgba(0,0,0,0.15);
    border-radius: 20px;
    font-size: 0.72rem;
    color: #fff;
}

/* System message */
.line-system-msg {
    text-align: center;
    padding: 6px 14px;
    font-size: 0.78rem;
    color: rgba(255,255,255,0.85);
    margin: 4px 0;
}

/* Avatar */
.line-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 0.85rem;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.line-avatar-sm { width: 22px; height: 22px; font-size: 0.65rem; }

/* Message row */
.line-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 4px;
    animation: msgIn 0.2s ease;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.line-msg-me { flex-direction: row-reverse; }
.line-msg-content { max-width: 75%; min-width: 0; }
.line-msg-name { font-size: 0.7rem; color: rgba(255,255,255,0.75); margin-bottom: 2px; padding-left: 4px; }

/* Bubble + time row */
.line-bubble-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
}
.line-bubble-row-me { flex-direction: row-reverse; }

/* Bubble */
.line-bubble {
    padding: 10px 14px;
    font-size: var(--chat-font-size, 0.92rem);
    line-height: 1.55;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.line-bubble-other {
    background: #fff;
    color: var(--text);
    border-radius: 0 18px 18px 18px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.line-bubble-me {
    background: #8CE63A;
    color: #1a1a1a;
    border-radius: 18px 0 18px 18px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

/* Time & read */
.line-msg-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 1px;
    flex-shrink: 0;
    padding-bottom: 2px;
}
.line-msg-time { font-size: 0.65rem; color: rgba(255,255,255,0.6); white-space: nowrap; }
.line-msg-read { font-size: 0.6rem; color: rgba(255,255,255,0.5); }

/* Input bar */
.chat-input-bar {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    align-items: center;
}
.chat-input-bar input {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid var(--border);
    border-radius: 24px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color var(--transition);
    background: var(--bg);
}
.chat-input-bar input:focus { border-color: var(--primary); }
.chat-send-btn {
    width: 42px; height: 42px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--transition), transform 0.1s;
    flex-shrink: 0;
}
.chat-send-btn:hover { background: var(--primary-dark); }
.chat-send-btn:active { transform: scale(0.92); }

/* Waiting screen */
.waiting-screen {
    text-align: center;
    padding: 60px 20px;
    color: rgba(255,255,255,0.9);
}
.waiting-screen h2 { font-size: 1.3rem; margin-bottom: 12px; }
.waiting-screen .pulse {
    display: inline-block;
    width: 16px; height: 16px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
    margin-right: 8px;
    vertical-align: middle;
}
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.5; transform: scale(1.3); } }

/* Peek page inherits LINE style */
.peek-messages {
    padding: 12px 16px 16px;
    min-height: 300px;
    max-height: 60vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.peek-footer {
    padding: 14px;
    background: var(--surface);
    border-radius: 0 0 var(--radius) var(--radius);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
}

/* ---- Settings panel ---- */
.settings-panel {
    position: fixed;
    top: 0; right: -320px;
    width: 300px; height: 100vh;
    background: var(--surface);
    box-shadow: -4px 0 20px rgba(0,0,0,0.1);
    z-index: 200;
    transition: right 0.3s ease;
    padding: 24px;
    overflow-y: auto;
}
.settings-panel.open { right: 0; }
.settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 199;
    display: none;
}
.settings-overlay.open { display: block; }

.settings-panel h3 { font-size: 1.1rem; margin-bottom: 16px; }
.settings-panel .form-group { margin-bottom: 14px; }
.font-size-slider { width: 100%; }

/* ---- Preview modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 28px;
    max-width: 480px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform 0.2s ease;
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal h3 { font-size: 1.1rem; margin-bottom: 16px; }
.modal-close { position: absolute; top: 12px; right: 16px; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); }
.modal .preview-info { display: flex; flex-direction: column; gap: 10px; }
.modal .preview-row { display: flex; justify-content: space-between; font-size: 0.9rem; }
.modal .preview-row .label { color: var(--text-muted); font-weight: 500; }
.modal .preview-msg { padding: 12px; background: var(--bg); border-radius: var(--radius-sm); font-size: 0.9rem; margin: 10px 0; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

/* ---- Peek page ---- */
.peek-wrapper {
    max-width: 800px;
    margin: 0 auto;
}
.peek-header {
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

/* ---- Utility ---- */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }
.inline-flex { display: inline-flex; align-items: center; gap: 6px; }

/* ---- Mobile responsive ---- */
@media (max-width: 768px) {
    .site-title { font-size: 1.1rem; }
    .card { padding: 16px; }
    .genre-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
    .genre-card { padding: 14px 10px; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar select { width: 100%; }
    .line-msg-content { max-width: 85%; }
    .line-bubble { font-size: 0.88rem; padding: 8px 12px; }
    .chat-actions { flex-wrap: wrap; }
    .chat-actions .btn-sm { font-size: 0.75rem; padding: 4px 10px; }
    .settings-panel { width: 260px; }
    .modal { padding: 20px; }
    .room-table { font-size: 0.8rem; }
    .room-table th, .room-table td { padding: 8px 6px; }

    /* hide PC table on mobile */
    .is-mobile .pc-only { display: none; }
    .is-pc .mobile-only { display: none; }
}

@media (min-width: 769px) {
    .mobile-only { display: none; }
}

/* ---- PWA Install Banner ---- */
#pwa-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
    z-index: 250;
    padding: 14px 20px;
    animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.pwa-banner-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    max-width: 600px;
    margin: 0 auto;
    font-size: 0.9rem;
}
@media (max-width: 768px) {
    .pwa-banner-content { flex-wrap: wrap; font-size: 0.85rem; }
    .pwa-banner-content span { flex-basis: 100%; text-align: center; }
}
