:root {
  --ink: #17211d;
  --muted: #66716c;
  --line: #dce3df;
  --paper: #ffffff;
  --canvas: #f2f5f3;
  --green: #176b50;
  --green-dark: #10513c;
  --mint: #dff0e8;
  --coral: #e56b53;
  --warning: #a85a21;
  --shadow: 0 10px 30px rgba(22, 46, 36, 0.07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  height: 68px;
  padding: 0 4vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  background: #13261f;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  color: #10221b; background: #9cd3b8; border-radius: 6px;
}
.brand-mark svg { width: 21px; }
.brand div { display: grid; gap: 2px; }
.brand strong { font-size: 14px; }
.brand div span { color: #b9c8c1; font-size: 12px; }
.privacy { display: flex; align-items: center; gap: 7px; color: #c8d6d0; font-size: 12px; }
.privacy svg { width: 16px; }

main { width: min(1440px, 94vw); margin: 0 auto; padding: 30px 0 52px; }
.workspace-head { display: flex; justify-content: space-between; align-items: end; margin-bottom: 24px; }
.eyebrow { margin: 0 0 7px; color: var(--green); font-size: 11px; font-weight: 800; }
h1 { margin: 0; font-size: clamp(25px, 3vw, 38px); font-weight: 750; }
.step-track { display: flex; gap: 22px; color: #87918d; font-size: 12px; }
.step-track span { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.step-track b { width: 23px; height: 23px; display: grid; place-items: center; border: 1px solid #b9c3be; border-radius: 50%; }
.step-track .active { color: var(--green); font-weight: 700; }
.step-track .active b { color: #fff; border-color: var(--green); background: var(--green); }

.tool-layout { display: grid; grid-template-columns: minmax(320px, .78fr) minmax(480px, 1.22fr); gap: 18px; align-items: start; }
.left-column, .right-column { display: grid; gap: 18px; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 20px; }
.panel-title { min-height: 34px; margin-bottom: 17px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-title > div { display: flex; align-items: center; gap: 10px; }
.panel-title h2 { margin: 0; font-size: 16px; }
.index { color: var(--coral); font-size: 11px; font-weight: 800; }
.muted { color: var(--muted); font-size: 12px; }

.drop-zone {
  min-height: 215px; padding: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px;
  text-align: center; border: 1px dashed #9eb4aa; background: #f8fbf9; transition: .2s ease;
}
.drop-zone.dragging { border-color: var(--green); background: var(--mint); }
.drop-zone > span:not(.upload-icon) { color: var(--muted); font-size: 12px; }
.upload-icon { width: 46px; height: 46px; display: grid; place-items: center; color: var(--green); background: var(--mint); border-radius: 50%; }
.upload-icon svg { width: 22px; }

.primary, .secondary, .icon-button, .segmented button {
  border: 0; border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; transition: .15s ease;
}
.primary { min-height: 42px; padding: 0 17px; color: white; background: var(--green); font-weight: 700; }
.primary:hover:not(:disabled) { background: var(--green-dark); }
.primary:disabled { cursor: not-allowed; opacity: .45; }
.primary svg, .secondary svg { width: 17px; }
.secondary { min-height: 36px; padding: 0 13px; color: var(--green-dark); border: 1px solid #b9cbc2; background: #fff; font-weight: 650; }
.secondary:hover { background: #edf6f1; }
.full { width: 100%; margin-top: 14px; }
.compact { min-height: 34px; font-size: 12px; }
.icon-button { width: 34px; height: 34px; color: var(--muted); background: transparent; }
.icon-button:hover { color: var(--green); background: #edf4f0; }
.icon-button svg { width: 17px; }

.thumb-grid { margin-top: 12px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.thumb { position: relative; aspect-ratio: 1; overflow: hidden; border: 1px solid var(--line); background: #eef2ef; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 4px; right: 4px; width: 25px; height: 25px; display: grid; place-items: center; color: #fff; border: 0; border-radius: 50%; background: rgba(18, 32, 26, .78); }
.thumb button svg { width: 14px; }
.api-key-field { margin-top: 14px; display: grid; gap: 7px; color: #4d5954; font-size: 11px; font-weight: 700; }
.api-key-field small { color: var(--muted); font-weight: 400; line-height: 1.45; }
.secret-input { position: relative; display: block; }
.secret-input input { padding-right: 42px; font-family: Consolas, monospace; }
.secret-input .icon-button { position: absolute; top: 4px; right: 4px; }

.recognition-bar { margin-top: 13px; }
.recognition-bar > div { margin-bottom: 6px; display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
progress { width: 100%; height: 6px; border: 0; appearance: none; }
progress::-webkit-progress-bar { background: #e7ece9; }
progress::-webkit-progress-value { background: var(--green); }

textarea, input {
  width: 100%; color: var(--ink); border: 1px solid #cad4cf; border-radius: 5px; outline: none; background: #fff;
}
input { height: 41px; padding: 0 11px; }
textarea { padding: 11px; resize: vertical; line-height: 1.55; }
input:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 107, 80, .09); }
#ocrText { min-height: 205px; }
.field-note { margin: 10px 0 0; display: flex; align-items: flex-start; gap: 6px; color: var(--warning); font-size: 11px; line-height: 1.45; }
.field-note svg { width: 15px; flex: 0 0 auto; }

.status-badge { padding: 5px 8px; color: var(--muted); border: 1px solid var(--line); border-radius: 3px; background: #f6f8f7; font-size: 11px; }
.status-badge.ready { color: var(--green-dark); border-color: #b7d8c8; background: var(--mint); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid label { display: grid; gap: 7px; color: #4d5954; font-size: 11px; font-weight: 700; }
.form-grid .wide { grid-column: 1 / -1; }

.language-row { margin-top: 18px; padding-top: 17px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: end; gap: 16px; }
.language-row > div > span { display: block; margin-bottom: 7px; color: #4d5954; font-size: 11px; font-weight: 700; }
.segmented { padding: 3px; display: flex; border: 1px solid var(--line); border-radius: 6px; background: #f5f7f6; }
.segmented button { min-height: 30px; padding: 0 11px; color: var(--muted); background: transparent; font-size: 11px; }
.segmented button.selected { color: var(--green-dark); background: #fff; box-shadow: 0 1px 4px rgba(20, 48, 37, .12); font-weight: 750; }

.output-actions { gap: 5px !important; }
.output-panel { min-height: 360px; }
.output-empty { min-height: 268px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #8a9590; text-align: center; }
.output-empty svg { width: 34px; height: 34px; stroke-width: 1.3; }
.output-empty strong { color: #5e6964; font-size: 13px; }
.output-empty span { font-size: 11px; }
#outputText { min-height: 480px; font-family: inherit; line-height: 1.65; }
.hidden { display: none !important; }
.toast { position: fixed; left: 50%; bottom: 28px; padding: 10px 15px; color: #fff; border-radius: 5px; background: #17211d; box-shadow: var(--shadow); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .2s ease; font-size: 12px; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 900px) {
  .workspace-head { align-items: flex-start; gap: 20px; }
  .step-track { display: none; }
  .tool-layout { grid-template-columns: 1fr; }
  .left-column, .right-column { display: contents; }
  .upload-panel { order: 1; }
  .evidence-panel { order: 2; }
  .details-panel { order: 3; }
  .output-panel { order: 4; }
}

@media (max-width: 560px) {
  .topbar { height: 60px; padding: 0 16px; }
  .privacy { display: none; }
  main { width: calc(100% - 24px); padding-top: 22px; }
  .panel { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .language-row { align-items: stretch; flex-direction: column; }
  .language-row .primary { width: 100%; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; padding: 0 5px; }
}
