/* ============================================================
   Handwriting-capture overlay — shared by create.html (the demo)
   and app.html (saving a profile to your account).
   Loaded after tokens.css + base.css.
   ============================================================ */
.hw-capture-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(15, 14, 17, 0.9);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  overflow-y: auto;
}
.hw-shell {
  width: 100%;
  max-width: 760px;
  max-height: calc(100vh - 2.5rem);
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  color: var(--text);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.hw-head {
  position: relative;
  padding: 1.25rem 3rem 1rem 1.4rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.hw-head h2 { font-size: 1.35rem; }
.hw-sub { color: var(--text-dim); font-size: 0.9rem; margin-top: 0.25rem; }
.hw-x {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  width: 2.1rem;
  height: 2.1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-dim);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.hw-x:hover { color: var(--text); }

.hw-body {
  padding: 1.25rem 1.4rem;
  overflow-y: auto;
  flex: 1;
}
.hw-foot {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.9rem 1.4rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.hw-foot .btn-primary { margin-left: auto; }
.hw-foot .btn-ghost, .hw-foot .link-btn { color: var(--text-dim); }
.hw-count { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-faint); }

/* intro */
.hw-steps { margin: 0 0 1rem 1.1rem; display: grid; gap: 0.5rem; color: var(--text-dim); font-size: 0.95rem; }
.hw-sentence-card {
  background: var(--paper);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 1.1rem 1.2rem;
  margin: 0 0 1rem;
}
.hw-sentence {
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--ink);
  line-height: 1.4;
}
.hw-sentence-note { font-size: 0.82rem; color: var(--ink-soft); margin-top: 0.5rem; }

/* photo */
.hw-drop {
  border: 1.5px dashed var(--stamp-gray);
  border-radius: var(--radius-md);
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.3rem;
  cursor: pointer;
  color: var(--text-dim);
}
.hw-drop:hover, .hw-drop:focus-visible { border-color: var(--airmail-blue-bright); }
.hw-photo-preview {
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 52vh;
}
.hw-photo-preview img { max-width: 100%; max-height: 52vh; display: block; }
.hw-photo-ctrls { display: flex; gap: 1.2rem; margin-top: 0.7rem; }

/* process */
.hw-spinner {
  width: 2.4rem;
  height: 2.4rem;
  margin: 1.5rem auto 1rem;
  border: 3px solid var(--border-strong);
  border-top-color: var(--postal-red);
  border-radius: 50%;
  animation: hw-spin 0.8s linear infinite;
}
@keyframes hw-spin { to { transform: rotate(360deg); } }
.hw-status { text-align: center; font-family: var(--font-mono); font-size: 0.85rem; color: var(--text-dim); }

/* fix */
.hw-fix { display: grid; gap: 1rem; }
.hw-photo-pane {
  border-radius: var(--radius-sm);
  overflow: auto;
  background: #f6f2e8;
  max-height: 46vh;
  box-shadow: inset 0 0 0 1px var(--border-on-surface);
}
.hw-photo-wrap { position: relative; display: inline-block; min-width: 100%; }
.hw-photo-img { display: block; width: 100%; height: auto; image-rendering: crisp-edges; }
.hw-box-layer { position: absolute; inset: 0; }
.hw-box {
  position: absolute;
  border: 1.5px solid rgba(60, 90, 120, 0.7);
  background: rgba(106, 147, 184, 0.12);
  cursor: move;
  touch-action: none;
}
.hw-box.is-focus {
  border-color: var(--postal-red);
  background: rgba(181, 57, 44, 0.14);
  z-index: 3;
}
.hw-box-tag {
  position: absolute;
  top: -0.95rem;
  left: -1.5px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.12rem 0.3rem;
  background: rgba(60, 90, 120, 0.9);
  color: #fff;
  border-radius: 2px 2px 0 0;
}
.hw-box.is-focus .hw-box-tag { background: var(--postal-red); }
.hw-box-handle {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: #fff;
  border: 1.5px solid rgba(60, 90, 120, 0.9);
  border-radius: 2px;
  cursor: nwse-resize;
  touch-action: none;
}
.hw-box.is-focus .hw-box-handle { border-color: var(--postal-red); }

.hw-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 0.35rem;
}
.hw-cell {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--paper);
  padding: 0.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  cursor: pointer;
}
.hw-cell.is-focus { outline: 2px solid var(--postal-red); outline-offset: -1px; }
.hw-cell.is-ok { box-shadow: inset 0 -3px 0 var(--airmail-blue); }
.hw-cell.is-warn { box-shadow: inset 0 -3px 0 var(--postal-red); }
.hw-cell-ch { font-family: var(--font-mono); font-size: 0.72rem; color: var(--ink-soft); }
.hw-cell-prev {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-faint);
  font-size: 0.9rem;
}
.hw-cell-prev canvas { width: 46px; height: 46px; }
.hw-cell-draw {
  position: absolute;
  top: 1px;
  right: 1px;
  border: none;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 3px;
  font-size: 0.68rem;
  line-height: 1;
  padding: 0.15rem 0.2rem;
  cursor: pointer;
  color: var(--ink-soft);
}
.hw-cell-draw:hover { background: var(--postal-red); color: #fff; }

/* draw pad */
.hw-pad-overlay {
  position: fixed;
  inset: 0;
  z-index: 130;
  background: rgba(15, 14, 17, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.hw-pad {
  background: var(--bg-raised);
  color: var(--text);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.25rem;
  width: 100%;
  max-width: 520px;
}
.hw-pad h3 { font-size: 1.15rem; margin-bottom: 0.2rem; }
.hw-pad-canvas-wrap { margin: 0.8rem 0; border-radius: var(--radius-sm); overflow: hidden; box-shadow: inset 0 0 0 1px var(--border-on-surface); }
.hw-pad-canvas { display: block; width: 100%; height: auto; background: var(--paper); touch-action: none; cursor: crosshair; }
.hw-pad-row { display: flex; align-items: center; gap: 0.8rem; }
.hw-pad-row .btn-primary { margin-left: auto; }
.hw-pad-row .btn-ghost, .hw-pad-row .link-btn { color: var(--text-dim); }

/* done */
.hw-done { display: grid; gap: 1rem; }
.hw-done-sample {
  background: var(--paper);
  border: 1px solid var(--border-on-surface);
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem;
  overflow: hidden;
}
.hw-done-sample svg { width: 100%; height: auto; max-height: 90px; }

/* hints sit on the dark overlay panel here, not on kraft */
.hw-shell .hint, .hw-pad .hint { color: var(--text-dim); }
.hw-sentence-note { color: var(--ink-soft); }
