/* כלי החתימה של ישרים. עקרונות הפורטל (Rubik, כרטיסים מעוגלים, כפתורים גדולים) בפלטה הסגולה-כהה. */
:root {
  --night: #0E0B1D;
  --deep: #2A1E4D;
  --purple: #5A3B8C;
  --lavender: #8B7CC7;
  --mist: #C9C2E3;
  --slate: #3A3A52;
  --ground: #F5F3FB;
  --card: #FFFFFF;
  --line: #E6E1F3;
  --line-soft: #F0EDF8;
  --muted: #5D5A73;
  --tint: #ECE8F7;
  --red-ink: #A3151B;
  --red-soft: #FDEEEF;
  --ok-ink: #2A1E4D;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Rubik', sans-serif; background: var(--ground); color: var(--night); font-size: 16px; -webkit-text-size-adjust: 100%; }
a { color: var(--purple); }
a:hover { color: var(--deep); }
h1, h2, h3 { margin: 0; font-weight: 700; }
p { margin: 0; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.mono { font-family: Consolas, Menlo, monospace; font-size: 12px; word-break: break-all; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.hidden { display: none !important; }

/* טפסים וכפתורים */
label { display: block; font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.field { width: 100%; height: 50px; border: 1.5px solid var(--mist); border-radius: 12px; padding: 0 14px; font: inherit; color: var(--night); background: #fff; }
select.field { padding-inline-end: 8px; }
.field.file { padding: 11px 12px; font-size: 14px; }
.field:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(90,59,140,.18); }
.field.code { font-size: 26px; letter-spacing: 6px; text-align: center; height: 60px; direction: ltr; }
.field.code.idnum { letter-spacing: 3px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.formgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.formgrid .wide { grid-column: 1 / -1; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.45; }
.check { display: flex; gap: 12px; align-items: flex-start; font-weight: 500; line-height: 1.45; margin: 0; cursor: pointer; }
.check input { width: 22px; height: 22px; flex-shrink: 0; accent-color: var(--purple); margin: 1px 0 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 22px; border: 0; border-radius: 13px; background: var(--purple); color: #fff; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--deep); color: #fff; }
.btn.block { display: flex; width: 100%; min-height: 56px; font-size: 18px; border-radius: 14px; }
.btn.outline { background: #fff; color: var(--purple); border: 1.5px solid var(--mist); }
.btn.outline:hover { background: var(--tint); color: var(--deep); }
.btn.quiet { background: var(--tint); color: var(--deep); }
.btn.quiet:hover { background: var(--mist); color: var(--deep); }
.btn.danger { background: #fff; color: var(--red-ink); border: 1.5px solid #F2C9CB; }
.btn.danger:hover { background: var(--red-soft); color: var(--red-ink); }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btnrow { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btnrow form { margin: 0; }
.linkbtn { background: none; border: 0; padding: 8px 4px; font: inherit; font-weight: 600; color: var(--mist); cursor: pointer; min-height: 44px; }
.linkbtn:hover { color: #fff; }

.error { background: var(--red-soft); color: var(--red-ink); border-radius: 12px; padding: 12px 14px; font-size: 15px; font-weight: 600; }
.notice { background: var(--tint); color: var(--deep); border-radius: 12px; padding: 12px 14px; font-size: 15px; font-weight: 600; line-height: 1.45; }
.dev { background: #FFF6DB; color: #6B4E00; border-radius: 12px; padding: 10px 14px; font-size: 14px; }
.card { background: var(--card); border-radius: 20px; padding: 22px; box-shadow: 0 1px 2px rgba(14,11,29,.06); }
.card h2 { font-size: 20px; }
.card .head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

/* תגיות סטטוס */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.st-waiting { background: #EEEDF3; color: var(--slate); }
.st-sent { background: #E4E9FB; color: #2F45A8; }
.st-viewed { background: #DDF1F8; color: #0C6480; }
.st-opened, .st-partial { background: #FDEFD6; color: #8A5600; }
.st-signed { background: #17924E; color: #fff; }
.st-sealing { background: #FFF1D6; color: #7A5200; }
.st-cancelled, .st-expired { background: #ECEBEF; color: var(--muted); }
.st-send_failed { background: var(--red-soft); color: var(--red-ink); }

/* ניהול: מבנה */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.side { background: linear-gradient(180deg, var(--night), var(--deep)); color: #fff; padding: 22px 16px; display: flex; flex-direction: column; gap: 26px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand:hover { color: #fff; }
.brand img { width: 36px; height: auto; background: #fff; border-radius: 10px; padding: 4px; }
.brand b { font-size: 22px; font-weight: 800; display: block; line-height: 1.1; }
.brand small { font-size: 12px; color: var(--mist); }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav a { display: flex; align-items: center; justify-content: space-between; min-height: 46px; padding: 0 14px; border-radius: 12px; color: var(--mist); text-decoration: none; font-weight: 600; }
.nav a:hover { background: rgba(201,194,227,.12); color: #fff; }
.nav a.on { background: var(--purple); color: #fff; }
.side .who { font-size: 14px; color: var(--mist); border-top: 1px solid rgba(201,194,227,.2); padding-top: 12px; }
.main { padding: 28px 32px 48px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.pagehead h1 { font-size: 28px; }

/* כרטיסי מונה */
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--card); border-radius: 16px; padding: 14px 16px; text-decoration: none; color: var(--night); display: flex; flex-direction: column; gap: 4px; border: 2px solid transparent; box-shadow: 0 1px 2px rgba(14,11,29,.06); }
.stat:hover { border-color: var(--mist); color: var(--night); }
.stat.on { border-color: var(--purple); }
.stat b { font-size: 26px; font-weight: 700; }
.stat span { font-size: 14px; color: var(--muted); font-weight: 600; }
.stat { border-top: 4px solid var(--mist); }
.stat.c-sent { border-top-color: #4F66D8; }
.stat.c-viewed { border-top-color: #1E9CC4; }
.stat.c-opened { border-top-color: #E8982A; }
.stat.c-signed { border-top-color: #17924E; }
.stat.c-signed b { color: #17924E; }
.stat.c-attention { border-top-color: #D8343C; }
.stat.on { border-color: var(--purple); border-top-width: 4px; }
/* התקדמות בשורה: ארבע נקודות, נשלח עד נחתם */
.track { display: inline-flex; gap: 4px; direction: rtl; }
.track i { width: 18px; height: 7px; border-radius: 4px; background: #E7E4F1; }
.stage-sent i:nth-child(-n+1) { background: #4F66D8; }
.stage-viewed i:nth-child(-n+2) { background: #1E9CC4; }
.stage-opened i:nth-child(-n+3), .stage-partial i:nth-child(-n+3) { background: #E8982A; }
.stage-signed i, .stage-sealing i { background: #17924E; }
.stage-send_failed i:first-child { background: #D8343C; }
/* עדכון חי */
.livebar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.livedot { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.livedot::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #B9B6C6; }
.livedot.on { color: #17924E; }
.livedot.on::before { background: #17924E; animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { background-color: #FFF4CF; } 100% { background-color: transparent; } }
@media (prefers-reduced-motion: reduce) { .livedot.on::before, .flash { animation: none; } }
.chipdate { font-size: 14px; color: var(--muted); white-space: nowrap; }
.version { display: block; font-size: 12px; opacity: .75; margin-top: 2px; }

.search { display: flex; gap: 10px; }
.search .field { flex: 1; min-width: 0; }

/* טבלה */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: start; font-size: 13px; color: var(--muted); font-weight: 600; padding: 0 12px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 13px 12px; border-bottom: 1px solid var(--line-soft); font-size: 15px; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table a.rowlink { color: var(--night); font-weight: 600; text-decoration: none; }
.table a.rowlink:hover { color: var(--purple); }
.table tbody tr:hover { background: #FBFAFE; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); line-height: 1.5; }
.num { font-size: 13px; color: var(--muted); direction: ltr; unicode-bidi: isolate; display: inline-block; }

/* פרטי מסמך */
.doc-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.signer-row { display: flex; flex-direction: column; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line-soft); }
.head + .signer-row { border-top: 0; padding-top: 0; }
.signer-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.step { background: var(--line-soft); border-radius: 10px; padding: 8px 8px; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.step b { font-weight: 700; }
.step.done.s-sent { background: #E4E9FB; color: #2F45A8; }
.step.done.s-viewed { background: #DDF1F8; color: #0C6480; }
.step.done.s-opened { background: #FDEFD6; color: #8A5600; }
.step.done.s-signed { background: #17924E; color: #fff; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li { position: relative; padding: 0 22px 16px 0; font-size: 14px; line-height: 1.4; }
.timeline li::before { content: ""; position: absolute; right: 3px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--lavender); }
.timeline .ev-sent::before, .timeline .ev-resent::before { background: #4F66D8; }
.timeline .ev-viewed::before { background: #1E9CC4; }
.timeline .ev-opened::before, .timeline .ev-copy_opened::before { background: #E8982A; }
.timeline .ev-signed::before, .timeline .ev-sealed::before, .timeline .ev-copy_unlocked::before { background: #17924E; }
.timeline .ev-send_failed::before, .timeline .ev-id_failed::before, .timeline .ev-otp_failed::before,
.timeline .ev-copy_bad_password::before, .timeline .ev-copy_locked::before, .timeline .ev-seal_failed::before { background: #D8343C; }
.timeline li::after { content: ""; position: absolute; right: 7px; top: 17px; bottom: -3px; width: 1.5px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline b { display: block; font-weight: 600; }
.timeline .meta { color: var(--muted); font-size: 13px; }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; min-width: 0; }
.dl { margin: 0; }
.secret { font-size: 26px; font-weight: 700; letter-spacing: 3px; direction: ltr; unicode-bidi: isolate; background: var(--tint); color: var(--deep); padding: 10px 14px; border-radius: 12px; text-align: center; }
.linkbox { font-size: 13px; word-break: break-all; direction: ltr; unicode-bidi: isolate; display: block; background: var(--line-soft); border-radius: 10px; padding: 8px 10px; }

/* תבניות */
.tpl-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line-soft); flex-wrap: wrap; }
.tpl-row:first-child { border-top: 0; }
.tag { font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: var(--tint); color: var(--deep); }

/* מסך הגדרת שדות */
.builder { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.tools { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 14px; max-height: calc(100vh - 32px); overflow-y: auto; }
.palette { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.palette button { min-height: 44px; border-radius: 10px; border: 1.5px solid var(--mist); background: #fff; font: inherit; font-size: 14px; font-weight: 600; color: var(--deep); cursor: pointer; }
.palette button:hover { background: var(--tint); }
.palette button.on { background: var(--purple); border-color: var(--purple); color: #fff; }
.pages { display: flex; flex-direction: column; gap: 16px; align-items: center; min-width: 0; }
.sheet { position: relative; width: 100%; max-width: 820px; background: #fff; box-shadow: 0 2px 12px rgba(14,11,29,.14); touch-action: pan-y; }
.sheet img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.sheet.placing { cursor: crosshair; touch-action: none; }
.box.ghost { background: rgba(90,59,140,.2); border-style: dashed; pointer-events: none; }
.box { position: absolute; border: 1px solid var(--purple); background: rgba(139,124,199,.28); border-radius: 2px; font-size: 9px; color: var(--deep); font-weight: 700; display: flex; align-items: center; justify-content: center; overflow: hidden; white-space: nowrap; cursor: move; touch-action: none; }
.box.sig { background: rgba(90,59,140,.3); }
.box.role2 { border-color: var(--slate); border-style: dashed; }
.box.sel { outline: 2px solid var(--night); z-index: 3; }
.box .grip { position: absolute; left: 0; bottom: 0; width: 9px; height: 9px; background: var(--purple); cursor: nesw-resize; touch-action: none; }

/* צד הלקוח */
.wrap { max-width: 480px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.wrap.wide { max-width: 760px; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 14px 20px; background: linear-gradient(135deg, var(--night), var(--deep)); color: #fff; }
.topbar img { width: 34px; height: auto; background: #fff; border-radius: 9px; padding: 3px; }
.topbar b { font-size: 21px; font-weight: 800; }
.content { display: flex; flex-direction: column; gap: 20px; padding: 24px 20px 32px; flex: 1; }
.hero { background: linear-gradient(135deg, var(--deep), var(--purple)); color: #fff; border-radius: 20px; padding: 24px 22px; display: flex; flex-direction: column; gap: 8px; }
.hero h1 { font-size: 26px; line-height: 1.2; }
.hero p { color: var(--mist); line-height: 1.5; }
.lead { font-size: 16px; line-height: 1.55; color: var(--muted); }
.foot { padding: 16px 20px 24px; font-size: 13px; color: var(--muted); text-align: center; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.lockline { display: inline-flex; align-items: center; gap: 6px; }
.icon { width: 18px; height: 18px; flex-shrink: 0; }
.bigicon { width: 64px; height: 64px; border-radius: 50%; background: var(--tint); color: var(--purple); display: flex; align-items: center; justify-content: center; align-self: center; }
.bigicon svg { width: 32px; height: 32px; }
.center { text-align: center; }
.doc-pages { display: flex; flex-direction: column; gap: 12px; margin: 0 -12px; }
.doc-pages img { display: block; width: 100%; height: auto; background: #fff; border-radius: 6px; box-shadow: 0 1px 6px rgba(14,11,29,.16); min-height: 300px; }
/* מסך החתימה */
.signbar { position: sticky; bottom: 0; margin: 0 -20px -32px; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); background: rgba(245,243,251,.96); border-top: 1px solid var(--line); z-index: 5; }
body.signing { overflow: hidden; }
.signsheet { position: fixed; inset: 0; z-index: 20; background: #fff; display: flex; flex-direction: column; gap: 12px; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); height: 100dvh; overscroll-behavior: contain; overflow-y: auto; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { font-size: 22px; }
.sheet-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.sheet-fields .field { height: 46px; }
.sheet-fields label { margin-bottom: 4px; font-size: 14px; }
.signsheet .pad-wrap { flex: 0 0 auto; height: min(38dvh, 290px); min-height: 190px; display: flex; }
.signsheet #sign_btn { margin-top: 4px; }
.signsheet .check { font-size: 17px; padding: 4px 0; }
.signsheet .check input { width: 26px; height: 26px; }
.btn[disabled] { background: #C9C6D6; color: #fff; opacity: 1; cursor: not-allowed; }
.pad-clear { position: absolute; top: 6px; left: 8px; background: rgba(255,255,255,.9); border: 1px solid var(--mist); border-radius: 10px; min-height: 40px; padding: 0 14px; font: inherit; font-weight: 700; color: var(--purple); cursor: pointer; }
.pad-wrap { position: relative; border: 2px dashed var(--mist); border-radius: 14px; background: #fff; touch-action: none; }
.pad-wrap canvas { display: block; width: 100%; height: 100%; min-height: 186px; border-radius: 12px; touch-action: none; }
.pad-hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--lavender); font-size: 18px; font-weight: 600; pointer-events: none; }
.pad-tools { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 14px; color: var(--muted); }
.textbtn { background: none; border: 0; font: inherit; font-weight: 700; color: var(--purple); cursor: pointer; min-height: 44px; padding: 0 4px; }
.sticky-bottom { position: sticky; bottom: 0; background: linear-gradient(0deg, var(--ground) 72%, rgba(245,243,251,0)); padding: 18px 0 14px; }
.viewer-bar { display: flex; gap: 10px; }
.viewer-bar .btn { flex: 1; }
.fingerprint { background: var(--line-soft); border-radius: 12px; padding: 12px 14px; font-size: 14px; display: flex; flex-direction: column; gap: 4px; }

/* כניסה לניהול */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: linear-gradient(160deg, var(--night), var(--deep) 60%, var(--purple)); }
.auth .card { width: 100%; max-width: 420px; padding: 30px 26px; display: flex; flex-direction: column; gap: 18px; box-shadow: 0 14px 44px rgba(14,11,29,.4); }
.auth-logo { display: flex; align-items: center; gap: 10px; }
.auth-logo img { width: 42px; }
.auth-logo b { font-size: 26px; font-weight: 800; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; padding: 12px 14px; gap: 10px; flex-direction: column; }
  .nav { flex-direction: row; overflow-x: auto; gap: 6px; }
  .nav a { white-space: nowrap; min-height: 42px; }
  .side .who { display: flex; justify-content: space-between; align-items: center; padding-top: 6px; }
  .main { padding: 18px 14px 40px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats .stat.c-signed { grid-column: 1 / -1; }
  .doc-grid, .builder { grid-template-columns: minmax(0, 1fr); }
  .tools { position: static; max-height: none; }
  .formgrid { grid-template-columns: minmax(0, 1fr); }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
  .table tr:last-child { border-bottom: 0; }
  .table td { border: 0; padding: 3px 0; }
  .card { padding: 18px 16px; }
}
@media (prefers-reduced-motion: no-preference) { .btn, .stat, .nav a { transition: background-color .12s, border-color .12s; } }

/* מסך הקוד, כמו בפורטל: 6 תיבות שה-JS מפעיל (בלי JS נשאר השדה הרגיל), בצבעי כלי החתימה */
.stack-tight { display: flex; flex-direction: column; gap: 6px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-between form { margin: 0; }
.otp-field { position: relative; }
.otp-on #code { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; z-index: 2; font-size: 16px; color: transparent; caret-color: transparent; cursor: text; -webkit-tap-highlight-color: transparent; }
.otp { direction: ltr; display: flex; justify-content: center; gap: 8px; }
.otp[hidden], .otp-done[hidden] { display: none; }
.otp-box {
  position: relative; width: 46px; height: 58px; border: 1.5px solid var(--mist); border-radius: 14px; background: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; color: var(--night);
  font-variant-numeric: tabular-nums;
  transition: border-color .22s ease, box-shadow .28s ease, background-color .25s ease, color .25s ease, transform .3s cubic-bezier(.34,1.56,.64,1);
}
.otp-box .d { display: inline-block; will-change: transform, opacity; }
.otp-box.filled { border-color: var(--lavender); background: #FBFAFF; }
.otp-box.active { border-color: var(--purple); box-shadow: 0 0 0 4px rgba(90,59,140,.14), 0 6px 14px -8px rgba(90,59,140,.6); transform: translateY(-2px); }
.otp-box.active::after { content: ""; position: absolute; width: 2px; height: 26px; border-radius: 2px; background: var(--purple); animation: otp-caret 1.1s ease-in-out infinite; }
.otp-box .d.in { animation: otp-in .34s cubic-bezier(.34,1.56,.64,1) both; }
.otp-box .d.out { animation: otp-out .14s ease-in both; }
.otp-box.bump { animation: otp-bump .28s cubic-bezier(.34,1.56,.64,1); }
/* בזמן הבדיקה: גל עדין שעובר על התיבות */
.otp.checking .otp-box { border-color: var(--purple); animation: otp-wave .9s ease-in-out infinite; }
.otp.checking .otp-box:nth-child(2) { animation-delay: .07s; }
.otp.checking .otp-box:nth-child(3) { animation-delay: .14s; }
.otp.checking .otp-box:nth-child(4) { animation-delay: .21s; }
.otp.checking .otp-box:nth-child(5) { animation-delay: .28s; }
.otp.checking .otp-box:nth-child(6) { animation-delay: .35s; }
/* קוד שגוי: אדום ורעידה שנרגעת */
.otp.bad .otp-box { border-color: #E3262F; background: var(--red-soft); color: var(--red-ink); box-shadow: none; transform: none; animation: none; }
.otp.shake { animation: otp-shake .55s cubic-bezier(.36,.07,.19,.97) both; }
.otp-msg { margin-top: 12px; text-align: center; color: var(--red-ink); font-size: 15px; font-weight: 600; }
.otp-msg.show { animation: otp-msg .3s ease-out both; }
.otp-msg[hidden] { display: none; }
/* קוד נכון: התיבות מתמלאות אחת אחרי השנייה, מתכנסות, ו-✓ מצטייר */
.otp.ok .otp-box { background: var(--purple); border-color: var(--purple); color: #fff; box-shadow: none; transform: none; animation: none; }
.otp.ok .otp-box:nth-child(2) { transition-delay: .05s; }
.otp.ok .otp-box:nth-child(3) { transition-delay: .1s; }
.otp.ok .otp-box:nth-child(4) { transition-delay: .15s; }
.otp.ok .otp-box:nth-child(5) { transition-delay: .2s; }
.otp.ok .otp-box:nth-child(6) { transition-delay: .25s; }
.otp.leave { animation: otp-leave .24s ease-in forwards; }
.otp-done { height: 62px; display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--deep); font-weight: 700; font-size: 18px; }
.otp-done .ring { width: 48px; height: 48px; border-radius: 50%; background: var(--purple); color: #fff; display: flex; align-items: center; justify-content: center; animation: otp-ring .42s cubic-bezier(.34,1.56,.64,1) both; box-shadow: 0 8px 20px -8px rgba(90,59,140,.8); }
.otp-done path { stroke-dasharray: 26; stroke-dashoffset: 26; animation: otp-draw .36s .2s ease-out forwards; }
.otp-done > span:last-child { animation: otp-msg .3s .25s ease-out both; }
@keyframes otp-caret { 0%, 100% { opacity: 1; } 50% { opacity: .15; } }
@keyframes otp-in { from { opacity: 0; transform: translateY(12px) scale(.4); } to { opacity: 1; transform: none; } }
@keyframes otp-out { to { opacity: 0; transform: translateY(-6px) scale(.6); } }
@keyframes otp-bump { 0% { transform: translateY(-2px) scale(1); } 40% { transform: translateY(-3px) scale(1.07); } 100% { transform: translateY(0) scale(1); } }
@keyframes otp-wave { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-6px); } }
@keyframes otp-shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(5px); } 30%, 50%, 70% { transform: translateX(-9px); } 40%, 60% { transform: translateX(9px); } }
@keyframes otp-msg { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes otp-leave { to { opacity: 0; transform: scale(.82); } }
@keyframes otp-ring { from { opacity: 0; transform: scale(.3); } to { opacity: 1; transform: none; } }
@keyframes otp-draw { to { stroke-dashoffset: 0; } }
@media (max-width: 360px) { .otp { gap: 6px; } .otp-box { width: 40px; height: 52px; font-size: 22px; } }

/* בזמן הקלדה: הכותרת מתכווצת, כדי שהשדה והכפתור יישארו מעל המקלדת */
.hero, .hero h1, .hero p, .topbar { transition: all .32s cubic-bezier(.2,.8,.2,1); }
body.typing .hero { padding: 12px 18px; gap: 0; }
body.typing .hero h1 { font-size: 19px; }
body.typing .hero p { display: none; }
body.typing .content { padding-bottom: 45vh; }
@media (prefers-reduced-motion: reduce) {
  .otp-box, .hero, .hero h1, .hero p, .topbar { transition: none; }
  .otp-box .d.in, .otp-box .d.out, .otp-box.bump, .otp.checking .otp-box, .otp.shake, .otp-msg.show,
  .otp.leave, .otp-done .ring, .otp-done > span:last-child { animation: none; }
  .otp-box.active::after { animation: none; }
  .otp-done path { animation: none; stroke-dashoffset: 0; }
}

/* כפתור בזמן שמירה: עיגול מסתובב, כדי שיהיה ברור שמשהו קורה */
.btn.busy { opacity: 1 !important; gap: 10px; }
.btn .spin { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid rgba(255,255,255,.35); border-top-color: #fff; animation: btn-spin .8s linear infinite; flex: 0 0 auto; }
@keyframes btn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn .spin { animation-duration: 2.4s; } }
/* ספירה לאחור עד שאפשר לבקש קוד חדש */
.textbtn[disabled] { color: var(--muted); cursor: default; }

/* חתימה קצרה מדי: ההנחיה נשארת גלויה ומבקשת להמשיך */
.pad-hint.short { color: var(--red-ink); font-weight: 700; font-size: 15px; align-items: flex-start; padding-top: 10px; }

.error[hidden] { display: none; }
.btn.busy, .btn.busy[disabled] { background: var(--purple); color: #fff; opacity: 1; cursor: progress; }
