:root {
  color-scheme: light;
  --brand: #0b5cad;
  --brand-dark: #073f78;
  --brand-soft: #eaf3fb;
  --orange: #ef6c32;
  --green: #1d7a50;
  --ink: #162336;
  --muted: #607086;
  --line: #dce5ee;
  --surface: #ffffff;
  --background: #f2f6fa;
  --shadow: 0 14px 35px rgba(19, 58, 93, 0.1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 100% 0%, rgba(11, 92, 173, 0.1), transparent 32rem),
    var(--background);
}

button,
textarea,
input {
  font: inherit;
}

button,
label[for="imageInput"] {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 4px 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

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

h1 {
  margin-bottom: 6px;
  font-size: clamp(25px, 6vw, 36px);
  line-height: 1.12;
  letter-spacing: -0.03em;
}

.subtitle {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.bank-badge {
  flex: 0 0 auto;
  margin-top: 2px;
  padding: 7px 10px;
  border: 1px solid #bdd8ef;
  border-radius: 999px;
  color: var(--brand-dark);
  background: var(--brand-soft);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.search-panel,
.result-panel,
.usage-note {
  border: 1px solid rgba(220, 229, 238, 0.9);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.search-panel,
.result-panel {
  padding: 18px;
}

.result-panel,
.usage-note {
  margin-top: 14px;
}

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

.section-heading > div {
  display: flex;
  align-items: center;
  gap: 9px;
}

.step-number {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--brand);
  font-size: 11px;
  font-weight: 800;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.text-button {
  border: 0;
  padding: 8px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

textarea {
  display: block;
  width: 100%;
  min-height: 128px;
  resize: vertical;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  padding: 13px 14px;
  color: var(--ink);
  outline: none;
  background: #fbfdff;
  font-size: 15px;
  line-height: 1.6;
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(11, 92, 173, 0.12);
}

.primary-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}

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

.button-primary {
  color: #fff;
  background: var(--brand);
  box-shadow: 0 8px 18px rgba(11, 92, 173, 0.2);
}

.button-secondary {
  border-color: #b9c9d9;
  color: var(--brand-dark);
  background: #fff;
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 13px 0;
  color: #91a0af;
  font-size: 12px;
}

.divider::before,
.divider::after {
  height: 1px;
  flex: 1;
  background: var(--line);
  content: "";
}

.ocr-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) minmax(0, 1.2fr);
  align-items: center;
  gap: 12px;
}

.button-ocr {
  border-color: #f2c2ab;
  color: #a43e13;
  background: #fff5f0;
}

#imageInput {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.ocr-row p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.ocr-status {
  margin-top: 14px;
  border-radius: 12px;
  padding: 11px 12px;
  background: #f7fafc;
}

.progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e3eaf1;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), #46a1df);
  transition: width 0.25s ease;
}

.progress-copy {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.image-preview {
  margin-top: 12px;
}

.image-preview img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f6f8fa;
}

.confidence-chip {
  border-radius: 999px;
  padding: 6px 9px;
  color: var(--green);
  background: #e8f6ef;
  font-size: 12px;
  font-weight: 800;
}

.confidence-chip.medium {
  color: #9a4e0c;
  background: #fff2dc;
}

.confidence-chip.low {
  color: #9f3131;
  background: #fdecec;
}

.answer-card {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid #bfd8ed;
  border-radius: 14px;
  background: #f7fbff;
}

.answer-letter-wrap {
  display: flex;
  min-height: 108px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--brand);
}

.answer-letter-wrap span {
  font-size: 12px;
  font-weight: 700;
  opacity: 0.82;
}

.answer-letter-wrap strong {
  margin-top: 2px;
  font-size: 42px;
  line-height: 1;
}

.answer-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  padding: 16px;
}

.answer-copy > p:first-child {
  margin-bottom: 0;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.55;
}

.mapping-note {
  margin: 7px 0 0;
  color: var(--orange);
  font-size: 12px;
  font-weight: 700;
}

.matched-question,
.source-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.matched-question span,
.source-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.matched-question p,
.source-row p {
  margin-bottom: 0;
  font-size: 14px;
  line-height: 1.55;
}

.source-row p {
  color: var(--green);
}

.warning-message {
  margin-top: 14px;
  border-left: 3px solid var(--orange);
  border-radius: 8px;
  padding: 10px 12px;
  color: #7d3a17;
  background: #fff5ee;
  font-size: 13px;
  line-height: 1.5;
}

.candidate-block {
  margin-top: 16px;
}

.candidate-block h3 {
  margin-bottom: 5px;
  font-size: 15px;
}

.candidate-hint {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.candidate-button {
  display: grid;
  width: 100%;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: start;
  gap: 9px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px;
  text-align: left;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
}

.candidate-rank {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  color: var(--brand);
  background: var(--brand-soft);
  font-size: 12px;
  font-weight: 800;
}

.candidate-question {
  font-size: 13px;
  line-height: 1.5;
}

.candidate-score {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.usage-note {
  padding: 15px 17px;
  box-shadow: none;
}

.usage-note h2 {
  margin-bottom: 6px;
  font-size: 14px;
}

.usage-note p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 4px 0;
  color: #8291a1;
  font-size: 11px;
}

.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  width: max-content;
  max-width: calc(100vw - 36px);
  transform: translateX(-50%);
  border-radius: 10px;
  padding: 10px 14px;
  color: #fff;
  background: rgba(22, 35, 54, 0.94);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  font-size: 13px;
  text-align: center;
}

.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;
}

[hidden] {
  display: none !important;
}

@media (max-width: 520px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .app-header {
    gap: 10px;
  }

  .subtitle {
    max-width: 230px;
  }

  .search-panel,
  .result-panel {
    padding: 15px;
    border-radius: 16px;
  }

  .ocr-row {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .ocr-row p {
    text-align: center;
  }

  footer {
    flex-direction: column;
    align-items: center;
    gap: 4px;
  }
}

@media (max-width: 390px) {
  .bank-badge {
    display: none;
  }

  .primary-actions {
    grid-template-columns: 1fr;
  }

  .answer-card {
    grid-template-columns: 74px minmax(0, 1fr);
  }

  .matched-question,
  .source-row {
    grid-template-columns: 62px minmax(0, 1fr);
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .app-shell {
    padding-top: 10px;
  }

  .app-header {
    align-items: center;
    padding-bottom: 10px;
  }

  .eyebrow,
  .subtitle,
  .usage-note,
  footer {
    display: none;
  }

  h1 {
    margin-bottom: 0;
    font-size: 22px;
  }

  .search-panel,
  .result-panel {
    padding: 12px;
  }

  textarea {
    min-height: 86px;
  }
}

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