:root {
    --brand-blue: #0028a8;
    --brand-blue-2: #0048b8;
    --navy: #07184f;
    --navy-2: #0b2367;
    --ink: #172033;
    --muted: #5d687a;
    --line: #d8deea;
    --surface: #ffffff;
    --canvas: #eef2f8;
    --success: #197a4b;
    --warning: #927200;
    --focus: #f4c542;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--canvas);
    font-family: "Noto Sans JP", system-ui, -apple-system, BlinkMacSystemFont, "Yu Gothic UI", sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

a {
    color: inherit;
}

a:focus-visible,
input:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
}

button,
input,
select {
    font: inherit;
}

.app-shell {
    display: grid;
    grid-template-columns: 256px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px 16px;
    color: #ffffff;
    background: linear-gradient(180deg, var(--navy), #06143f);
    border-right: 1px solid rgba(255, 255, 255, 0.14);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    background: linear-gradient(135deg, var(--brand-blue), var(--brand-blue-2));
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 8px;
    font-weight: 700;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    color: #dce7ff;
    font-size: 13px;
}

.side-nav {
    display: grid;
    gap: 8px;
    min-height: 0;
    padding-top: 8px;
}

.side-nav-label {
    margin: 0 0 4px;
    padding: 0 12px;
    color: #9fb3e8;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.side-link {
    position: relative;
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    min-height: 46px;
    padding: 10px 12px;
    color: #dce7ff;
    text-decoration: none;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    font-weight: 700;
}

.side-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.14);
}

.side-link.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.24);
    box-shadow: inset 4px 0 0 #7fb0ff;
}

.side-icon {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    font-size: 14px;
    line-height: 1;
}

.settings-link {
    margin-top: 8px;
}

.workspace {
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(260px, 420px) auto;
    gap: 24px;
    align-items: center;
    min-height: 88px;
    padding: 16px 32px;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--brand-blue);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: 30px;
    line-height: 1.3;
}

h2 {
    margin-bottom: 0;
    font-size: 24px;
    line-height: 1.4;
}

.search {
    position: relative;
}

.search label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.search input {
    width: 100%;
    min-height: 48px;
    padding: 0 16px;
    color: var(--ink);
    background: #f7f9fc;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
}

.top-status {
    display: grid;
    gap: 4px;
    justify-items: end;
    color: var(--muted);
    white-space: nowrap;
}

.top-status strong {
    color: var(--navy);
}

.text-button {
    min-height: 32px;
    padding: 0;
    color: var(--brand-blue);
    background: transparent;
    border: 0;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}

.main-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.8fr);
    gap: 24px;
    width: min(1180px, calc(100% - 48px));
    margin: 24px auto 48px;
}

.welcome-panel,
.panel,
.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.welcome-panel {
    min-height: 260px;
    display: grid;
    align-items: end;
    padding: 32px;
    color: #ffffff;
    background:
        linear-gradient(90deg, rgba(7, 24, 79, 0.96), rgba(0, 40, 168, 0.78), rgba(7, 24, 79, 0.52)),
        url("/assets/img/toyolite_hero.jpg") center / cover no-repeat;
}

.welcome-panel h2 {
    margin-bottom: 12px;
    color: #ffffff;
    font-size: 36px;
}

.welcome-panel p:not(.eyebrow) {
    max-width: 680px;
    margin-bottom: 0;
    color: #f0f5ff;
    font-size: 17px;
    line-height: 1.7;
}

.stat-panel {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.stat-card {
    min-height: 120px;
    padding: 20px;
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 14px;
}

.stat-card strong {
    display: inline-block;
    margin-top: 14px;
    color: var(--navy);
    font-size: 32px;
    line-height: 1;
}

.stat-card small {
    margin-left: 4px;
    color: var(--muted);
}

.panel {
    padding: 24px;
}

.main-grid > .alert {
    grid-column: 1 / -1;
}

.app-panel {
    grid-column: 1 / -1;
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.app-card {
    min-height: 208px;
    padding: 22px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-top: 6px solid var(--brand-blue);
    border-radius: 8px;
}

.app-card.green {
    border-top-color: var(--success);
}

.app-card.amber {
    border-top-color: var(--warning);
}

.app-card.slate {
    border-top-color: #48566d;
}

.app-label {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 4px 10px;
    color: var(--brand-blue);
    background: #edf3ff;
    border-radius: 8px;
    font-weight: 700;
}

.app-card h3 {
    margin: 16px 0 10px;
    font-size: 21px;
    line-height: 1.4;
}

.app-card p {
    color: var(--muted);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 4px 10px;
    color: #334155;
    background: #eef2f7;
    border: 1px solid #d7dee9;
    border-radius: 8px;
    font-weight: 700;
    white-space: nowrap;
}

.update-list {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.update-row {
    display: grid;
    grid-template-columns: 110px 80px 1fr;
    gap: 12px;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--line);
}

.update-row:last-child {
    border-bottom: 0;
}

.update-row time {
    color: var(--muted);
}

.update-row span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 4px 8px;
    color: var(--brand-blue);
    background: #edf3ff;
    border-radius: 8px;
    font-weight: 700;
}

.update-row p {
    margin: 0;
}

.settings-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.settings-panel p:not(.eyebrow) {
    margin: 10px 0 0;
    color: var(--muted);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(7, 24, 79, 0.94), rgba(0, 40, 168, 0.72)),
        url("/assets/img/toyolite_hero.jpg") center / cover no-repeat;
}

.login-card {
    width: min(100%, 440px);
    padding: 32px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.login-brand .brand-mark {
    color: #ffffff;
}

.login-brand h1 {
    font-size: 32px;
}

.form-stack,
.settings-form {
    display: grid;
    gap: 16px;
}

.settings-form .form-actions {
    width: 100%;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: stretch;
}

.field {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.field label {
    color: var(--ink);
    font-weight: 700;
}

.field input,
.field select {
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    color: var(--ink);
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.field input[readonly] {
    color: var(--muted);
    background: #f7f9fc;
    border-style: dashed;
}

.support-text {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.field.has-support {
    grid-template-rows: auto 48px minmax(42px, auto);
}

.account-icon-row {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 16px;
    align-items: center;
    padding: 16px;
    background: #f7f9fc;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.profile-preview {
    display: grid;
    width: 72px;
    height: 72px;
    place-items: center;
    color: #ffffff;
    background: var(--brand-blue);
    border: 1px solid #cddcff;
    border-radius: 8px;
    font-size: 28px;
    font-weight: 700;
    object-fit: cover;
}

.generated-avatar {
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.avatar-blue {
    background: var(--brand-blue);
}

.avatar-green {
    background: #197a4b;
}

.avatar-slate {
    background: #48566d;
}

.avatar-amber {
    background: #927200;
}

.avatar-red {
    background: #a83232;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    color: var(--muted);
    font-size: 14px;
}

.check-row input {
    width: auto;
    min-height: auto;
}

.avatar-mode-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 12px;
    padding: 0;
    border: 0;
}

.avatar-mode-picker legend {
    width: 100%;
    margin-bottom: 2px;
    font-weight: 700;
}

.avatar-mode-picker label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 10px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-weight: 700;
}

.avatar-mode-picker label:has(input:checked) {
    color: var(--brand-blue);
    background: #edf3ff;
    border-color: #cddcff;
}

.avatar-mode-picker label.disabled {
    color: var(--muted);
    background: #eef2f7;
}

.avatar-mode-picker input {
    width: auto;
    min-height: auto;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 4px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    min-width: 136px;
    padding: 12px 18px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-weight: 700;
    cursor: pointer;
}

.button.primary {
    color: #ffffff;
    background: var(--brand-blue);
}

.button.secondary {
    color: var(--brand-blue);
    background: #ffffff;
    border-color: var(--brand-blue);
}

.alert {
    padding: 14px 16px;
    border-radius: 8px;
    border: 1px solid;
}

.alert p {
    margin: 0;
}

.alert p + p {
    margin-top: 6px;
}

.alert.error {
    color: #7a0000;
    background: #fff0f0;
    border-color: #f3b4b4;
}

.alert.success {
    color: #0f5132;
    background: #edf8f2;
    border-color: #b8dfca;
}

.settings-main {
    grid-column: 1 / -1;
}

.user-list-panel {
    grid-column: 1 / -1;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 14px 16px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--line);
}

th {
    color: var(--muted);
    background: #f7f9fc;
}

tr:last-child td {
    border-bottom: 0;
}

.member-picker {
    margin: 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.member-picker legend {
    padding: 0 8px;
    font-weight: 700;
}

.member-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.member-grid label {
    display: grid;
    grid-template-columns: 20px 1fr auto;
    gap: 8px;
    align-items: center;
    min-height: 44px;
    padding: 8px 10px;
    background: #f7f9fc;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.member-grid small {
    color: var(--muted);
}

.group-edit-list {
    display: grid;
    gap: 16px;
    margin-top: 24px;
}

.group-edit-card {
    display: grid;
    gap: 16px;
    padding: 18px;
    background: #f7f9fc;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.chat-panel {
    grid-column: 1 / -1;
    padding: 0;
    overflow: hidden;
}

.chat-page .workspace {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-page .topbar {
    flex-shrink: 0;
    min-height: 60px;
    padding: 6px 24px;
    gap: 16px;
}

.chat-page .topbar h1 { font-size: 22px; }
.chat-page .topbar .eyebrow { margin-bottom: 0; font-size: 11px; }
.chat-page .search input { min-height: 36px; }
.chat-page .top-status { display: flex; align-items: center; gap: 12px; white-space: normal; }
.chat-page .main-grid {
    width: calc(100% - 16px);
    flex: 1;
    min-height: 0;
    margin-top: 8px;
    margin-bottom: 0;
    padding-bottom: 0;
    grid-template-rows: minmax(0, 1fr);
}
.chat-page .chat-panel { min-height: 0; }
.chat-page .chat-layout { height: 100%; position: relative; }
.group-toggle {
    position: absolute;
    top: 16px;
    left: 284px;
    z-index: 3;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #fff;
    color: var(--brand-blue);
    font-size: 22px;
    cursor: pointer;
}
.chat-rail-heading { padding-right: 24px; }
.chat-layout.groups-collapsed { grid-template-columns: minmax(0, 1fr); }
.groups-collapsed .chat-groups { display: none; }
.groups-collapsed .group-toggle { left: 8px; }
.groups-collapsed .chat-room-header { padding-left: 44px; }

@media (max-width: 1040px) {
    .chat-page .app-shell { height: 100dvh; grid-template-rows: auto minmax(0, 1fr); }
    .chat-page .workspace { height: 100%; }
    .chat-page .topbar { grid-template-columns: minmax(0, 1fr) auto; }
    .chat-page .search { display: none; }
    .group-toggle { left: auto; right: 12px; }
    .chat-layout.groups-collapsed { grid-template-rows: minmax(0, 1fr); }
    .groups-collapsed .group-toggle { right: auto; }
}

.chat-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    height: max(480px, calc(100dvh - 160px));
    min-height: 0;
    background: #ffffff;
}

.chat-groups {
    display: grid;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 16px;
    padding: 20px;
    background: #f5f7fb;
    border-right: 1px solid var(--line);
}

.chat-rail-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.chat-rail-heading h2 {
    font-size: 20px;
}

.room-count {
    display: inline-grid;
    min-width: 32px;
    min-height: 32px;
    place-items: center;
    color: var(--brand-blue);
    background: #edf3ff;
    border: 1px solid #cddcff;
    border-radius: 8px;
    font-weight: 700;
}

.group-list {
    display: grid;
    gap: 8px;
    align-content: start;
    overflow: auto;
}

.group-list a {
    display: grid;
    gap: 8px;
    min-height: 104px;
    padding: 12px;
    text-decoration: none;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.group-list a:hover {
    border-color: #b9c7de;
}

.group-list a.active {
    background: #f9fbff;
    border-color: var(--brand-blue);
    box-shadow: inset 4px 0 0 var(--brand-blue);
}

.room-row,
.room-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.room-row strong,
.room-preview {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.room-row small,
.room-meta small,
.empty-text,
.empty-chat p {
    color: var(--muted);
}

.room-preview {
    color: #39465c;
    font-size: 14px;
}

.room-preview b {
    color: var(--ink);
}

.room-meta {
    justify-content: flex-start;
}

.room-meta small {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 8px;
    background: #eef2f7;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
}

.chat-room {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-height: 0;
    min-width: 0;
    background: #fbfcfe;
}

.chat-room-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 64px;
    padding: 12px 20px;
    background: #ffffff;
    border-bottom: 1px solid var(--line);
}

.room-title-block {
    min-width: 0;
}

.room-title-block h2 {
    overflow: hidden;
    margin: 0;
    font-size: 20px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-room-header p:not(.eyebrow) {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.chat-header-actions {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.message-list {
    display: grid;
    min-height: 0;
    min-width: 0;
    overscroll-behavior: contain;
    align-content: start;
    gap: 14px;
    padding: 24px;
    overflow: auto;
    background:
        linear-gradient(180deg, rgba(245, 247, 251, 0.92), rgba(251, 252, 254, 0.96));
}

.message-item {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 12px;
    max-width: 880px;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
}

.message-avatar,
.member-avatar {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    color: #ffffff;
    background: var(--brand-blue);
    border-radius: 8px;
    font-weight: 700;
    object-fit: cover;
}

.message-content {
    min-width: 0;
    padding: 14px 16px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.message-item header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.message-author {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
}

.message-item time {
    color: var(--muted);
    font-size: 14px;
}

.message-delete-form {
    margin: 0;
}

.message-delete-form button {
    min-height: 28px;
    padding: 3px 8px;
    color: var(--muted);
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.message-delete-form button:hover {
    color: #7a0000;
    background: #fff0f0;
    border-color: #f3b4b4;
}

.message-item p {
    margin-bottom: 8px;
    white-space: normal;
    overflow-wrap: anywhere;
}

.mention {
    display: inline;
    color: var(--brand-blue);
    background: #edf3ff;
    border-radius: 6px;
    font-weight: 700;
}

.attachment-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.attachment-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: min(100%, 420px);
    min-height: 36px;
    padding: 6px 10px;
    color: var(--brand-blue);
    background: #edf3ff;
    border: 1px solid #cddcff;
    border-radius: 8px;
    font-weight: 700;
}

.attachment-preview {
    display: block;
    width: min(100%, 320px);
}

.attachment-preview img {
    display: block;
    max-width: 100%;
    max-height: 220px;
    width: auto;
    height: auto;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.attachment-link span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-link small {
    color: var(--muted);
    white-space: nowrap;
}

.chat-form {
    display: grid;
    gap: 10px;
    padding: 16px 24px 22px;
    background: #ffffff;
    border-top: 1px solid var(--line);
}

.chat-form label {
    font-weight: 700;
}

.chat-form textarea {
    width: 100%;
    resize: none;
    height: 44px;
    min-height: 44px;
    padding: 12px 14px;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
}

.chat-form:focus-within textarea {
    height: 112px;
    min-height: 112px;
}

.chat-form:not(:focus-within) {
    gap: 6px;
    padding-top: 8px;
    padding-bottom: 10px;
}

.chat-compose-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.mention-picker {
    position: relative;
}

.mention-picker summary {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 6px 10px;
    color: var(--brand-blue);
    background: #edf3ff;
    border: 1px solid #cddcff;
    border-radius: 8px;
    font-weight: 700;
    list-style: none;
    cursor: pointer;
}

.mention-picker summary::after {
    content: "▼";
    margin-left: 8px;
    font-size: 10px;
}

.mention-picker summary::-webkit-details-marker {
    display: none;
}

.mention-picker-panel,
.mention-suggest {
    position: absolute;
    z-index: 20;
    display: grid;
    gap: 4px;
    width: min(280px, calc(100vw - 40px));
    max-height: 240px;
    padding: 8px;
    overflow: auto;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 42px rgba(7, 24, 79, 0.16);
}

.mention-picker-panel {
    right: 0;
    top: calc(100% + 8px);
}

.mention-picker-panel button,
.mention-suggest button {
    min-height: 36px;
    padding: 7px 10px;
    color: var(--ink);
    text-align: left;
    background: transparent;
    border: 0;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
}

.mention-picker-panel button:hover,
.mention-suggest button:hover {
    color: var(--brand-blue);
    background: #edf3ff;
}

.textarea-wrap {
    position: relative;
}

.mention-suggest {
    left: 12px;
    bottom: calc(100% + 8px);
}

.mention-suggest[hidden] {
    display: none;
}

.chat-form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.file-field {
    display: flex;
    align-items: center;
    gap: 0;
    min-height: 48px;
    padding: 0 10px;
    color: var(--brand-blue);
    background: #f7f9fc;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-weight: 700;
}

.file-field input {
    max-width: 260px;
}

.button.compact {
    min-width: 96px;
    min-height: 34px;
    padding: 6px 12px;
    font-size: 14px;
}

.member-popover {
    position: relative;
}

.member-popover summary {
    list-style: none;
}

.member-popover summary::-webkit-details-marker {
    display: none;
}

.member-popover-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 10;
    display: grid;
    gap: 10px;
    width: min(320px, calc(100vw - 40px));
    max-height: 420px;
    padding: 12px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 42px rgba(7, 24, 79, 0.16);
}

.chat-members-heading {
    display: grid;
    gap: 2px;
}

.chat-members-heading h2 {
    margin: 0;
    font-size: 16px;
    line-height: 1.3;
}

.member-list {
    display: grid;
    align-content: start;
    gap: 10px;
    overflow: auto;
}

.member-item {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    min-height: 42px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.member-item .member-avatar {
    width: 30px;
    height: 30px;
    background: #48566d;
    font-size: 13px;
}

.member-item strong,
.member-item small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.member-item small {
    color: var(--muted);
    font-size: 12px;
}

.empty-chat {
    display: grid;
    place-content: center;
    padding: 48px;
    text-align: center;
}

@media (max-width: 1040px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
    }

    .side-nav {
        display: flex;
        align-items: center;
        gap: 8px;
        padding-top: 0;
        overflow-x: auto;
    }

    .side-nav-label {
        display: none;
    }

    .settings-link {
        margin-top: 0;
    }

    .topbar,
    .main-grid {
        grid-template-columns: 1fr;
    }

    .top-status {
        justify-items: start;
    }

    .app-grid,
    .stat-panel {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .member-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .chat-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
        height: max(600px, calc(100dvh - 180px));
    }

    .chat-groups {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .group-list,
    .member-list {
        max-height: 320px;
    }

    .chat-groups .group-list {
        max-height: 120px;
    }
}

@media (max-width: 640px) {
    .sidebar,
    .topbar {
        padding: 14px 16px;
    }

    .main-grid {
        width: min(100% - 24px, 1180px);
        gap: 16px;
        margin-top: 16px;
    }

    .welcome-panel {
        min-height: 300px;
        padding: 24px;
    }

    .welcome-panel h2 {
        font-size: 30px;
    }

    .app-grid,
    .stat-panel {
        grid-template-columns: 1fr;
    }

    .panel {
        padding: 18px;
    }

    .update-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .settings-panel {
        align-items: flex-start;
        flex-direction: column;
    }

    .settings-form {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .account-icon-row {
        grid-template-columns: 56px minmax(0, 1fr);
        padding: 12px;
    }

    .profile-preview {
        width: 56px;
        height: 56px;
        font-size: 22px;
    }

    .member-grid {
        grid-template-columns: 1fr;
    }

    .chat-form-actions,
    .chat-room-header,
    .chat-header-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .chat-groups,
    .message-list,
    .chat-room-header,
    .chat-form {
        padding: 16px;
    }

    .member-popover-panel {
        left: 0;
        right: auto;
        width: 100%;
    }

    .message-item {
        grid-template-columns: 32px minmax(0, 1fr);
        gap: 10px;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
    }

    .file-field {
        align-items: flex-start;
        flex-direction: column;
        padding: 10px 12px;
    }

    .file-field input {
        max-width: 100%;
    }

    .chat-compose-top {
        align-items: stretch;
        flex-direction: column;
    }

    .mention-picker-panel {
        left: 0;
        right: auto;
    }

    .login-card {
        padding: 24px;
    }
}
