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

/* ── Base ──────────────────────────────────────────────── */
html, body {
    height: 100%;
    overflow: hidden;
    background: #bbb;
    font-family: "Geneva", "Verdana", system-ui, sans-serif;
    font-size: 14px;
    color: #000;
    -webkit-user-select: none;
    user-select: none;
}

/* ── App shell ─────────────────────────────────────────── */
#app {
    display: none;
    flex-direction: column;
    height: 100%;
    max-width: 860px;
    margin: 0 auto;
    background: #fff;
    border-left: 2px solid #000;
    border-right: 2px solid #000;
}
#app.visible { display: flex; }

/* ── Title bar ─────────────────────────────────────────── */
.titlebar {
    flex-shrink: 0;
    height: 28px;
    border-bottom: 2px solid #000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    padding: 0 8px;
    position: relative;
}
.titlebar-stripes {
    position: absolute;
    inset: 4px;
    background: repeating-linear-gradient(90deg, transparent 0, transparent 1px, #000 1px, #000 2px);
    background-size: 3px 100%;
    opacity: 0.25;
    z-index: 0;
    pointer-events: none;
}
.titlebar-title {
    background: #fff;
    padding: 0 12px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    z-index: 1;
    white-space: nowrap;
}
.titlebar-left, .titlebar-right {
    position: absolute;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 4px;
}
.titlebar-left  { left: 8px; }
.titlebar-right { right: 8px; }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
    background: #fff;
    border: 2px solid #000;
    padding: 4px 10px;
    font: inherit;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 2px 2px 0 #000;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    -webkit-user-select: none;
    user-select: none;
}
.btn:active { background: #000; color: #fff; box-shadow: none; transform: translate(2px, 2px); }
.btn:disabled { background: #e0e0e0; color: #888; border-color: #888; box-shadow: none; cursor: not-allowed; transform: none !important; }

.btn-sm { padding: 2px 7px; box-shadow: 1px 1px 0 #000; }
.btn-sm:active { transform: translate(1px, 1px); }

.icon-btn {
    width: 20px; height: 20px; padding: 0;
    background: #fff; border: 2px solid #000;
    box-shadow: 2px 2px 0 #000; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: bold; line-height: 1;
}
.icon-btn:active { background: #000; color: #fff; box-shadow: none; transform: translate(1px, 1px); }

/* ── Emoji picker ──────────────────────────────────────── */
#emoji-picker {
    display: none;
    grid-template-columns: repeat(10, 1fr);
    gap: 0;
    background: #fff;
    border-bottom: 2px solid #000;
    padding: 6px 8px;
}
.emoji-btn {
    background: none;
    border: none;
    padding: 4px 2px;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
    text-align: center;
}
.emoji-btn:active { background: #eee; }

#emoji-toggle {
    width: 36px;
    height: 46px;
    font-size: 18px;
    flex-shrink: 0;
    border: 2px solid #000;
    box-shadow: 2px 2px 0 #000;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    -webkit-user-select: none;
    user-select: none;
}
#emoji-toggle:active { background: #000; color: #fff; box-shadow: none; transform: translate(2px, 2px); }

/* ── Messages ──────────────────────────────────────────── */
#messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fafafa;
    -webkit-user-select: text;
    user-select: text;
    overscroll-behavior: contain;
}
#messages::-webkit-scrollbar { width: 5px; }
#messages::-webkit-scrollbar-thumb { background: #999; }

.msg {
    max-width: 72%;
    padding: 7px 11px;
    border: 2px solid #000;
    background: #fff;
    line-height: 1.45;
    word-break: break-word;
    position: relative;
}
.msg-in       { align-self: flex-start; box-shadow: 3px 3px 0 #ccc; }
.msg-out      { align-self: flex-end;   box-shadow: 3px 3px 0 #000; background: #f9f9f9; }
.msg-system   {
    align-self: center;
    max-width: 90%;
    background: #f0f0f0;
    border-style: dashed;
    font-size: 12px;
    color: #555;
    text-align: center;
    box-shadow: none;
}
.msg-admin    { background: #000; color: #fff; border-color: #000; box-shadow: 3px 3px 0 #555; }
.msg-pending  { opacity: 0.45; }

.msg-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 4px;
    font-size: 11px;
    color: #555;
}
.msg-admin .msg-meta { color: #aaa; }

.msg-name { font-weight: bold; font-size: 12px; color: #000; }
.msg-admin .msg-name { color: #fff; }

.msg-time { margin-left: auto; font-size: 10px; font-style: italic; }

.reply-btn {
    background: none; border: none; padding: 0; cursor: pointer;
    font: inherit; font-size: 10px; text-decoration: underline;
    color: #666;
}
.reply-btn:hover { color: #000; }
.msg-admin .reply-btn { color: #aaa; }

.dev-badge {
    background: #fff; color: #000; border: 1px solid #fff;
    padding: 1px 4px; font-size: 9px; font-weight: bold;
    text-transform: uppercase; letter-spacing: 0.5px;
}

.quote {
    border-left: 3px solid #000;
    padding: 3px 8px;
    margin-bottom: 5px;
    font-size: 11px;
    color: #555;
    background: #f5f5f5;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.msg-admin .quote { border-color: #fff; background: #222; color: #bbb; }

.msg-text { font-size: 14px; }

/* ── Input area ────────────────────────────────────────── */
#input-area {
    flex-shrink: 0;
    border-top: 2px solid #000;
    background: #f0f0f0;
}
#reply-bar {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    border-bottom: 1px solid #ccc;
    font-size: 12px;
    background: #fffde0;
}
#reply-bar.visible { display: flex; }
#reply-bar-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #333; }

#send-error {
    display: none;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: bold;
    background: #000;
    color: #fff;
    text-align: center;
}
#send-error.visible { display: block; }

#input-row {
    display: flex;
    align-items: flex-end;
    padding: 8px;
    gap: 6px;
}
#msg-input {
    flex: 1;
    border: 2px solid #000;
    padding: 8px 10px;
    font: inherit;
    font-size: 14px;
    resize: none;
    height: 46px;
    background: #fff;
    outline: none;
    -webkit-user-select: text;
    user-select: text;
}
#msg-input:disabled { background: #f0f0f0; color: #888; cursor: not-allowed; }

#send-btn {
    height: 46px;
    flex-shrink: 0;
}

/* ── Status bar ────────────────────────────────────────── */
#statusbar {
    flex-shrink: 0;
    height: 20px;
    border-top: 1px solid #ccc;
    background: #f8f8f8;
    display: flex;
    align-items: center;
    padding: 0 10px;
    gap: 6px;
}
#status-text {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #777;
}
.status-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #ccc;
    border: 1px solid #aaa;
    flex-shrink: 0;
}
.status-dot.live { background: #000; border-color: #000; }

/* ── Auth screen ───────────────────────────────────────── */
#auth-screen {
    display: none;
    position: fixed;
    inset: 0;
    background: #bbb;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}
#auth-screen.visible { display: flex; }

.auth-card {
    background: #fff;
    border: 2px solid #000;
    box-shadow: 5px 5px 0 #000;
    width: 100%;
    max-width: 360px;
}
.auth-tabs {
    display: flex;
    border-bottom: 2px solid #000;
}
.auth-tab {
    flex: 1;
    padding: 9px;
    border: none;
    background: #fff;
    font: inherit;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
}
.auth-tab + .auth-tab { border-left: 2px solid #000; }
.auth-tab.active { background: #000; color: #fff; }

.auth-body { padding: 18px; }

.field { margin-bottom: 12px; }
.field label {
    display: block;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 3px;
}
.field input {
    width: 100%;
    border: 2px solid #000;
    padding: 7px 9px;
    font: inherit;
    font-size: 13px;
    background: #fff;
    outline: none;
    -webkit-user-select: text;
    user-select: text;
}
.field input:focus { background: #fafafa; }
.field-hint { font-size: 10px; color: #666; margin-top: 3px; line-height: 1.4; }

.tos-row {
    display: none;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    margin-bottom: 12px;
}
.tos-row.visible { display: flex; }
.tos-row a { color: #000; font-weight: bold; }

.auth-submit { width: 100%; padding: 9px; font-size: 12px; }

.auth-error {
    display: none;
    margin-top: 10px;
    border: 2px solid #000;
    padding: 7px;
    font-size: 11px;
    font-weight: bold;
    text-align: center;
    color: #c00;
}
.auth-error.visible { display: block; }

/* ── Modals ────────────────────────────────────────────── */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.93);
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}
.overlay.visible { display: flex; }

.modal {
    background: #fff;
    border: 2px solid #000;
    box-shadow: 5px 5px 0 #000;
    width: 100%;
    max-width: 420px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
}
.modal-body {
    padding: 18px;
    overflow-y: auto;
    flex: 1;
    font-size: 13px;
    line-height: 1.6;
    -webkit-user-select: text;
    user-select: text;
}
.modal-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.modal-input {
    width: 100%;
    border: 2px solid #000;
    padding: 7px 9px;
    font: inherit;
    font-size: 13px;
    margin-bottom: 8px;
    outline: none;
    -webkit-user-select: text;
    user-select: text;
}

/* ── Toast notice ──────────────────────────────────────── */
#notice {
    display: none;
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: #fff;
    border: 2px solid #fff;
    outline: 2px solid #000;
    padding: 7px 16px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    z-index: 999;
    white-space: nowrap;
    pointer-events: none;
}
