:root {
  --primary: #0F766E;
  --primary-2: #1D4E89;
  --primary-soft: #D3EFEA;
  --accent: #E8A33D;
  --bg: #F2F5F4;
  --surface: #FFFFFF;
  --ink: #1F2A30;
  --ink-soft: #5E6B72;
  --ink-faint: #97A3A8;
  --outline: #E2E8E6;
  --good: #16A34A;
  --warn: #E8A33D;
  --bad: #DC4C3E;
  --radius: 20px;
  --shadow: 0 1px 2px rgba(16, 40, 36, .04), 0 8px 24px rgba(16, 40, 36, .06);
  --arabic: "UKIJ Tuz", "Noto Naskh Arabic", "Noto Sans Arabic", "Microsoft Uighur", "Segoe UI", "Geeza Pro", "Tahoma", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
html { background: var(--bg); }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 880px; margin: 0 auto; padding: 0 20px; }

/* 顶部 */
.hero {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; padding: 36px 0 92px;
  padding-top: max(36px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { width: 52px; height: 52px; border-radius: 14px; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }
.hero h1 { margin: 0; font-size: 28px; letter-spacing: .5px; }
.brand p { margin: 2px 0 0; opacity: .82; font-size: 14px; }
.lead { margin: 18px 0 0; opacity: .88; font-size: 15px; max-width: 560px; }

main { margin-top: -64px; padding-bottom: 32px; }
.notice { background: #FFF6E6; color: #8A5A0B; border: 1px solid #F3DDB3; border-radius: 14px; padding: 10px 16px; margin-bottom: 14px; font-weight: 500; }
.notice.off { background: #FDECEA; color: #A1352B; border-color: #F5C9C3; }
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--outline); padding: 22px; margin-bottom: 18px;
}

/* 上传 */
.drop {
  border: 2px dashed #C9D6D2; border-radius: 16px; padding: 34px 18px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s; outline: none;
}
.drop:hover, .drop:focus-visible { border-color: var(--primary); background: #F6FBFA; }
.drop.over { border-color: var(--accent); background: #FFF8EC; }
.drop-icon { width: 46px; height: 46px; color: var(--primary); }
.drop-title { font-size: 17px; font-weight: 600; margin-top: 6px; }
.link { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.drop-sub { color: var(--ink-faint); font-size: 13px; margin-top: 4px; }
.btn.camera-btn { display: none; width: 100%; margin-top: 12px; }

.chips { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  background: #F1F6F5; border: 1px solid var(--outline); border-radius: 999px; padding: 5px 6px 5px 12px; font-size: 13px;
}
.chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.chip .size { color: var(--ink-faint); }
.chip button { border: 0; background: transparent; cursor: pointer; color: var(--ink-faint); width: 22px; height: 22px; border-radius: 50%; font-size: 15px; line-height: 1; }
.chip button:hover { background: #E3ECEA; color: var(--ink); }

.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 18px; }
.seg { display: inline-flex; background: #EEF3F2; border-radius: 14px; padding: 4px; }
.seg button {
  border: 0; background: transparent; padding: 8px 16px; border-radius: 10px; cursor: pointer;
  font: inherit; color: var(--ink-soft); display: flex; flex-direction: column; align-items: center; line-height: 1.25;
}
.seg button small { font-size: 11px; color: var(--ink-faint); }
.seg button.on { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.seg button:disabled { opacity: .45; cursor: not-allowed; }
.code {
  flex: 1; min-width: 140px; height: 48px; border: 1px solid var(--outline); border-radius: 12px; padding: 0 14px; font: inherit;
}
.code:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }

.btn {
  height: 48px; border-radius: 14px; padding: 0 22px; font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn svg { width: 20px; height: 20px; fill: currentColor; }
.btn.primary { background: var(--primary); color: #fff; margin-left: auto; min-width: 140px; box-shadow: 0 4px 14px rgba(15, 118, 110, .28); }
.btn.primary:hover:not(:disabled) { background: #0C655E; }
.btn.primary:disabled { background: #B9CCC8; box-shadow: none; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--primary); border-color: #BFD8D3; }
.btn.text { background: transparent; color: var(--primary); height: 36px; padding: 0 12px; }
.btn.text:hover { background: #EEF6F4; }
.error { margin-top: 14px; background: #FDECEA; color: #A1352B; border-radius: 12px; padding: 10px 14px; font-size: 14px; }

/* 进度 */
.status { padding: 16px 18px; }
.status-row { display: flex; align-items: center; gap: 14px; }
.status-text { flex: 1; min-width: 0; }
#statusMain { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-sub { color: var(--ink-faint); font-size: 13px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--primary-soft); border-top-color: var(--primary); animation: spin .8s linear infinite; flex: none; }
.spinner.done { animation: none; border-color: var(--good); position: relative; }
.spinner.done::after { content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px; border: solid var(--good); border-width: 0 3px 3px 0; transform: rotate(45deg); }
.spinner.fail { animation: none; border-color: var(--bad); }
.bar { height: 4px; background: var(--primary-soft); border-radius: 4px; margin-top: 12px; overflow: hidden; }
.bar-fill { height: 100%; width: 30%; background: var(--primary); border-radius: 4px; animation: slide 1.3s ease-in-out infinite; }
.bar.idle .bar-fill { animation: none; width: 100%; }
.bar.upload .bar-fill { animation: none; transition: width .2s; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }

/* 结果 */
.result { padding: 0; overflow: hidden; }
.result-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 12px 22px; border-bottom: 1px solid var(--outline); }
.result-head h2 { margin: 0 auto 0 0; font-size: 17px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--primary); }
.icon-btn:hover { background: #EEF6F4; }
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }
.switch { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 13px; cursor: pointer; margin-right: 4px; user-select: none; }
.switch input { display: none; }
.track { width: 38px; height: 22px; border-radius: 11px; background: #D5DEDB; position: relative; transition: background .15s; }
.thumb { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track .thumb { transform: translateX(16px); }

.result-body { padding: 8px 22px 22px; max-height: 70vh; overflow: auto; }
.fhead { display: flex; align-items: center; gap: 8px; margin: 18px 0 6px; font-weight: 600; font-size: 14px; color: var(--ink); }
.fhead::before { content: ""; width: 6px; height: 16px; border-radius: 3px; background: var(--primary); }
.fhead.sub { font-weight: 500; color: var(--ink-soft); }
.fhead.sub::before { background: var(--accent); }
.note { color: var(--ink-faint); font-size: 13px; margin: 2px 0 8px; }
.line { display: flex; align-items: baseline; gap: 12px; padding: 6px 0; border-bottom: 1px dashed #EEF2F1; }
.line:last-child { border-bottom: 0; }
.conf { flex: none; font: 12px/1 ui-monospace, Menlo, Consolas, monospace; color: var(--ink-faint); display: inline-flex; align-items: center; gap: 5px; min-width: 46px; }
.conf::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.conf.mid::before { background: var(--warn); }
.conf.low::before { background: var(--bad); }
.hide-conf .conf { display: none; }
.txt { flex: 1; font-family: var(--arabic); font-size: 19px; line-height: 1.75; unicode-bidi: plaintext; text-align: start; word-break: break-word; }
.block { font-family: var(--arabic); font-size: 18px; line-height: 1.8; white-space: pre-wrap; unicode-bidi: plaintext; word-break: break-word; margin: 4px 0 10px; }

.foot { color: var(--ink-faint); font-size: 12.5px; text-align: center; margin: 6px 0 0; }

.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); z-index: 20;
}
.dropmask {
  position: fixed; inset: 0; background: rgba(15, 118, 110, .12); border: 3px dashed var(--accent); z-index: 10;
  display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 600; color: var(--primary); pointer-events: none;
}

@media (max-width: 640px) {
  .wrap { padding: 0 14px; }
  .hero { padding-bottom: 84px; }
  .hero h1 { font-size: 24px; }
  .card { padding: 16px; border-radius: 18px; }
  .drop { padding: 26px 12px; }
  .btn.camera-btn { display: inline-flex; }
  .controls { gap: 10px; }
  .seg { width: 100%; }
  .seg button { flex: 1; }
  .btn.primary { width: 100%; margin-left: 0; }
  .result-head { padding-left: 16px; }
  .result-body { padding: 6px 16px 18px; max-height: none; }
  .txt { font-size: 18px; }
}
