/**
 * hanasiai - 共通CSS
 */

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

/* Base */
html {
    font-size: 16px;
    line-height: 1.6;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #333;
    background-color: #f8f9fa;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: #007bff;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Layout */
header {
    background: #fff;
    padding: 0 1rem;
    border-bottom: 1px solid #dee2e6;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

header nav {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 56px;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: bold;
    color: #007bff !important;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-right a {
    color: #555;
    font-size: 0.9rem;
}

.nav-user {
    font-size: 0.9rem;
    color: #333;
    font-weight: 500;
}

main {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1rem;
    flex: 1;
}

footer {
    background: #fff;
    padding: 1.25rem 1rem 1rem;
    text-align: center;
    border-top: 1px solid #dee2e6;
    font-size: 0.85rem;
    color: #888;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    margin-bottom: 0.5rem;
}

.footer-links a {
    color: #888;
    font-size: 0.8rem;
    text-decoration: none;
}

.footer-links a:hover {
    color: #555;
    text-decoration: underline;
}

/* Announcements bar */
.announcements-bar {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 1rem;
}

.announcement-item {
    font-size: 0.85rem;
    color: #1e40af;
    padding: 0.25rem 0;
}

.announcement-item + .announcement-item {
    border-top: 1px solid #dbeafe;
}

[data-theme="dark"] .announcements-bar {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .announcement-item {
    color: #93c5fd;
    border-color: #334155;
}

/* Landing Page */
.landing {
    text-align: center;
    max-width: 900px;
    margin: 0 auto;
}

.landing-hero {
    padding: 3rem 1rem;
}

.landing-hero h1 {
    font-size: 2.5rem;
    color: #007bff;
    margin-bottom: 0.5rem;
}

.landing-subtitle {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 2rem;
}

.landing-free-badge {
    display: inline-block;
    background: #d1fae5;
    color: #065f46;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.5rem 1.25rem;
    border-radius: 20px;
    margin-bottom: 1.5rem;
}

[data-theme="dark"] .landing-free-badge {
    background: #1a3b2a;
    color: #6ee7b7;
}

.landing-cta {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn-lg {
    padding: 0.75rem 2rem;
    font-size: 1.1rem;
}

.btn-outline {
    background: transparent;
    border: 2px solid #007bff;
    color: #007bff;
}

.btn-outline:hover {
    background: #007bff;
    color: #fff;
}

.landing-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    padding: 1rem;
    margin-bottom: 2rem;
}

.feature-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.feature-card h3 {
    font-size: 1rem;
    margin-bottom: 0.4rem;
}

.feature-card p {
    font-size: 0.85rem;
    color: #666;
    line-height: 1.5;
}

.landing-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    padding: 2rem 1rem;
}

.stat-item { text-align: center; }
.stat-num { display: block; font-size: 2rem; font-weight: 700; color: #007bff; }
.stat-txt { font-size: 0.8rem; color: #999; }

/* Password toggle */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    flex: 1;
    padding-right: 2.5rem;
}

.pw-toggle {
    position: absolute;
    right: 0.5rem;
    background: transparent !important;
    border: none !important;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem;
    min-width: auto;
    min-height: auto;
    opacity: 0.5;
}

.pw-toggle:hover {
    opacity: 1;
    background: transparent !important;
}

/* Room card preview */
.room-card-preview {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 0.35rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Input hints */
.input-hints {
    display: flex;
    justify-content: flex-end;
    padding: 0.15rem 0.25rem;
}

.char-count {
    font-size: 0.7rem;
    color: #aaa;
}

/* Message name link */
.msg-name-link {
    color: inherit;
    text-decoration: none;
}

.msg-name-link:hover {
    color: #007bff;
    text-decoration: underline;
}

/* Static Pages */
.static-page {
    max-width: 700px;
    margin: 0 auto;
}

.static-page h1 {
    font-size: 1.4rem;
    margin-bottom: 1.25rem;
}

.static-card {
    background: #fff;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.static-card h2 {
    font-size: 1.05rem;
    margin: 1.25rem 0 0.5rem;
    color: #333;
}

.static-card p {
    margin-bottom: 0.75rem;
    line-height: 1.7;
    font-size: 0.9rem;
    color: #555;
}

.static-card ul {
    margin: 0 0 0.75rem 1.5rem;
    font-size: 0.9rem;
    color: #555;
    line-height: 1.8;
}

.info-table {
    width: 100%;
}

.info-table th {
    width: 140px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #555;
    background: transparent;
}

.info-table td {
    font-size: 0.9rem;
}

.terms-updated {
    color: #999;
    font-size: 0.8rem;
    margin-bottom: 1rem;
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 500;
    background: #007bff;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}

.btn:hover {
    background: #0056b3;
    text-decoration: none;
    color: #fff;
}

.btn-primary { background: #007bff; }
.btn-primary:hover { background: #0056b3; }

.btn-block {
    display: block;
    width: 100%;
    text-align: center;
}

/* Form */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: #555;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
    width: 100%;
    font-size: 1rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    transition: border-color 0.15s;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-error {
    background: #f8d7da;
    color: #842029;
    border: 1px solid #f5c2c7;
}

.alert-success {
    background: #d1e7dd;
    color: #0f5132;
    border: 1px solid #badbcc;
}

/* Auth */
.auth-container {
    display: flex;
    justify-content: center;
    padding-top: 2rem;
}

.auth-card {
    background: #fff;
    border-radius: 8px;
    padding: 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.auth-card h1 {
    margin-bottom: 1.5rem;
    font-size: 1.4rem;
    text-align: center;
}

.auth-link {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.9rem;
    color: #666;
}

/* Room List */
.room-list-container {
    max-width: 900px;
    margin: 0 auto;
}

.room-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.room-list-header h1 {
    font-size: 1.5rem;
}

.room-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.room-card {
    display: block;
    background: #fff;
    border-radius: 8px;
    padding: 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    transition: box-shadow 0.15s;
    color: #333;
    text-decoration: none;
}

.room-card:hover {
    box-shadow: 0 3px 12px rgba(0,0,0,0.1);
    text-decoration: none;
}

.room-card-inner {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.room-card-thumb {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    background: #f0f0f0;
}

.room-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.room-card-body {
    flex: 1;
    min-width: 0;
}

.room-card-title {
    font-size: 1.1rem;
    margin-bottom: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.room-lock {
    font-size: 0.85rem;
    flex-shrink: 0;
}

.room-card-desc {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.room-card-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: #999;
}

/* Activity badges */
.activity-badge {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
    white-space: nowrap;
}

.activity-posted {
    background: #dbeafe;
    color: #1e40af;
}

.activity-visited {
    background: #f3f4f6;
    color: #6b7280;
}

/* Room Search */
.room-search {
    margin-bottom: 1rem;
}

.room-search-form {
    display: flex;
    gap: 0;
    position: relative;
}

.room-search-input {
    width: 100%;
    padding: 0.6rem 2.75rem 0.6rem 1rem;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 0.95rem;
    background: #fff;
}

.room-search-input:focus {
    border-color: #007bff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
}

.room-search-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: #007bff !important;
    color: #fff;
    border: none !important;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    min-width: auto;
    min-height: auto;
}

.room-search-btn:hover {
    background: #0056b3 !important;
}

/* Room card wrapper */
.room-card-wrapper {
    position: relative;
}

.room-card-wrapper.has-unread .room-card {
    border-left: 3px solid #007bff;
}

/* Unread badge */
.unread-badge {
    display: inline-block;
    background: #007bff;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
    margin-left: 0.35rem;
    vertical-align: middle;
}

/* Favorite button */
.fav-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: #ccc;
    padding: 0.25rem;
    transition: color 0.15s;
    line-height: 1;
}

.fav-btn:hover {
    color: #ffc107;
    background: none;
}

.fav-btn.is-fav {
    color: #ffc107;
}

.room-card-wrapper .fav-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
}

/* Chat header */
.chat-header-top {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-header-top h1 {
    flex: 1;
}

.chat-header-top .fav-btn {
    font-size: 1.4rem;
}

/* Form check (remember me) */
.form-check {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.form-check label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: normal;
    cursor: pointer;
}

.form-check input[type="checkbox"] {
    width: auto;
}

/* Room Thumbnail (password page / detail) */
.room-thumbnail-large {
    text-align: center;
    margin-bottom: 1rem;
}

.room-thumbnail-large img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    object-fit: cover;
}

.room-password-notice {
    text-align: center;
    color: #888;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* Form hints */
.form-hint {
    font-size: 0.8rem;
    color: #999;
    margin-top: 0.25rem;
}

input[type="file"] {
    font-size: 0.9rem;
    padding: 0.4rem;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #888;
}

.empty-state p {
    margin-bottom: 1rem;
}

/* Chat */
.chat-container {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
}

.chat-header {
    margin-bottom: 1rem;
}

.chat-header h1 {
    font-size: 1.3rem;
    margin: 0.25rem 0;
}

.chat-description {
    font-size: 0.9rem;
    color: #666;
}

.back-link {
    font-size: 0.85rem;
    color: #888;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    background: #e8e4df;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* LINE風メッセージ行 */
.msg-row {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    max-width: 80%;
}

.msg-row.msg-other {
    align-self: flex-start;
}

.msg-row.msg-mine {
    align-self: flex-end;
    flex-direction: row-reverse;
}

/* アバター（相手のみ） */
.msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #007bff;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
    align-self: flex-start;
    margin-top: 1.2rem;
}

.msg-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.msg-mine .msg-content {
    align-items: flex-end;
}

.msg-other .msg-content {
    align-items: flex-start;
}

/* 名前（相手のみ） */
.msg-name {
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 0.15rem;
    padding-left: 0.25rem;
}

/* 吹き出し */
.msg-bubble {
    padding: 0.6rem 0.85rem;
    border-radius: 18px;
    word-break: break-word;
    max-width: 100%;
    position: relative;
}

.msg-other .msg-bubble {
    background: #fff;
    border-top-left-radius: 4px;
}

.msg-mine .msg-bubble {
    background: #82e87d;
    border-top-right-radius: 4px;
}

.msg-text {
    font-size: 0.95rem;
    line-height: 1.5;
}

.msg-img {
    margin-top: 0.25rem;
}

.msg-img img {
    max-width: 280px;
    max-height: 200px;
    border-radius: 10px;
    cursor: pointer;
    transition: opacity 0.15s;
    display: block;
}

.msg-img img:hover {
    opacity: 0.85;
}

/* タイムスタンプ + メッセージフッター */
.msg-footer {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.15rem;
    padding: 0 0.25rem;
}

.msg-time {
    font-size: 0.65rem;
    color: #999;
}

.msg-actions {
    display: flex;
    gap: 0.2rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.msg-row:hover .msg-actions {
    opacity: 1;
}

.react-btn, .delete-btn, .ban-btn {
    background: transparent !important;
    border: none !important;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.15rem 0.3rem;
    opacity: 0.6;
    transition: opacity 0.15s;
    line-height: 1;
    border-radius: 4px;
    min-width: 24px;
    min-height: 24px;
}

.react-btn:hover, .delete-btn:hover, .ban-btn:hover {
    opacity: 1;
    background: rgba(0,0,0,0.05) !important;
}

/* リアクション */
.msg-reactions {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-top: 0.2rem;
    padding: 0 0.25rem;
}

.reaction-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    padding: 0.1rem 0.4rem;
    font-size: 0.75rem;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 12px;
    cursor: pointer;
}

.reaction-tag:hover {
    background: #e0e0e0;
}

.reaction-tag.mine {
    background: #d4edda;
    border-color: #82e87d;
}

.reaction-picker {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border-radius: 12px;
    padding: 0.5rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 100;
    gap: 0.25rem;
}

.reaction-picker button {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 6px;
    transition: background 0.15s;
}

.reaction-picker button:hover {
    background: #f0f0f0;
}

/* 日付区切り */
.date-separator {
    text-align: center;
    margin: 0.75rem 0;
}

.date-separator span {
    background: rgba(0,0,0,0.08);
    color: #666;
    font-size: 0.75rem;
    padding: 0.2rem 0.75rem;
    border-radius: 10px;
}

/* 入力中表示 */
.typing-indicator {
    font-size: 0.8rem;
    color: #888;
    padding: 0.25rem 0.5rem;
    font-style: italic;
}

/* 空メッセージ案内 */
.empty-chat-notice {
    text-align: center;
    padding: 3rem 1rem;
    color: #aaa;
}

.chat-input {
    margin-top: 0.75rem;
}

.image-preview {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: #f0f0f0;
    border-radius: 6px;
}

.image-preview img {
    max-width: 120px;
    max-height: 80px;
    border-radius: 4px;
    object-fit: cover;
}

.image-preview-remove {
    background: #dc3545;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 14px;
    line-height: 24px;
    text-align: center;
    cursor: pointer;
    padding: 0;
}

.image-preview-remove:hover {
    background: #b02a37;
}

.chat-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.chat-input-row textarea {
    flex: 1;
    resize: none;
    min-height: 44px;
}

.btn-image {
    height: 44px;
    background: #6c757d;
    font-size: 1.1rem;
    padding: 0.5rem 0.75rem;
}

.btn-image:hover {
    background: #565e64;
}

.btn-send {
    height: 44px;
    white-space: nowrap;
}

.btn-send:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.chat-login-prompt {
    text-align: center;
    padding: 1rem;
    background: #fff;
    border-radius: 8px;
    margin-top: 0.75rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    color: #666;
}

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background: #f5f5f5;
    font-weight: bold;
}

/* Pinned messages bar */
.pinned-bar {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    overflow: hidden;
}

.pinned-bar-header {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #92400e;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pinned-list { padding: 0 0.75rem 0.5rem; }
.pinned-list.collapsed { display: none; }
.pinned-item { font-size: 0.8rem; padding: 0.25rem 0; cursor: pointer; color: #555; border-bottom: 1px solid #fef3c7; }
.pinned-item:hover { color: #007bff; }
.msg-pinned { position: relative; }
.msg-pinned::before { content: '📌'; position: absolute; top: -6px; right: -6px; font-size: 0.7rem; }

/* Reply */
.reply-preview {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: #e8f4fd;
    border-left: 3px solid #007bff;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    color: #555;
}

.reply-preview button {
    background: transparent !important;
    border: none !important;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0;
    color: #999;
    min-width: auto;
    min-height: auto;
}

.msg-reply-quote {
    font-size: 0.75rem;
    color: #888;
    padding: 0.2rem 0.5rem;
    background: rgba(0,0,0,0.04);
    border-left: 2px solid #007bff;
    border-radius: 2px;
    margin-bottom: 0.25rem;
    cursor: pointer;
}

.msg-reply-quote:hover { color: #007bff; }

/* Edited badge */
.msg-edited {
    font-size: 0.6rem;
    color: #aaa;
    font-style: italic;
}

/* File attachment */
.msg-file {
    margin-top: 0.3rem;
}

.msg-file a {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.6rem;
    background: rgba(0,0,0,0.05);
    border-radius: 6px;
    font-size: 0.8rem;
    color: #007bff;
    text-decoration: none;
}

.msg-file a:hover { background: rgba(0,0,0,0.1); }

/* Read count */
.read-count {
    font-size: 0.7rem;
    color: #999;
    font-weight: normal;
}

/* Avatar */
.avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    margin: 0 auto;
    background: #007bff;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.avatar-initial-large {
    color: #fff;
    font-size: 2rem;
    font-weight: 600;
}

.msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Image modal */
.image-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.image-modal img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 4px;
    object-fit: contain;
}

/* Theme toggle */
.theme-toggle {
    background: transparent !important;
    border: none !important;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.2rem;
    min-width: auto;
    min-height: auto;
    line-height: 1;
}

/* Mention badge in nav */
.mention-badge-nav {
    background: #ef4444;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 10px;
}

/* Mention highlight in message */
.mention-highlight {
    background: #dbeafe;
    color: #1e40af;
    padding: 0 0.15rem;
    border-radius: 2px;
    font-weight: 500;
}

/* File button */
.btn-file {
    height: 44px;
    background: #6c757d;
    font-size: 1.1rem;
    padding: 0.5rem 0.75rem;
}

.btn-file:hover { background: #565e64; }

/* Typing animation */
.typing-dots {
    display: inline-block;
}

.typing-dots::after {
    content: '';
    animation: typingDots 1.4s infinite;
}

@keyframes typingDots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

/* Chat search */
.chat-search-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.chat-search-bar input {
    flex: 1;
    padding: 0.4rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.85rem;
}

.chat-search-bar button {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    background: #6c757d;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.search-results {
    max-height: 200px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.search-result-item {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    font-size: 0.8rem;
}

.search-result-item:hover { background: #f8f9fa; }

/* Header icons */
.header-icon-btn {
    background: transparent !important;
    border: none !important;
    font-size: 1rem;
    cursor: pointer;
    padding: 0.2rem 0.3rem;
    min-width: auto;
    min-height: auto;
    line-height: 1;
    opacity: 0.6;
}

.header-icon-btn:hover { opacity: 1; background: transparent !important; }

/* Online count */
.online-count {
    font-size: 0.7rem;
    color: #22c55e;
    white-space: nowrap;
}

/* Scroll bottom button */
.scroll-bottom-btn {
    position: absolute;
    bottom: 120px;
    right: 2rem;
    background: #007bff !important;
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 0.4rem 1rem;
    font-size: 0.8rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 10;
}

.scroll-bottom-btn:hover { background: #0056b3 !important; }

/* ========================================
   Dark Mode
   ======================================== */
[data-theme="dark"] body { background: #1a1a2e; color: #e0e0e0; }
[data-theme="dark"] header { background: #16213e; border-color: #2a2a4a; }
[data-theme="dark"] footer { background: #16213e; border-color: #2a2a4a; color: #666; }
[data-theme="dark"] .footer-links a { color: #666; }
[data-theme="dark"] .nav-brand { color: #64b5f6 !important; }
[data-theme="dark"] .nav-right a, [data-theme="dark"] .nav-user { color: #aaa; }
[data-theme="dark"] main { color: #e0e0e0; }
[data-theme="dark"] .auth-card, [data-theme="dark"] .static-card { background: #1e293b; box-shadow: 0 1px 4px rgba(0,0,0,0.3); }
[data-theme="dark"] .room-card { background: #1e293b; color: #e0e0e0; box-shadow: 0 1px 4px rgba(0,0,0,0.3); }
[data-theme="dark"] .room-card:hover { box-shadow: 0 3px 12px rgba(0,0,0,0.4); }
[data-theme="dark"] .room-card-desc { color: #999; }
[data-theme="dark"] .room-search-input { background: #1e293b; border-color: #334155; color: #e0e0e0; }
[data-theme="dark"] input, [data-theme="dark"] textarea, [data-theme="dark"] select { background: #1e293b; border-color: #334155; color: #e0e0e0; }
[data-theme="dark"] .chat-messages { background: #0f1a2e; }
[data-theme="dark"] .msg-other .msg-bubble { background: #1e293b; color: #e0e0e0; }
[data-theme="dark"] .msg-mine .msg-bubble { background: #1a5c2e; }
[data-theme="dark"] .date-separator span { background: rgba(255,255,255,0.1); color: #888; }
[data-theme="dark"] .msg-name { color: #999; }
[data-theme="dark"] .msg-avatar { background: #334155; }
[data-theme="dark"] .chat-login-prompt { background: #1e293b; color: #aaa; }
[data-theme="dark"] .pinned-bar { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .pinned-bar-header { color: #fbbf24; }
[data-theme="dark"] .pinned-item { color: #aaa; border-color: #334155; }
[data-theme="dark"] .reply-preview { background: #1e293b; border-color: #64b5f6; }
[data-theme="dark"] .msg-reply-quote { background: rgba(255,255,255,0.05); }
[data-theme="dark"] .msg-file a { background: rgba(255,255,255,0.05); color: #64b5f6; }
[data-theme="dark"] .reaction-tag { background: #334155; border-color: #475569; color: #e0e0e0; }
[data-theme="dark"] .reaction-tag.mine { background: #1a5c2e; border-color: #22c55e; }
[data-theme="dark"] .reaction-picker { background: #1e293b; box-shadow: 0 4px 20px rgba(0,0,0,0.4); }
[data-theme="dark"] .reaction-picker button:hover { background: #334155; }
[data-theme="dark"] .image-preview { background: #1e293b; }
[data-theme="dark"] .alert-error { background: #3b1a1a; color: #f87171; border-color: #5c2020; }
[data-theme="dark"] .alert-success { background: #1a3b2a; color: #6ee7b7; border-color: #2a5c3a; }
[data-theme="dark"] .stat-card { background: #1e293b; }
[data-theme="dark"] table th { background: #1e293b; color: #aaa; }
[data-theme="dark"] table td { border-color: #334155; }
[data-theme="dark"] .chat-search-bar input { background: #1e293b; border-color: #334155; color: #e0e0e0; }
[data-theme="dark"] .search-results { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .search-result-item { border-color: #334155; }
[data-theme="dark"] .search-result-item:hover { background: #334155; }
[data-theme="dark"] .image-modal { background: rgba(0,0,0,0.95); }
[data-theme="dark"] .feature-card { background: #1e293b; }
[data-theme="dark"] .feature-card p { color: #999; }
[data-theme="dark"] .landing-subtitle { color: #999; }
[data-theme="dark"] .stat-num { color: #64b5f6; }
[data-theme="dark"] .btn-outline { border-color: #64b5f6; color: #64b5f6; }
[data-theme="dark"] .btn-outline:hover { background: #64b5f6; color: #1a1a2e; }
[data-theme="dark"] .room-card-preview { color: #777; }

/* ========================================
   Responsive — Tablet (max-width: 1024px)
   ======================================== */
@media (max-width: 1024px) {
    .landing-features { grid-template-columns: repeat(2, 1fr); }
    .landing-stats { gap: 2rem; }
    .room-list-container, .chat-container, .static-page { max-width: 100%; }
}

/* ========================================
   Responsive — Mobile (max-width: 640px)
   ======================================== */
@media (max-width: 640px) {
    /* Layout */
    main { padding: 0.75rem 0.5rem; }
    header nav { height: 48px; }
    .nav-brand { font-size: 1.1rem; }
    .nav-right { gap: 0.4rem; font-size: 0.8rem; }
    .nav-user { font-size: 0.8rem; }
    footer { padding: 0.75rem 0.5rem; }
    .footer-links { gap: 0.75rem; flex-wrap: wrap; }
    .footer-links a { font-size: 0.7rem; }

    /* Auth */
    .auth-card { margin: 0 0.25rem; padding: 1.25rem; max-width: 100%; }

    /* Landing */
    .landing-hero { padding: 2rem 0.5rem; }
    .landing-hero h1 { font-size: 1.8rem; }
    .landing-subtitle { font-size: 0.95rem; }
    .landing-cta { flex-direction: column; gap: 0.75rem; }
    .btn-lg { padding: 0.65rem 1.5rem; font-size: 1rem; }
    .landing-features { grid-template-columns: 1fr 1fr; gap: 0.75rem; padding: 0.5rem; }
    .feature-card { padding: 1rem; }
    .feature-icon { font-size: 1.5rem; }
    .feature-card h3 { font-size: 0.9rem; }
    .feature-card p { font-size: 0.8rem; }
    .landing-stats { gap: 1.5rem; padding: 1rem; }
    .stat-num { font-size: 1.5rem; }

    /* Room list */
    .room-list-header { flex-direction: column; gap: 0.5rem; align-items: stretch; }
    .room-list-header h1 { font-size: 1.2rem; }
    .room-card { padding: 0.75rem; }
    .room-card-inner { gap: 0.5rem; }
    .room-card-thumb { width: 56px; height: 56px; border-radius: 8px; flex-shrink: 0; }
    .room-card-title { font-size: 0.95rem; }
    .room-card-meta { flex-wrap: wrap; gap: 0.35rem; font-size: 0.7rem; }
    .room-card-preview { font-size: 0.75rem; }
    .room-search-input { font-size: 0.85rem; padding: 0.5rem; }
    .fav-btn { font-size: 1.1rem; }
    .room-card-wrapper .fav-btn { top: 0.5rem; right: 0.5rem; }

    /* Chat */
    .chat-container { height: calc(100vh - 120px); }
    .chat-header-top { flex-wrap: wrap; gap: 0.35rem; }
    .chat-header-top h1 { font-size: 1rem; flex-basis: 100%; }
    .msg-row { max-width: 92%; }
    .msg-avatar { width: 28px; height: 28px; font-size: 0.7rem; }
    .msg-bubble { padding: 0.5rem 0.7rem; border-radius: 14px; }
    .msg-text { font-size: 0.88rem; }
    .msg-img img { max-width: 180px; max-height: 130px; }
    .msg-file a { font-size: 0.75rem; }
    .msg-footer { font-size: 0.6rem; }
    .msg-time { font-size: 0.6rem; }
    .msg-actions { gap: 0.15rem; }
    .react-btn, .delete-btn, .ban-btn { font-size: 0.75rem; min-width: 20px; min-height: 20px; }
    .reaction-tag { font-size: 0.65rem; padding: 0.05rem 0.3rem; }
    .reaction-picker { bottom: 70px; left: 10%; right: 10%; transform: none; width: auto; }
    .reaction-picker button { font-size: 1.2rem; padding: 0.2rem; }
    .date-separator span { font-size: 0.65rem; }
    .pinned-bar-header { font-size: 0.8rem; }
    .pinned-item { font-size: 0.75rem; }

    /* Chat input */
    .chat-input-row { gap: 0.3rem; }
    .chat-input-row textarea { min-height: 36px; font-size: 16px; }
    .btn-image, .btn-file { height: 36px; font-size: 0.95rem; padding: 0.3rem 0.5rem; }
    .btn-send { height: 36px; font-size: 0.85rem; padding: 0.3rem 0.75rem; }
    .image-preview img { max-width: 80px; max-height: 60px; }
    .reply-preview { font-size: 0.75rem; padding: 0.3rem 0.5rem; }
    .chat-search-bar { flex-wrap: wrap; }
    .chat-search-bar input { min-width: 0; }
    .scroll-bottom-btn { bottom: 90px; right: 1rem; font-size: 0.75rem; padding: 0.3rem 0.75rem; }

    /* Search */
    .search-results { max-height: 150px; }
    .search-result-item { font-size: 0.75rem; padding: 0.4rem 0.5rem; }

    /* Static pages */
    .static-card { padding: 1rem; }
    .static-card h2 { font-size: 0.95rem; }
    .static-card p, .static-card ul { font-size: 0.85rem; }
    .info-table th { width: 100px; font-size: 0.8rem; }

    /* Profile */
    .avatar-large { width: 60px; height: 60px; }
    .avatar-initial-large { font-size: 1.5rem; }
}
