:root {
  --page: #f6f8fa;
  --surface: #ffffff;
  --surface-subtle: #f8fafb;
  --ink: #17212b;
  --muted: #66717e;
  --border: #d7dee5;
  --border-strong: #bcc7d1;
  --blue: #1769c2;
  --blue-dark: #11549d;
  --blue-soft: #eaf3fc;
  --green: #198754;
  --green-soft: #e8f5ee;
  --red: #b42318;
  --red-soft: #fef0ee;
  --focus: #8bc4ff;
  --shadow: 0 8px 24px rgb(25 38 52 / 8%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--page);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--page);
  color: var(--ink);
  line-height: 1.5;
}

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

button {
  color: inherit;
}

button:not(:disabled),
[role="button"] {
  cursor: pointer;
}

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

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 8px 12px;
  border-radius: 4px;
  color: #fff;
  background: var(--blue-dark);
  transform: translateY(-150%);
}

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

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-inner,
.page-shell,
.site-footer {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
}

.header-inner {
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

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

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  background: var(--green);
  font-size: 14px;
  font-weight: 800;
}

.brand-text {
  font-size: 18px;
  font-weight: 700;
}

.privacy-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.privacy-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.page-shell {
  padding: 34px 0 48px;
}

.intro {
  margin-bottom: 26px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 38px);
  line-height: 1.2;
  letter-spacing: 0;
}

.intro-note {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.main-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: -1px;
  padding-left: 12px;
  position: relative;
  z-index: 1;
}

.main-tab {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  color: var(--muted);
  background: transparent;
  font-weight: 650;
}

.main-tab:hover {
  color: var(--ink);
  background: #eef2f5;
}

.main-tab.is-active {
  border-color: var(--border);
  color: var(--blue-dark);
  background: var(--surface);
}

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

.tool-options {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
}

.option-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.option-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.segmented {
  display: inline-flex;
  min-height: 36px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #eef2f5;
}

.segment {
  min-width: 112px;
  min-height: 28px;
  padding: 3px 12px;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.segment:hover {
  color: var(--ink);
}

.segment.is-active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1px 3px rgb(22 32 43 / 12%);
}

.segmented-small {
  min-height: 32px;
}

.segmented-small .segment {
  min-width: 82px;
  min-height: 24px;
  padding: 2px 9px;
  font-size: 12px;
}

.check-control {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.check-control input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--blue);
}

.check-control.compact {
  min-height: 36px;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.editor-pane {
  min-width: 0;
  padding: 18px;
}

.editor-pane + .editor-pane {
  border-left: 1px solid var(--border);
}

.field-heading {
  display: flex;
  min-height: 28px;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 7px;
}

.field-heading label {
  font-size: 14px;
  font-weight: 700;
}

.field-count {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

textarea {
  display: block;
  width: 100%;
  min-height: 282px;
  resize: vertical;
  padding: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  outline: 0;
  color: var(--ink);
  background: var(--surface);
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

textarea::placeholder,
input::placeholder {
  color: #919ba5;
}

textarea:focus,
.text-field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--focus);
}

textarea[readonly] {
  background: #fbfcfd;
}

.action-bar {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
}

.primary-actions,
.result-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button,
.icon-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 5px;
  font-weight: 680;
}

.button {
  min-width: 84px;
  padding: 7px 14px;
  font-size: 14px;
}

.button-primary {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
}

.button-primary:hover:not(:disabled) {
  border-color: var(--blue-dark);
  background: var(--blue-dark);
}

.button-secondary {
  border-color: #7ba7d4;
  color: var(--blue-dark);
  background: var(--blue-soft);
}

.button-secondary:hover:not(:disabled) {
  border-color: var(--blue);
  background: #dcecfb;
}

.button-quiet,
.icon-button {
  border-color: var(--border-strong);
  color: #34404c;
  background: var(--surface);
}

.button-quiet:hover:not(:disabled),
.icon-button:hover:not(:disabled) {
  border-color: #8795a3;
  background: #f1f4f6;
}

.icon-button {
  width: 38px;
  min-width: 38px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

button:focus-visible,
[role="button"]:focus-visible,
input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.status-line {
  min-height: 23px;
  margin: 0;
  padding: 7px 18px 10px;
  color: var(--muted);
  font-size: 13px;
}

.status-line.is-success {
  color: var(--green);
}

.status-line.is-error {
  color: var(--red);
}

.file-mode-options {
  justify-content: flex-start;
}

.drop-zone {
  display: flex;
  min-height: 190px;
  margin: 22px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 7px;
  border: 2px dashed var(--border-strong);
  border-radius: 7px;
  color: var(--muted);
  background: var(--surface-subtle);
  text-align: center;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.drop-zone strong {
  color: var(--ink);
  font-size: 16px;
}

.drop-zone span:last-child {
  font-size: 13px;
}

.upload-symbol {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid #9ab8d7;
  border-radius: 50%;
  color: var(--blue);
  background: #fff;
  font-size: 24px;
  font-weight: 700;
}

.file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 22px 18px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-subtle);
}

.file-info > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.file-info strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-info span {
  color: var(--muted);
  font-size: 12px;
}

.image-preview {
  margin: 0 22px 20px;
  padding: 16px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: #f3f5f7;
  text-align: center;
}

.image-preview img {
  display: block;
  max-width: 100%;
  max-height: 360px;
  margin: 0 auto;
  object-fit: contain;
}

.image-preview figcaption {
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

.file-output-block,
.decode-file-form {
  padding: 0 22px 22px;
}

.file-output-heading {
  align-items: center;
}

.file-output-block textarea,
.decode-file-form textarea {
  min-height: 210px;
}

.file-actions .status-line {
  padding: 0;
}

.decode-file-form {
  padding-top: 22px;
}

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.text-field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 650;
}

.text-field input {
  width: 100%;
  min-height: 40px;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  outline: 0;
  color: var(--ink);
  background: var(--surface);
  font-weight: 400;
}

.site-footer {
  display: flex;
  min-height: 70px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 44px));
  padding: 11px 15px;
  border: 1px solid #9ac9af;
  border-radius: 6px;
  color: #115c3b;
  background: var(--green-soft);
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 650;
}

.toast.is-error {
  border-color: #efb2aa;
  color: var(--red);
  background: var(--red-soft);
}

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

[hidden] {
  display: none !important;
}

@media (max-width: 820px) {
  .editor-grid {
    grid-template-columns: 1fr;
  }

  .editor-pane + .editor-pane {
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  textarea {
    min-height: 230px;
  }

  .action-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .result-actions {
    justify-content: flex-end;
  }

  .file-actions .status-line {
    min-height: 23px;
  }
}

@media (max-width: 600px) {
  .header-inner,
  .page-shell,
  .site-footer {
    width: min(100% - 24px, 1120px);
  }

  .page-shell {
    padding-top: 24px;
  }

  .privacy-state {
    font-size: 0;
  }

  .privacy-state::after {
    content: "本地处理";
    font-size: 12px;
  }

  .intro {
    margin-bottom: 22px;
  }

  h1 {
    font-size: 28px;
  }

  .main-tabs {
    padding-left: 6px;
  }

  .main-tab {
    min-width: 0;
    flex: 1;
    padding: 0 8px;
  }

  .tool-options {
    align-items: stretch;
    flex-direction: column;
    gap: 9px;
  }

  .option-group {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
  }

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

  .segment {
    min-width: 0;
    white-space: normal;
  }

  .editor-pane {
    padding: 14px;
  }

  textarea {
    min-height: 210px;
  }

  .action-bar {
    padding: 12px 14px;
  }

  .primary-actions,
  .result-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .icon-button {
    width: 100%;
  }

  .check-control.compact {
    justify-content: center;
  }

  .button {
    min-width: 0;
  }

  .status-line {
    padding-right: 14px;
    padding-left: 14px;
  }

  .drop-zone {
    min-height: 170px;
    margin: 16px;
    padding: 20px;
  }

  .file-info,
  .image-preview {
    margin-right: 16px;
    margin-left: 16px;
  }

  .file-output-block,
  .decode-file-form {
    padding-right: 16px;
    padding-left: 16px;
  }

  .file-output-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .site-footer {
    align-items: flex-start;
    justify-content: center;
    flex-direction: column;
    gap: 2px;
  }
}

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