:root {
  color-scheme: light;
  font-family: "Segoe UI", system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #26362e;
  background: #eaf0e8;
  --forest: #213b32;
  --forest-deep: #1c332b;
  --green: #2b604a;
  --green-hover: #204d3a;
  --ink: #26362e;
  --soft-ink: #5d6f64;
  --line: #e0e7de;
  --paper: #f9faf7;
  --error: #a5322f;
  --focus: #638a74;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; }
h1, h2, h3, p { margin: 0; }
button, input, textarea { font: inherit; }
button { border: 0; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
input:focus-visible, textarea:focus-visible { outline-offset: 1px; }
.icon-definitions { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.brand { display: flex; align-items: center; gap: .8rem; font-size: 1.4rem; font-weight: 700; letter-spacing: .06em; }
.brand-icon { display: grid; place-items: center; flex: none; width: 2.6rem; height: 2.6rem; border-radius: .9rem; background: #d4ebd4; color: var(--forest); }
.brand-icon .icon { width: 1.45rem; height: 1.45rem; }
.icon-button { display: inline-grid; width: 2.6rem; height: 2.6rem; border-radius: .8rem; place-items: center; background: transparent; }
.icon-button:hover { background: #e9efe7; }
.button { min-height: 2.75rem; display: inline-flex; justify-content: center; align-items: center; gap: .5rem; border-radius: .8rem; padding: .65rem 1rem; font-weight: 650; white-space: nowrap; }
.primary { background: var(--green); color: white; }
.primary:hover:not(:disabled) { background: var(--green-hover); }
.primary:disabled { background: #dce8dc; color: #60746a; }
.quiet { background: #edf2eb; color: #324c3d; }
.quiet:hover { background: #e2ebdf; }
.danger { background: #a5322f; color: #fff; }
.danger:hover:not(:disabled) { background: #872724; }
.danger:disabled { opacity: .55; }
.form-error { color: var(--error); font-size: .875rem; line-height: 1.6; }

.startup { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 1rem; color: var(--soft-ink); }
.auth-view { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 2rem; background: radial-gradient(ellipse at 75% 0%, #f5f8f0, transparent 65%), #eaf0e8; }
.auth-shell { width: min(100%, 880px); min-height: 535px; display: grid; grid-template-columns: .98fr 1.02fr; overflow: hidden; border: 1px solid #e0e7dc; border-radius: 1.75rem; background: #fff; box-shadow: 0 23px 65px #294b3619; }
.auth-brand { display: grid; align-content: space-between; justify-items: start; gap: 1.5rem; padding: 2rem; color: #f2f8ef; background: radial-gradient(ellipse at 45% 48%, #3b594a 0%, var(--forest) 62%, var(--forest-deep) 100%); overflow: hidden; }
.auth-brand-label { display: flex; align-items: center; gap: .5rem; color: #c6d9c9; font-size: .875rem; }
.auth-brand-label .icon { width: 1rem; height: 1rem; }
.auth-art { position: relative; width: min(100%, 286px); aspect-ratio: 1; justify-self: center; display: grid; place-content: center; }
.art-ring { position: absolute; inset: 0; border: 1px solid #b8d6b942; border-radius: 50%; }
.art-ring-inner { inset: 13%; border-style: dashed; }
.art-home { width: 8.5rem; height: 8.5rem; display: grid; place-items: center; border-radius: 2.6rem; background: #d9edce; color: #2d5843; transform: rotate(-10deg); box-shadow: 0 18px 40px #152e2660; }
.art-home .icon { width: 4.5rem; height: 4.5rem; stroke-width: 1.35; }
.art-bubble { position: absolute; width: 4.1rem; height: 4.1rem; display: grid; place-items: center; right: 10%; top: 55%; border: .22rem solid var(--forest); border-radius: 1.4rem; color: #784e34; background: #f3d3ae; transform: rotate(12deg); box-shadow: 0 8px 18px #152e264d; }
.art-bubble .icon { width: 2rem; height: 2rem; }
.auth-panel { width: 100%; max-width: 460px; display: grid; align-content: center; gap: 1.5rem; padding: clamp(1.55rem, 4vw, 3.5rem); margin: auto; }
.auth-tabs { display: flex; gap: .25rem; padding: .25rem; width: fit-content; border-radius: .85rem; background: #edf2eb; }
.auth-tabs button { background: transparent; color: var(--soft-ink); border-radius: .65rem; min-height: 2.4rem; padding: .5rem .9rem; font-size: .875rem; font-weight: 600; }
.auth-tabs button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 4px #203b3014; }
.auth-heading h1 { font-size: 1.85rem; letter-spacing: .015em; line-height: 1.25; }
.auth-heading p { margin-top: .6rem; color: var(--soft-ink); line-height: 1.65; }
#auth-form { display: grid; gap: .9rem; }
.field { display: grid; min-width: 0; gap: .35rem; }
.field span { font-size: .875rem; font-weight: 650; }
.field input { min-width: 0; width: 100%; min-height: 2.85rem; padding: .65rem .8rem; border: 1px solid #dbe5da; border-radius: .75rem; background: #f9fbf8; color: var(--ink); }
.auth-submit { margin-top: .25rem; }

.app-view { height: 100vh; height: 100dvh; display: grid; place-items: center; padding: 1.3rem; }
.workspace { height: 100%; width: min(100%, 1340px); display: grid; grid-template-columns: clamp(15.5rem, 24vw, 20rem) minmax(0, 1fr); overflow: hidden; border: 1px solid #dbe5d9; border-radius: 1.45rem; background: var(--paper); box-shadow: 0 20px 60px #2e4a331c; }
.sidebar { min-width: 0; min-height: 0; display: flex; flex-direction: column; color: #eef5ec; background: var(--forest); }
.sidebar-brand { padding: 1.55rem 1.25rem 1.2rem; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: .2rem .85rem 1rem; scrollbar-color: #5c7565 transparent; }
.sidebar-section + .sidebar-section { margin-top: 1.4rem; }
.sidebar-section h2 { display: flex; justify-content: space-between; padding: .35rem .55rem .55rem; color: #c3d4c6; font-size: .84rem; font-weight: 650; }
.sidebar-list { display: grid; gap: .2rem; }
.sidebar-row { display: flex; align-items: center; gap: .7rem; width: 100%; min-height: 3rem; min-width: 0; padding: .48rem .55rem; color: inherit; background: transparent; border-radius: .75rem; text-align: left; }
.sidebar-row:hover:not(:disabled) { background: #ffffff0b; }
.sidebar-row[aria-current="true"] { background: #ffffff17; }
.sidebar-row:focus-visible, .sidebar-option:focus-visible, .sidebar .icon-button:focus-visible { outline-color: #b0d3b9; outline-offset: -2px; }
.sidebar-row .icon:last-child { margin-left: auto; width: 1rem; height: 1rem; color: #a8c2ab; }
.sidebar-row .avatar .icon { margin: 0; width: 1.25rem; height: 1.25rem; color: inherit; }
.sidebar-text { display: grid; flex: 1; gap: .2rem; min-width: 0; }
.sidebar-title, .profile-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-title { font-size: .9375rem; font-weight: 650; }
.sidebar-subtitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #bacabf; font-size: .8125rem; }
.member-tags { display: flex; align-items: center; gap: .45rem; min-width: 0; }
.role-tag { flex: none; padding: .12rem .42rem; border-radius: 999px; color: #46604b; background: #e2ebde; font-size: .75rem; font-weight: 650; line-height: 1.3; }
.sidebar .role-tag { background: #405a4c; color: #ecf6e9; }
.sidebar-error { margin: 1rem .55rem 0; color: #ffe1c3; font-size: .875rem; }
.sidebar-footer { display: grid; gap: .25rem; flex: none; padding: .55rem .9rem .9rem; border-top: 1px solid #ffffff18; background: #1e372e; }
.sidebar-option { min-height: 2.65rem; display: flex; align-items: center; gap: .55rem; padding: .5rem .6rem; border-radius: .65rem; color: #d7e6d8; background: transparent; text-align: left; }
.sidebar-option:hover { background: #ffffff13; }
.profile { min-width: 0; display: flex; align-items: center; gap: .65rem; padding: .55rem .35rem .1rem .45rem; }
.profile-details { display: grid; flex: 1; min-width: 0; gap: .12rem; }
.profile-name { font-weight: 650; }
.profile-role { color: #bbcfc0; font-size: .8rem; }
.logout-button { color: #d4e1d2; }
.logout-button:hover { background: #ffffff16; }
.avatar { width: 2.35rem; height: 2.35rem; flex: none; display: grid; place-items: center; border-radius: .8rem; background: #e6edda; color: #425b3e; font-weight: 700; line-height: 1; }
.avatar.group-avatar { background: #d8ecd3; color: #365840; }
.avatar[data-tone="1"] { background: #e9dfef; color: #625070; }
.avatar[data-tone="2"] { background: #f2e0cb; color: #714e32; }
.avatar[data-tone="3"] { background: #dfeaf1; color: #456474; }
.avatar[data-tone="4"] { background: #f3dfe2; color: #775053; }

.chat { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.chat-header { display: flex; align-items: center; gap: .8rem; min-height: 4.85rem; padding: .75rem clamp(1rem, 3vw, 2rem); border-bottom: 1px solid var(--line); background: #fff; }
.chat-heading { min-width: 0; }
.chat-heading h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.16rem; line-height: 1.4; }
.chat-heading p { margin-top: .13rem; color: var(--soft-ink); font-size: .875rem; }
.chat-heading .chat-alert { color: var(--error); }
.chat-avatar { width: 2.7rem; height: 2.7rem; border-radius: .95rem; }
.back-button { display: none; }
.chat-scroll { min-height: 0; overflow-y: auto; overscroll-behavior: contain; background: radial-gradient(ellipse at top, #f3f7ef, transparent 85%), var(--paper); }
.chat-scroll:focus-visible { outline-offset: -2px; }
.chat-inner { max-width: 920px; min-height: 100%; margin: 0 auto; padding: 1.15rem clamp(1rem, 4vw, 2.3rem); display: flex; flex-direction: column; }
.chat-state { text-align: center; margin: auto 0; display: grid; justify-items: center; gap: .55rem; padding: 1.4rem; color: var(--soft-ink); }
.chat-state .state-icon { display: grid; place-items: center; width: 3.8rem; height: 3.8rem; margin-bottom: .35rem; border-radius: 1.25rem; color: #41664d; background: #e4eee0; }
.chat-state .state-icon .icon { width: 1.9rem; height: 1.9rem; }
.chat-state strong { font-size: 1.1rem; color: var(--ink); }
.chat-state p { font-size: .94rem; }
.retry-button { align-self: center; margin: 0 auto auto; }
.older-button { margin: 0 auto .75rem; min-height: 2.3rem; padding: .4rem .85rem; border: 1px solid var(--line); border-radius: 999px; color: #45624f; background: #fff; font-size: .875rem; }
.older-button:hover { background: #eef3eb; }
.messages { display: grid; gap: 1.15rem; margin-top: auto; }
.message { display: flex; align-items: start; gap: .6rem; }
.message.own { flex-direction: row-reverse; }
.message .avatar { width: 2.1rem; height: 2.1rem; border-radius: .72rem; font-size: .91rem; }
.message-content { min-width: 0; max-width: min(78%, 37rem); display: grid; justify-items: start; gap: .35rem; }
.own .message-content { justify-items: end; }
.message-meta { max-width: 100%; display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; font-size: .8125rem; }
.own .message-meta { justify-content: flex-end; }
.message-sender { color: #3d5147; font-weight: 650; overflow-wrap: anywhere; }
.message-time { color: var(--soft-ink); white-space: nowrap; }
.message-bubble { max-width: 100%; width: fit-content; padding: .6rem .8rem; border: 1px solid #e3e9e0; border-radius: .25rem .9rem .9rem .9rem; background: #fff; overflow-wrap: anywhere; white-space: pre-wrap; line-height: 1.52; }
.own .message-bubble { border-color: #dbe9d7; border-radius: .9rem .25rem .9rem .9rem; background: #e4efdf; }
.photo-button { display: grid; max-width: 100%; padding: 0; border: 1px solid var(--line); border-radius: .85rem; overflow: hidden; background: #eaf0e8; }
.message-image { display: block; width: min(220px, 59vw); aspect-ratio: 3/2; object-fit: cover; }

.composer-area { padding: .85rem clamp(.8rem, 3vw, 1.65rem) calc(.85rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #fff; }
.composer { max-width: 920px; display: grid; gap: .55rem; margin: 0 auto; }
.composer-row { display: flex; align-items: flex-end; gap: .5rem; padding: .35rem; border: 1px solid #dce5db; border-radius: .95rem; background: #f7f9f6; }
.composer-row:focus-within { border-color: #779780; }
.composer-row textarea { width: 100%; min-width: 0; min-height: 2.75rem; max-height: 8.1rem; border: 0; padding: .6rem .25rem; line-height: 1.55; background: transparent; color: var(--ink); resize: none; }
.composer-row textarea:focus { outline: none; }
.composer-row textarea::placeholder { color: #607166; }
.attach-button { flex: none; height: 2.75rem; color: #486351; }
.send-button { flex: none; padding-inline: .85rem; }
.send-button .icon { width: 1.05rem; height: 1.05rem; }
.attachment { display: flex; align-items: center; gap: .55rem; width: fit-content; max-width: 100%; padding: .25rem; border-radius: .7rem; background: #edf3eb; }
.attachment img { flex: none; width: 2.4rem; height: 2.4rem; border-radius: .52rem; object-fit: cover; }
.attachment span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .875rem; }
.attachment .icon-button { flex: none; }

dialog { max-width: min(calc(100vw - 2rem), 32rem); width: 100%; max-height: min(85vh, 680px); padding: 1.3rem; border: 1px solid var(--line); border-radius: 1rem; color: var(--ink); background: #fff; box-shadow: 0 22px 65px #13352238; overflow: auto; }
dialog::backdrop { background: #17322884; }
.dialog-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; }
.dialog-heading h2 { font-size: 1.3rem; }
.dialog-heading p { margin-top: .35rem; color: var(--soft-ink); line-height: 1.6; }
.code-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: .6rem; }
.admin-status { margin-top: .65rem; color: var(--green); font-size: .875rem; }
.admin-status.error { color: var(--error); }
.admin-members { margin-top: 1.3rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.admin-members h3 { margin-bottom: .5rem; font-size: 1rem; }
.admin-member { display: flex; align-items: center; gap: .6rem; min-height: 3.4rem; padding-block: .3rem; }
.admin-member-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.remove-button { min-height: 2.35rem; border-radius: .65rem; background: #faf0ee; color: var(--error); padding: .3rem .65rem; }
.remove-button:hover { background: #f5e2df; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .9rem; }
.photo-dialog { max-width: min(calc(100vw - 2rem), 65rem); width: max-content; max-height: calc(100vh - 2rem); position: relative; padding: .4rem; background: #f5f7f3; }
.photo-dialog form { display: flex; justify-content: flex-end; margin-bottom: .25rem; }
.photo-dialog img { display: block; max-width: 100%; max-height: calc(100vh - 6rem); object-fit: contain; }

@media (max-width: 760px) {
  .app-view { padding: 0; }
  .workspace { grid-template-columns: 1fr; border: 0; border-radius: 0; }
  .workspace[data-mobile-screen="list"] .chat { display: none; }
  .workspace[data-mobile-screen="chat"] .sidebar { display: none; }
  .sidebar-brand { padding-top: max(1.3rem, env(safe-area-inset-top)); }
  .sidebar-footer { padding-bottom: calc(.75rem + env(safe-area-inset-bottom)); }
  .chat-header { min-height: 4.25rem; padding-top: max(.55rem, env(safe-area-inset-top)); gap: .5rem; }
  .back-button { display: inline-grid; margin-left: -.45rem; }
  .auth-view { padding: 1rem; }
  .auth-shell { max-width: 440px; grid-template-columns: 1fr; min-height: auto; border-radius: 1.25rem; }
  .auth-brand { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.25rem; gap: .75rem; }
  .auth-art { display: none; }
  .auth-panel { gap: 1.25rem; }
  .auth-heading h1 { font-size: 1.6rem; }
}

@media (max-width: 360px) {
  .auth-brand-label { display: none; }
  .send-button .icon { display: none; }
}
