:root {
  color-scheme: light dark;
  --background: #f4f6f8;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --text: #17202a;
  --text-muted: #5b6775;
  --border: #d8dee6;
  --primary: #175cd3;
  --primary-hover: #124aa9;
  --primary-text: #ffffff;
  --accent: #087a55;
  --accent-soft: #e9f7f1;
  --danger: #b42318;
  --focus: #84adff;
  --shadow: 0 14px 36px rgba(29, 41, 57, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  min-height: 100dvh;
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
textarea,
input {
  font: inherit;
}

button,
label,
input {
  touch-action: manipulation;
}

.skip-link {
  position: fixed;
  z-index: 10;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  transform: translateY(-150%);
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--primary);
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  min-height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--text);
  color: var(--surface);
  font-weight: 750;
}

.service-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 14px;
}

.service-status > span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.workspace {
  width: min(100% - 32px, 760px);
  margin: 0 auto;
  padding: 56px 0 80px;
}

.tool {
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.tool-heading {
  margin-bottom: 32px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 750;
}

h1,
h2,
p {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.25;
}

h2 {
  margin: 0;
  font-size: 17px;
}

form {
  display: grid;
  gap: 24px;
}

.field-group,
.option-group {
  display: grid;
  gap: 8px;
}

label,
legend,
.toggle-title {
  font-weight: 650;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

textarea {
  width: 100%;
  min-height: 112px;
  padding: 14px 16px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-subtle);
  color: var(--text);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

textarea:hover {
  border-color: var(--text-muted);
}

textarea:focus-visible,
button:focus-visible,
input:focus-visible + label,
.switch input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.field-error {
  min-height: 24px;
  margin: 0;
  color: var(--danger);
  font-size: 14px;
}

.segmented-control {
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-subtle);
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control label {
  min-width: 0;
  min-height: 40px;
  display: grid;
  place-items: center;
  padding: 8px 12px;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
}

.segmented-control input:checked + label {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.12);
}

.toggle-row {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.toggle-row > div {
  display: grid;
}

.toggle-meta {
  color: var(--text-muted);
  font-size: 14px;
}

.switch {
  position: relative;
  width: 52px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch > span[aria-hidden] {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: #98a2b3;
  transition: background-color 180ms ease;
}

.switch > span[aria-hidden]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 180ms ease;
}

.switch input:checked + span {
  background: var(--accent);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

button {
  min-height: 48px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.primary-button {
  width: 100%;
  background: var(--primary);
  color: var(--primary-text);
}

.primary-button:hover {
  background: var(--primary-hover);
}

.download-status {
  min-height: 24px;
  margin: -12px 0 0;
  color: var(--accent);
  text-align: center;
  font-size: 14px;
  font-weight: 650;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 560px) {
  .topbar {
    min-height: 56px;
    padding: 0 16px;
  }

  .service-status {
    font-size: 12px;
  }

  .workspace {
    width: 100%;
    padding: 0;
  }

  .tool {
    min-height: calc(100dvh - 56px);
    padding: 28px 20px 40px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .tool-heading {
    margin-bottom: 28px;
  }

  h1 {
    font-size: 26px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #11151a;
    --surface: #1a2027;
    --surface-subtle: #222a33;
    --text: #f1f5f9;
    --text-muted: #aab6c3;
    --border: #3b4653;
    --primary: #6ea2ff;
    --primary-hover: #8db5ff;
    --primary-text: #071426;
    --accent: #5bd3a6;
    --accent-soft: #153c31;
    --danger: #ff8a80;
    --focus: #8db5ff;
    --shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
  }

  .brand-mark {
    background: #f1f5f9;
    color: #11151a;
  }

}

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