:root {
  color-scheme: light;
  --bg: #fff8ef;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: #ffffff;
  --ink: #1d1916;
  --muted: #776d65;
  --line: rgba(42, 31, 22, 0.12);
  --brand-red: #ee174a;
  --brand-orange: #ff6a1f;
  --brand-soft: #fff0e8;
  --mint: #dff8ef;
  --blue: #e8f1ff;
  --shadow: 0 22px 70px rgba(85, 53, 23, 0.14);
  --button-shadow: 0 12px 24px rgba(238, 23, 74, 0.2);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(115deg, rgba(255, 246, 229, 0.96) 0%, rgba(255, 253, 247, 0.96) 47%, rgba(255, 241, 242, 0.96) 100%),
    #fffaf2;
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

button:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.app-shell {
  width: min(1220px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 0 34px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  min-height: 46px;
}

.brand {
  display: inline-flex;
  align-items: center;
  color: #070736;
  text-decoration: none;
}

.brand-logo {
  display: block;
  width: auto;
  height: 46px;
}

.topnav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 38px;
}

.topnav a {
  color: #6d625b;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}

.nav-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: end;
  min-width: 98px;
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 10px 24px rgba(42, 31, 22, 0.06);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 318px;
  gap: 20px;
  align-items: stretch;
  padding-top: 58px;
}

.chat-panel,
.side-panel {
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(380px, 1fr) auto auto;
  min-height: calc(100vh - 160px);
  overflow: hidden;
  border-radius: 28px;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 74px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.58);
}

.assistant-avatar {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #f01853 0%, #ff7127 100%);
  color: #fff;
  font-weight: 900;
  box-shadow: var(--button-shadow);
}

.chat-title {
  min-width: 0;
}

.chat-title p,
.chat-title span {
  margin: 0;
}

.chat-title p {
  font-size: 1rem;
  font-weight: 900;
}

.chat-title span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.runtime-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.runtime-pills span {
  min-height: 28px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--mint);
  color: #24634e;
  font-size: 0.76rem;
  font-weight: 800;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  padding: 22px 20px 26px;
  scroll-behavior: smooth;
}

.message {
  display: flex;
}

.message--assistant,
.message--system {
  justify-content: flex-start;
}

.message--user {
  justify-content: flex-end;
}

.message-bubble {
  max-width: min(620px, 78%);
  padding: 12px 14px 8px;
  border: 1px solid rgba(42, 31, 22, 0.08);
  border-radius: 19px;
  background: #fff;
  box-shadow: 0 10px 26px rgba(42, 31, 22, 0.07);
}

.message--user .message-bubble {
  border-color: transparent;
  background: linear-gradient(135deg, #ee174a 0%, #ff6a1f 100%);
  color: #fff;
  box-shadow: var(--button-shadow);
}

.message--system .message-bubble {
  max-width: 520px;
  background: var(--blue);
  color: #345071;
  box-shadow: none;
}

.message-bubble p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.58;
  font-size: 0.96rem;
}

.message-bubble img {
  display: block;
  width: 100%;
  max-height: 320px;
  margin-bottom: 10px;
  border-radius: 14px;
  object-fit: cover;
}

.message-bubble time {
  display: block;
  margin-top: 6px;
  color: rgba(119, 109, 101, 0.82);
  font-size: 0.72rem;
  text-align: right;
}

.message--user .message-bubble time {
  color: rgba(255, 255, 255, 0.78);
}

.command-bar {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 250, 244, 0.72);
}

.command-bar::-webkit-scrollbar {
  display: none;
}

.command-button {
  min-width: 84px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(238, 23, 74, 0.18);
  border-radius: 999px;
  background: #fff;
  color: #d61b45;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(42, 31, 22, 0.05);
  white-space: nowrap;
}

.command-button--primary {
  border-color: transparent;
  background: linear-gradient(135deg, #ee174a 0%, #ff6a1f 100%);
  color: #fff;
  box-shadow: var(--button-shadow);
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 12px;
  padding: 16px 18px 18px;
  background: rgba(255, 255, 255, 0.7);
}

.composer textarea {
  width: 100%;
  min-height: 48px;
  max-height: 132px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 18px;
  outline: none;
  padding: 13px 15px;
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(42, 31, 22, 0.02);
}

.composer textarea:focus,
.side-panel input:focus,
.side-panel select:focus {
  border-color: rgba(238, 23, 74, 0.48);
  box-shadow: 0 0 0 4px rgba(238, 23, 74, 0.08);
}

.send-button,
.inline-controls button {
  min-height: 48px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, #ee174a 0%, #ff6a1f 100%);
  color: #fff;
  font-weight: 900;
  box-shadow: var(--button-shadow);
}

.side-panel {
  align-self: stretch;
  border-radius: 28px;
  overflow: hidden;
}

.side-section {
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.side-section:last-child {
  border-bottom: 0;
}

.section-kicker {
  margin: 0 0 10px;
  color: #e01b48;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.identity-block h2,
.identity-block p {
  margin: 0;
}

.identity-block h2 {
  overflow-wrap: anywhere;
  font-size: 1.05rem;
  line-height: 1.35;
}

.identity-block p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 36px;
  color: var(--muted);
  font-size: 0.86rem;
}

.section-row strong {
  color: var(--ink);
  font-size: 1rem;
  letter-spacing: 0.04em;
}

.side-panel label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.side-panel input,
.side-panel select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: 0;
  padding: 0 13px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
}

.inline-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 10px;
}

.plan-controls {
  display: grid;
  gap: 10px;
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100% - 24px, 760px);
    padding-top: 14px;
  }

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

  .topnav {
    display: none;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding-top: 24px;
  }

  .chat-panel {
    min-height: 72vh;
  }

  .side-panel {
    border-radius: 22px;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: 100%;
    padding: 10px;
  }

  .brand-logo {
    height: 40px;
  }

  .nav-cta {
    display: none;
  }

  .workspace {
    gap: 12px;
  }

  .chat-panel {
    min-height: calc(100vh - 92px);
    border-radius: 22px;
  }

  .chat-header {
    align-items: flex-start;
  }

  .runtime-pills {
    max-width: 116px;
  }

  .message-bubble {
    max-width: 88%;
  }

  .command-bar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: hidden;
  }

  .command-button {
    width: 100%;
    min-width: 0;
  }

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

  .send-button {
    min-height: 44px;
  }
}
