:root {
  color-scheme: light;
  --bg: #e8ecf4;
  --panel: #ffffff;
  --panel-soft: #f6f8fc;
  --hover: #dfe7f5;
  --line: #c8d2e3;
  --ink: #0f172a;
  --muted: #475569;
  --accent: #f0a31e;
  --blue: #3563e9;
  --success: #20b96b;
  font-family: Inter, "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

.app-shell {
  height: 100vh;
  min-width: 980px;
  display: grid;
  grid-template-columns: 128px 240px minmax(0, 1fr);
  background: var(--bg);
}

.sidenav {
  background: rgba(255, 255, 255, 0.8);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 14px 8px 10px;
}

.brand-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 0 0 10px;
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.hermes-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.brand-block strong {
  max-width: 104px;
  font-size: 13px;
  line-height: 1.2;
}

.brand-block span {
  color: var(--muted);
  font-size: 11px;
}

.mini-button {
  min-height: 24px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: #dbe4f5;
  color: #1f2d43;
  font-weight: 700;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 10px;
}

.nav-item {
  width: 100%;
  min-height: 36px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #26364f;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  font-size: 13px;
  text-align: left;
}

.nav-item span {
  width: 14px;
  color: #34445e;
}

.nav-item:hover,
.nav-item.active {
  background: #d7e3ff;
  color: #255cf2;
}

.session-pane {
  min-height: 0;
  max-height: 100vh;
  border-right: 1px solid var(--line);
  background: rgba(232, 236, 244, 0.86);
  display: flex;
  flex-direction: column;
  padding-top: 10px;
  overflow: hidden;
}

.new-chat {
  align-self: flex-start;
  margin: 0 10px 10px;
  min-height: 32px;
  border: 0;
  border-radius: 10px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.session-search {
  margin: 0 10px 8px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 0 12px;
  font-size: 13px;
  outline: none;
}

.session-search:focus {
  border-color: var(--accent);
}

.session-pane.guest .new-chat,
.session-pane.guest .session-search {
  display: none;
}

.session-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding-bottom: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(71, 85, 105, 0.42) transparent;
}

.session-list::-webkit-scrollbar {
  width: 6px;
}

.session-list::-webkit-scrollbar-track {
  background: transparent;
}

.session-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(71, 85, 105, 0.38);
}

.session-item {
  position: relative;
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) 30px;
  gap: 6px;
  border: 0;
  border-left: 4px solid transparent;
  background: transparent;
  color: var(--ink);
  padding: 0 8px 0 0;
  text-align: left;
}

.session-open {
  min-width: 0;
  display: grid;
  gap: 3px;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 9px 0 9px 10px;
  text-align: left;
}

.session-open strong,
.session-open span,
.session-open small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-open strong {
  font-size: 13px;
}

.session-open span {
  color: #526173;
  font-size: 12px;
}

.session-open small {
  color: #64748b;
  font-size: 11px;
}

.session-item:hover {
  background: #dce5f5;
}

.session-item.active {
  background: #c8d8f8;
  border-left-color: var(--accent);
}

.session-more {
  grid-column: 2;
  align-self: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: #dbe4f5;
  color: #4b5b73;
}

.session-empty {
  padding: 14px 12px;
  color: var(--muted);
  font-size: 13px;
}

.main-pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.titlebar {
  height: 52px;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.titlebar h1 {
  margin: 0;
  font-size: 18px;
  text-align: center;
}

.connection,
.title-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #334155;
  font-size: 13px;
}

.title-actions {
  justify-content: flex-end;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #94a3b8;
}

.dot.online {
  background: var(--success);
}

.dot.offline,
.danger-dot {
  background: #ef4444;
}

.danger-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.seg {
  min-height: 34px;
  min-width: 72px;
  border: 0;
  background: #b8c0ce;
  color: #334155;
  font-weight: 800;
}

.seg.active {
  border-radius: 8px;
  background: #f0a31e;
  color: #fff;
}

.chat-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat-header {
  flex-shrink: 0;
  padding: 10px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.comm-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  padding: 0 12px;
  color: #1f2d43;
  font-size: 13px;
}

.chat-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.chat-title-row h2 {
  margin: 0;
  font-size: 20px;
}

.tag {
  border-radius: 8px;
  background: #cbdcff;
  color: var(--accent);
  padding: 4px 12px;
  font-size: 13px;
}

.ghost {
  border: 0;
  background: transparent;
  color: #334155;
  min-height: 32px;
  padding: 0 8px;
}

.chat-meta {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 8px;
  color: #334155;
  font-size: 12px;
}

.messages {
  flex: 1;
  overflow: auto;
  padding: 14px 18px 18px;
}

.message {
  display: grid;
  grid-template-columns: 34px minmax(0, 680px);
  gap: 10px;
  margin-bottom: 12px;
}

.message.user {
  grid-template-columns: minmax(0, 680px) 34px;
  justify-content: end;
}

.message img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
}

.message.user img {
  grid-column: 2;
  display: none;
}

.message-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  padding: 12px 16px;
  line-height: 1.62;
  font-size: 14px;
}

.message.user .message-card {
  grid-column: 1;
  background: #fef7e7;
  border-color: #f3c779;
}

.message-card strong {
  display: block;
  margin-bottom: 6px;
  color: #43536b;
}

.message-card p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-card small {
  display: block;
  margin-top: 12px;
  color: #64748b;
}

.composer {
  flex-shrink: 0;
  margin: 8px 12px 12px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: #fff;
  padding: 8px 12px;
}

.composer textarea {
  width: 100%;
  min-height: 56px;
  max-height: 120px;
  border: 0;
  outline: 0;
  resize: vertical;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
}

.attachment-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  max-width: 260px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f6f8fc;
  color: #26364f;
  padding: 0 8px 0 10px;
  font-size: 12px;
}

.attachment-chip img {
  width: 32px;
  height: 24px;
  border-radius: 6px;
  object-fit: cover;
  background: #e2e8f0;
}

.attachment-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-chip small {
  color: var(--muted);
}

.attachment-chip button {
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: #dbe4f5;
  color: #42536c;
  line-height: 1;
}

.composer-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.icon-btn,
.pill,
.pill-select {
  min-height: 30px;
  border: 0;
  border-radius: 999px;
  background: #dbe4f5;
  color: #0f2748;
  padding: 0 10px;
  font-size: 12px;
}

.pill.active {
  font-weight: 700;
}

.pill em {
  color: var(--accent);
  font-style: normal;
}

.tool-sep {
  width: 1px;
  height: 24px;
  background: var(--line);
  margin: 0 4px;
}

.send {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  margin-left: auto;
}

.send:disabled {
  opacity: 0.58;
  cursor: wait;
}

.empty-panel {
  flex: 1;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 20px;
}

.empty-panel.task-mode {
  display: block;
  padding: 26px 34px;
  overflow: auto;
}

.empty-panel > div {
  width: min(430px, 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 22px 24px;
  box-shadow: 0 10px 24px rgba(20, 32, 48, 0.08);
}

.empty-panel.task-mode > div {
  width: 100%;
  max-width: none;
}

.empty-panel h2 {
  margin: 0 0 10px;
  font-size: 22px;
}

.empty-panel p {
  color: var(--muted);
  line-height: 1.62;
  font-size: 14px;
}

.primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  padding: 0 14px;
  font-weight: 800;
  font-size: 14px;
}

@media (min-width: 921px) {
  .app-shell {
    grid-template-columns: 112px 210px minmax(0, 1fr);
  }

  .sidenav {
    padding: 10px 6px 8px;
  }

  .brand-block {
    gap: 4px;
    padding-bottom: 8px;
  }

  .hermes-avatar {
    width: 34px;
    height: 34px;
  }

  .brand-block strong {
    max-width: 92px;
    font-size: 12px;
  }

  .brand-block span {
    font-size: 10px;
  }

  .mini-button {
    min-height: 22px;
    padding: 0 12px;
  }

  .nav-list {
    gap: 3px;
    padding-top: 8px;
  }

  .nav-item {
    min-height: 32px;
    border-radius: 8px;
    gap: 8px;
    padding: 0 9px;
    font-size: 12px;
  }

  .session-pane {
    padding-top: 8px;
  }

  .new-chat {
    margin: 0 8px 8px;
    min-height: 30px;
    padding: 0 12px;
  }

  .session-search {
    margin: 0 8px 8px;
    height: 32px;
    font-size: 12px;
  }

  .titlebar {
    height: 44px;
    gap: 10px;
    padding: 0 12px;
  }

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

  .connection,
  .title-actions {
    gap: 8px;
    font-size: 12px;
  }

  .seg {
    min-height: 30px;
    min-width: 64px;
  }

  .chat-header {
    padding: 8px 16px 10px;
  }

  .comm-bar {
    min-height: 32px;
    gap: 7px;
    font-size: 12px;
  }

  .chat-title-row {
    gap: 8px;
    margin-top: 8px;
  }

  .chat-title-row h2 {
    font-size: 18px;
  }

  .tag {
    padding: 3px 10px;
    font-size: 12px;
  }

  .ghost {
    min-height: 28px;
    padding: 0 6px;
  }

  .chat-meta {
    gap: 12px;
    margin-top: 6px;
  }

  .messages {
    padding: 12px 16px 14px;
  }

  .message {
    grid-template-columns: 30px minmax(0, 640px);
    gap: 8px;
    margin-bottom: 10px;
  }

  .message.user {
    grid-template-columns: minmax(0, 640px) 30px;
  }

  .message img {
    width: 26px;
    height: 26px;
  }

  .message-card {
    border-radius: 8px;
    padding: 10px 14px;
    line-height: 1.55;
    font-size: 13px;
  }

  .message-card strong {
    margin-bottom: 4px;
  }

  .composer {
    margin: 6px 10px 10px;
    border-radius: 10px;
    padding: 6px 10px;
  }

  .composer textarea {
    min-height: 40px;
    max-height: 92px;
    font-size: 12px;
  }

  .composer-tools {
    gap: 5px;
    padding-top: 6px;
  }

  .icon-btn,
  .pill,
  .pill-select {
    min-height: 28px;
    padding: 0 9px;
    font-size: 11px;
  }

  .send {
    width: 34px;
    height: 34px;
    font-size: 16px;
  }

  .empty-panel {
    padding: 18px;
  }

  .empty-panel.task-mode {
    padding: 18px;
  }

  .empty-panel > div {
    width: min(390px, 100%);
    border-radius: 8px;
    padding: 18px 20px;
    box-shadow: 0 8px 18px rgba(20, 32, 48, 0.06);
  }

  .empty-panel h2 {
    margin-bottom: 8px;
    font-size: 18px;
  }

  .empty-panel p {
    line-height: 1.55;
    font-size: 13px;
  }

  .empty-panel.task-mode > div {
    width: 100%;
  }

  .local-task-head {
    display: grid;
  }

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

  .local-task-list {
    grid-template-columns: 1fr;
  }
}

[hidden] {
  display: none !important;
}

.local-task-panel {
  width: 100%;
}

.workspace-panel,
.settings-panel,
.platform-panel {
  width: 100%;
}

.local-task-panel h2 {
  margin-bottom: 8px;
}

.local-task-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 16px;
}

.local-task-panel p,
.local-task-empty,
.local-task-row span,
.local-task-row small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.local-task-form {
  display: grid;
  grid-template-columns: minmax(220px, 0.35fr) minmax(420px, 1fr) auto;
  align-items: stretch;
  gap: 10px;
  margin: 18px 0;
}

.local-task-form input,
.local-task-form textarea {
  min-height: 72px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 10px 12px;
  outline: none;
}

.local-task-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.local-task-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  text-align: left;
}

.local-task-row div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.local-task-row em {
  flex: 0 0 auto;
  align-self: start;
  border-radius: 999px;
  background: #eef6ff;
  color: #0f5ea8;
  font-size: 12px;
  font-style: normal;
  padding: 4px 9px;
}

.task-download {
  display: inline-flex;
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}

.workspace-grid,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.workspace-grid article,
.settings-grid article {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  padding: 14px;
}

.workspace-grid strong,
.settings-grid strong {
  display: block;
  margin-bottom: 6px;
}

.workspace-grid span,
.settings-grid span {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.workspace-grid p,
.settings-grid p {
  margin: 8px 0 0;
}

.workspace-field {
  display: grid;
  gap: 7px;
  max-width: 420px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
}

.workspace-field select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  font: inherit;
}

.platform-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.platform-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 12px;
}

.platform-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  padding: 14px;
}

.platform-card-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.platform-card-head strong {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
}

.platform-card-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.switch {
  flex: 0 0 auto;
  position: relative;
  display: inline-flex;
  width: 42px;
  height: 24px;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  width: 100%;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 0.15s ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.24);
  transition: transform 0.15s ease;
}

.switch input:checked + span {
  background: var(--success);
}

.switch input:checked + span::after {
  transform: translateX(18px);
}

.platform-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin: 10px 0;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.platform-status.ready {
  background: #dcfce7;
  color: #166534;
}

.platform-status.todo {
  background: #eef2ff;
  color: #304f9f;
}

.platform-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.platform-field {
  display: grid;
  gap: 5px;
  color: #334155;
  font-size: 12px;
}

.platform-field span {
  font-weight: 700;
}

.platform-field em {
  margin-left: 3px;
  color: #ef4444;
  font-style: normal;
}

.platform-field input,
.platform-field textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  font: inherit;
  font-size: 12px;
  outline: none;
}

.platform-field textarea {
  resize: vertical;
  line-height: 1.45;
}

.platform-field input:focus,
.platform-field textarea:focus {
  border-color: var(--accent);
}

.platform-field-wide {
  margin-top: 10px;
}

.platform-card-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.platform-result {
  min-height: 22px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.platform-result.ok {
  color: #15803d;
}

.platform-result.error {
  color: #dc2626;
}

.platform-events {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  padding: 14px;
}

.platform-events-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.platform-events-head span,
.platform-empty {
  color: var(--muted);
  font-size: 13px;
}

.platform-event-list {
  display: grid;
  gap: 8px;
}

.platform-event {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr) 120px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 9px 10px;
  font-size: 12px;
}

.platform-event span {
  color: #334155;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.platform-event small {
  color: var(--muted);
  text-align: right;
}

.platform-event.ok {
  border-left: 4px solid var(--success);
}

.platform-event.error {
  border-left: 4px solid #ef4444;
}

@media (max-width: 920px) {
  body {
    overflow: auto;
  }

  .app-shell {
    min-width: 0;
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
  }

  .sidenav,
  .session-pane {
    position: static;
    border-right: 0;
  }

  .sidenav {
    padding: 14px;
  }

  .nav-list {
    flex-direction: row;
    overflow: auto;
  }

  .nav-item {
    flex: 0 0 auto;
    width: auto;
  }

  .session-pane {
    max-height: 240px;
    border-bottom: 1px solid var(--line);
    overflow: hidden;
  }

  .titlebar {
    grid-template-columns: 1fr;
    height: auto;
    padding: 12px 16px;
  }

  .title-actions {
    justify-content: flex-start;
  }

  .message,
  .message.user {
    grid-template-columns: 1fr;
  }

  .message img {
    display: none;
  }
}
