:root {
  color-scheme: light;
  --bg: #f4efe3;
  --panel: rgba(255, 251, 242, 0.92);
  --panel-border: rgba(88, 95, 74, 0.16);
  --ink: #2f3626;
  --muted: #66705a;
  --accent: #3f6a53;
  --accent-soft: rgba(63, 106, 83, 0.12);
  --gold: #c38a3f;
  --shadow: 0 20px 45px rgba(79, 69, 49, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top, rgba(129, 166, 143, 0.25), transparent 30%),
    linear-gradient(180deg, #f8f4ea 0%, #f1ead9 45%, #ede5d2 100%);
}

button,
input {
  font: inherit;
}

button {
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.05rem;
  background: var(--accent);
  color: #f8f8f2;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  opacity: 0.94;
}

button.secondary {
  background: rgba(83, 74, 56, 0.88);
}

code {
  padding: 0.1rem 0.35rem;
  border-radius: 0.4rem;
  background: rgba(66, 68, 55, 0.1);
  font-family: "Sarasa Mono SC", "JetBrains Mono", monospace;
}

.page-shell {
  width: min(1200px, calc(100vw - 1.5rem));
  margin: 0 auto;
  padding: 1rem 0 calc(1.5rem + env(safe-area-inset-bottom));
}

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.top-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 1.5rem;
  padding: 1.4rem 1.6rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--gold);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.7rem, 2.4vw, 2.4rem);
}

h2 {
  font-size: 1.1rem;
}

.subtitle {
  margin-top: 0.45rem;
  color: var(--muted);
}

.status-group {
  display: grid;
  gap: 0.9rem;
  min-width: 260px;
}

.label {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.2rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  background: rgba(115, 117, 100, 0.12);
}

.status-connected {
  background: rgba(63, 106, 83, 0.14);
  color: #30533f;
}

.status-disconnected,
.status-error {
  background: rgba(141, 87, 64, 0.14);
  color: #83482f;
}

.status-idle {
  background: rgba(114, 122, 140, 0.14);
  color: #50596b;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(290px, 0.92fr);
  align-items: start;
  gap: 1rem;
  margin-top: 1rem;
}

.play-column {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.output-panel,
.side-panel {
  padding: 1.2rem 1.3rem;
}

.output-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1rem;
}

.ready-hint {
  color: var(--muted);
  font-size: 0.92rem;
}

.output {
  height: clamp(19rem, 48vh, 34rem);
  min-height: 19rem;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 1rem;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(249, 245, 236, 0.96), rgba(243, 236, 222, 0.96));
  border: 1px solid rgba(110, 99, 74, 0.12);
}

.line {
  white-space: pre-wrap;
  line-height: 1.65;
  padding: 0.25rem 0;
  color: var(--ink);
}

.line-room {
  margin: 0.25rem 0 0.4rem;
  color: var(--accent);
  font-weight: 700;
}

.line-command {
  color: #6b5640;
  font-family: "Sarasa Mono SC", "JetBrains Mono", monospace;
}

.line-status {
  color: var(--muted);
}

.line-system {
  color: #5d6844;
}

.side-panel {
  display: grid;
  gap: 1.2rem;
  position: sticky;
  top: 1rem;
  align-self: start;
}

.guide-list {
  margin: 0.75rem 0 0;
  padding-left: 1.15rem;
  color: var(--muted);
  line-height: 1.65;
}

.guide-list.compact {
  margin-top: 0.65rem;
}

.entry-grid {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.85rem;
}

.entry-card {
  padding: 0.9rem 1rem;
  border-radius: 18px;
  background: rgba(63, 106, 83, 0.08);
  border: 1px solid rgba(63, 106, 83, 0.12);
}

.entry-title {
  margin-bottom: 0.45rem;
  font-weight: 700;
}

.entry-note {
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.quick-actions-wrap {
  display: grid;
  gap: 0.65rem;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.quick-action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.12rem;
  width: 100%;
  min-height: 3.2rem;
  padding: 0.58rem 0.72rem;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(63, 106, 83, 0.12);
  border-radius: 16px;
}

.quick-action span {
  font-weight: 700;
  line-height: 1.25;
}

.quick-action code {
  padding: 0;
  background: transparent;
  color: inherit;
  font-size: 0.78rem;
  opacity: 0.82;
}

.go-menu {
  display: grid;
  gap: 0.7rem;
  padding: 0.85rem 0.9rem;
  border-radius: 18px;
  background: rgba(246, 240, 228, 0.94);
  border: 1px solid rgba(99, 89, 66, 0.12);
}

.go-menu[hidden] {
  display: none;
}

.go-menu-copy {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
}

#go-menu-title {
  font-size: 0.98rem;
}

#go-menu-hint {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
  text-align: right;
}

.go-menu-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.5rem;
}

.direction-button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  min-height: 3rem;
  padding: 0.6rem 0.78rem;
  border-radius: 15px;
  background: rgba(63, 106, 83, 0.12);
  color: var(--accent);
}

.direction-button.secondary {
  background: rgba(83, 74, 56, 0.12);
  color: #5f4f3a;
}

.direction-title {
  font-weight: 700;
}

.direction-button code {
  padding: 0;
  background: transparent;
  color: inherit;
  font-size: 0.8rem;
  opacity: 0.8;
}

.section-note {
  margin-top: 0.8rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.command-panel {
  display: grid;
  gap: 0.9rem;
  padding: 1rem;
  position: sticky;
  bottom: calc(0.75rem + env(safe-area-inset-bottom));
  z-index: 5;
  background: rgba(255, 251, 242, 0.97);
}

.command-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
}

.command-summary {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
  max-width: 19rem;
}

.command-form {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 0.8rem;
}

.command-label {
  color: var(--muted);
  font-weight: 600;
  padding-top: 0.9rem;
}

.command-entry {
  min-width: 0;
}

#command-input {
  width: 100%;
  min-height: 3.2rem;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(93, 90, 77, 0.16);
  background: rgba(255, 252, 245, 0.94);
  color: var(--ink);
  font-size: 16px;
}

#command-input:focus {
  outline: 2px solid rgba(63, 106, 83, 0.18);
  border-color: rgba(63, 106, 83, 0.3);
}

.command-tip {
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

@media (max-width: 920px) {
  .top-bar,
  .main-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .page-shell {
    padding-bottom: calc(5.5rem + env(safe-area-inset-bottom));
  }

  .output {
    height: min(44vh, 24rem);
    min-height: 16rem;
  }

  .side-panel {
    position: static;
  }

  .command-panel {
    bottom: calc(0.65rem + env(safe-area-inset-bottom));
  }

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

  .command-header,
  .command-form {
    grid-template-columns: 1fr;
  }

  .command-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .command-label {
    padding-top: 0;
  }

  #send-button {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100%, calc(100vw - 0.9rem));
    padding-top: 0.7rem;
  }

  .top-bar,
  .output-panel,
  .side-panel,
  .command-panel {
    border-radius: 20px;
  }

  .top-bar,
  .output-panel,
  .side-panel {
    padding: 1rem;
  }

  .status-group {
    min-width: 0;
  }

  .button-row button {
    flex: 1 1 0;
  }

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

  .quick-action {
    min-height: 0;
    padding: 0.52rem 0.66rem;
  }

  .go-menu-copy {
    flex-direction: column;
    align-items: flex-start;
  }

  #go-menu-hint {
    text-align: left;
  }

  .go-menu-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
