:root {
  color-scheme: light;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #101827;
  --muted: #647083;
  --subtle: #8793a5;
  --line: #dde5ef;
  --line-strong: #bfccd9;
  --primary: #0f766e;
  --primary-dark: #0a5b55;
  --blue: #285bb8;
  --amber: #a35c00;
  --violet: #5b55b4;
  --danger: #b42318;
  --shadow: 0 24px 70px rgba(30, 42, 62, 0.11);
  --soft-shadow: 0 10px 28px rgba(30, 42, 62, 0.07);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  color: var(--ink);
  background:
    linear-gradient(180deg, #f8fafc 0%, #edf3f8 100%);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: 40px;
  padding: 8px 10px;
}

textarea {
  padding: 11px 12px;
  resize: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.15;
}

h2 {
  font-size: 23px;
  line-height: 1.2;
}

a {
  color: var(--blue);
}

.hidden {
  display: none !important;
}

.eyebrow {
  color: var(--primary);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.2;
  letter-spacing: 0;
  text-transform: uppercase;
}

.error {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span,
.section-head,
.hint,
#uploadSummary,
#editorMeta,
.brand p,
.status-strip span,
.context-stats span,
.file-meta,
.file-path,
.tool-card span,
.composer-meta,
.session-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.login-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(100%, 900px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.82fr);
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.login-visual {
  min-height: 420px;
  display: grid;
  place-items: center;
  padding: 30px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.13), rgba(40, 91, 184, 0.1)),
    #eef6f4;
}

.visual-window {
  width: min(100%, 460px);
  display: grid;
  gap: 14px;
  border: 1px solid rgba(121, 138, 161, 0.25);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--soft-shadow);
  padding: 18px;
}

.visual-bar,
.visual-row {
  display: flex;
  gap: 8px;
}

.visual-bar span {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--primary);
}

.visual-bar span:nth-child(2) {
  background: var(--blue);
}

.visual-bar span:nth-child(3) {
  background: var(--amber);
}

.visual-prompt,
.visual-response,
.visual-row span {
  border-radius: 10px;
  background: #edf3f9;
}

.visual-prompt {
  width: 76%;
  height: 44px;
}

.visual-response {
  justify-self: end;
  width: 62%;
  height: 72px;
  background: #e8f4f1;
}

.visual-row span {
  width: 30%;
  height: 66px;
}

.login-form {
  display: grid;
  align-content: center;
  gap: 16px;
  padding: 38px;
}

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

.login-form p:not(.error):not(.eyebrow) {
  color: var(--muted);
  line-height: 1.65;
}

.app-shell {
  height: 100dvh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr) 286px;
  gap: 12px;
  padding: 12px;
}

.sidebar,
.workbench,
.inspector,
.view,
.upload-card,
.metric,
.file-item,
.context-block {
  border: 1px solid var(--line);
}

.sidebar,
.workbench,
.inspector {
  min-width: 0;
  min-height: 0;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--soft-shadow);
}

.sidebar {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #10252b;
  color: #fff;
  font-weight: 900;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.text-btn,
.nav-btn,
.prompt-chip,
.send-btn,
.secondary-upload,
.file-actions .btn,
.file-actions a,
.context-tool {
  min-height: 36px;
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.15;
  text-decoration: none;
  white-space: nowrap;
}

.primary-btn,
.send-btn {
  background: var(--primary);
  color: #fff;
}

.primary-btn:hover,
.send-btn:hover {
  background: var(--primary-dark);
}

.secondary-btn,
.prompt-chip,
.secondary-upload,
.file-actions .btn,
.file-actions a,
.context-tool {
  background: #eef3f7;
  color: #263548;
}

.ghost-btn,
.text-btn {
  background: transparent;
  color: var(--muted);
}

.text-btn {
  min-height: 28px;
  padding: 5px 6px;
  font-size: 12px;
}

.full-btn {
  width: 100%;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-width: 0;
  background: transparent;
  color: #354258;
  text-align: left;
}

.nav-btn.active {
  background: #e8f4f1;
  color: var(--primary);
}

.nav-glyph {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(15, 118, 110, 0.12);
  color: var(--primary);
  font-weight: 900;
}

.session-section {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 850;
}

.session-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 7px;
  scrollbar-width: thin;
}

@media (min-width: 1181px) {
  .app-shell.inspector-hidden {
    grid-template-columns: 276px minmax(0, 1fr);
  }

  .app-shell.inspector-hidden .inspector {
    display: none;
  }
}

.session-item {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #f5f8fb;
  padding: 9px;
}

.session-item.active {
  border-color: rgba(15, 118, 110, 0.35);
  background: #edf8f5;
}

.session-main {
  min-width: 0;
  display: grid;
  gap: 3px;
  text-align: left;
  background: transparent;
  color: var(--ink);
  padding: 0;
}

.session-title {
  overflow: hidden;
  font-size: 13px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-delete {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: transparent;
  color: var(--subtle);
}

.status-strip {
  display: grid;
  gap: 8px;
  border-radius: 12px;
  background: #f6f8fb;
  padding: 11px;
}

.status-strip div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.status-strip strong {
  max-width: 128px;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workbench {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
}

.topbar {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 2px 2px 4px;
}

.topbar h2 {
  margin-top: 4px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.mobile-tabs {
  display: none;
}

.warning {
  border: 1px solid #e7cb82;
  border-radius: 10px;
  background: #fff7df;
  color: #724900;
  padding: 9px 11px;
  font-size: 13px;
  line-height: 1.45;
}

.workspace {
  min-height: 0;
  display: grid;
}

.view {
  min-height: 0;
  display: none;
  border-radius: 14px;
  background: var(--panel);
  overflow: hidden;
}

.view.active {
  display: flex;
}

.chat-view {
  flex-direction: column;
}

.welcome-panel {
  display: grid;
  gap: 12px;
  padding: 28px 30px 16px;
}

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

.welcome-panel p:not(.eyebrow) {
  max-width: 720px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}

.welcome-panel.compact {
  display: none;
}

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

.tool-card {
  min-height: 108px;
  display: grid;
  align-content: start;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfe;
  color: var(--ink);
  padding: 13px;
  text-align: left;
}

.tool-card:hover {
  border-color: rgba(15, 118, 110, 0.45);
  background: #f2faf7;
}

.tool-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 900;
}

.search-icon {
  background: #e8f4f1;
  color: var(--primary);
}

.file-icon {
  background: #e9effb;
  color: var(--blue);
}

.doc-icon {
  background: #fff1d8;
  color: var(--amber);
}

.plan-icon {
  background: #efedfb;
  color: var(--violet);
}

.log {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 18px 30px;
  background: linear-gradient(180deg, #fff 0%, #fafcfe 100%);
  scrollbar-width: thin;
}

.message {
  max-width: min(78%, 760px);
  position: relative;
  border-radius: 14px;
  padding: 12px 14px;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.65;
}

.message.user {
  align-self: flex-end;
  border-bottom-right-radius: 5px;
  background: var(--primary);
  color: #fff;
}

.message.assistant,
.message.system {
  align-self: flex-start;
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
  background: #fff;
}

.message.system {
  border-color: #e7cb82;
  background: #fff7df;
  color: #5c4000;
}

.message a {
  color: var(--blue);
  font-weight: 750;
}

.message h1,
.message h2,
.message h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.message p,
.message ul,
.message ol,
.message pre {
  margin: 0 0 9px;
}

.message p:last-child,
.message ul:last-child,
.message ol:last-child,
.message pre:last-child {
  margin-bottom: 0;
}

.message ul,
.message ol {
  padding-left: 20px;
}

.message code {
  border-radius: 5px;
  background: #edf2f7;
  padding: 2px 5px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.message pre {
  overflow: auto;
  border-radius: 9px;
  background: #111827;
  color: #e5e7eb;
  padding: 10px;
}

.message pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.message blockquote {
  margin: 0 0 8px;
  border-left: 3px solid var(--line-strong);
  padding-left: 10px;
  color: var(--muted);
}

.composer {
  flex: 0 0 auto;
  display: grid;
  gap: 9px;
  border-top: 1px solid var(--line);
  background: #fff;
  padding: 12px;
}

.composer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px;
}

.quick-prompts {
  display: flex;
  gap: 7px;
}

.prompt-chip {
  min-height: 30px;
  padding: 6px 10px;
  font-size: 12px;
}

.composer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px;
  gap: 8px;
  align-items: end;
}

.composer textarea {
  min-height: 48px;
  max-height: 156px;
  line-height: 1.48;
}

.send-btn {
  min-height: 48px;
}

.files-view,
.editor-view {
  flex-direction: column;
  gap: 12px;
  padding: 18px;
}

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

.panel-head h2 {
  margin-top: 4px;
}

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

.metric {
  min-height: 76px;
  display: grid;
  align-content: center;
  gap: 5px;
  border-radius: 12px;
  background: #fbfcfe;
  padding: 13px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.metric strong {
  overflow-wrap: anywhere;
  font-size: 22px;
}

.upload-card {
  display: grid;
  gap: 10px;
  border-radius: 12px;
  background: #f8fafc;
  padding: 12px;
}

.upload-drop {
  min-height: 84px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--primary);
  cursor: pointer;
  text-align: center;
}

.upload-drop.dragging {
  border-color: var(--primary);
  background: #eef9f5;
}

.upload-drop input,
.secondary-upload input {
  display: none;
}

.upload-drop strong {
  font-size: 15px;
}

.upload-drop span,
.upload-line p {
  color: var(--muted);
  font-size: 12px;
}

.upload-line {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 9px;
}

.meta-row,
.filter-bar {
  display: grid;
  gap: 9px;
}

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

.filter-bar {
  grid-template-columns: minmax(0, 1fr) 156px 156px;
}

.file-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 9px;
  scrollbar-width: thin;
}

.folder-group {
  display: grid;
  gap: 8px;
}

.folder-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #eef6f3;
  color: #21433d;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 900;
}

.file-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border-radius: 12px;
  background: #fff;
  padding: 11px;
}

.file-item.active {
  border-color: rgba(15, 118, 110, 0.55);
  background: #f2faf7;
}

.file-path {
  margin-bottom: 3px;
  color: var(--blue);
  word-break: break-word;
}

.file-name {
  font-size: 14px;
  font-weight: 850;
  line-height: 1.35;
  word-break: break-word;
}

.file-meta {
  margin-top: 4px;
}

.file-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.file-badge {
  border-radius: 999px;
  background: #eef3f7;
  color: #334155;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
}

.file-badge.text {
  background: #e8f4f1;
  color: var(--primary);
}

.file-actions,
.editor-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.editor-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 8px;
  align-items: center;
}

.editor {
  flex: 1;
  min-height: 0;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.62;
}

.inspector {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
  overflow: auto;
  scrollbar-width: thin;
}

.context-block {
  display: grid;
  gap: 10px;
  border-radius: 12px;
  background: #fbfcfe;
  padding: 12px;
}

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

.context-stats div {
  display: grid;
  gap: 3px;
  border-radius: 9px;
  background: #f2f6fa;
  padding: 9px;
}

.context-stats strong {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.tool-stack,
.recent-files {
  display: grid;
  gap: 8px;
}

.context-tool {
  width: 100%;
  text-align: left;
}

.recent-file {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 9px;
  text-align: left;
}

.recent-file strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-file span {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 246px minmax(0, 1fr);
  }

  .inspector {
    position: fixed;
    top: 12px;
    right: 12px;
    bottom: 12px;
    width: min(340px, calc(100vw - 24px));
    z-index: 20;
    transform: translateX(calc(100% + 20px));
    transition: transform 180ms ease;
  }

  .app-shell.inspector-open .inspector {
    transform: translateX(0);
  }

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

@media (max-width: 820px) {
  .app-shell {
    height: 100dvh;
    min-height: 100dvh;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 10px;
    padding: 8px;
  }

  .sidebar {
    min-height: auto;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 8px;
    border-radius: 14px;
    padding: 10px;
  }

  .sidebar .nav-list,
  .session-section,
  .status-strip {
    display: none;
  }

  .full-btn {
    width: auto;
    min-width: 96px;
  }

  .workbench {
    border-radius: 14px;
    padding: 10px;
  }

  .topbar {
    min-height: auto;
    display: grid;
    gap: 9px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    align-items: center;
  }

  .mobile-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    border-radius: 10px;
    background: #eef3f7;
    padding: 4px;
  }

  .mobile-tabs .nav-btn {
    min-height: 34px;
    justify-content: center;
    padding: 7px 6px;
  }

  .warning {
    padding: 8px 10px;
    font-size: 12px;
  }

  .welcome-panel {
    gap: 9px;
    padding: 16px 16px 10px;
  }

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

  .welcome-panel p:not(.eyebrow) {
    display: none;
  }

  .tool-grid {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .tool-card {
    min-width: 166px;
    min-height: 92px;
  }

  .log {
    padding: 12px 14px;
  }

  .message {
    max-width: 92%;
  }

  .composer-meta {
    display: grid;
    gap: 7px;
  }

  .quick-prompts {
    overflow-x: auto;
    scrollbar-width: none;
  }

  .files-view,
  .editor-view {
    padding: 12px;
  }

  .filter-bar,
  .meta-row,
  .editor-picker {
    grid-template-columns: 1fr;
  }

  .file-item {
    grid-template-columns: 1fr;
  }

  .file-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .editor-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto auto;
  }
}

@media (max-width: 520px) {
  .login-shell {
    padding: 10px;
  }

  .login-card {
    grid-template-columns: 1fr;
    border-radius: 14px;
  }

  .login-visual {
    min-height: 190px;
    padding: 18px;
  }

  .login-form {
    padding: 24px;
  }

  .login-form h1 {
    font-size: 27px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand h1 {
    font-size: 16px;
  }

  .brand p {
    display: none;
  }

  .top-actions {
    grid-template-columns: 1fr auto auto;
  }

  #logoutBtn {
    display: none;
  }

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

  .composer-row {
    grid-template-columns: minmax(0, 1fr) 64px;
  }

  .composer textarea,
  .send-btn {
    min-height: 58px;
  }

  .send-btn {
    padding: 8px;
  }

  .panel-head,
  .editor-actions {
    align-items: stretch;
  }

  .panel-head {
    flex-direction: column;
  }

  .editor-actions {
    grid-template-columns: 1fr;
  }
}
