:root {
  color-scheme: light;
  --canvas: #f7f8f4;
  --paper: #fff;
  --ink: #182821;
  --muted: #52655c;
  --faint: #66786e;
  --border: #dce4db;
  --forest: #162924;
  --forest-light: #233b32;
  --green: #244c37;
  --lime: #cae89e;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-size: 14px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, textarea, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
:focus-visible { outline: 2px solid #639649; outline-offset: 3px; }
svg { display: block; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.icon { width: 19px; height: 19px; flex: 0 0 auto; }
.icon-library { width: 0; height: 0; position: absolute; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.workspace { display: grid; grid-template-columns: 266px minmax(0, 1fr); height: 100vh; height: 100dvh; overflow: hidden; }
.sidebar { background: var(--forest); color: #f3f7ee; min-height: 0; display: flex; flex-direction: column; padding: 29px 19px 15px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 5px; margin-bottom: 31px; }
.brand-mark { display: grid; flex: 0 0 auto; width: 41px; height: 41px; place-items: center; color: #19372a; background: var(--lime); border-radius: 13px; }
.brand-mark svg { width: 25px; height: 25px; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 16px; font-weight: 720; letter-spacing: .01em; }
.brand span { color: #afc3b8; font-size: 11px; margin-top: 3px; letter-spacing: .12em; }
.new-project { display: flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid #526c5c; background: #20382e; color: #f3f7ee; border-radius: 10px; padding: 11px; font-weight: 640; }
.new-project:hover { background: #304d3c; border-color: #718f78; }
.new-project .icon { color: var(--lime); }
.projects-block { margin: 28px 0 24px; display: flex; flex-direction: column; min-height: 75px; overflow: hidden; }
.section-label { font-size: 11px; font-weight: 650; color: #afc3b8; letter-spacing: .12em; margin: 0 8px 11px; }
.projects { display: grid; gap: 5px; overflow-y: auto; }
.project-tab, .tool-link { display: flex; align-items: center; gap: 9px; min-height: 42px; padding: 0 9px; border: 1px solid transparent; border-radius: 8px; background: transparent; text-align: left; color: #e3ece4; text-decoration: none; }
.project-tab[aria-selected="true"] { background: #30493b; border-color: #3e5849; color: #f8fbf4; }
.project-tab[aria-selected="true"] > .icon { color: var(--lime); }
.project-tab:hover, .tool-link:hover { background: #284234; }
.project-tab strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; font-weight: 620; }
.project-tab .count { padding: 2px 6px; font-size: 11px; color: #e0f3cd; background: #4b654c; border-radius: 6px; }
.tool-link { min-height: 35px; font-size: 12px; color: #cbd9d0; }
.tool-link .icon { width: 15px; height: 15px; color: #adc4b4; }
.tool-link span { flex: 1; }
.sidebar-footer { margin-top: auto; padding: 15px 4px 0 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid #344a3f; }
.storage-info { display: flex; align-items: center; gap: 8px; font-size: 11px; color: #c4d4ca; white-space: nowrap; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #84ad63; flex-shrink: 0; }
.dot.offline { background: #e5ab75; }
.fade { color: #afc3b8; padding: 4px 8px; font-size: 12px; }
.icon-button { display: inline-grid; flex: 0 0 auto; place-items: center; width: 36px; height: 36px; border-radius: 8px; border: 0; background: transparent; color: inherit; }
.icon-button:hover:enabled { background: #dce9de80; }
.icon-button:disabled { opacity: .45; }
.sidebar .icon-button { color: #c4d4ca; }
.sidebar .icon-button:hover { background: #365042; }
.sidebar-backdrop, .menu { display: none; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { min-height: 66px; flex-shrink: 0; background: #fbfcf9; border-bottom: 1px solid #e3e8e0; padding: 0 29px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.breadcrumb, .top-actions { display: flex; align-items: center; gap: 12px; }
.breadcrumb { color: var(--faint); min-width: 0; font-size: 13px; }
.breadcrumb > span:first-child { flex-shrink: 0; }
.breadcrumb strong { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb-line { width: 11px; height: 1px; background: #a1b1a5; transform: rotate(-62deg); flex-shrink: 0; }
.mode { display: flex; align-items: center; gap: 7px; border: 1px solid #dce9d8; background: #eef5e9; color: #395640; padding: 6px 10px; border-radius: 7px; font-size: 11px; white-space: nowrap; }
.rename { color: var(--muted); }
.connection-banner { background: #fff2dc; padding: 9px 20px; color: #724e23; text-align: center; font-size: 13px; }

.conversation { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: auto; }
.conversation:focus { outline-offset: -3px; }
.empty { width: min(100% - 40px, 755px); margin: auto; padding: 35px 0 25px; text-align: center; }
.hero-mark { position: relative; display: grid; place-items: center; width: 71px; height: 71px; margin: 0 auto 20px; border: 1px solid #cbdcc3; background: #e4f0db; color: #305943; border-radius: 21px; box-shadow: 0 5px 0 #d9e8d1; }
.hero-mark svg { width: 38px; height: 38px; stroke-width: 1.45; }
.hero-mark span { position: absolute; right: -6px; top: -6px; width: 17px; height: 17px; background: #cbe98e; border: 3px solid var(--canvas); border-radius: 6px; transform: rotate(12deg); }
h1, h2, p { margin-top: 0; }
.empty h1 { font-size: clamp(27px, 4vw, 40px); font-weight: 760; letter-spacing: -.035em; margin-bottom: 10px; }
.empty > p { color: var(--muted); line-height: 1.7; margin: 0 auto 27px; font-size: 14px; }
.starters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; max-width: 680px; margin: 0 auto; text-align: left; }
.starter { display: grid; min-height: 112px; justify-items: start; align-content: center; text-align: left; padding: 12px 14px; border: 1px solid #dbe4d9; border-radius: 12px; background: #fcfdfa; color: var(--ink); }
.starter:hover { background: #eef4e9; border-color: #a5bfa6; }
.starter-icon { display: grid; place-items: center; width: 30px; height: 30px; margin-bottom: 8px; color: #3d674b; background: #eaf1e5; border-radius: 8px; }
.starter-icon .icon { width: 17px; height: 17px; }
.starter strong { margin-bottom: 3px; font-size: 13px; }
.starter > span:last-child { color: var(--muted); font-size: 11px; line-height: 1.5; }
.messages { width: min(100% - 46px, 820px); margin: 0 auto; }
.messages:not(:empty) { padding: 25px 0 12px; }
.exchange { display: grid; gap: 15px; margin-bottom: 26px; }
.user-message { width: fit-content; max-width: min(87%, 650px); justify-self: end; border: 1px solid #dde8d9; background: #eaf2e5; border-radius: 16px 16px 4px 16px; padding: 12px 15px; overflow-wrap: anywhere; }
.message-text { margin: 0; white-space: pre-wrap; line-height: 1.75; overflow-wrap: anywhere; }
.message-time { display: block; margin-top: 7px; color: var(--muted); font-size: 11px; }
.lines { line-height: 1.75; overflow-wrap: anywhere; }
.lines h3 { font-size: 17px; margin: 14px 0 6px; }
.lines p, .lines ul, .lines ol { margin: 0 0 9px; }
.lines > :last-child { margin-bottom: 0; }
.lines li { padding-left: 2px; }
.lines a { color: #285b3e; }
.lines pre { overflow: auto; padding: 12px; border-radius: 8px; background: #f0f4ef; white-space: pre; }
.lines code { font-family: ui-monospace, monospace; font-size: .92em; }
.msg-images { display: flex; flex-wrap: wrap; gap: 8px; margin-block: 4px; }
.msg-images img { display: block; width: auto; max-width: min(175px, 100%); height: auto; max-height: 155px; object-fit: contain; border-radius: 8px; }
.reply { display: grid; grid-template-columns: 32px minmax(0,1fr); gap: 10px; max-width: 100%; }
.reply .brand-mark { width: 32px; height: 32px; border-radius: 9px; }
.reply .brand-mark svg { width: 19px; height: 19px; }
.reply-images { margin-top: 10px; }
.reply-images a { display: block; max-width: 100%; }
.reply-images img { max-width: min(300px, 100%); max-height: 240px; }
.reply-card { border: 1px solid var(--border); background: var(--paper); border-radius: 4px 14px 14px 14px; padding: 11px 14px; min-width: 0; }
.reply-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.reply-head strong { font-size: 12px; }
.copy-reply { float: right; width: 28px; height: 25px; margin: -2px -4px 3px 8px; color: var(--muted); }
.copy-reply .icon { width: 15px; height: 15px; }
.reply-card.pending, .reply-card.processing, .reply-card.failed { width: fit-content; max-width: 100%; color: var(--muted); }
.reply-card.failed { background: #fff6ed; color: #804226; border-color: #f1d4bc; }
.reply-card.pending .reply-head, .reply-card.processing .reply-head { margin: 0; }
.typing-indicator { display: inline-flex; align-items: center; gap: 4px; color: #52765a; }
.typing-indicator span { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: typing-bounce 1s ease-in-out infinite; }
.typing-indicator span:nth-child(2) { animation-delay: .13s; }
.typing-indicator span:nth-child(3) { animation-delay: .26s; }
@keyframes typing-bounce {
  0%, 65%, 100% { transform: translateY(0); opacity: .45; }
  32% { transform: translateY(-3px); opacity: 1; }
}
.file-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.file-link { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border); padding: 5px 8px; border-radius: 7px; color: var(--green); font-size: 12px; text-decoration: none; overflow-wrap: anywhere; }
.file-link:hover { background: #eaf1e8; }

.compose-area { flex-shrink: 0; width: min(100% - 46px, 820px); margin: 0 auto; padding-top: 10px; background: var(--canvas); }
.composer { border: 1px solid #d6e0d6; border-radius: 16px; box-shadow: 0 4px 18px #1c382210; background: var(--paper); padding: 12px 12px 9px; }
.composer:focus-within { border-color: #9bb39d; }
.composer textarea { display: block; width: 100%; min-height: 56px; max-height: min(29vh, 190px); resize: vertical; padding: 2px 5px; background: transparent; outline: none; border: 0; color: var(--ink); line-height: 1.65; }
textarea::placeholder { color: #64746a; }
.composer-bar, .composer-tools { display: flex; align-items: center; gap: 10px; }
.composer-bar { justify-content: space-between; }
.composer-tools { min-width: 0; }
.add-image { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 5px; padding: 6px 7px; color: #395746; border: 0; border-radius: 6px; background: transparent; font-size: 12px; }
.add-image:hover { background: #edf3eb; }
.add-image .icon { width: 17px; height: 17px; }
.compose-hint { color: var(--faint); font-size: 11px; }
.send { display: inline-flex; flex: 0 0 auto; gap: 5px; align-items: center; border: 0; border-radius: 9px; background: var(--green); color: #fff; padding: 9px 12px; font-size: 12px; font-weight: 670; }
.send:disabled { color: #e0e9de; background: #667a6b; }
.send:hover:enabled, .primary:hover:enabled { background: #366449; }
.send .icon { width: 16px; height: 16px; }
.compose-meta { text-align: center; min-height: 35px; padding: 8px 0 10px; color: var(--faint); font-size: 11px; }
.compose-meta .error { margin: 0; }
.previews { display: flex; gap: 10px; overflow: auto; padding: 2px 2px 11px; }
.preview { position: relative; flex: 0 0 66px; height: 59px; border-radius: 8px; background: #eef2ec; border: 1px solid var(--border); }
.preview-file { flex-basis: 155px; display: flex; align-items: center; padding: 8px 27px 8px 8px; }
.preview-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.preview img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.preview button { position: absolute; top: 2px; right: 2px; border: 0; border-radius: 5px; background: #13241de6; color: white; padding: 2px; }
.preview button .icon { width: 14px; height: 14px; }

.loading, .login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.loading { color: var(--muted); }
.login { background: radial-gradient(ellipse at 22% 15%, #3f6652, var(--forest) 63%); }
.login-card { width: min(100%, 425px); background: #fafcf7; border: 1px solid #d5e0d1; padding: 32px; border-radius: 21px; box-shadow: 0 20px 65px #0a1f16a0; }
.login-card .brand-mark { margin-bottom: 20px; }
.login-kicker { color: #49634e; font-size: 11px; letter-spacing: .12em; font-weight: 660; }
.login-card h1 { font-size: 29px; margin: 6px 0 7px; letter-spacing: -.04em; }
.login-card > p { color: var(--muted); line-height: 1.6; margin-bottom: 24px; }
.login-field + .login-field { margin-top: 13px; }
form label:not(.sr-only) { display: block; margin-bottom: 7px; font-weight: 660; font-size: 13px; }
form input:not([type="file"]) { width: 100%; padding: 10px 11px; border: 1px solid #cad8ca; border-radius: 8px; color: var(--ink); background: #fff; }
.primary, .secondary { display: inline-flex; justify-content: center; align-items: center; gap: 7px; border: 1px solid transparent; border-radius: 8px; padding: 10px 13px; font-weight: 660; }
.primary { background: var(--green); color: #fff; }
.primary:disabled { opacity: .65; }
.secondary { background: #f1f4ef; color: #334b3d; border-color: var(--border); }
.secondary:hover { background: #e8efe6; }
.login-card .primary { width: 100%; margin-top: 15px; }
.back-to-workspace { width: 100%; margin-top: 9px; }
.error { color: #993a26; font-size: 12px; margin: 7px 0 0; }
dialog { width: min(410px, calc(100% - 30px)); border: 1px solid var(--border); background: #fbfcf9; border-radius: 16px; padding: 21px; color: var(--ink); box-shadow: 0 15px 55px #15271f50; }
dialog::backdrop { background: #17282085; }
.dialog-header, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dialog-header { margin-bottom: 15px; }
.dialog-header h2 { margin: 0; font-size: 19px; }
.dialog-actions { justify-content: flex-end; margin-top: 17px; }

@media (max-width: 740px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; z-index: 5; width: min(275px, 86vw); transform: translateX(-100%); visibility: hidden; }
  .sidebar.open { transform: translateX(0); visibility: visible; }
  .sidebar-backdrop { display: block; z-index: 4; position: fixed; inset: 0; border: 0; background: #11261b85; }
  .menu { display: inline-grid; color: var(--green); margin-left: -6px; }
  .topbar { min-height: 57px; padding: 0 12px; gap: 7px; }
  .breadcrumb { margin-right: auto; gap: 6px; }
  .top-actions { gap: 4px; }
  .mode { padding: 5px 7px; }
  .messages, .compose-area { width: calc(100% - 23px); }
  .empty { width: calc(100% - 25px); }
}

@media (max-width: 440px) {
  .starter { padding: 8px; min-height: 102px; }
  .starters { gap: 5px; }
  .compose-hint { display: none; }
  .empty { padding-top: 22px; }
  .hero-mark { width: 55px; height: 55px; border-radius: 16px; margin-bottom: 17px; }
  .hero-mark svg { width: 31px; height: 31px; }
  .empty > p { font-size: 13px; margin-bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
}

#local-cases:not([hidden]) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}

#local-cases strong { grid-column: 1 / -1; }
#local-cases a { text-align: center; text-decoration: none; }

.reply-preview { padding: 0; border: 0; background: transparent; max-width: 100%; cursor: zoom-in; }
#image-dialog { width: min(1060px, calc(100% - 24px)); padding: clamp(10px, 2vw, 20px); }
#image-dialog::backdrop { background: #111a17c9; }
.image-dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.image-dialog-header h2 { margin: 0; font-size: 1rem; overflow-wrap: anywhere; }
.image-dialog-stage { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 6px; margin-block: 10px; }
#large-image { grid-column: 2; display: block; width: 100%; height: auto; max-height: 72dvh; object-fit: contain; }
#previous-image { grid-column: 1; }
#next-image { grid-column: 3; }
#previous-image, #next-image { font-size: 26px; }
#image-position { text-align: center; color: var(--muted); }
