/* ══════════════════════════════════════
   Active Knitting Page
══════════════════════════════════════ */

.ak-shell { z-index: 102; }

/* ── Topbar ── */
.ak-topbar {
  height: 44px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

.ak-tb-back {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-mid);
  font-family: var(--font-sans);
  font-size: var(--fs-12);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  transition: all 0.12s;
}
.ak-tb-back:hover { border-color: var(--ink-mid); color: var(--ink); }

.ak-tb-name {
  font-size: var(--fs-12);
  color: var(--ink-mid);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.ak-tb-chip {
  height: 30px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.ak-chip-label {
  font-size: var(--fs-9);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-light);
}

.ak-chip-num {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums lining-nums;
  font-size: var(--fs-15);
  font-weight: 600;
  color: var(--ink);
}

.ak-chip-sep {
  font-size: var(--fs-12);
  color: var(--ink-light);
}

.ak-chip-total {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums lining-nums;
  font-size: var(--fs-12);
  color: var(--ink-light);
}

.ak-chip-rep {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums lining-nums;
  font-size: var(--fs-12);
  font-weight: 700;
  color: var(--accent);
}

/* ── Chart zone ── */
.ak-chart-zone {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
}

.ak-chart-area {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px;
  background: #F0F2F4;
  touch-action: pan-x pan-y; /* native scroll; Ctrl+wheel dispatched to zoom signal in Rust */
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.ak-chart-img-wrap {
  display: block;
  position: relative;
  line-height: 0;
  width: 100%;
  max-width: 640px;
  margin: 0 auto; /* centers at normal zoom; at high zoom overflows right (scrollable) */
}

.ak-chart-img {
  display: block;
  width: 100%;
  height: auto;
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.ak-row-highlight {
  position: absolute;
  left: 0;
  right: 0;
  background: rgba(99, 102, 241, 0.15);
  border-top: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  pointer-events: none;
}

/* Text piece row highlight — top-anchored (boundaries go top→bottom) */
.ak-text-row-highlight {
  position: absolute;
  left: 0;
  right: 0;
  background: rgba(139, 92, 246, 0.25);
  border-top: 2px solid #8b5cf6;
  border-bottom: 2px solid #8b5cf6;
  pointer-events: none;
}

.ak-chart-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
}

/* Shown over the full-page image when grid boundary not yet marked */
.ak-chart-placeholder-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  border-radius: var(--radius-md);
}

.ak-placeholder-text {
  font-size: var(--fs-12);
  color: var(--ink-light);
  font-style: italic;
}

/* ── Bottom bar ── */
.ak-bottom-bar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 4px 12px;
  gap: 8px;
  min-height: 40px;
  flex-shrink: 0;
}

.ak-instr-content {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ak-side-pill {
  font-size: var(--fs-12);
  font-weight: 700;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  flex-shrink: 0;
  font-family: var(--font-sans);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums lining-nums;
}

.ak-session-label {
  font-size: var(--fs-12);
  color: var(--ink-mid);
  white-space: nowrap;
  font-variant-numeric: tabular-nums lining-nums;
}

/* ── Split prev-row button ── */
.ak-split-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex-shrink: 0;
}

.ak-split-btn {
  display: flex;
}

.ak-split-main {
  height: 24px;
  padding: 0 8px;
  background: var(--accent);
  border: none;
  border-right: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px 0 0 4px;
  color: var(--bg);
  font-family: var(--font-sans);
  font-size: var(--fs-12);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: opacity 0.15s;
}
.ak-split-main:hover:not(:disabled) { opacity: 0.88; }
.ak-split-main:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

.ak-split-arrow {
  height: 24px;
  width: 20px;
  background: var(--accent-lt);
  border: 1px solid var(--accent);
  border-radius: 0 4px 4px 0;
  color: var(--accent);
  font-size: var(--fs-10);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
}
.ak-split-arrow:hover { opacity: 0.8; }

/* ── Back dropdown menu (opens below, anchored to right edge of split button) ── */
.ak-back-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 200;
  min-width: 190px;
}

.ak-back-menu-item {
  display: block;
  width: 100%;
  height: 38px;
  padding: 0 14px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-12);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: background 0.15s;
}
.ak-back-menu-item:last-child { border-bottom: none; }
.ak-back-menu-item:hover:not(:disabled) { background: var(--surface2); }
.ak-back-menu-item:disabled { opacity: 0.38; cursor: not-allowed; }

.ak-back-menu-dim { color: var(--ink-mid); }

/* ── Next-row button ── */
.ak-next-btn {
  height: 24px;
  padding: 0 8px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--fs-12);
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  transition: opacity 0.15s;
}
.ak-next-btn:hover { opacity: 0.88; }

/* ── Reset confirm overlay ── */
.ak-overlay {
  background: rgba(0,0,0,0.55);
  z-index: 300;
  align-items: center;
  justify-content: center;
}

.ak-confirm-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  padding: 20px;
  width: 300px;
  max-width: calc(100vw - 40px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow);
}

.ak-confirm-title {
  font-size: var(--fs-16);
  font-weight: 600;
  color: var(--ink);
}

.ak-confirm-sub {
  font-size: var(--fs-12);
  color: var(--ink-mid);
  line-height: 1.5;
  margin-top: -4px;
}

.ak-confirm-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.ak-confirm-cancel {
  flex: 1;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ink-mid);
  font-family: var(--font-sans);
  font-size: var(--fs-12);
  cursor: pointer;
  transition: all 0.12s;
}
.ak-confirm-cancel:hover { border-color: var(--ink-mid); color: var(--ink); }

.ak-confirm-ok {
  flex: 1;
  height: 36px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--danger);
  color: #fff;
  font-family: var(--font-sans);
  font-size: var(--fs-12);
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.ak-confirm-ok:hover { opacity: 0.88; }

/* ── Jump-to-row modal ── */
.ak-jump-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  padding: 20px;
  width: 340px;
  max-width: calc(100vw - 40px);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.ak-jump-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  color: var(--ink-light);
  font-size: var(--fs-16);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: all 0.12s;
}
.ak-jump-close:hover { background: var(--surface2); color: var(--ink); }

.ak-jump-title {
  font-size: var(--fs-16);
  font-weight: 600;
  color: var(--ink);
  padding-right: 28px;
}


.ak-jump-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ak-jump-feedback {
  min-height: 18px;
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--accent);
  text-align: center;
}

.ak-jump-input {
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface2);
  color: var(--ink);
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums lining-nums;
  font-size: var(--fs-24);
  font-weight: 400;
  text-align: center;
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.ak-jump-input:focus { border-color: var(--accent); }
.ak-jump-input::placeholder { color: var(--ink-light); font-size: var(--fs-14); }

.ak-jump-actions {
  display: flex;
  gap: 8px;
}

.ak-jump-cancel {
  flex: 1;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ink-mid);
  font-family: var(--font-sans);
  font-size: var(--fs-12);
  cursor: pointer;
  transition: all 0.12s;
}
.ak-jump-cancel:hover { border-color: var(--ink-mid); color: var(--ink); }

.ak-jump-confirm {
  flex: 1;
  height: 36px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font-sans);
  font-size: var(--fs-12);
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.ak-jump-confirm:hover:not(:disabled) { opacity: 0.88; }
.ak-jump-confirm:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Quick Reference ? button ── */
.ak-tb-icon {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ink-mid);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.ak-tb-icon:hover { background: var(--accent-lt); color: var(--accent); border-color: var(--accent); }
.ak-tb-icon-active { background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* ── Quick Reference slide panel ── */
.ak-ref-panel {
  position: fixed;
  top: 44px;
  right: 0;
  bottom: 48px;
  width: 272px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 90;
  transform: translateX(110%);
  transition: transform 0.22s ease;
  overflow-y: auto;
  padding: 16px;
  box-shadow: var(--shadow);
}
.ak-ref-panel-open { transform: translateX(0); }

.ak-ref-title {
  font-size: var(--fs-12);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-light);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.ak-ref-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.ak-ref-tab {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-sans);
  font-size: var(--fs-12);
  font-weight: 500;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  background: transparent;
  color: var(--ink-mid);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.ak-ref-tab:hover { border-color: var(--ok); color: var(--ok); }
.ak-ref-tab-active { background: var(--ok-lt); border-color: var(--ok); color: var(--ok); font-weight: 600; }

.ak-ref-img-btn {
  display: block;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.ak-ref-img {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  display: block;
}
.ak-ref-hint {
  display: block;
  font-size: var(--fs-10);
  color: var(--ink-mid);
  text-align: center;
  padding: 4px 0 0;
  font-style: italic;
}
.ak-ref-empty {
  font-size: var(--fs-12);
  color: var(--ink-mid);
  text-align: center;
  padding: 16px 0;
  font-style: italic;
}

/* ── Quick Reference lightbox ── */
.ak-lightbox {
  z-index: 9999;
  background: rgba(0, 0, 0, 0.93);
  flex-direction: column;
  align-items: stretch;
}
.ak-lightbox-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: var(--fs-18);
  cursor: pointer;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ak-lightbox-close:hover { background: rgba(255, 255, 255, 0.3); }
.ak-lightbox-img-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}
.ak-lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center;
  user-select: none;
  pointer-events: none;
}
.ak-lightbox-hint {
  padding: 10px;
  text-align: center;
  font-size: var(--fs-12);
  color: rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}
