:root {
  color-scheme: light;
  --bg: #f3f6f8;
  --panel: #ffffff;
  --line: #d7e0e7;
  --text: #1f2a37;
  --muted: #697789;
  --brand: #247c75;
  --brand-dark: #17665f;
  --gold: #f2bc3f;
  --red: #c43b37;
  --soft: #edf7f5;
  --shadow: 0 12px 30px rgba(39, 64, 83, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

.app-shell {
  width: min(1140px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 14px 0 24px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 10px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-weight: 800;
  font-size: 13px;
}

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

h1 {
  margin-bottom: 4px;
  font-size: clamp(26px, 3vw, 38px);
}

.website-link {
  display: inline-flex;
  margin-bottom: 6px;
  color: var(--brand-dark);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.website-link:hover {
  text-decoration: underline;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

h3 {
  font-size: 15px;
}

.subtitle {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 15px;
}

.browser-tip {
  max-width: 320px;
  padding: 8px 10px;
  border: 1px solid #f0d28a;
  background: #fff8e2;
  color: #745016;
  border-radius: 8px;
  line-height: 1.35;
  font-size: 13px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hidden {
  display: none !important;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin: 24px 0 16px;
}

.section-head p,
.tool-topbar p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.module-card {
  display: grid;
  min-height: 180px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.module-card:hover {
  transform: translateY(-2px);
  border-color: rgba(36, 124, 117, 0.45);
  box-shadow: 0 16px 36px rgba(39, 64, 83, 0.12);
}

.module-card h3 {
  margin-bottom: 10px;
  font-size: 24px;
}

.module-card p {
  color: var(--muted);
  line-height: 1.6;
}

.module-card .tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: end;
}

.module-card .tag {
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
}

.tool-topbar {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin: 12px 0 10px;
}

.connection-panel,
.settings-panel,
.command-panel,
.note-panel {
  padding: 14px;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.status-badge {
  min-width: 72px;
  text-align: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2f6;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.status-badge.connected {
  background: var(--soft);
  color: var(--brand-dark);
}

.control-grid,
.form-grid,
.action-grid,
.note-grid {
  display: grid;
  gap: 10px;
}

.connect-grid {
  grid-template-columns: 118px minmax(150px, 1fr) 126px repeat(3, minmax(88px, 96px));
  align-items: end;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(510px, 1fr) minmax(390px, 0.9fr);
  gap: 12px;
  margin-top: 12px;
}

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

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input,
select {
  height: 36px;
  padding: 0 10px;
}

textarea {
  min-height: 70px;
  resize: vertical;
  padding: 8px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  line-height: 1.4;
  font-size: 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(36, 124, 117, 0.12);
}

button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 800;
  font-size: 14px;
}

.compact {
  min-height: 34px;
  padding: 0 10px;
}

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

.primary {
  color: #fff;
  background: var(--brand);
}

.primary:hover:not(:disabled) {
  background: var(--brand-dark);
}

.secondary {
  color: var(--text);
  background: #f4f8fa;
  border-color: var(--line);
}

.secondary:hover:not(:disabled) {
  background: #eaf1f4;
}

.danger-lite {
  color: var(--red);
}

.warn {
  color: #7d5611;
  background: #fff7df;
  border-color: #efd389;
}

.ghost {
  min-height: 30px;
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.action-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 10px;
}

.command-panel {
  display: grid;
  gap: 9px;
}

.manual-send {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px;
  gap: 8px;
}

.note-panel {
  margin-top: 12px;
}

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

.note-grid p {
  margin: 0;
  padding: 9px 10px;
  border-radius: 8px;
  background: #f6f9fb;
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
}

.command-guide {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.guide-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: #f6f9fb;
  border-bottom: 1px solid var(--line);
}

.guide-head h3 {
  margin: 0;
}

.guide-head span {
  min-width: 0;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guide-list {
  display: grid;
  max-height: 210px;
  overflow: auto;
}

.guide-list p {
  margin: 0;
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
}

.guide-row {
  display: grid;
  grid-template-columns: 74px minmax(92px, 0.8fr) minmax(0, 1.8fr);
  gap: 8px;
  align-items: start;
  padding: 7px 10px;
  border-top: 1px solid #edf2f5;
  font-size: 12px;
  line-height: 1.35;
}

.guide-row:first-child {
  border-top: 0;
}

.guide-row strong {
  color: var(--text);
}

.guide-row code {
  color: var(--brand-dark);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-weight: 800;
  white-space: normal;
  overflow-wrap: anywhere;
}

.guide-row span {
  color: var(--muted);
}

.toast-stack {
  position: fixed;
  top: 18px;
  right: 18px;
  display: grid;
  gap: 10px;
  z-index: 10;
}

.toast {
  width: min(360px, calc(100vw - 36px));
  padding: 14px 16px;
  border-radius: 8px;
  background: #fff;
  border-left: 5px solid var(--brand);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.14);
  line-height: 1.5;
  font-weight: 700;
}

.toast.error {
  border-left-color: var(--red);
}

dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
}

dialog::backdrop {
  background: rgba(17, 24, 39, 0.35);
}

dialog form {
  padding: 24px;
}

dialog p {
  color: var(--muted);
  line-height: 1.6;
}

dialog menu {
  display: flex;
  justify-content: flex-end;
  margin: 20px 0 0;
  padding: 0;
}

@media (max-width: 920px) {
  .hero,
  .workspace,
  .tool-topbar,
  .section-head {
    grid-template-columns: 1fr;
    display: grid;
  }

  .connect-grid,
  .form-grid,
  .action-grid,
  .note-grid,
  .module-grid {
    grid-template-columns: 1fr;
  }
}
