:root {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #1c2430;
  background: #eef2f6;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  font-size: 16px;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgb(31 111 173 / 28%);
  outline-offset: 2px;
}

.ui-icon {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1.5px solid currentColor;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.app-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, #f7f9fb 0%, #e8edf3 100%);
}

.phone-frame {
  width: min(100%, 414px);
  height: min(860px, calc(100dvh - 48px));
  min-height: 720px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  overflow: hidden;
  border: 1px solid #d9e1ea;
  border-radius: 8px;
  background: #f8fafc;
  box-shadow: 0 24px 70px rgb(28 36 48 / 14%);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 18px 14px;
  background: #ffffff;
  border-bottom: 1px solid #e6ebf1;
}

.top-bar > div:first-child {
  min-width: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 4px;
  color: #647286;
  font-size: 12px;
  line-height: 1.3;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

h2 {
  font-size: 19px;
  line-height: 1.25;
  letter-spacing: 0;
}

h3 {
  font-size: 15px;
  line-height: 1.35;
  letter-spacing: 0;
}

.screen {
  overflow-y: auto;
  padding: 14px;
}

.view-stack {
  display: grid;
  gap: 12px;
}

.chat-workspace {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto auto;
  gap: 12px;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #285d93;
  background: #eef6ff;
}

.install-button {
  min-width: 54px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  color: #ffffff;
  background: #1f6fad;
  font-size: 13px;
  font-weight: 800;
}

.icon-button:active,
.primary-button:active,
.secondary-button:active,
.danger-button:active,
.text-button:active,
.bottom-nav button:active {
  transform: translateY(1px);
}

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

.inline-notice {
  padding: 11px 12px;
  border: 1px solid #dde6ef;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.55;
  background: #ffffff;
}

.inline-notice.ok {
  color: #146b42;
  border-color: #c9ead7;
  background: #f0faf4;
}

.inline-notice.wait {
  color: #7b4b12;
  border-color: #f3d9ac;
  background: #fff8ec;
}

.inline-notice.bad {
  color: #a51c14;
  border-color: #f0c9c5;
  background: #fffafa;
}

.pwa-status {
  padding: 10px 14px;
  border-bottom: 1px solid #e5ecf3;
  color: #4f6174;
  background: #f6f9fc;
  font-size: 13px;
  line-height: 1.55;
}

.pwa-status.ok {
  color: #146b42;
  background: #f0faf4;
}

.pwa-status.bad {
  color: #a51c14;
  background: #fff5f4;
}

.conversation-rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(148px, 68%);
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.conversation-rail::-webkit-scrollbar {
  display: none;
}

.conversation-card {
  min-height: 86px;
  display: grid;
  gap: 6px;
  align-content: center;
  text-align: left;
  padding: 12px;
  border: 1px solid #dce6f0;
  border-radius: 8px;
  color: #344358;
  background: #ffffff;
  scroll-snap-align: start;
}

.conversation-card.active {
  border-color: #94bee4;
  background: #edf6ff;
  box-shadow: inset 0 0 0 1px rgb(31 111 173 / 12%);
}

.conversation-card span {
  color: #647286;
  font-size: 12px;
  line-height: 1.2;
}

.conversation-card strong {
  font-size: 17px;
  line-height: 1.2;
}

.conversation-card small {
  color: #516277;
  font-size: 12px;
  line-height: 1.35;
}

.conversation-card.active span {
  color: #1f6fad;
  font-weight: 800;
}

.status-pill {
  min-height: 58px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid #dde6ef;
  border-radius: 8px;
  background: #ffffff;
}

.status-pill svg {
  grid-row: span 2;
}

.status-pill span {
  color: #657386;
  font-size: 12px;
}

.status-pill strong {
  font-size: 15px;
  line-height: 1.2;
}

.status-pill.info svg,
.status-pill.info strong {
  color: #2269a8;
}

.status-pill.wait svg,
.status-pill.wait strong {
  color: #a45c14;
}

.status-pill.ok svg,
.status-pill.ok strong {
  color: #207a4c;
}

.panel,
.goal-panel,
.input-panel,
.alert-panel,
.profile-panel,
.decision-panel,
.live-panel,
.support-panel,
.detail-shell,
.send-confirm-panel {
  border: 1px solid #dde6ef;
  border-radius: 8px;
  background: #ffffff;
}

.panel,
.goal-panel,
.alert-panel,
.decision-panel,
.live-panel,
.send-confirm-panel {
  padding: 14px;
}

.section-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.goal-panel {
  display: grid;
  gap: 12px;
}

.live-panel {
  display: grid;
  gap: 11px;
}

.live-copy {
  color: #354256;
  font-size: 16px;
  line-height: 1.55;
}

.live-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #647286;
  font-size: 13px;
}

.live-meta strong {
  color: #1f6fad;
  font-size: 16px;
}

.conversation-hint {
  padding: 10px;
  border-radius: 8px;
  color: #48586d;
  background: #f4f7fa;
  font-size: 14px;
  line-height: 1.55;
}

.node-strip {
  display: grid;
  gap: 4px;
  padding: 10px 11px;
  border-radius: 8px;
  color: #263449;
  background: #edf6ff;
}

.node-strip span {
  color: #587089;
  font-size: 12px;
  line-height: 1.35;
}

.node-strip strong {
  font-size: 15px;
  line-height: 1.35;
}

.metric-row {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 10px;
}

.metric-row div {
  padding: 10px;
  border-radius: 8px;
  background: #f4f7fa;
}

.metric-row span {
  display: block;
  margin-bottom: 5px;
  color: #657386;
  font-size: 12px;
}

.metric-row strong {
  font-size: 15px;
}

.progress-track,
.mini-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 8px;
  background: #e8eef5;
}

.progress-fill,
.mini-progress div {
  height: 100%;
  border-radius: inherit;
  background: #2d75b8;
}

.check-list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.check-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  color: #354256;
  font-size: 14px;
  line-height: 1.4;
}

.check-list svg {
  flex: 0 0 auto;
  color: #2d75b8;
}

.primary-button,
.secondary-button,
.danger-button,
.text-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  font-weight: 700;
  letter-spacing: 0;
}

.primary-button {
  width: 100%;
  color: #ffffff;
  background: #1f6fad;
}

.primary-button.compact {
  width: auto;
  padding: 0 14px;
}

.secondary-button {
  padding: 0 14px;
  color: #24415c;
  border: 1px solid #cdd8e4;
  background: #ffffff;
}

.danger-button {
  width: 100%;
  color: #ffffff;
  background: #b42318;
}

.text-button {
  min-height: 34px;
  padding: 0 8px;
  color: #1f6fad;
  background: #edf6ff;
}

.risk-badge,
.count-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.risk-低 {
  color: #146b42;
  background: #e8f6ee;
}

.risk-中 {
  color: #91540f;
  background: #fff2dc;
}

.risk-高,
.count-badge.warn {
  color: #a51c14;
  background: #ffe7e4;
}

.count-badge {
  color: #285d93;
  background: #eaf3ff;
}

.chat-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.chat-panel {
  min-height: 250px;
}

.bubble {
  max-width: 88%;
  padding: 11px 12px;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.55;
}

.bubble.user {
  justify-self: end;
  color: #ffffff;
  background: #1f6fad;
}

.bubble.assistant {
  justify-self: start;
  color: #263449;
  background: #eef3f8;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.chip-row button {
  min-height: 32px;
  padding: 5px 8px;
  border-radius: 8px;
  color: #24415c;
  background: #ffffff;
  font-size: 12px;
  font-weight: 700;
}

.detail-panel {
  display: grid;
  gap: 12px;
}

.detail-shell {
  overflow: hidden;
}

.detail-toggle,
.detail-collapse {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  border-radius: 8px;
  color: #24415c;
  background: #ffffff;
  font-weight: 800;
}

.detail-toggle span {
  font-size: 14px;
}

.detail-toggle strong,
.detail-collapse {
  color: #1f6fad;
  font-size: 13px;
}

.detail-collapse {
  min-height: 36px;
  justify-content: center;
  background: #edf6ff;
}

.risk-list,
.gate-list,
.ordered-steps {
  display: grid;
  gap: 8px;
}

.risk-card {
  display: grid;
  gap: 6px;
  padding: 11px;
  border: 1px solid #e2e9f1;
  border-radius: 8px;
  background: #f8fafc;
}

.risk-card p {
  color: #5f6d80;
  font-size: 14px;
  line-height: 1.55;
}

.risk-card strong {
  color: #28374b;
}

.ordered-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: steps;
}

.ordered-steps li {
  min-height: 42px;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: center;
  color: #354256;
  font-size: 14px;
  line-height: 1.45;
  counter-increment: steps;
}

.ordered-steps li::before {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  background: #1f6fad;
  content: counter(steps);
  font-size: 13px;
  font-weight: 800;
}

.gate-row {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 8px;
  align-items: center;
  min-height: 38px;
}

.gate-row p {
  color: #354256;
  font-size: 14px;
  line-height: 1.45;
}

.gate-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.gate-state.ok {
  color: #146b42;
  background: #e8f6ee;
}

.gate-state.wait {
  color: #91540f;
  background: #fff2dc;
}

.input-panel {
  display: grid;
  grid-template-columns: 1fr 48px;
  gap: 8px;
  padding: 8px;
  position: sticky;
  bottom: 0;
  z-index: 2;
  box-shadow: 0 -8px 18px rgb(248 250 252 / 80%);
}

.input-panel textarea {
  width: 100%;
  min-height: 76px;
  max-height: 118px;
  resize: none;
  padding: 11px 12px;
  border: 1px solid #d7e1eb;
  border-radius: 8px;
  color: #263449;
  background: #f7fafc;
  line-height: 1.45;
}

.input-panel button {
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  background: #1f6fad;
  min-height: 76px;
}

.send-confirm-panel {
  display: grid;
  gap: 12px;
  border-color: #cbdced;
  background: #fbfdff;
}

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

.confirm-row {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 8px;
  background: #f4f7fa;
}

.confirm-row span {
  color: #647286;
  font-size: 12px;
  font-weight: 700;
}

.confirm-row strong {
  color: #263449;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}

.support-panel {
  overflow: hidden;
}

.support-toggle {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  color: #24415c;
  background: #ffffff;
  font-weight: 800;
}

.support-toggle span {
  font-size: 14px;
}

.support-toggle strong {
  color: #1f6fad;
  font-size: 13px;
}

.support-body {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px;
}

.support-note {
  color: #647286;
  font-size: 13px;
  line-height: 1.5;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-top: 12px;
  padding: 4px;
  border-radius: 8px;
  background: #eef3f8;
}

.segmented button {
  min-height: 34px;
  border-radius: 6px;
  color: #59687a;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.segmented button.active {
  color: #1f6fad;
  background: #ffffff;
  box-shadow: 0 1px 3px rgb(28 36 48 / 10%);
}

.task-list,
.plain-list {
  display: grid;
  gap: 9px;
}

.empty-state {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid #dde6ef;
  border-radius: 8px;
  background: #ffffff;
}

.empty-state p {
  color: #647286;
  font-size: 14px;
  line-height: 1.55;
}

.task-row,
.list-row {
  border: 1px solid #dde6ef;
  border-radius: 8px;
  background: #ffffff;
}

.task-row {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.task-row-main {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px;
  align-items: start;
}

.task-row-main p,
.body-copy,
.decision-panel p,
.explain-block p,
.profile-panel span {
  color: #647286;
  font-size: 14px;
  line-height: 1.55;
}

.status-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
}

.status-dot.ok {
  background: #24945b;
}

.status-dot.wait {
  background: #cc7a1f;
}

.status-dot.info {
  background: #1f6fad;
}

.status-dot.bad {
  background: #c43b32;
}

.task-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #647286;
  font-size: 13px;
}

.task-row footer {
  display: flex;
  justify-content: space-between;
  color: #647286;
  font-size: 12px;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 12px;
}

.list-row p {
  margin-top: 4px;
  color: #647286;
  font-size: 13px;
  line-height: 1.3;
  word-break: break-word;
}

.list-row span {
  flex: 0 0 auto;
  color: #1f6fad;
  font-size: 13px;
  font-weight: 700;
}

.row-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.row-title svg {
  color: #46637e;
}

.decision-panel {
  display: grid;
  gap: 10px;
  background: #f7fafc;
}

.alert-panel {
  display: grid;
  gap: 12px;
  border-color: #f0c9c5;
  background: #fffafa;
}

.alert-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #a51c14;
  background: #ffe7e4;
}

.explain-block {
  padding: 11px;
  border-radius: 8px;
  background: #ffffff;
}

.explain-block strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.action-row {
  display: flex;
  gap: 8px;
}

.profile-panel {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px;
}

.avatar {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #1f6fad;
  background: #eaf3ff;
}

.api-config-panel {
  display: grid;
  gap: 12px;
}

.api-config-form {
  display: grid;
  gap: 10px;
}

.api-config-form label {
  display: grid;
  gap: 6px;
}

.api-config-form label span {
  color: #647286;
  font-size: 13px;
  font-weight: 700;
}

.api-config-form input,
.api-config-form textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 11px;
  border: 1px solid #d7e1eb;
  border-radius: 8px;
  color: #263449;
  background: #f7fafc;
  line-height: 1.45;
}

.api-config-form textarea {
  min-height: 76px;
  resize: vertical;
}

.bottom-nav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 8px 8px 10px;
  border-top: 1px solid #e1e7ef;
  background: #ffffff;
}

.bottom-nav button {
  min-width: 0;
  min-height: 52px;
  display: grid;
  place-items: center;
  gap: 4px;
  border-radius: 8px;
  color: #6b7788;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.bottom-nav button.active {
  color: #1f6fad;
  background: #edf6ff;
}

@media (max-width: 460px) {
  .app-shell {
    padding: 0;
    background: #f8fafc;
  }

  .phone-frame {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .screen {
    padding: 12px;
  }

  .conversation-rail {
    grid-auto-columns: minmax(142px, 72%);
  }
}

@media (max-width: 370px) {
  .top-bar {
    padding: 16px 12px 12px;
  }

  .install-button {
    min-width: 48px;
    padding-inline: 9px;
    font-size: 12px;
  }

  .status-pill {
    min-height: 64px;
    padding: 9px;
  }

  .segmented {
    grid-template-columns: repeat(3, 1fr);
  }

  .bottom-nav {
    padding-inline: 4px;
  }

  .bottom-nav button {
    font-size: 11px;
  }

  .gate-row {
    grid-template-columns: 1fr;
  }

  .conversation-rail {
    grid-auto-columns: minmax(136px, 78%);
  }
}
