:root {
  --bg: #d8c4a1;
  --bg-accent: #b79669;
  --panel: #f6ecdc;
  --panel-alt: #efe1cb;
  --panel-border: #b49366;
  --text: #2f2418;
  --muted: #6f5a42;
  --muted-strong: #543f2b;
  --brand: #71502f;
  --brand-strong: #4f351e;
  --brand-soft: #e8d5b6;
  --ok: #365840;
  --error: #983f33;
  --shadow: 0 18px 38px rgba(61, 40, 19, 0.16);
  --shadow-soft: 0 8px 20px rgba(61, 40, 19, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  background:
    radial-gradient(circle at top left, rgba(255, 244, 223, 0.44), transparent 28rem),
    radial-gradient(circle at bottom right, rgba(104, 72, 40, 0.14), transparent 30rem),
    repeating-linear-gradient(
      0deg,
      rgba(118, 87, 53, 0.035) 0,
      rgba(118, 87, 53, 0.035) 1px,
      transparent 1px,
      transparent 12px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(255, 249, 238, 0.08) 0,
      rgba(255, 249, 238, 0.08) 1px,
      transparent 1px,
      transparent 18px
    ),
    linear-gradient(145deg, #d7c09d 0%, #c1a176 48%, #b2875f 100%);
}

.page-shell {
  min-height: 100vh;
  padding: 20px 24px 28px;
}

.login-layout {
  min-height: calc(100vh - 48px);
  display: grid;
  place-items: center;
}

.login-card,
.panel {
  background:
    linear-gradient(180deg, rgba(255, 250, 242, 0.52), rgba(255, 250, 242, 0.08)),
    repeating-linear-gradient(
      135deg,
      rgba(117, 86, 52, 0.02) 0,
      rgba(117, 86, 52, 0.02) 2px,
      rgba(255, 255, 255, 0.02) 2px,
      rgba(255, 255, 255, 0.02) 8px
    ),
    var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: var(--shadow-soft);
}

.login-card {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  overflow: hidden;
}

.login-copy {
  padding: 42px;
  background:
    radial-gradient(circle at top left, rgba(233, 196, 141, 0.18), transparent 18rem),
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.025) 0,
      rgba(255, 255, 255, 0.025) 3px,
      rgba(46, 29, 15, 0.03) 3px,
      rgba(46, 29, 15, 0.03) 7px
    ),
    linear-gradient(150deg, #6f4d2e, #4b311d);
  color: #f5ead9;
}

.login-copy > p {
  margin: 0;
}

.login-feature-grid {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

.login-feature-card {
  padding: 14px 16px;
  border: 1px solid rgba(246, 227, 196, 0.18);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 243, 220, 0.08), rgba(255, 243, 220, 0.03)),
    rgba(33, 20, 11, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 236, 207, 0.08);
}

.login-feature-card h2 {
  margin: 0 0 6px;
  font-size: 15px;
  color: #f8ecdc;
}

.login-feature-card p {
  margin: 0;
  color: rgba(245, 234, 217, 0.84);
  font-size: 13px;
  line-height: 1.6;
}

.login-workflow {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.login-workflow span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 244, 223, 0.12);
  border: 1px solid rgba(245, 223, 192, 0.2);
  color: #f7ead7;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.login-copy h1,
.console-title h1 {
  margin: 0 0 8px;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  line-height: 1.1;
  font-weight: 700;
}

.console-title h1 {
  margin: 0;
  color: #3a2819;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 0 rgba(255, 245, 229, 0.45);
}

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

.dashboard {
  width: min(1360px, 100%);
  margin: 0 auto;
}

.dashboard,
.panel,
.stack-form {
  display: grid;
  gap: 14px;
}

.action-stack {
  display: grid;
  gap: 8px;
}

.action-row-compact {
  min-height: 0;
}

.dashboard-compact {
  gap: 16px;
}

.console-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 2px 2px 4px;
}

.console-title {
  display: grid;
  gap: 4px;
}

.titleplate {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 10px 16px 12px;
  border-radius: 14px;
  border: 1px solid rgba(117, 81, 43, 0.55);
  background:
    linear-gradient(180deg, rgba(255, 248, 236, 0.58), rgba(231, 210, 176, 0.28)),
    repeating-linear-gradient(
      90deg,
      rgba(255, 249, 239, 0.08) 0,
      rgba(255, 249, 239, 0.08) 1px,
      transparent 1px,
      transparent 14px
    ),
    linear-gradient(180deg, rgba(108, 74, 41, 0.1), rgba(255, 248, 235, 0.18));
  box-shadow:
    inset 0 1px 0 rgba(255, 247, 231, 0.65),
    inset 0 -1px 0 rgba(122, 88, 51, 0.08),
    0 12px 28px rgba(70, 46, 23, 0.08);
}

.titleplate::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(136, 98, 58, 0.18);
  border-radius: 10px;
  pointer-events: none;
}

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

.titleplate-primary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.titleplate-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: 520px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(117, 81, 43, 0.28);
  background: linear-gradient(180deg, rgba(255, 248, 236, 0.8), rgba(231, 210, 176, 0.56));
  color: var(--muted-strong);
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.titleplate-status.warning {
  color: #7a541f;
  border-color: rgba(158, 112, 35, 0.35);
}

.titleplate-status.success {
  color: #32573e;
  border-color: rgba(54, 88, 64, 0.28);
}

.titleplate-status.error {
  color: #8f3d32;
  border-color: rgba(152, 63, 51, 0.3);
}

.titleplate-seal {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(117, 73, 35, 0.5);
  background:
    linear-gradient(180deg, rgba(131, 45, 31, 0.94), rgba(98, 31, 24, 0.96));
  color: #f5dfd6;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  box-shadow:
    inset 0 1px 0 rgba(255, 214, 198, 0.24),
    0 5px 10px rgba(99, 34, 25, 0.18);
}

.titleplate-divider {
  position: relative;
  height: 8px;
}

.titleplate-divider::before,
.titleplate-divider::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  border-radius: 999px;
}

.titleplate-divider::before {
  top: 2px;
  height: 2px;
  background: linear-gradient(90deg, rgba(145, 110, 67, 0.05), rgba(145, 110, 67, 0.72), rgba(145, 110, 67, 0.05));
}

.titleplate-divider::after {
  top: 6px;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 245, 226, 0.12), rgba(255, 245, 226, 0.68), rgba(255, 245, 226, 0.12));
}

.console-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.meta-chip,
.panel-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid #b9976b;
  background:
    linear-gradient(180deg, rgba(255, 246, 232, 0.85), rgba(231, 210, 176, 0.82));
  color: #5c452d;
  font-size: 12px;
  font-weight: 600;
}

.hero-copy,
.compact-copy,
.panel-head p,
.status-card,
.ghost-link,
.rules-guide-card p,
.rules-example p {
  color: var(--muted);
}

.eyebrow,
.section-kicker {
  margin: 0;
  color: #8b6d49;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  font-weight: 700;
}

.section-kicker {
  margin-bottom: 4px;
}


.overview-grid,
.grid.two-up,
.rules-guide-grid {
  display: grid;
  gap: 14px;
}

.overview-grid {
  grid-template-columns: 1.1fr 0.9fr;
}

.grid.two-up,
.compact-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.rules-guide-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tab-shell {
  display: grid;
  gap: 14px;
}

.workspace-lower-panel {
  margin-top: 2px;
}

.tabbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(121, 84, 47, 0.08), rgba(255, 249, 239, 0.38)),
    rgba(246, 236, 220, 0.88);
  box-shadow: var(--shadow-soft);
}

.tab-button {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: #61492f;
  font-size: 13px;
  font-weight: 600;
  box-shadow: none;
}

.tab-button.is-active {
  background: var(--brand-soft);
  border-color: #b68d5f;
  color: #432b18;
  box-shadow: inset 0 1px 0 rgba(255, 248, 236, 0.55);
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.panel {
  padding: 16px 18px;
}

.panel-compact {
  gap: 12px;
}

.panel-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.compact-head {
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
}

.panel-head p {
  margin: 0;
  font-size: 13px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted-strong);
}

.compact-form {
  gap: 12px;
}

.field-inline {
  max-width: 180px;
}

input[type="text"],
input[type="password"],
input[type="file"],
textarea,
button,
.secondary-button {
  font: inherit;
}

input[type="text"],
input[type="password"],
input[type="file"],
textarea {
  width: 100%;
  border: 1px solid #c1a074;
  border-radius: 10px;
  padding: 10px 12px;
  background:
    linear-gradient(180deg, rgba(255, 249, 240, 0.88), rgba(244, 231, 207, 0.92));
  color: var(--text);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="file"]:focus,
textarea:focus {
  outline: none;
  border-color: #8d6840;
  box-shadow: 0 0 0 3px rgba(122, 87, 46, 0.14);
}

textarea {
  resize: vertical;
}

button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 231, 195, 0.08), rgba(0, 0, 0, 0.08)),
    linear-gradient(180deg, var(--brand), var(--brand-strong));
  color: #f8ead7;
  text-decoration: none;
  cursor: pointer;
  transition: transform 150ms ease, opacity 150ms ease, box-shadow 150ms ease;
  box-shadow: 0 10px 22px rgba(79, 53, 30, 0.2);
  font-size: 13px;
  font-weight: 600;
}

.secondary-button {
  background:
    linear-gradient(180deg, rgba(255, 246, 232, 0.95), rgba(230, 210, 177, 0.92));
  border-color: #c09b6a;
  color: #4f351e;
  box-shadow: none;
}

.danger-button {
  background:
    linear-gradient(180deg, rgba(254, 239, 235, 0.95), rgba(238, 210, 201, 0.92));
  border-color: #bf877c;
  color: #7a2e25;
}

button[hidden],
.secondary-button[hidden] {
  display: none;
}

button:hover,
.secondary-button:hover,
.ghost-link:hover,
.tab-button:hover {
  transform: translateY(-1px);
}

.ghost-link {
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid #b99669;
  background:
    linear-gradient(180deg, rgba(255, 246, 233, 0.92), rgba(236, 217, 188, 0.88));
  font-size: 13px;
}

.action-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.inline-field {
  display: grid;
  gap: 4px;
  max-width: 320px;
}

.inline-field-grow {
  flex: 1 1 320px;
  max-width: none;
}

.inline-field span {
  font-size: 12px;
  color: #6e5439;
}

.inline-field input {
  min-width: 0;
}

.generate-config-row {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.mode-switch-field {
  display: grid;
  gap: 4px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.mode-switch-field legend {
  padding: 0;
  font-size: 12px;
  color: #6e5439;
  margin-bottom: 4px;
}

.mode-switch {
  display: inline-flex;
  align-items: center;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid #b99669;
  background:
    linear-gradient(180deg, rgba(255, 246, 233, 0.92), rgba(236, 217, 188, 0.88));
  box-shadow: inset 0 1px 0 rgba(255, 247, 231, 0.72);
}

.mode-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-switch label {
  min-width: 58px;
  padding: 7px 14px;
  border-radius: 9px;
  color: #6b5238;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.mode-switch input:checked + label {
  background: linear-gradient(180deg, #7a5734, #5a3d23);
  color: #f8ecdd;
  box-shadow: 0 6px 14px rgba(77, 51, 28, 0.18);
}

.mode-switch label:hover {
  transform: translateY(-1px);
}

.action-row-wrap {
  flex-wrap: wrap;
}

.status-card,
.code-block,
.rules-editor {
  border-radius: 12px;
  padding: 12px 13px;
  border: 1px solid #c7a679;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(119, 88, 54, 0.018) 0,
      rgba(119, 88, 54, 0.018) 1px,
      transparent 1px,
      transparent 10px
    ),
    linear-gradient(180deg, rgba(248, 238, 222, 0.96), rgba(238, 224, 197, 0.94));
}

.status-card {
  min-height: 60px;
  white-space: pre-wrap;
  font-size: 12.5px;
  line-height: 1.5;
}

.overview-grid .panel {
  padding-top: 12px;
  padding-bottom: 12px;
}

.overview-grid .status-card {
  min-height: 58px;
  padding: 10px 12px;
}

.code-block,
.rules-editor {
  min-height: 220px;
  margin: 0;
  overflow: auto;
  font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.rules-editor {
  min-height: 400px;
}

#parse-result,
#detect-result,
#generate-result,
#embedding-result,
#vector-query-result {
  height: 360px;
  max-height: 58vh;
  overflow-y: auto;
  overflow-x: auto;
}

.rules-guide-card,
.rules-example {
  border-radius: 12px;
  border: 1px solid #c4a173;
  background:
    linear-gradient(180deg, rgba(255, 248, 236, 0.72), rgba(239, 225, 201, 0.82));
  padding: 14px;
}

.rules-guide-card h3,
.rules-example-title {
  margin: 0 0 6px;
  font-size: 13px;
}

.rules-example-code {
  margin: 8px 0 0;
  padding: 12px;
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(252, 245, 234, 0.95), rgba(238, 224, 198, 0.95));
  border: 1px solid #cfab7d;
  overflow: auto;
  font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.panel.section-updated,
.code-block.section-updated {
  animation: resultGlow 1.5s ease;
}

.panel.section-updated {
  border-color: #9c7447;
  box-shadow: 0 18px 38px rgba(61, 40, 19, 0.16), 0 0 0 3px rgba(151, 112, 64, 0.14);
}

.code-block.section-updated {
  border-color: #ae8353;
  background:
    linear-gradient(180deg, rgba(254, 246, 230, 0.98), rgba(241, 228, 202, 0.96));
}

@keyframes resultGlow {
  0% {
    transform: translateY(6px);
    box-shadow: 0 0 0 0 rgba(139, 101, 57, 0.18);
  }

  35% {
    transform: translateY(0);
    box-shadow: 0 0 0 8px rgba(139, 101, 57, 0.11);
  }

  100% {
    transform: translateY(0);
    box-shadow: 0 0 0 0 rgba(36, 88, 143, 0);
  }
}

.status-card.success {
  color: var(--ok);
}

.status-card.error,
.flash-error {
  color: var(--error);
}

.status-card.warning {
  color: #7a5627;
}

.flash-stack {
  width: min(1360px, 100%);
  margin: 0 auto 14px;
}

.flash {
  padding: 12px 14px;
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 247, 235, 0.96), rgba(239, 225, 201, 0.94));
  border: 1px solid var(--panel-border);
}

@media (max-width: 1080px) {
  .overview-grid,
  .grid.two-up,
  .compact-grid,
  .rules-guide-grid,
  .login-card {
    grid-template-columns: 1fr;
  }

  .console-bar {
    flex-direction: column;
  }

  .console-meta {
    justify-content: flex-start;
  }

  .titleplate-top {
    flex-wrap: wrap;
  }

  .titleplate-primary {
    width: 100%;
    flex-wrap: wrap;
  }

  .titleplate-status {
    max-width: 100%;
  }
}

@media (max-width: 720px) {
  .page-shell {
    padding: 14px;
  }

  .panel {
    padding: 14px;
  }

  .action-row {
    flex-wrap: wrap;
  }

  .tabbar {
    gap: 6px;
  }

  .tab-button {
    flex: 1 1 calc(50% - 6px);
  }

  #parse-result,
  #detect-result,
  #generate-result,
  #embedding-result,
  #vector-query-result,
  .rules-editor {
    height: 300px;
    max-height: none;
  }
}
