/* Shovelbox - Platinum HIG + MSN Messenger aesthetic
 * Inspired by Mac OS 8 (1997) and MSN Messenger 1.0
 * Mobile-first, 320-428px optimized
 */

/* ========================================================================= */
/* RESET & BASE                                                              */
/* ========================================================================= */

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

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    height: 100%;
    font-family: -apple-system, "Lucida Grande", Geneva, Verdana, sans-serif;
    font-size: var(--sb-font-size, 16px);
    line-height: 1.4;
    color: #000;
    background: #E8E8E8;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

a {
    color: #336699;
    text-decoration: none;
}

a:active {
    color: #224466;
}

/* ========================================================================= */
/* PLATINUM CONTROLS                                                         */
/* ========================================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 8px 16px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: #000;
    background: #DDDDDD;
    border: 1px solid #999;
    border-top-color: #FFF;
    border-left-color: #FFF;
    border-radius: 3px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.btn:active {
    border-top-color: #999;
    border-left-color: #999;
    border-bottom-color: #FFF;
    border-right-color: #FFF;
    background: #CCCCCC;
}

.btn-primary {
    background: #336699;
    color: #FFF;
    border-color: #224466;
    border-top-color: #5588BB;
    border-left-color: #5588BB;
}

.btn-primary:active {
    background: #2A557A;
    border-top-color: #224466;
    border-left-color: #224466;
    border-bottom-color: #5588BB;
    border-right-color: #5588BB;
}

.btn-send {
    min-width: 60px;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 700;
    background: #336699;
    color: #FFF;
    border-color: #224466;
    border-top-color: #5588BB;
    border-left-color: #5588BB;
    border-radius: 3px;
    flex-shrink: 0;
}

.btn-send:active {
    background: #2A557A;
}

.btn-small {
    min-height: 32px;
    padding: 4px 12px;
    font-size: 12px;
}

.btn-danger {
    color: #CC0000;
    border-color: #CC9999;
}

.btn-danger:active {
    background: #FFE0E0;
}

/* Inset text field (classic Mac style) */
input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 16px;
    color: #000;
    background: #FFF;
    border: 2px solid #999;
    border-top-color: #666;
    border-left-color: #666;
    border-bottom-color: #CCC;
    border-right-color: #CCC;
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
    border-color: #336699;
}

/* ========================================================================= */
/* TITLE BAR                                                                 */
/* ========================================================================= */

#titlebar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    height: 48px;
    padding: 0 8px;
    background: linear-gradient(to bottom, #E0E0E0, #C8C8C8);
    border-bottom: 1px solid #999;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
    padding-top: env(safe-area-inset-top);
    height: calc(48px + env(safe-area-inset-top));
}

#drawer-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    font-size: 20px;
    color: #333;
    background: none;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

#channel-name {
    flex: 1;
    font-size: 16px;
    font-weight: 700;
    color: #000;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 4px;
}

#titlebar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.team-name {
    font-size: 11px;
    color: #666;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.titlebar-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    font-size: 16px;
    color: #666;
    text-decoration: none;
}

.logout-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    font-size: 16px;
    color: #999;
    text-decoration: none;
}

.titlebar-back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    font-size: 24px;
    color: #336699;
    text-decoration: none;
    flex-shrink: 0;
}

/* ========================================================================= */
/* CHANNEL DRAWER                                                            */
/* ========================================================================= */

#drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 199;
    background: rgba(0,0,0,0.3);
}

#drawer-overlay.open {
    display: block;
}

#drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    width: 280px;
    background: #E0E0E0;
    border-right: 1px solid #999;
    box-shadow: 2px 0 8px rgba(0,0,0,0.15);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    display: flex;
    flex-direction: column;
}

#drawer.open {
    transform: translateX(0);
}

.drawer-header {
    padding: 16px;
    font-size: 14px;
    font-weight: 700;
    color: #333;
    border-bottom: 1px solid #BBB;
    background: linear-gradient(to bottom, #E8E8E8, #D8D8D8);
    flex-shrink: 0;
}

#channel-list {
    flex: 1;
    overflow-y: auto;
}

.drawer-footer {
    padding: 12px 16px;
    border-top: 1px solid #BBB;
    flex-shrink: 0;
}

.drawer-add-workspace {
    font-size: 13px;
    color: #336699;
}

.drawer-settings-link {
    font-size: 13px;
    color: #336699;
}

.drawer-logout-link {
    font-size: 13px;
    color: #CC0000;
    margin-left: 16px;
}

.drawer-actions {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    border-bottom: 1px solid #BBB;
    flex-shrink: 0;
}

.drawer-action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 4px 8px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: #336699;
    background: #E8E8E8;
    border: 1px solid #BBB;
    border-top-color: #DDD;
    border-left-color: #DDD;
    border-radius: 3px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}

.drawer-action-btn:active {
    background: #D0D0D0;
}

/* ========================================================================= */
/* WORKSPACE SWITCHER                                                        */
/* ========================================================================= */

.ws-switcher {
    flex-shrink: 0;
    border-bottom: 1px solid #BBB;
    background: linear-gradient(to bottom, #D0D0D0, #C0C0C0);
    padding: 8px;
}

.ws-switcher-items {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    align-items: center;
}

.ws-switcher-items::-webkit-scrollbar {
    display: none;
}

.ws-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 6px;
    border: 2px solid transparent;
    background: #D8D8D8;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
    font-family: inherit;
    padding: 0;
}

.ws-icon img {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    display: block;
}

.ws-icon.ws-active {
    border-color: #336699;
    background: #B8D4F0;
}

.ws-icon:disabled {
    cursor: default;
}

.ws-initial {
    font-size: 16px;
    font-weight: 700;
    color: #555;
}

.ws-icon.ws-add {
    border: 2px dashed #AAA;
    background: transparent;
    font-size: 18px;
    color: #888;
    text-decoration: none;
    font-weight: 300;
}

.ws-icon.ws-add:active {
    background: #C8C8C8;
}

.ws-switch-form {
    display: inline;
}

/* ========================================================================= */
/* CHANNEL LIST                                                              */
/* ========================================================================= */

.channel-list {
    list-style: none;
    padding: 4px 0;
}

.channel-item {
    margin: 0;
}

.channel-link {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 16px;
    color: #000;
    text-decoration: none;
    gap: 6px;
    -webkit-tap-highlight-color: transparent;
}

.channel-link:active,
.channel-item.active .channel-link {
    background: #B8D4F0;
}

.channel-icon {
    font-size: 14px;
    color: #666;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.channel-name {
    font-size: 15px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.channel-item.active .channel-name {
    font-weight: 700;
}

/* ========================================================================= */
/* MAIN CONTENT                                                              */
/* ========================================================================= */

#content {
    position: fixed;
    top: 48px;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    top: calc(48px + env(safe-area-inset-top));
    padding-bottom: env(safe-area-inset-bottom);
}

/* ========================================================================= */
/* MESSAGE LIST                                                              */
/* ========================================================================= */

.message-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 0;
}

.message-row {
    display: flex;
    gap: var(--sb-msg-gap, 8px);
    padding: var(--sb-msg-padding, 6px 12px);
}

.message-row:hover {
    background: rgba(0,0,0,0.02);
}

.message-avatar {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    margin-top: 2px;
    display: var(--sb-avatar-display, block);
}

.message-avatar img {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    display: block;
}

.avatar-placeholder {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    background: #CCC;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
}

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

.message-header {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 1px;
}

.message-author {
    font-size: 14px;
    font-weight: 700;
    color: #000;
}

.message-time {
    font-size: 11px;
    color: #999;
}

.message-text {
    font-size: var(--sb-font-size, 15px);
    line-height: 1.45;
    color: #111;
    word-break: break-word;
    overflow-wrap: break-word;
}

.message-text pre {
    margin: 6px 0;
    padding: 8px 10px;
    background: #F5F5F0;
    border: 1px solid #CCC;
    border-radius: 3px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.4;
}

.message-text code {
    font-family: "SF Mono", Monaco, "Courier New", monospace;
    font-size: 13px;
    padding: 1px 4px;
    background: #F0EDE6;
    border: 1px solid #DDD;
    border-radius: 2px;
}

.message-text pre code {
    padding: 0;
    background: none;
    border: none;
}

.message-text a {
    color: #336699;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.mention {
    color: #336699;
    font-weight: 600;
    background: rgba(51,102,153,0.1);
    padding: 0 2px;
    border-radius: 2px;
}

/* System messages (join/leave) */
.system-message {
    padding: 3px 12px;
}

.system-text {
    font-size: 12px;
    color: #999;
    font-style: italic;
    padding-left: 36px;
}

/* ========================================================================= */
/* FILE ATTACHMENTS                                                          */
/* ========================================================================= */

.message-files {
    margin-top: 6px;
}

.file-attachment {
    display: inline-block;
    margin: 2px 0;
}

.file-thumb {
    max-width: 240px;
    max-height: 180px;
    border-radius: 4px;
    border: 1px solid #CCC;
    display: block;
    margin-bottom: 2px;
}

.file-name {
    font-size: 13px;
    color: #336699;
}

/* ========================================================================= */
/* REACTIONS                                                                 */
/* ========================================================================= */

.reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    min-height: 28px;
    font-size: 13px;
    background: #F0F0F0;
    border: 1px solid #CCC;
    border-radius: 12px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
}

.reaction-pill.reacted {
    background: #D6E8F8;
    border-color: #336699;
}

.reaction-pill:active {
    background: #DDD;
}

.reaction-emoji {
    font-size: 15px;
    line-height: 1;
}

.reaction-count {
    font-size: 12px;
    color: #666;
    font-weight: 600;
}

.reaction-add,
.reaction-add-solo {
    color: #999;
    font-size: 16px;
    font-weight: 400;
    min-width: 28px;
    padding: 2px 6px;
}

.reaction-add-solo {
    display: none;
    background: none;
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    min-height: 28px;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.message-row:hover .reaction-add-solo {
    display: inline-flex;
}

/* Thread link */
.thread-link {
    display: inline-block;
    margin-top: 4px;
    font-size: 13px;
    color: #336699;
    font-weight: 500;
}

.thread-link:active {
    color: #224466;
}

/* Thread header */
.thread-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid #CCC;
    background: #F0F0F0;
}

.back-link {
    font-size: 14px;
    color: #336699;
    font-weight: 600;
}

.thread-count {
    font-size: 12px;
    color: #999;
}

.thread-parent {
    background: #F8F8F5;
    border-bottom: 1px solid #DDD;
    padding-bottom: 10px;
    margin-bottom: 4px;
}

/* ========================================================================= */
/* COMPOSE BAR                                                               */
/* ========================================================================= */

.compose-bar {
    flex-shrink: 0;
    padding: 8px 8px;
    background: #E0E0E0;
    border-top: 1px solid #BBB;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.4);
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
}

.compose-bar form {
    display: flex;
    gap: 6px;
    align-items: center;
}

.compose-input {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    resize: none;
    line-height: 1.4;
}

/* Formatting toolbar */
.compose-toolbar {
    display: flex;
    gap: 2px;
    padding: 0 0 4px;
}

.fmt-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 28px;
    font-family: inherit;
    font-size: 13px;
    color: #555;
    background: #E8E8E8;
    border: 1px solid #BBB;
    border-top-color: #DDD;
    border-left-color: #DDD;
    border-radius: 3px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.fmt-btn:active {
    background: #D0D0D0;
    border-top-color: #BBB;
    border-left-color: #BBB;
}

/* ========================================================================= */
/* EMOJI PICKER OVERLAY                                                      */
/* ========================================================================= */

.emoji-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.emoji-overlay.hidden {
    display: none;
}

.emoji-picker {
    width: 100%;
    max-width: 428px;
    max-height: 50vh;
    background: #E8E8E8;
    border-top: 1px solid #999;
    border-radius: 12px 12px 0 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: env(safe-area-inset-bottom);
}

.emoji-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 8px;
    font-weight: 700;
    font-size: 14px;
    color: #333;
    position: sticky;
    top: 0;
    background: #E8E8E8;
}

.emoji-close {
    width: 32px;
    height: 32px;
    font-size: 22px;
    color: #666;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 4px 8px;
}

.emoji-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    min-height: 44px;
    font-size: 24px;
    background: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.emoji-btn:active {
    background: #B8D4F0;
}

.custom-emoji-btn img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.emoji-section-label {
    padding: 8px 16px 4px;
    font-size: 11px;
    font-weight: 700;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========================================================================= */
/* LOGIN                                                                     */
/* ========================================================================= */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: #B0B0B0;
    overflow: auto;
}

.login-window {
    width: 100%;
    max-width: 320px;
    background: #E8E8E8;
    border: 1px solid #999;
    border-top-color: #FFF;
    border-left-color: #FFF;
    border-radius: 4px;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.25);
    overflow: hidden;
}

.login-titlebar {
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 700;
    color: #FFF;
    background: linear-gradient(to right, #336699, #5588BB);
    text-shadow: 0 1px 1px rgba(0,0,0,0.3);
}

.login-content {
    padding: 24px 20px;
    text-align: center;
}

.login-icon {
    font-size: 48px;
    margin-bottom: 12px;
    filter: grayscale(0.3);
}

.login-subtitle {
    font-size: 14px;
    color: #666;
    margin-bottom: 20px;
}

.login-btn {
    display: block;
    width: 100%;
    text-align: center;
    text-decoration: none;
    margin-bottom: 16px;
}

.login-hint {
    font-size: 11px;
    color: #999;
}

.login-error {
    padding: 8px 12px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #CC0000;
    background: #FFE0E0;
    border: 1px solid #CC9999;
    border-radius: 3px;
}

.login-back-link {
    display: inline-block;
    margin-top: 4px;
    font-size: 13px;
    color: #336699;
}

/* ========================================================================= */
/* SETTINGS                                                                  */
/* ========================================================================= */

.settings-content {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0;
}

.settings-tabs {
    display: flex;
    border-bottom: 1px solid #BBB;
    background: #E0E0E0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
}

.settings-tab {
    flex: 1;
    min-width: 0;
    padding: 12px 8px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    text-decoration: none;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    -webkit-tap-highlight-color: transparent;
}

.settings-tab.active {
    color: #336699;
    border-bottom-color: #336699;
}

.settings-tab:active {
    background: rgba(0,0,0,0.04);
}

.settings-panel {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.settings-section {
    margin-bottom: 24px;
}

.settings-heading {
    font-size: 16px;
    font-weight: 700;
    color: #333;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid #CCC;
}

.settings-muted {
    font-size: 13px;
    color: #999;
}

.settings-action {
    margin-top: 16px;
}

/* Profile card */
.profile-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin-bottom: 16px;
    background: #F0F0F0;
    border: 1px solid #CCC;
    border-radius: 4px;
}

.profile-avatar {
    border-radius: 6px;
    flex-shrink: 0;
}

.profile-info {
    min-width: 0;
}

.profile-name {
    font-size: 16px;
    font-weight: 700;
    color: #000;
}

.profile-title {
    font-size: 13px;
    color: #666;
}

/* Presence */
.presence-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.presence-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.presence-dot.online {
    background: #2EB67D;
}

.presence-dot.away {
    background: #ECB22E;
}

/* Form elements */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
}

.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
}

.radio-label input[type="radio"] {
    margin: 0;
    width: auto;
    min-height: auto;
}

/* Feedback messages */
.prefs-saved {
    padding: 8px 12px;
    margin: 8px 0;
    font-size: 13px;
    color: #2B7A3C;
    background: #E0F5E0;
    border: 1px solid #99CC99;
    border-radius: 3px;
}

.prefs-error {
    padding: 8px 12px;
    margin: 8px 0;
    font-size: 13px;
    color: #CC0000;
    background: #FFE0E0;
    border: 1px solid #CC9999;
    border-radius: 3px;
}

/* Workspace list (settings page) */
.workspace-list {
    margin-bottom: 12px;
}

.workspace-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid #CCC;
    border-radius: 4px;
    margin-bottom: 6px;
    background: #F5F5F5;
}

.workspace-row.ws-current {
    border-color: #336699;
    background: #EEF4FA;
}

.workspace-row-icon {
    flex-shrink: 0;
}

.workspace-row-icon img {
    border-radius: 4px;
    display: block;
}

.ws-initial-lg {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    background: #CCC;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
}

.workspace-row-info {
    flex: 1;
    min-width: 0;
}

.workspace-row-name {
    font-size: 14px;
    font-weight: 600;
    color: #000;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ws-badge {
    font-size: 10px;
    font-weight: 700;
    color: #336699;
    background: #D6E8F8;
    padding: 1px 6px;
    border-radius: 8px;
    text-transform: uppercase;
}

.workspace-row-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* ========================================================================= */
/* EMPTY STATES                                                              */
/* ========================================================================= */

.empty-state,
.empty-messages {
    padding: 40px 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

.auth-expired {
    padding: 20px;
    text-align: center;
    font-size: 14px;
    color: #CC0000;
}

.loading {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

/* ========================================================================= */
/* UTILITIES                                                                 */
/* ========================================================================= */

.hidden {
    display: none !important;
}

img[alt] {
    font-size: 11px;
    color: #999;
}

body {
    -webkit-touch-callout: none;
}

.message-text {
    -webkit-touch-callout: default;
    -webkit-user-select: text;
    user-select: text;
}

/* ========================================================================= */
/* SEARCH                                                                    */
/* ========================================================================= */

.search-bar {
    padding: 12px 16px;
    border-bottom: 1px solid #BBB;
    background: #E0E0E0;
}

.search-input {
    width: 100%;
}

.search-results {
    padding: 0;
    overflow-y: auto;
    flex: 1;
}

.search-meta {
    padding: 8px 16px;
    font-size: 12px;
    color: #999;
    border-bottom: 1px solid #DDD;
}

.search-result {
    display: block;
    padding: 10px 16px;
    border-bottom: 1px solid #EEE;
    text-decoration: none;
    color: inherit;
}

.search-result:active {
    background: #F0F0F0;
}

.search-result-header {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 2px;
}

.search-result-author {
    font-size: 13px;
    font-weight: 700;
    color: #000;
}

.search-result-channel {
    font-size: 12px;
    color: #336699;
}

.search-result-time {
    font-size: 11px;
    color: #999;
    margin-left: auto;
}

.search-result-text {
    font-size: 14px;
    color: #333;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.search-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
}

.search-page-info {
    font-size: 13px;
    color: #666;
}

/* ========================================================================= */
/* NEW DM PANEL                                                              */
/* ========================================================================= */

.newdm-panel {
    width: 100%;
    max-width: 428px;
    max-height: 70vh;
    background: #E8E8E8;
    border-top: 1px solid #999;
    border-radius: 12px 12px 0 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom);
}

.newdm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 8px;
    font-size: 14px;
    color: #333;
    flex-shrink: 0;
}

.newdm-search {
    padding: 0 12px 8px;
    flex-shrink: 0;
}

#newdm-results {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.user-picker-list {
    padding: 4px 0;
}

.user-picker-item {
    display: block;
}

.user-picker-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 16px;
    min-height: 44px;
    font-family: inherit;
    font-size: 14px;
    color: #000;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
}

.user-picker-btn:active {
    background: #B8D4F0;
}

.user-picker-avatar {
    border-radius: 4px;
    flex-shrink: 0;
}

.user-picker-name {
    font-weight: 500;
}

/* ========================================================================= */
/* CONTACT INFO                                                              */
/* ========================================================================= */

.contact-info {
    margin-bottom: 8px;
}

.contact-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid #EEE;
}

.contact-label {
    font-size: 13px;
    font-weight: 600;
    color: #666;
    min-width: 60px;
}

.contact-value {
    font-size: 14px;
    color: #000;
}

.profile-email {
    font-size: 12px;
    color: #336699;
    margin-top: 2px;
}

.form-hint {
    font-weight: 400;
    color: #999;
    font-size: 11px;
}

/* ========================================================================= */
/* TOKEN PASTE / RELAY                                                       */
/* ========================================================================= */

.token-help {
    margin-bottom: 16px;
    font-size: 13px;
    color: #555;
}

.token-help summary {
    cursor: pointer;
    color: #336699;
    font-weight: 600;
    padding: 4px 0;
}

.token-steps {
    padding: 8px 0 8px 20px;
    font-size: 13px;
    line-height: 1.6;
}

.token-steps li {
    margin-bottom: 4px;
}

.token-steps code {
    font-family: "SF Mono", Monaco, "Courier New", monospace;
    font-size: 12px;
    padding: 1px 4px;
    background: #F0EDE6;
    border: 1px solid #DDD;
    border-radius: 2px;
    word-break: break-all;
}
