:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #edf1ee;
  background: #101414;
  --background: #101414;
  --panel: #171d1c;
  --raised: #1d2523;
  --edge: #303b36;
  --edge-soft: #252e2a;
  --ink: #edf1ee;
  --muted: #a3b0a8;
  --quiet: #8a9c91;
  --mint: #b8ebd1;
  --mint-strong: #91dcb8;
  --dock-height: 79px;
  --side: clamp(16px, 5vw, 29px);
  -webkit-font-smoothing: antialiased;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(ellipse 34rem 20rem at 50% 0, #24383199 0, transparent 90%), var(--background);
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button:focus-visible, a:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--mint); outline-offset: 3px; }
button:disabled { opacity: .52; cursor: default; }
button:not(:disabled):active { transform: scale(.982); }
a { color: var(--mint); text-underline-offset: .23em; }
p, h1, h2 { margin: 0; }
h1, h2 { overflow-wrap: anywhere; }
h1 { font-size: clamp(1.95rem, 8vw, 2.85rem); line-height: 1.16; font-weight: 750; letter-spacing: -.045em; }
h2 { font-size: 1.13rem; font-weight: 700; letter-spacing: -.025em; }
.lead { margin-top: 7px; font-size: .91rem; line-height: 1.55; color: var(--muted); }
.lead:empty { display: none; }

.shell { position: relative; width: 100%; max-width: 720px; min-height: 100dvh; margin: 0 auto; }
.app-header {
  position: sticky; z-index: 3; top: 0;
  display: flex; align-items: center; gap: 13px;
  min-height: 69px;
  padding: calc(10px + env(safe-area-inset-top)) var(--side) 10px;
  background: #111715d9;
  -webkit-backdrop-filter: blur(18px) saturate(120%);
  backdrop-filter: blur(18px) saturate(120%);
  border-bottom: 1px solid #536d5d29;
}
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-name { white-space: nowrap; font-size: 1rem; line-height: 1; font-weight: 780; letter-spacing: .025em; }
.brand-name span { color: #b5c6bb; font-weight: 590; margin-left: 3px; }
.identity-mark {
  --mark-size: 31px;
  display: inline-grid; position: relative; isolation: isolate; place-items: center;
  flex: 0 0 auto; width: var(--mark-size); height: var(--mark-size); border-radius: 31%;
  background: radial-gradient(circle at 32% 13%, #c4fada71, transparent 56%),
    conic-gradient(from 24deg at 51% 45%, #172e23, #315747, #7aa088, #1d4d38, #101d15, #172e23);
  border: 1px solid #8cb39f80;
  box-shadow: inset 0 1px 1px #d5ffe940, inset 0 -5px 10px #0d1813bb, 0 3px 10px #060a08b3;
}
.identity-mark::before, .identity-mark::after {
  content: ""; position: absolute; width: 57%; height: 34%; border: max(1px, calc(var(--mark-size) / 42)) solid #ddfbe6;
  border-radius: 50%; transform: rotate(-38deg);
}
.identity-mark::after { width: 42%; height: 25%; transform: translate(12%, 26%) rotate(-38deg); border-color: #9fe4be; opacity: .85; }
.identity-mark > span { position: absolute; top: 24%; right: 23%; width: 8%; aspect-ratio: 1; border-radius: 50%; background: #edfff3; box-shadow: 0 0 6px #ddfbe6; }
.right { margin-left: auto; }
.icon-button {
  display: inline-grid; flex-shrink: 0; place-items: center; width: 44px; height: 44px;
  border: 1px solid #37423d; border-radius: 15px; background: linear-gradient(#232d28, #1b2420);
  color: #d7e0d9; box-shadow: inset 0 1px 0 #ffffff0c, 0 2px 8px #00000014;
  transition: background .15s, border-color .15s, transform .15s;
}
.icon-button:hover { border-color: #667c6e; }

.rail-icon, .grid-icon, .bubble-icon, .more-icon, .search-icon, .add-icon,
.close-icon, .back-icon, .forward-icon, .send-icon { position: relative; display: inline-block; flex: 0 0 auto; }
.rail-icon { width: 17px; height: 15px; border: 1.6px solid currentColor; border-radius: 4px; }
.rail-icon::after { content: ""; position: absolute; top: 1px; bottom: 1px; left: 4px; border-left: 1.5px solid currentColor; }
.grid-icon {
  width: 16px; height: 16px; border-radius: 2px;
  background: linear-gradient(currentColor, currentColor) left top / 6.4px 6.4px no-repeat,
    linear-gradient(currentColor, currentColor) right top / 6.4px 6.4px no-repeat,
    linear-gradient(currentColor, currentColor) left bottom / 6.4px 6.4px no-repeat,
    linear-gradient(currentColor, currentColor) right bottom / 6.4px 6.4px no-repeat;
}
.bubble-icon { width: 19px; height: 15px; border: 1.7px solid currentColor; border-radius: 5px; }
.bubble-icon::after { content: ""; position: absolute; width: 5px; height: 5px; left: 2px; top: calc(100% - 2px); transform: skewY(-36deg); border-left: 1.7px solid currentColor; }
.more-icon { width: 4px; height: 4px; border-radius: 50%; background: currentColor; box-shadow: -6px 0 currentColor, 6px 0 currentColor; }
.search-icon { width: 14px; height: 14px; border: 1.6px solid currentColor; border-radius: 50%; margin: -2px 4px 0 0; }
.search-icon::after { content: ""; position: absolute; width: 5px; height: 1.6px; background: currentColor; bottom: -2px; right: -3px; transform: rotate(45deg); border-radius: 1px; }
.add-icon, .close-icon { width: 16px; height: 16px; }
.add-icon::before, .add-icon::after, .close-icon::before, .close-icon::after { content: ""; position: absolute; inset: 7px 1px auto; height: 1.6px; border-radius: 2px; background: currentColor; }
.add-icon::after { transform: rotate(90deg); }
.close-icon::before { transform: rotate(45deg); }
.close-icon::after { transform: rotate(-45deg); }
.back-icon, .forward-icon { width: 8px; height: 8px; border-right: 1.7px solid currentColor; border-top: 1.7px solid currentColor; }
.back-icon { transform: rotate(-135deg); margin: 0 2px 0 4px; }
.forward-icon { transform: rotate(45deg); margin: 0 5px 0 0; }
.send-icon { width: 14px; height: 17px; }
.send-icon::before { content: ""; position: absolute; left: 6px; top: 2px; bottom: 0; width: 2px; border-radius: 1px; background: currentColor; }
.send-icon::after { content: ""; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border: 2px solid currentColor; border-right: 0; border-bottom: 0; transform: rotate(45deg); border-radius: 1px; }

.main { padding: 22px var(--side) calc(var(--dock-height) + 25px + env(safe-area-inset-bottom)); }
.page-heading { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; margin: 4px 0 22px; }
.page-heading > div { min-width: 0; }
.page-heading .outline { flex-shrink: 0; }
.outline, .primary, .back, .text-action {
  display: inline-flex; gap: 8px; align-items: center; justify-content: center;
  border-radius: 13px; min-height: 44px; font-weight: 650;
  transition: background .15s, border-color .15s, transform .15s;
}
.outline { padding: 8px 13px; border: 1px solid #46594e; background: #24322a; color: #dceddf; white-space: nowrap; }
.outline:hover { background: #2d4136; border-color: #647e6e; }
.primary { padding: 10px 19px; color: #133124; background: linear-gradient(#cff5dd, #a4dabc); border: 1px solid #d5ffe4b0; box-shadow: inset 0 1px 0 #f0fff480, 0 6px 16px #0a151366; }
.primary:hover { background: #d1f7dd; }
.back, .text-action { padding: 0 9px 0 0; border: 0; color: var(--mint); background: none; }
.back { margin-bottom: 12px; }
.text-action { padding: 0 8px; }
.text-action:hover { text-decoration: underline; text-underline-offset: 4px; }

[data-theme="blue"], .space-card, .space-heading { --tint: #243c3c; --theme-ink: #acdcd7; }
[data-theme="plum"] { --tint: #44384b; --theme-ink: #e1c6e7; }
[data-theme="mint"] { --tint: #294338; --theme-ink: #b5e9cf; }
[data-theme="amber"] { --tint: #4a3c2b; --theme-ink: #f4d9a6; }
.space-list { display: grid; gap: 13px; }
.space-card {
  display: flex; align-items: flex-start; gap: 14px; width: 100%; text-align: left;
  padding: 15px; min-height: 113px; border: 1px solid #53665b75; border-radius: 20px;
  color: var(--ink); background: linear-gradient(122deg, var(--tint) -10%, #1d2623 44%, #19201d 100%);
  box-shadow: inset 0 1px 0 #f1fff410, 0 8px 18px #00000022;
  transition: border-color .17s, transform .17s;
}
.space-card:hover { border-color: #a2c7b4; }
.space-card .forward-icon { align-self: center; color: var(--theme-ink); }
.card-copy { flex: 1; min-width: 0; }
.card-title { display: block; font-size: 1.14rem; font-weight: 710; overflow-wrap: anywhere; }
.card-description { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: #bbc9c0; font-size: .875rem; line-height: 1.45; margin-top: 5px; overflow-wrap: anywhere; }
.card-meta { display: flex; flex-wrap: wrap; gap: 3px 11px; color: #acb9b0; font-size: .74rem; line-height: 1.45; margin-top: 11px; }
.card-tasks { color: var(--theme-ink); }
.space-symbol {
  display: inline-grid; place-items: center; width: 46px; height: 46px; flex: 0 0 auto;
  color: var(--theme-ink); font-size: 1.1rem; font-weight: 730;
  border-radius: 16px; border: 1px solid #bad5c447; background: #14211eac; box-shadow: inset 0 1px 0 #ffffff0e;
}
.space-heading {
  position: relative; isolation: isolate; overflow: hidden; padding: 22px 21px;
  background: linear-gradient(123deg, var(--tint), #1b2723 76%);
  border: 1px solid #657a6b65; border-radius: 25px; margin-bottom: 16px;
}
.space-heading::after {
  content: ""; position: absolute; z-index: -1; width: 22rem; height: 16rem; top: -5rem; left: 55%;
  transform: rotate(-24deg); border-radius: 50%;
  background: repeating-radial-gradient(ellipse at center, #ffffff18 0 1px, transparent 2px 21px);
  -webkit-mask-image: linear-gradient(95deg, #000 40%, transparent 90%);
  mask-image: linear-gradient(95deg, #000 40%, transparent 90%);
}
.space-heading .space-symbol { margin-bottom: 16px; }
.space-heading h1 { font-size: clamp(1.65rem, 7vw, 2.6rem); }
.empty-spaces {
  display: grid; justify-items: center; align-content: center; min-height: clamp(255px, 42dvh, 447px); padding: 30px 16px;
  background: radial-gradient(ellipse 180px 155px at 50% 39%, #263f32 0, transparent 86%), #151c19;
  border: 1px dashed #3d5045; border-radius: 24px; color: #dbe6de; text-align: center;
}
.empty-spaces p { font-size: 1.03rem; font-weight: 690; margin: 15px 0 2px; }
.empty-mark { width: 53px; height: 53px; border: 1px solid #527661; border-radius: 18px; display: grid; place-items: center; color: var(--mint); background: #20362b; }
.empty-mark .grid-icon { transform: scale(1.16); }

.document, .tasks { padding: 16px; background: #171f1b; border: 1px solid var(--edge-soft); border-radius: 19px; }
.document { line-height: 1.65; overflow-wrap: anywhere; }
.document:empty { display: none; }
.document h2, .document h3, .message h2, .message h3 { font-size: 1.035em; margin: 14px 0 6px; line-height: 1.45; }
.document > :first-child, .message > :first-child { margin-top: 0; }
.document p + p, .message p + p { margin-top: .56em; }
.document ul, .document ol, .message ul, .message ol { padding-left: 22px; margin: .45em 0; }
.document pre, .message pre { white-space: pre-wrap; overflow-wrap: anywhere; background: #101613; padding: 11px; border-radius: 9px; margin: .6em 0; }
.table-scroll { width: 100%; overflow-x: auto; margin: 10px 0; }
table { border-collapse: collapse; width: 100%; font-size: .86em; }
td, th { padding: 7px 9px; border: 1px solid #506154; text-align: left; }
th { background: #273a30; }
.tasks { margin-top: 16px; }
.section-title { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 8px; }
.section-title span { color: var(--mint); font-size: .86rem; font-variant-numeric: tabular-nums; }
.task { display: flex; min-height: 48px; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid #36473a; line-height: 1.42; cursor: pointer; overflow-wrap: anywhere; }
.task:last-child { border-bottom: 0; }
.task input { width: 19px; height: 19px; flex-shrink: 0; accent-color: var(--mint-strong); }
.task input:checked + span { color: #a5b8aa; text-decoration: line-through; }
.contextual-chat { margin-top: 17px; }

.tab-bar {
  display: grid; grid-template-columns: 1fr 1fr; gap: 5px; z-index: 3;
  position: fixed; left: 50%; bottom: max(9px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(calc(100% - 2 * var(--side)), 660px);
  padding: 5px;
  background: #19221edb; -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border: 1px solid #566b5b78; border-radius: 19px;
  box-shadow: inset 0 1px 0 #ffffff16, 0 13px 27px #00000070;
}
.tab-bar button {
  display: flex; align-items: center; justify-content: center; gap: 9px; min-width: 0; min-height: 45px; border-radius: 13px;
  font-size: .88rem; font-weight: 700;
  color: #a6b5ac; background: transparent; border: 1px solid transparent;
  transition: background .18s, color .18s, transform .15s;
}
.tab-bar button[aria-current] { border-color: #81a9924f; background: linear-gradient(#314d3d, #263b30); color: #dbf5e5; }
.nav-count { color: #b3dbc5; font-size: .79em; margin-left: 3px; font-variant-numeric: tabular-nums; }

body[data-screen="chat"] .shell {
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  height: var(--visible-height, 100dvh); min-height: 0; overflow: hidden;
}
body[data-screen="chat"] .main { min-height: 0; padding: 0; }
body[data-screen="chat"] .tab-bar { position: relative; left: auto; bottom: auto; transform: none; align-self: end; justify-self: center; margin: 8px 0 max(9px, env(safe-area-inset-bottom)); }
#chat-view { display: grid; grid-template-rows: minmax(0, 1fr) auto; height: 100%; min-height: 0; }
.chat-heading { min-width: 0; }
.chat-heading h1 { font-size: 1.11rem; letter-spacing: -.014em; }
.chat-heading .lead { margin-top: 3px; font-size: .74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body[data-screen="chat"] .brand .identity-mark { --mark-size: 34px; }
.chat-list {
  display: flex; flex-direction: column; gap: 22px; min-height: 0; overflow-y: auto;
  padding: 17px var(--side) 18px; overscroll-behavior-y: contain; scrollbar-width: thin; scrollbar-color: #354e3f transparent;
}
.exchange { display: flex; flex-direction: column; gap: 9px; flex: 0 0 auto; }
.exchange:first-child { margin-top: auto; }
.reply-group { display: grid; gap: 5px; max-width: 90%; }
.reply-byline { display: flex; align-items: center; gap: 7px; color: #aab8b0; font-size: .72rem; font-weight: 650; padding-left: 2px; }
.reply-byline .identity-mark { --mark-size: 19px; border-radius: 28%; box-shadow: none; }
.message {
  min-width: 0; max-width: 100%; width: fit-content; padding: 10px 13px 11px; line-height: 1.62;
  border: 1px solid #687c6f50; border-radius: 17px 17px 17px 5px; color: var(--ink);
  background: linear-gradient(145deg,#252f2a,#1e2722);
  box-shadow: inset 0 1px 0 #fffffb0d, 0 4px 11px #00000019;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.message.sender { align-self: end; max-width: 88%; background: linear-gradient(135deg,#335748,#294437); color: #eff9f3; border-color: #6f9f897b; border-radius: 17px 17px 5px 17px; }
.message-time { color: #9aada2; text-align: right; font-size: .71rem; margin: -4px 2px 1px 0; font-variant-numeric: tabular-nums; }
.message.status { font-size: .85rem; color: #bacbc0; }
.message.status[data-status="failed"] { color: #ffb9b9; }
.chat-empty {
  display: grid; justify-items: center; align-content: center; align-self: stretch; flex: 1; min-height: 134px; text-align: center; margin: auto 0;
}
.chat-empty .identity-mark { --mark-size: 54px; }
.chat-empty p { margin-top: 13px; color: #d9e7de; font-size: .98rem; font-weight: 630; }
.chat-empty .text-action { margin-top: 1px; color: #a6c6b1; font-size: .88rem; }
.compose {
  display: flex; align-items: end; gap: 8px;
  padding: 5px 6px 5px 9px; margin: 0 var(--side);
  background: linear-gradient(#202a24,#1b241f); border: 1px solid #6f8b785f; border-radius: 20px;
  box-shadow: inset 0 1px 0 #ffffff1b, 0 8px 21px #00000025;
}
.compose:focus-within { border-color: #98c0a6; }
input, textarea {
  width: 100%; min-width: 0; padding: 10px 12px; font-size: 16px; color: var(--ink);
  background: #141c17; border: 1px solid #47594e; border-radius: 12px;
}
textarea::placeholder, input::placeholder { color: #a0b0a5; opacity: 1; }
.compose textarea {
  min-height: 44px; max-height: min(110px, 29vh); resize: none; padding: 9px 4px 9px 5px; line-height: 25px;
  border: 0; background: transparent; outline: none;
}
.compose textarea:focus-visible { outline: none; }
.send { flex: 0 0 44px; width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 15px; }

.login {
  position: relative; overflow: hidden; max-width: 430px; margin: clamp(22px, 8dvh, 71px) auto;
  padding: clamp(21px, 6vw, 32px); background: radial-gradient(ellipse 230px 155px at 22% 0, #2d4538 0, transparent 100%), #1a231e;
  border: 1px solid #60776880; border-radius: 25px;
  box-shadow: inset 0 1px 0 #ffffff14, 0 20px 46px #080d0aaa;
}
.auth-emblem { margin-bottom: 20px; }
.auth-emblem .identity-mark { --mark-size: 55px; }
.login h1 { font-size: clamp(1.58rem, 7vw, 2.15rem); }
.login form { display: grid; gap: 7px; margin-top: 22px; }
.login label { align-self: end; color: #e1e9e3; font-size: .87rem; }
.login input { min-height: 47px; margin-bottom: 5px; }
.login button { margin-top: 6px; }
.error { color: #ffb8b8; font-size: .88rem; }
.error:empty { display: none; }

.sheet {
  width: min(calc(100% - 28px), 440px); max-height: min(76dvh, 650px); padding: 17px;
  color: var(--ink); background: #1a251e; border: 1px solid #566e5d; border-radius: 22px; box-shadow: 0 22px 70px #0009;
}
.sheet::backdrop { background: #070d0ac7; -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.sheet-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sheet-title h2 { font-size: 1.3rem; font-weight: 740; }
.sheet .lead { margin-bottom: 17px; }
.sheet.drawer {
  margin: 0 auto 0 max(0px, calc((100vw - 720px) / 2)); width: min(87vw, 350px); max-width: 350px; max-height: none;
  height: var(--visible-height, 100dvh); padding: calc(17px + env(safe-area-inset-top)) 16px calc(15px + env(safe-area-inset-bottom));
  border: 0; border-right: 1px solid #72877778; border-radius: 0 25px 25px 0;
  background: radial-gradient(ellipse 250px 200px at 0 0,#2b4133,transparent 96%), #17211b;
}
.sheet.drawer[open] { display: flex; flex-direction: column; animation: drawer-open .22s cubic-bezier(.2,.74,.23,1); }
@keyframes drawer-open { from { transform: translateX(-14px); opacity: .65; } to { transform: translateX(0); opacity: 1; } }
.drawer-nav { display: flex; gap: 8px; margin: 17px 0 18px; }
.drawer-nav button {
  flex: 1; display: flex; justify-content: center; align-items: center; gap: 7px; min-height: 45px; padding: 7px 6px;
  white-space: nowrap; color: #dce8df; background: #233429; border: 1px solid #4b6656; border-radius: 12px; font-size: .83rem;
}
.drawer-search {
  display: flex; align-items: center; gap: 8px; padding: 0 11px; color: #a8bdb0; flex-shrink: 0;
  background: #121c16; border: 1px solid #435a4b; border-radius: 13px;
}
.drawer-search:focus-within { border-color: #99c3ab; }
.drawer-search input { min-height: 44px; padding: 8px 3px; border: 0; background: transparent; border-radius: 0; }
.drawer-search input:focus-visible { outline: none; }
.quick-spaces { display: grid; align-content: start; gap: 8px; margin-top: 14px; padding-bottom: 12px; min-height: 0; overflow-y: auto; }
.quick-spaces .lead { margin: 10px 3px; }
.drawer-space {
  display: flex; align-items: center; gap: 10px; min-height: 61px; width: 100%; text-align: left; padding: 8px;
  color: var(--ink); background: #202e25; border: 1px solid #3b5144; border-radius: 14px; flex-shrink: 0;
}
.drawer-space .space-symbol { width: 34px; height: 34px; border-radius: 12px; font-size: .95rem; background: var(--tint, #233c30); }
.drawer-space .card-title { font-size: .94rem; }
.drawer-space .card-description { font-size: .74rem; margin-top: 2px; -webkit-line-clamp: 1; }
.drawer-space .forward-icon { color: #c3dbc9; }
.drawer-space[aria-current], .drawer-space:hover { background: #304637; border-color: #8bb09a; }
.drawer-create { width: 100%; margin-top: auto; }
.quick-spaces + .drawer-create { flex-shrink: 0; }
.toast {
  position: fixed; z-index: 4; max-width: calc(100vw - 36px); left: 50%; transform: translateX(-50%);
  bottom: calc(var(--dock-height) + 15px + env(safe-area-inset-bottom)); padding: 10px 14px;
  background: #294433; color: #edfff2; border: 1px solid #7b9f88; border-radius: 11px; font-size: .86rem;
  box-shadow: 0 6px 20px #0007;
}
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 350px) { .space-card { gap: 10px; padding: 12px; } .card-meta { margin-top: 8px; } .reply-group { max-width: 96%; } }
@media (max-height: 470px) {
  .app-header { min-height: 50px; padding-block: 4px; }
  body[data-screen="chat"] .tab-bar { margin-block: 4px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
