:root {
  color-scheme: dark;
  --ink: #ecf7f4;
  --muted: #91aaa8;
  --line: rgba(155, 217, 204, .17);
  --panel: rgba(13, 28, 37, .86);
  --panel-soft: rgba(20, 44, 52, .72);
  --cyan: #63dcc4;
  --amber: #f0c979;
  --danger: #f28f83;
  --shadow: 0 24px 70px rgba(0, 0, 0, .3);
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #071118; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 72% 0%, rgba(56, 129, 126, .2), transparent 34rem),
    radial-gradient(circle at 0% 68%, rgba(35, 92, 96, .14), transparent 30rem),
    linear-gradient(160deg, #08131b 0%, #0b1922 46%, #071118 100%);
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

button, .button {
  min-height: 42px;
  border: 1px solid rgba(99, 220, 196, .26);
  border-radius: 11px;
  padding: 0 15px;
  color: var(--ink);
  background: rgba(24, 54, 61, .72);
  cursor: pointer;
  text-decoration: none;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

button:hover, .button:hover {
  transform: translateY(-1px);
  border-color: rgba(99, 220, 196, .65);
  background: rgba(38, 78, 79, .72);
}

button:disabled { opacity: .55; cursor: wait; transform: none; }
button.primary { color: #071714; background: var(--cyan); border-color: var(--cyan); font-weight: 750; }
button.primary:hover { background: #8ae8d5; }
.button.secondary { background: transparent; }

.topbar {
  position: relative;
  z-index: 2;
  width: min(1280px, calc(100% - 40px));
  min-height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(99, 220, 196, .55);
  border-radius: 13px 13px 17px 13px;
  color: var(--cyan);
  background: rgba(31, 82, 82, .56);
  font-family: Georgia, serif;
  font-size: 1.25rem;
  font-weight: 700;
  transform: rotate(-4deg);
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.02rem; letter-spacing: .02em; }
.brand small { margin-top: 3px; color: var(--muted); font-size: .59rem; letter-spacing: .2em; }

.account { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: .84rem; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #62747a; }
.status-dot.online { background: var(--cyan); box-shadow: 0 0 14px rgba(99, 220, 196, .78); }
.text-link, .text-button { color: var(--muted); }
.text-link { text-decoration: none; }
.text-link:hover, .text-button:hover { color: var(--cyan); }
.text-button { min-height: auto; border: 0; padding: 5px; background: transparent; }

.notice {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 13px 20px;
  border-block: 1px solid rgba(240, 201, 121, .24);
  color: #dfd3b5;
  background: rgba(83, 65, 31, .28);
}

.hidden { display: none !important; }

.layout {
  position: relative;
  z-index: 1;
  width: min(1500px, calc(100% - 40px));
  margin: 0 auto;
  padding: 12px 0 70px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
  gap: 18px;
  align-items: start;
}

.control-panel, .result-panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.tab-panel h2, .panel-heading h2 {
  margin: 0;
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: 1.08rem;
  font-weight: 500;
}

.tab-panel h2::before {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin: 0 9px 2px 0;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px rgba(99, 220, 196, .56);
  content: "";
}

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

.control-panel {
  position: sticky;
  top: 14px;
  min-width: 0;
  max-height: calc(100vh - 28px);
  overflow: hidden;
}

.tab-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 18, 24, .52);
}

.tab-button {
  min-width: 0;
  min-height: 50px;
  padding: 0 5px;
  border: 0;
  border-right: 1px solid rgba(155, 217, 204, .09);
  border-radius: 0;
  color: var(--muted);
  background: transparent;
  font-size: .78rem;
}

.tab-button:last-child { border-right: 0; }
.tab-button:hover { transform: none; background: rgba(38, 78, 79, .32); }
.tab-button.active {
  color: var(--cyan);
  background: rgba(42, 101, 97, .28);
  box-shadow: inset 0 -2px var(--cyan);
}

.tab-panels {
  max-height: calc(100vh - 128px);
  overflow-y: auto;
  scrollbar-color: #315c5a transparent;
}

.tab-panel { padding: 20px; }
.tab-panel[hidden] { display: none; }

.command-button {
  min-height: 62px;
  text-align: left;
  color: #c7d9d5;
}

.command-button small {
  display: block;
  max-width: calc(100% - 18px);
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: .66rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-button::after {
  float: right;
  color: var(--cyan);
  content: "›";
}

.command-button.needs-input {
  border-style: dashed;
}

.command-button.needs-input::after {
  color: var(--amber);
  content: "＋";
}

.command-group + .command-group {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.custom-command label {
  min-width: 0;
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: .72rem;
}

input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  outline: none;
  color: var(--ink);
  background: rgba(2, 10, 14, .5);
}

input:focus { border-color: rgba(99, 220, 196, .62); box-shadow: 0 0 0 3px rgba(99, 220, 196, .08); }
input::placeholder { color: #627b7b; }

.result-panel {
  min-width: 0;
  overflow: hidden;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 21px 15px;
  border-bottom: 1px solid var(--line);
}

.panel-kicker {
  display: block;
  margin-bottom: 5px;
  color: var(--cyan);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .16em;
}

.feed {
  height: calc(100vh - 225px);
  min-height: 560px;
  padding: 20px 24px;
  overflow-y: auto;
  scrollbar-color: #315c5a transparent;
}

.message {
  margin: 0 0 12px;
  padding: 13px 14px;
  border-left: 2px solid rgba(99, 220, 196, .42);
  border-radius: 0 11px 11px 0;
  color: #c7d9d5;
  background: rgba(22, 45, 51, .5);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user-message { border-left-color: rgba(240, 201, 121, .68); }
.message.error-message { border-left-color: var(--danger); color: #f5b4ac; }
.message-tag { display: block; margin-bottom: 6px; color: var(--cyan); font-size: .61rem; font-weight: 700; letter-spacing: .15em; }
.user-message .message-tag { color: var(--amber); }
.message p { margin: 0; line-height: 1.65; }
.message img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  margin: 12px auto 0;
  border-radius: 11px;
}

.custom-command {
  padding: 14px 15px 16px;
  border-top: 1px solid var(--line);
  background: rgba(7, 18, 24, .52);
}

.custom-command > div { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 7px; }
.custom-command button { color: #071714; background: var(--cyan); border-color: var(--cyan); font-weight: 700; }

.hint { margin: 12px 0; color: var(--muted); font-size: .82rem; line-height: 1.65; }
.choice-row { display: flex; flex-wrap: wrap; gap: 15px; margin-bottom: 12px; }
.choice-row label { display: flex; align-items: center; gap: 7px; color: #c7d9d5; font-size: .82rem; }
.choice-row input { width: auto; min-height: auto; accent-color: var(--cyan); }
.code-result { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; margin-top: 12px; }
.code-result code { min-width: 0; padding: 12px; border: 1px dashed rgba(240, 201, 121, .48); border-radius: 10px; color: var(--amber); background: rgba(7, 18, 24, .45); }
.bound-state { display: flex; gap: 10px; align-items: baseline; margin-top: 12px; color: var(--cyan); }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .control-panel { position: static; max-height: none; }
  .tab-panels { max-height: none; }
  .feed { height: 58vh; min-height: 420px; }
}

@media (max-width: 720px) {
  .topbar, .layout { width: min(100% - 24px, 1500px); }
  .topbar { min-height: 68px; }
  .account { max-width: 52%; flex-wrap: wrap; justify-content: flex-end; }
}

@media (max-width: 460px) {
  .tab-panel { padding: 15px; }
  .tab-button { font-size: .72rem; }
  .quick-grid { grid-template-columns: 1fr 1fr; }
  .custom-command > div, .code-result { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
