:root {
  color-scheme: light;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #edf3fb;
  color: #172033;
  font-synthesis: none;
  --primary: #0b5bd3;
  --primary-dark: #0848a8;
  --primary-soft: #e9f1ff;
  --border: #d9e2ef;
  --muted: #667085;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --warning: #9a6700;
  --warning-soft: #fff8e7;
  --success: #067647;
  --shadow: 0 12px 34px rgba(34, 65, 109, 0.09);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: #edf3fb;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 80% -10%, rgba(55, 129, 238, 0.2), transparent 34rem),
    linear-gradient(180deg, #f5f8fc 0%, #edf3fb 100%);
}

button,
textarea,
input {
  font: inherit;
}

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

button:focus-visible,
a:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(11, 91, 211, 0.28);
  outline-offset: 2px;
}

.app-shell {
  width: min(100%, 46rem);
  margin: 0 auto;
  padding:
    max(1.25rem, env(safe-area-inset-top))
    1rem
    max(2rem, env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.5rem 0.25rem 1.15rem;
}

.brand-mark {
  display: grid;
  width: 3.6rem;
  height: 3.6rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 1rem;
  background: linear-gradient(145deg, #1372ed, #073d98);
  box-shadow: 0 10px 24px rgba(11, 91, 211, 0.28);
  color: #fff;
  font-size: 1.6rem;
  font-weight: 800;
}

.brand-copy {
  min-width: 0;
}

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

h1 {
  margin-bottom: 0.2rem;
  font-size: clamp(1.55rem, 5vw, 2rem);
  line-height: 1.2;
}

h2 {
  margin-bottom: 0.25rem;
  font-size: 1.1rem;
}

h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

.eyebrow {
  margin-bottom: 0.25rem;
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.subtitle,
.help-text,
footer,
.session-details {
  color: var(--muted);
}

.subtitle {
  margin-bottom: 0;
  font-size: 0.9rem;
}

.job-history {
  margin-top: 1rem;
}

.job-history select {
  width: 100%;
  min-height: 44px;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: #fff;
  color: inherit;
  font: inherit;
}

.mobile-picker-note summary {
  cursor: pointer;
  min-height: 32px;
}

.identity-card,
.direction-card,
.work-card,
.operation-card {
  margin-bottom: 0.85rem;
  border: 1px solid rgba(217, 226, 239, 0.94);
  border-radius: 1.15rem;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.identity-card,
.direction-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
}

.identity-card h2 {
  margin-bottom: 0.2rem;
}

.identity-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.5rem;
}

.status-line,
.session-details,
.direction-summary {
  margin-bottom: 0;
}

.status-line {
  color: var(--muted);
  font-size: 0.9rem;
}

.session-details {
  margin-top: 0.25rem;
  font-size: 0.8rem;
}

.direction-summary {
  font-size: 1.05rem;
  font-weight: 750;
}

.field-label {
  display: block;
  margin-bottom: 0.45rem;
  color: #344054;
  font-size: 0.84rem;
  font-weight: 700;
}

.swap-button,
.text-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font-weight: 750;
}

.swap-button {
  min-width: 4rem;
  min-height: 2.75rem;
  border-radius: 999px;
  background: var(--primary-soft);
}

.swap-button:disabled,
.text-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  padding: 0.3rem;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  background: #e5edf7;
}

.mode-tab {
  min-height: 2.8rem;
  border: 0;
  border-radius: 0.68rem;
  background: transparent;
  color: #475467;
  cursor: pointer;
  font-weight: 750;
}

.mode-tab.is-active {
  background: #fff;
  box-shadow: 0 3px 12px rgba(34, 65, 109, 0.12);
  color: var(--primary);
}

.work-card {
  padding: 1rem;
}

.section-heading,
.result-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.section-heading {
  margin-bottom: 0.9rem;
}

.section-heading h2 {
  margin-bottom: 0;
}

.counter,
.file-limit {
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

textarea {
  width: 100%;
  min-height: 10rem;
  resize: vertical;
  margin-bottom: 0.85rem;
  padding: 0.85rem;
  border: 1px solid #cdd8e7;
  border-radius: 0.85rem;
  background: #fbfcfe;
  color: #172033;
  line-height: 1.65;
}

textarea::placeholder {
  color: #98a2b3;
}

.button {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 0.75rem;
  padding: 0.65rem 1rem;
  cursor: pointer;
  text-decoration: none;
  font-weight: 750;
}

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

.button-wide {
  width: 100%;
}

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

.button-primary:not(:disabled):active {
  background: var(--primary-dark);
}

.button-secondary {
  border-color: #cdd8e7;
  background: #fff;
  color: #344054;
}

.button-danger {
  border-color: #f5b7b1;
  background: var(--danger-soft);
  color: var(--danger);
}

.result-card,
.job-card,
.warning-card {
  margin-top: 0.9rem;
  border-radius: 0.9rem;
  padding: 0.9rem;
}

.result-card,
.job-card {
  border: 1px solid #d5e3f8;
  background: #f8fbff;
}

.warning-card {
  border: 1px solid #f1d38c;
  background: var(--warning-soft);
  color: #694b00;
}

.warning-card p {
  margin: 0.35rem 0 0.5rem;
  font-size: 0.86rem;
  line-height: 1.5;
}

.danger-text {
  color: var(--danger);
}

.text-result {
  max-height: 21rem;
  overflow: auto;
  margin: 0.75rem 0 0;
  padding: 0;
  background: transparent;
  color: #172033;
  font-family: inherit;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.file-source-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.65rem;
}

.file-picker {
  display: flex;
  min-height: 3.2rem;
  align-items: center;
  justify-content: center;
  border: 1px dashed #8cadda;
  border-radius: 0.85rem;
  background: var(--primary-soft);
  color: var(--primary);
  cursor: pointer;
  font-weight: 750;
}

.file-picker-camera {
  background: #f7faff;
}

.file-picker:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.5;
}

.file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 420px) {
  .file-source-actions {
    grid-template-columns: 1fr;
  }
}

.selected-file {
  min-height: 1.3rem;
  margin: 0.6rem 0 0.85rem;
  color: #475467;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.job-details {
  margin: 0.75rem 0;
}

.job-details div {
  display: grid;
  grid-template-columns: 4rem minmax(0, 1fr);
  gap: 0.5rem;
  padding: 0.3rem 0;
}

.job-details dt {
  color: var(--muted);
  font-size: 0.8rem;
}

.job-details dd {
  min-width: 0;
  margin: 0;
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.status-badge {
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  background: #e6edf6;
  color: #344054;
  font-size: 0.75rem;
  font-weight: 800;
}

.status-badge[data-tone="active"] {
  background: #e9f1ff;
  color: var(--primary);
}

.status-badge[data-tone="success"] {
  background: #e8f7ef;
  color: var(--success);
}

.status-badge[data-tone="error"] {
  background: var(--danger-soft);
  color: var(--danger);
}

.progress-track {
  height: 0.52rem;
  overflow: hidden;
  border-radius: 999px;
  background: #dce6f3;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0b5bd3, #48a2ff);
  transition: width 180ms ease;
}

.job-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-top: 0.8rem;
}

.download-receipt {
  margin-top: 0.8rem;
  border: 1px solid #b7ddc9;
  border-radius: 0.8rem;
  padding: 0.8rem;
  background: #f2fbf6;
}

.download-receipt p {
  margin-bottom: 0.65rem;
  line-height: 1.5;
}

.download-receipt .help-text {
  margin: 0.65rem 0 0.35rem;
  font-size: 0.78rem;
}

.download-url {
  display: block;
  overflow-wrap: anywhere;
  color: #475467;
  font-size: 0.7rem;
  line-height: 1.45;
  user-select: all;
}

.operation-card {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  box-shadow: none;
}

.operation-card p {
  flex: 1 1 10rem;
  min-width: 0;
  margin: 0;
  color: #475467;
  font-size: 0.86rem;
  line-height: 1.45;
}

#stopWaitingButton {
  flex: 0 0 auto;
  margin-left: auto;
  white-space: nowrap;
}

.operation-indicator {
  width: 0.62rem;
  height: 0.62rem;
  flex: 0 0 auto;
  margin-top: 0.3rem;
  border-radius: 50%;
  background: #98a2b3;
}

.operation-indicator[data-tone="busy"] {
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(11, 91, 211, 0.12);
}

.operation-indicator[data-tone="success"] {
  background: var(--success);
}

.operation-indicator[data-tone="error"] {
  background: var(--danger);
}

footer {
  padding: 0.5rem 0.35rem 0;
  text-align: center;
  font-size: 0.74rem;
  line-height: 1.5;
}

footer p {
  margin-bottom: 0;
}

@media (min-width: 42rem) {
  .app-shell {
    padding-right: 1.5rem;
    padding-left: 1.5rem;
  }

  .work-card,
  .identity-card,
  .direction-card {
    padding: 1.25rem;
  }

  .job-actions {
    grid-template-columns: repeat(4, 1fr);
  }
}

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