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

:root {
    --bg: #1a1a2e;
    --surface: #16213e;
    --border: #0f3460;
    --text: #e0e0e0;
    --text-muted: #888;
    --accent: #e94560;
    --accent-hover: #ff6b6b;
    --input-bg: #0f3460;
    --success: #4ecdc4;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

.container {
    max-width: 700px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

header {
    margin-bottom: 2rem;
}

header h1 {
    font-size: 1.8rem;
    color: var(--accent);
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.back {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
}

.back:hover {
    color: var(--text);
}

h2 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

section {
    margin-bottom: 2rem;
}

input[type="text"], select {
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    font-size: 0.95rem;
    width: 100%;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

button {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
}

button:hover {
    background: var(--accent-hover);
}

button.danger {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

button.danger:hover {
    background: var(--accent);
    color: white;
}

#create-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

#create-form input {
    flex: 1;
    min-width: 200px;
}

#create-form details {
    width: 100%;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

#create-form details label {
    display: block;
    margin-top: 0.5rem;
}

#create-form details select {
    width: auto;
    margin-left: 0.5rem;
}

#rooms-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.room-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.2s;
}

.room-card:hover {
    border-color: var(--accent);
}

.room-card .name {
    font-weight: 500;
}

.room-card .meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.room-card.expired {
    opacity: 0.5;
}

.empty {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Room page */
.room-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding-bottom: 0;
}

.room-page header {
    margin-bottom: 1rem;
    flex-shrink: 0;
}

#online-users {
    font-size: 0.8rem;
    color: var(--success);
    margin-top: 0.25rem;
}

#chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.msg {
    padding: 0.3rem 0;
    word-wrap: break-word;
}

.msg .author {
    font-weight: 600;
    color: var(--accent);
    margin-right: 0.5rem;
}

.msg a {
    color: #6cb4ee;
    text-decoration: underline;
}

.msg .time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 0.5rem;
}

.msg.system {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
}

.msg.whisper {
    color: var(--accent);
    font-size: 0.85rem;
    font-style: italic;
    opacity: 0.9;
}

.attachment {
    margin-top: 0.4rem;
}

.attachment img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 6px;
    display: block;
}

.attachment video {
    max-width: 100%;
    max-height: 400px;
    border-radius: 6px;
    display: block;
}

.attachment audio {
    display: block;
    max-width: 100%;
}

.attachment-name {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-left: 0.5rem;
}

.text-attachment pre {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin-bottom: 0.25rem;
}

.text-attachment a {
    font-size: 0.8rem;
    color: var(--accent);
    text-decoration: none;
}

.file-download {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
}

.file-download:hover {
    text-decoration: underline;
}

#attachment-preview {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

#attachment-preview-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
}

#attachment-cancel {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    padding: 0 0.25rem;
    cursor: pointer;
}

#attachment-cancel:hover {
    color: var(--accent);
}

#message-form {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 0 1rem;
    flex-shrink: 0;
}

#message-form input[type="text"] {
    flex: 1;
}

#attach-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.4rem 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

#attach-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}

#chat.drag-over {
    outline: 2px dashed var(--accent);
    outline-offset: -4px;
    border-radius: 8px;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    width: 90%;
    max-width: 350px;
}

.modal-content h2 {
    color: var(--text);
    margin-bottom: 1rem;
}

.modal-content form {
    display: flex;
    gap: 0.5rem;
}

.modal-content input {
    flex: 1;
}

.hidden {
    display: none !important;
}

/* Admin */
.admin-page header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.admin-page header a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

th, td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--text-muted);
    font-weight: 500;
}

td a {
    color: var(--accent);
    text-decoration: none;
}

.slug {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
}

/* Load more */
#load-more {
    text-align: center;
    padding: 0.5rem;
}

#load-more button {
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.8rem;
    padding: 0.3rem 0.8rem;
}

/* Typing indicator */
#typing-indicator {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    min-height: 1.2em;
    padding: 0 0.25rem;
}

/* Share button */
.room-header-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.share-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    white-space: nowrap;
}

.share-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* Room card preview */
.room-card-info {
    flex: 1;
    min-width: 0;
}

.room-card-preview {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    margin-top: 0.2rem;
}

.last-msg {
    font-size: 0.8rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.last-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.7;
    white-space: nowrap;
}
