:root {
  --ink: #1c2525;
  --muted: #5e6a68;
  --canvas: #eef1ed;
  --paper: #fdfdf9;
  --line: #c8d0c9;
  --accent: #ac3c21;
  --accent-soft: #f2d7cb;
  --ready: #18735b;
  --waiting: #a96810;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background-color: var(--canvas);
  background-image: linear-gradient(rgba(28, 37, 37, 0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(28, 37, 37, 0.035) 1px, transparent 1px);
  background-size: 24px 24px;
  font-family: "Avenir Next", "Hiragino Sans GB", "PingFang SC", sans-serif;
  letter-spacing: 0;
}

.shell {
  width: min(100% - 32px, 1060px);
  margin: 0 auto;
  padding: 48px 0 64px;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 390px);
  padding: 32px;
  border: 1px solid var(--ink);
  border-left: 6px solid var(--accent);
  background: var(--paper);
  box-shadow: 7px 7px 0 rgba(28, 37, 37, 0.1);
}

.login-panel h1 {
  margin-bottom: 26px;
}

.login-panel form {
  display: grid;
  gap: 16px;
}

.login-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-panel input {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0 10px;
  color: var(--ink);
  background: var(--paper);
  font: 14px "SFMono-Regular", "Menlo", monospace;
}

.login-error {
  margin: 0;
  color: #7d2818;
  font-size: 13px;
}

.masthead,
.section-heading,
.tool-row,
.connection,
.service-facts {
  display: flex;
  align-items: center;
}

.masthead {
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 30px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-family: "Avenir Next Condensed", "Avenir Next", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  font-family: "Songti SC", "STSong", serif;
  font-weight: 600;
  letter-spacing: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 38px;
  line-height: 1.12;
}

h2 {
  margin-bottom: 8px;
  font-size: 23px;
}

.connection {
  flex: 0 0 auto;
  gap: 9px;
  color: var(--muted);
  font-size: 14px;
}

.text-button {
  border: 0;
  padding: 0;
  color: var(--muted);
  background: transparent;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

body.is-diagnostics-window #open-diagnostics-button {
  display: none;
}

.signal {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--waiting);
  box-shadow: 0 0 0 4px rgba(169, 104, 16, 0.13);
}

.signal.is-connected {
  background: var(--ready);
  box-shadow: 0 0 0 4px rgba(24, 115, 91, 0.13);
}

.service-overview {
  display: grid;
  grid-template-columns: minmax(230px, 0.9fr) minmax(0, 1.6fr);
  gap: 24px;
  padding: 28px 30px;
  border: 1px solid var(--ink);
  border-left: 6px solid var(--accent);
  background: var(--paper);
  box-shadow: 7px 7px 0 rgba(28, 37, 37, 0.1);
}

.overview-title p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.service-facts {
  justify-content: space-between;
  gap: 16px;
  margin: 0;
}

.service-facts div {
  min-width: 0;
}

.service-facts dt {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

.service-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: "SFMono-Regular", "Menlo", monospace;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.task-creation,
.tool-detail {
  margin-top: 54px;
}

.window-layout {
  margin-top: 54px;
}

.diagnostics {
  margin-top: 42px;
}

.diagnostic-actions {
  display: flex;
  gap: 8px;
}

.diagnostic-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.diagnostic-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.diagnostic-facts div {
  min-width: 0;
  padding: 14px 16px;
  border-right: 1px solid var(--line);
}

.diagnostic-facts div:last-child {
  border-right: 0;
}

.diagnostic-facts dt {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.diagnostic-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
  font: 13px/1.45 "SFMono-Regular", "Menlo", monospace;
}

.diagnostic-events {
  min-height: 72px;
  max-height: 180px;
  margin: 0;
  overflow: auto;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ink);
  color: #d9ece0;
  background: var(--ink);
  font: 12px/1.55 "SFMono-Regular", "Menlo", monospace;
  white-space: pre-wrap;
}

.service-update {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: end;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.service-update h3,
.service-update p {
  margin: 0;
}

.service-update h3 {
  margin-bottom: 4px;
  font-family: "Songti SC", "STSong", serif;
  font-size: 17px;
}

.service-update p {
  color: var(--muted);
  font-size: 13px;
}

.service-update label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.service-update input {
  height: 38px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0 10px;
  font: 14px "SFMono-Regular", "Menlo", monospace;
}

.service-update-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.service-update-output {
  max-height: 180px;
  margin: 0;
  overflow: auto;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: #f3f6f0;
  font: 12px/1.55 "SFMono-Regular", "Menlo", monospace;
  white-space: pre-wrap;
}

.window-layout-status {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.window-layout-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.arrangement-window {
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: 3px 3px 0 rgba(28, 37, 37, 0.06);
}

.arrangement-window-info {
  font-weight: 400;
  padding: 16px 16px 0;
}

.window-layout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}

.window-header-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.arrangement-window strong {
  min-width: 0;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.window-preview {
  display: grid;
  place-items: center;
  width: min(calc(100% - 32px), 210px);
  aspect-ratio: 16 / 9;
  margin: 0 16px 16px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  color: inherit;
  background: #1c2525;
  cursor: zoom-in;
}

.window-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.window-preview:hover,
.window-preview:focus-visible {
  border-color: var(--accent);
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
}

.window-preview.is-pending::after {
  content: "等待截图";
  color: #d6ded5;
  font: 700 12px "Avenir Next", "Hiragino Sans GB", "PingFang SC", sans-serif;
}

.window-task-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 12px 16px;
}

.window-task-footer > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.window-preview-dialog {
  width: min(100% - 32px, 1120px);
  max-height: calc(100vh - 48px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  box-shadow: 8px 8px 0 rgba(28, 37, 37, 0.18);
}

.window-preview-dialog::backdrop {
  background: rgba(28, 37, 37, 0.72);
}

.window-preview-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.window-preview-dialog-header h2,
.window-preview-dialog-header p {
  margin: 0;
}

.window-preview-dialog-header h2 {
  margin-top: 3px;
  font-size: 18px;
}

.window-preview-dialog img {
  display: block;
  width: 100%;
  max-height: calc(100vh - 150px);
  object-fit: contain;
  background: #1c2525;
}

.start-window-task,
.window-task-detail,
.activate-window-button,
.close-window-button {
  min-height: 26px;
  border-radius: 0;
  padding: 2px 8px;
  font: 700 12px "Avenir Next", "Hiragino Sans GB", "PingFang SC", sans-serif;
  cursor: pointer;
}

.start-window-task {
  border: 1px solid var(--ready);
  color: var(--paper);
  background: var(--ready);
}

.start-window-task:hover,
.start-window-task:focus-visible {
  color: var(--paper);
  background: var(--ink);
  outline: none;
}

.window-task-detail {
  border: 1px solid var(--ink);
  color: var(--ink);
  background: var(--paper);
}

.activate-window-button {
  border: 1px solid var(--ready);
  color: var(--ready);
  background: var(--paper);
}

.close-window-button {
  flex: 0 0 auto;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: var(--paper);
}

.window-task-detail:hover,
.window-task-detail:focus-visible,
.activate-window-button:hover,
.activate-window-button:focus-visible,
.close-window-button:hover,
.close-window-button:focus-visible {
  color: var(--paper);
  background: var(--ink);
  outline: none;
}

.section-heading {
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 12px;
}

.section-heading h2,
.section-heading p {
  margin-bottom: 0;
}

#tool-count {
  color: var(--muted);
  font-size: 14px;
}

.tool-list {
  background: var(--paper);
}

.tool-row {
  min-height: 72px;
  width: 100%;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-align: left;
  background: transparent;
  cursor: pointer;
}

.tool-row:hover,
.tool-row:focus-visible {
  background: #f3f6f0;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.tool-row:last-child {
  border-bottom: 1px solid var(--ink);
}

.tool-row:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.tool-name {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
}

.tool-description {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.tool-state {
  flex: 0 0 auto;
  padding: 5px 8px;
  color: var(--waiting);
  background: #fff3d7;
  font-size: 12px;
  font-weight: 700;
}

.tool-state.is-ready {
  color: var(--ready);
  background: #d9ede6;
}

.detail-heading,
.execution-controls,
.log-heading,
.action-buttons {
  display: flex;
  align-items: center;
}

.detail-heading {
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--ink);
}

.detail-heading > div {
  flex: 1;
  min-width: 0;
}

.detail-heading h2 {
  margin-bottom: 5px;
}

.task-window-label {
  margin: 8px 0 0;
  color: var(--muted);
  font: 12px "SFMono-Regular", "Menlo", monospace;
}

.icon-button {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 1px solid var(--ink);
  color: var(--ink);
  background: var(--paper);
  font-size: 22px;
  cursor: pointer;
}

.icon-button:hover,
.icon-button:focus-visible {
  color: var(--paper);
  background: var(--ink);
  outline: none;
}

.execution-controls {
  justify-content: space-between;
  gap: 24px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.coordinate-list {
  margin-top: 28px;
  border-bottom: 1px solid var(--line);
}

.coordinate-entry {
  display: flex;
  align-items: end;
  gap: 8px;
  padding: 0 0 14px;
}

.coordinate-entry label {
  display: grid;
  flex: 1;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.coordinate-entry input {
  width: min(100%, 280px);
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0 10px;
  color: var(--ink);
  background: var(--paper);
  font: 14px "SFMono-Regular", "Menlo", monospace;
}

.coordinate-list-error {
  margin: 0 0 12px;
  color: #7d2818;
  font-size: 13px;
}

.coordinate-items {
  display: grid;
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.coordinate-items li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.coordinate-items code {
  font: 14px "SFMono-Regular", "Menlo", monospace;
}

.coordinate-items .coordinate-list-empty {
  color: var(--muted);
  font-size: 14px;
}

.argument-field {
  display: grid;
  flex: 1;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.argument-field input,
.argument-field select {
  width: min(100%, 470px);
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0 10px;
  color: var(--ink);
  background: var(--paper);
  font: 14px "SFMono-Regular", "Menlo", monospace;
}

.argument-field input:focus,
.argument-field select:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(172, 60, 33, 0.18);
}

.option-checkbox {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.option-checkbox input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--ready);
}

.option-checkbox:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.4;
}

.action-buttons {
  flex: 0 0 auto;
  gap: 8px;
}

.command-button {
  min-width: 62px;
  min-height: 38px;
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 0 12px;
  color: var(--ink);
  background: var(--paper);
  font: 700 14px "Avenir Next", "Hiragino Sans GB", "PingFang SC", sans-serif;
  cursor: pointer;
}

.command-button:hover:not(:disabled),
.command-button:focus-visible:not(:disabled) {
  color: var(--paper);
  background: var(--ink);
  outline: none;
}

.start-button {
  border-color: var(--ready);
  color: var(--paper);
  background: var(--ready);
}

.stop-button {
  border-color: var(--accent);
  color: var(--accent);
}

.command-button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.window-runs {
  margin-top: 28px;
}

.player-status,
.task-screenshot {
  margin-top: 28px;
}

.task-screenshot-frame {
  display: grid;
  min-height: 180px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--paper);
}

.task-screenshot-frame img {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: contain;
}

.task-screenshot-frame p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.window-selection-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--ink);
}

.window-selection-heading .eyebrow,
.window-selection-heading h3,
.window-selection-heading > p {
  margin: 0;
}

.window-selection-heading h3 {
  font-family: "Songti SC", "STSong", serif;
  font-size: 20px;
  font-weight: 600;
}

.window-selection-heading > p {
  color: var(--muted);
  font-size: 13px;
}

.player-status-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-status-actions p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.window-run-list {
  border-bottom: 1px solid var(--ink);
  background: var(--paper);
}

.player-status-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  border: 1px solid var(--line);
  border-top: 0;
  background: var(--paper);
}

.player-status-facts div {
  min-width: 0;
  padding: 16px;
  border-right: 1px solid var(--line);
}

.player-status-facts div:last-child {
  border-right: 0;
}

.player-status-facts dt {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.player-status-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
  font: 700 22px "SFMono-Regular", "Menlo", monospace;
  font-variant-numeric: tabular-nums;
}

.window-run {
  display: flex;
  min-height: 68px;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.window-run:last-child {
  border-bottom: 0;
}

.window-run > div:first-child {
  display: grid;
  flex: 1;
  min-width: 0;
  gap: 3px;
}

.window-run strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.window-run small {
  color: var(--muted);
  font: 12px "SFMono-Regular", "Menlo", monospace;
}

.window-run-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.home-run {
  width: 100%;
  border: 0;
  color: inherit;
  text-align: left;
  background: var(--paper);
  cursor: pointer;
}

.home-run:hover,
.home-run:focus-visible {
  background: #f3f6f0;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.run-action {
  min-width: 48px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  background: var(--paper);
  font: 700 12px "Avenir Next", "Hiragino Sans GB", "PingFang SC", sans-serif;
  cursor: pointer;
}

.run-action:hover:not(:disabled),
.run-action:focus-visible:not(:disabled) {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
  outline: none;
}

.run-action.is-stop {
  border-color: var(--accent);
  color: var(--accent);
}

.run-action:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.window-list-empty {
  margin: 0;
  padding: 18px 16px;
  color: var(--muted);
  font-size: 14px;
}

.log-section {
  margin-top: 28px;
}

.log-heading {
  justify-content: space-between;
  padding-bottom: 10px;
}

.log-heading .eyebrow,
.log-heading h3 {
  margin: 0;
}

.log-heading h3 {
  font-family: "Songti SC", "STSong", serif;
  font-size: 20px;
  font-weight: 600;
}

.execution-log {
  min-height: 300px;
  max-height: 500px;
  margin: 0;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--ink);
  color: #d9ece0;
  background: #1c2525;
  font: 13px/1.6 "SFMono-Regular", "Menlo", monospace;
  white-space: pre-wrap;
}

.error-message {
  margin: 24px 0 0;
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
  color: #7d2818;
  background: var(--accent-soft);
  font-size: 14px;
}

@media (max-width: 700px) {
  .shell {
    width: min(100% - 24px, 1060px);
    padding-top: 28px;
  }

  .masthead,
  .service-overview,
  .service-facts {
    align-items: flex-start;
  }

  .masthead,
  .service-overview {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .service-facts {
    width: 100%;
    flex-direction: column;
  }

  h1 {
    font-size: 32px;
  }

  .tool-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .task-creation,
  .tool-detail,
  .window-layout,
  .diagnostics {
    margin-top: 36px;
  }

  .diagnostic-facts {
    grid-template-columns: 1fr 1fr;
  }

  .service-update {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .diagnostic-facts div:nth-child(2) {
    border-right: 0;
  }

  .arrangement-window {
    min-width: 0;
  }

  .window-preview {
    margin: 0 12px 12px;
  }

  .execution-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .action-buttons {
    flex-wrap: wrap;
  }

  .window-run {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .player-status-facts {
    grid-template-columns: 1fr;
  }

  .player-status-facts div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .player-status-facts div:last-child {
    border-bottom: 0;
  }

  .window-run-actions {
    width: 100%;
    margin-left: 0;
  }

  .run-action {
    flex: 1;
  }

  .argument-field input {
    width: 100%;
  }
}
