/* style.css — balanced dark mobile theme */

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}

:root {
    --bg: #11141c;
    --bg-elev-1: #171c27;
    --bg-elev-2: #1c2330;
    --bg-elev-3: #20293a;

    --border: #2c3548;
    --border-soft: #39445b;

    --text: #e7ecf5;
    --text-soft: #b7c0d4;
    --text-muted: #95a0b6;

    --link: #7fc4ff;
    --link-hover: #b5deff;
    --link-visited: #c7afff;

    --accent: #6f8fff;
    --accent-hover: #88a2ff;
    --accent-soft: rgba(111, 143, 255, 0.18);
    --accent-ring: rgba(111, 143, 255, 0.28);

    --success: #9dde8e;
    --danger: #ff9898;

    --bubble-me: #2a3a60;
    --bubble-other: #1c2535;
    --archive-bg: #435343;
    --archive-bg-soft: #4e644e;

    --shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 19px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img,
video,
iframe,
canvas,
svg {
    display: block;
    max-width: 100%;
    height: auto;
}

.page {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
}

.container {
    width: 100%;
    padding: 18px 14px 30px;
}

a {
    color: var(--link);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    word-break: break-word;
    overflow-wrap: anywhere;
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

a:visited {
    color: var(--link-visited);
}

a:hover,
a:focus-visible {
    color: var(--link-hover);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

a.chip-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 48px;
    min-height: 48px;
    padding: 10px 14px;
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    background: var(--bg-elev-2);
    color: #eef4ff;
    text-decoration: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
    font-size: 1.05rem;
}

a.chip-link:hover,
a.chip-link:focus-visible {
    background: #26324a;
    border-color: #5872b8;
    color: #ffffff;
}

header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px;
    background: rgba(13, 17, 26, 0.96);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(8px);
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.header-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}

header a,
header span {
    font-size: 1rem;
}

header a {
    display: inline-flex;
    align-items: center;
    min-width: 48px;
    min-height: 48px;
    padding: 10px 14px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: #eaf2ff;
    text-decoration: none;
}

header a:hover,
header a:focus-visible {
    background: var(--accent-soft);
    border-color: rgba(125, 152, 255, 0.45);
    color: #ffffff;
}

header span {
    color: var(--text-muted);
}

.errors,
.info {
    margin: 0 0 12px;
    font-size: 1rem;
}

.errors {
    color: var(--danger);
}

.info {
    color: var(--success);
}

form {
    margin: 12px 0;
}

input[type="text"],
input[type="password"],
textarea,
.message-input,
.message-textarea,
#message {
    width: 100%;
    min-height: 48px;
    padding: 14px 16px;
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    background: var(--bg-elev-1);
    color: var(--text);
    font: inherit;
    font-size: 1.05rem;
    line-height: 1.45;
}

input[type="text"]::placeholder,
input[type="password"]::placeholder,
textarea::placeholder {
    color: #8f9ab0;
}

textarea,
.message-textarea {
    min-height: 160px;
    resize: vertical;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

button,
input[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 48px;
    min-height: 48px;
    padding: 8px 16px;
    border: none;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 500;
}

button:hover,
input[type="submit"]:hover,
button:focus-visible,
input[type="submit"]:focus-visible {
    background: var(--accent-hover);
}

button:disabled,
input[type="submit"]:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.dialog-list,
.users-table,
table {
    width: 100%;
    border-collapse: collapse;
}

.dialog-list {
    margin: 10px 0;
}

.users-table {
    margin: 10px 0;
}

.dialog-list th,
.users-table th {
    display: none;
}

.dialog-list tr,
.users-table tr {
    display: block;
    margin-bottom: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-elev-1);
}

.dialog-list td,
.users-table td {
    display: block;
    padding: 4px 0;
    border: none;
    font-size: 1rem;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.dialog-list .clickable-row {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.dialog-list .clickable-row:hover {
    background: #26324a;
}

.archive-cell {
    background: var(--archive-bg);
    color: #eef7ee;
    border-radius: 8px;
    padding-inline: 8px;
}

.dialog-list .clickable-row:hover .archive-cell {
    background: var(--archive-bg-soft);
}

.message {
    width: 100%;
    margin: 8px 0;
    padding: 14px 16px;
    border-radius: 18px;
    font-size: 1.05rem;
    line-height: 1.6;
    word-break: break-word;
    overflow-wrap: anywhere;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.message.me {
    background: var(--bubble-me);
    margin-left: 0;
}

.message.other {
    background: var(--bubble-other);
    margin-right: 0;
}

.message small {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

pre {
    margin: 0;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-elev-1);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-wrap: break-word;
    font: inherit;
    line-height: 1.55;
}

#chatBox pre {
    min-height: 80px;
}

.search-results {
    margin: 12px 0 16px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-elev-1);
}

.search-results ul {
    margin: 10px 0 0;
    padding-left: 20px;
}

.search-results li {
    margin-bottom: 12px;
    line-height: 1.5;
}

.search-results li:last-child {
    margin-bottom: 0;
}

.welcome-box {
    width: calc(100% - 24px);
    max-width: 920px;
    margin: 24px auto;
    padding: 22px;
    border: 1px solid var(--border-soft);
    border-radius: 18px;
    background: var(--bg-elev-1);
    box-shadow: var(--shadow);
    color: var(--text);
}

.welcome-head {
    margin-bottom: 18px;
    text-align: center;
}

.welcome-head h1 {
    margin: 0 0 8px;
    font-size: 1.9rem;
    line-height: 1.2;
    color: #f3f7ff;
}

.welcome-head .subtitle {
    margin: 0;
    font-size: 1rem;
    color: var(--text-soft);
}

.welcome-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.welcome-card {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-elev-2);
}

.welcome-card h2 {
    margin: 0 0 10px;
    font-size: 1.02rem;
    line-height: 1.35;
    color: #f2f6ff;
}

.welcome-card ul {
    margin: 0;
    padding-left: 18px;
}

.welcome-card li {
    margin: 0 0 8px;
    color: var(--text-soft);
    line-height: 1.5;
}

.welcome-card li:last-child {
    margin-bottom: 0;
}

.welcome-card strong {
    color: #ffffff;
}

footer {
    padding: 1em;
    text-align: center;
    color: #888;
    font-size: 0.95rem;
}

@media (max-width: 600px) {
    body {
        font-size: 18px;
    }

    .page {
        max-width: 100%;
    }

    .container {
        padding: 16px 12px 28px;
    }

    header {
        padding: 10px;
    }

    .header-title {
        font-size: 1rem;
    }

    header a,
    header span {
        font-size: 0.96rem;
    }

    header a {
        padding: 9px 12px;
    }

    .welcome-box {
        width: calc(100% - 24px);
        margin: 16px 12px;
        padding: 18px 16px;
        border-radius: 16px;
    }

    .welcome-head h1 {
        font-size: 1.55rem;
    }

    .welcome-head .subtitle {
        font-size: 0.97rem;
    }

    .welcome-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .welcome-card {
        padding: 14px;
    }
}

@media (max-width: 380px) {
    body {
        font-size: 17px;
        line-height: 1.6;
    }

    .container {
        padding: 14px 10px 24px;
    }

    header {
        padding: 8px;
        gap: 8px;
    }

    .header-left,
    .header-right {
        gap: 6px;
    }

    header a {
        min-width: 44px;
        min-height: 44px;
        padding: 8px 11px;
        font-size: 0.93rem;
    }

    .header-title {
        width: 100%;
        font-size: 0.98rem;
        text-align: center;
    }

    input[type="text"],
    input[type="password"],
    textarea,
    button,
    input[type="submit"],
    a.chip-link {
        min-height: 44px;
        font-size: 1rem;
    }

    .dialog-list tr,
    .users-table tr,
    .message,
    .welcome-card {
        padding-left: 12px;
        padding-right: 12px;
    }

    .welcome-box {
        width: calc(100% - 16px);
        margin: 12px 8px;
        padding: 16px 12px;
        border-radius: 14px;
    }

    .welcome-head h1 {
        font-size: 1.5rem;
    }

    .welcome-card h2 {
        font-size: 1rem;
    }

    .welcome-card ul {
        padding-left: 16px;
    }
}

@media (min-width: 768px) {
    .dialog-list,
    .users-table {
        overflow: hidden;
        border-radius: 10px;
        background: var(--bg-elev-1);
    }

    .dialog-list th,
    .users-table th {
        display: table-cell;
        padding: 10px 12px;
        background: var(--bg-elev-2);
        color: #cfd8ea;
        font-weight: 500;
        text-align: left;
    }

    .dialog-list tr,
    .users-table tr {
        display: table-row;
        margin: 0;
        padding: 0;
        border: none;
        border-radius: 0;
    }

    .dialog-list td,
    .users-table td {
        display: table-cell;
        padding: 10px 12px;
        border-top: 1px solid var(--border);
        font-size: 0.98rem;
        vertical-align: top;
    }

    .message {
        max-width: 82%;
    }

    .message.me {
        margin-left: auto;
    }

    .message.other {
        margin-right: auto;
    }
}

@media print {
    body {
        background: #fff;
        color: #000;
        font-size: 12pt;
    }

    header,
    footer,
    .no-print {
        display: none !important;
    }

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


.export-btn {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1000;

    display: inline-flex;
    align-items: center;
    min-width: 48px;
    min-height: 48px;
    padding: 10px 14px;

    border: 1px solid var(--border-soft);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: #eaf2ff !important;
    text-decoration: none;
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow);
}

.export-btn:hover,
.export-btn:focus-visible {
    background: var(--accent-soft);
    border-color: rgba(125, 152, 255, 0.45);
    color: #ffffff !important;
}
