@font-face {
  font-family: "IBM Plex Sans";
  src: url("/fonts/plex-400.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans";
  src: url("/fonts/plex-500.ttf") format("truetype");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans";
  src: url("/fonts/plex-600.ttf") format("truetype");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

:root {
  --ground: #edf3f2;
  --surface: #ffffff;
  --raised: #f4f7f7;
  --border: #dce5e3;
  --rule: #edf1f0;
  --control: #cbd6d3;
  --text: #131716;
  --muted: #58615f;
  --faint: #6d7775;
  --accent: #1b6c80;
  --accent-pale: #e4f0f2;
  --negative: #a93435;
  --negative-pale: #fbe9e9;
  --primary: #171b1a;
  --radius-sheet: 16px;
  --radius-panel: 10px;
  --radius-control: 7px;
  --gap: 24px;
  --pad: 24px;
  --font: "IBM Plex Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--ground);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background: var(--ground);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button,
summary,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-frame {
  min-height: 100vh;
  padding: 0 8px 8px;
}

.topbar {
  min-height: 56px;
  padding: max(8px, env(safe-area-inset-top)) 8px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
}

.brand-mark {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.connection {
  color: var(--muted);
  font-size: 13px;
}

.connection::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--faint);
  vertical-align: 1px;
}

.connection.online::before {
  background: var(--accent);
}

.connection.offline::before {
  background: var(--negative);
}

.sheet {
  width: min(100%, 1080px);
  margin: 0 auto 8px;
  padding: var(--pad);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sheet);
}

.title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--gap);
  margin-bottom: 28px;
}

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

h1 {
  margin-bottom: 6px;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.title-row p {
  margin-bottom: 0;
  max-width: 54ch;
  color: var(--muted);
  font-size: 14px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(320px, 0.88fr);
  gap: var(--gap);
  align-items: stretch;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  padding: 20px;
}

.form-panel {
  background: var(--surface);
}

.status-panel {
  background: var(--raised);
}

.status-stack {
  display: grid;
  gap: 16px;
  align-content: start;
}

.notes-panel {
  background: var(--surface);
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: 16px;
  font-weight: 600;
}

.section-heading > span {
  color: var(--muted);
  font-size: 13px;
}

.field {
  margin-bottom: 18px;
}

.field > label,
.label-row label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
}

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

.label-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

input[type="password"],
input[type="text"],
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 3px solid var(--accent-pale);
  outline-offset: 1px;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.remember {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.remember input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.primary-button,
.secondary-link {
  min-height: 44px;
  border-radius: var(--radius-control);
  cursor: pointer;
}

.primary-button {
  width: 100%;
  padding: 10px 16px;
  color: #fff;
  background: var(--primary);
  border: 1px solid var(--primary);
  font-weight: 500;
}

.primary-button:hover {
  background: #2a302f;
}

.primary-button:active {
  transform: translateY(1px);
}

.primary-button:focus-visible,
.secondary-link:focus-visible,
.text-button:focus-visible,
summary:focus-visible,
.brand:focus-visible {
  outline: 3px solid var(--accent-pale);
  outline-offset: 2px;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.text-button {
  padding: 0;
  color: var(--accent);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 13px;
}

.help {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 13px;
}

.help summary {
  color: var(--text);
  cursor: pointer;
}

.help p {
  margin: 10px 0 0;
}

code {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.pill-neutral {
  color: #353a39;
  background: #e8eceb;
}

.pill-active {
  color: var(--accent);
  background: var(--accent-pale);
}

.pill-success {
  color: #0a5537;
  background: #dff5e8;
}

.pill-error {
  color: var(--negative);
  background: var(--negative-pale);
}

.flow {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 4px 0 20px;
}

.flow-step {
  min-width: 0;
  padding-top: 10px;
  border-top: 4px solid #d9dfdd;
  color: var(--muted);
}

.flow-step strong {
  display: block;
  font-size: 13px;
  font-weight: 500;
}

.flow-step.complete {
  border-color: var(--accent);
  color: var(--text);
}

.flow-step.active {
  border-color: var(--accent);
  color: var(--accent);
}

.flow-step.error {
  border-color: var(--negative);
  color: var(--negative);
}

.empty-copy,
.status-message {
  margin-bottom: 0;
  color: var(--muted);
}

.notes-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  color: var(--muted);
  list-style: none;
}

.notes-list li {
  padding-left: 14px;
  position: relative;
}

.notes-list li::before {
  content: "";
  position: absolute;
  top: 0.62em;
  left: 0;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.status-message {
  min-height: 42px;
  color: var(--text);
}

.job-meta {
  margin: 20px 0 0;
  padding: 12px;
  color: var(--muted);
  background: var(--surface);
  border-radius: 6px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.result-actions {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--control);
  text-decoration: none;
}

.error-box {
  padding: 14px;
  color: var(--negative);
  background: var(--negative-pale);
  border-radius: 7px;
}

.error-box p {
  margin: 5px 0 12px;
  color: #682426;
}

.noscript {
  margin: 16px;
  padding: 12px;
  color: var(--negative);
  background: var(--negative-pale);
}

@media (max-width: 760px) {
  .app-frame {
    padding: 0;
  }

  .topbar {
    min-height: 58px;
    padding: max(9px, env(safe-area-inset-top)) 18px 9px;
  }

  .sheet {
    width: 100%;
    min-height: calc(100vh - 58px);
    padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
    border: 0;
    border-radius: 0;
  }

  h1 {
    font-size: 24px;
  }

  .title-row {
    margin-bottom: 20px;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .panel {
    padding: 16px;
  }

  .section-heading {
    margin-bottom: 16px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .primary-button,
  .secondary-link,
  .connection,
  .flow-step {
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 120ms ease;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}
