/*
 * workshop-scoped.css
 * Auto-scoped combination of workshop.css + template-creator.css
 * All selectors scoped to #workshopView so styles don't leak into FormaAPP.
 *
 * Renames applied:
 *   .app           → .workshop-app
 *   .header        → .ws-header
 *   .header-top    → .ws-header-top
 *   .header-context→ .ws-header-context
 *   body.bp-phone  → #workshopView.ws-phone
 *   body.bp-tablet → #workshopView.ws-tablet
 *   body.bp-wide   → #workshopView.ws-wide
 */

/* ══════════════════════════════════════════════════════════════════
   TOKENS & BASE
   ══════════════════════════════════════════════════════════════════ */

#workshopView {
  /* FormaAPP header offset — matches .main-content padding-top */
  --app-header-h: calc(70px + env(safe-area-inset-top, 0px));

  /* Backgrounds */
  --bg:        #1a202c;
  --surface:   #2d3748;
  --surface2:  #374151;

  /* Text */
  --ink:       #f7fafc;
  --ink2:      #e2e8f0;
  --ink3:      #a0aec0;

  /* Accent */
  --accent:    #68d391;
  --accent-fg: #1a202c;
  --green:     #68d391;
  --red:       #fc8181;
  --border:    #4a5568;

  /* Pressed / secondary control fill (replaces hardcoded #4a5568 / #374151) */
  --tap-surface: #4a5568;

  /* Floating panels (fraction picker, etc.) */
  --elev-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);

  /* Shadows */
  --shadow:    none;
  --shadow-lg: none;

  /* Layout */
  --radius:    14px;
  --radius-sm: 10px;
  --font:      'DM Sans', sans-serif;
  --mono:      'DM Mono', monospace;

  /* Base styles (from body) */
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* Element resets (scoped) */
#workshopView button { font-family: var(--font); cursor: pointer; border: none; background: none; -webkit-tap-highlight-color: transparent; }
#workshopView ul { list-style: none; }
#workshopView input,
#workshopView textarea { font-family: var(--font); }

/* ══════════════════════════════════════════════════════════════════
   WORKSHOP — App shell
   ══════════════════════════════════════════════════════════════════ */

/* Remove .main-content's 1rem side padding for workshop so it fills full width */
#workshopView {
  margin-left: -1rem;
  margin-right: -1rem;
  width: calc(100% + 2rem);
}

/* When Workshop is active, remove global app bottom padding (100px) to avoid
   an extra page-level scroll container under tablet calculator columns. */
main.main-content:has(#workshopView.active) {
  padding-bottom: 0;
}

#workshopView .workshop-app {
  max-width: 430px;
  margin: 0 auto;
  padding: 0 0 20px;
}

/* ── Header (renamed from .header) ───────────────────────────── */
#workshopView .ws-header {
  padding: 14px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#workshopView .ws-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#workshopView .ws-header-context {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink2);
  overflow: hidden;
}

#workshopView .ctx-project { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
#workshopView .ctx-sep { color: var(--ink3); }
#workshopView .ctx-section { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }

/* ── Unit bar ────────────────────────────────────────────────── */
#workshopView .unit-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 0 16px 10px;
}

#workshopView .unit-bar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

#workshopView .unit-bar-label {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--ink3);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  min-width: 34px;
}

#workshopView .unit-arrow {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--ink3);
}

#workshopView .unit-toggle {
  display: flex;
  background: var(--bg);
  border-radius: 8px;
  padding: 2px;
  gap: 1px;
  flex: 1;
}

#workshopView .unit-opt {
  flex: 1;
  padding: 5px 4px;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 6px;
  color: var(--ink3);
  transition: all 0.15s;
  cursor: pointer;
  text-align: center;
  background: transparent;
  border: none;
  font-family: var(--font);
}

#workshopView .unit-opt.active {
  background: var(--accent);
  color: var(--accent-fg);
}

/* ── Mode rail ───────────────────────────────────────────────── */
#workshopView .mode-rail {
  display: flex;
  gap: 6px;
  padding: 0 16px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#workshopView .mode-rail::-webkit-scrollbar { display: none; }

#workshopView .mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink3);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.16s ease;
  box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
}

#workshopView .mode-btn:active {
  background: var(--surface2);
}

#workshopView .col-keypad,
#workshopView .col-rows { display: contents; }

#workshopView .mode-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

#workshopView .mode-btn.active {
  background: var(--accent);
  color: var(--accent-fg);
}

#workshopView .mode-btn.active:active {
  background: #48bb78;
}

/* ── Total card ──────────────────────────────────────────────── */
#workshopView .total-card {
  margin: 0 16px 0;
  background: var(--accent);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 16px 18px;
}

#workshopView .total-inner { min-width: 0; }

#workshopView .record-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: calc(100% - 32px);
  margin: 0 16px 14px;
  padding: 13px;
  background: var(--surface2);
  color: var(--ink2);
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: 0.88rem;
  font-weight: 700;
  font-family: var(--font);
  letter-spacing: 0.02em;
  transition: background 0.14s;
}

#workshopView .record-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
#workshopView .record-btn:active { background: var(--tap-surface); }

#workshopView .total-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 500;
  color: rgba(26,32,44,0.65);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

#workshopView .total-label-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

#workshopView .total-label-row .total-label {
  margin-bottom: 0;
}

#workshopView .money-toggle {
  display: flex;
  background: rgba(26,32,44,0.2);
  border-radius: 8px;
  padding: 2px;
  gap: 1px;
}

#workshopView .money-opt {
  padding: 2px 9px;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 6px;
  color: rgba(26,32,44,0.55);
  cursor: pointer;
  transition: all 0.15s;
  background: transparent;
  border: none;
  font-family: var(--font);
}

#workshopView .money-opt.active {
  background: rgba(26,32,44,0.25);
  color: #1a202c;
}

#workshopView .total-amount {
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex-wrap: wrap;
  min-width: 0;
}

#workshopView .total-value {
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 500;
  color: #1a202c;
  line-height: 1.4;
  display: inline-block;
  word-break: break-word;
  min-width: 0;
}

#workshopView .total-value.bump {
  transform: scale(1.04);
  color: #1a202c;
}

#workshopView .total-unit {
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(26,32,44,0.6);
  flex-shrink: 0;
}

/* ── Rows list ───────────────────────────────────────────────── */
#workshopView .rows-wrap {
  margin: 0 16px 14px;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

#workshopView .rows-list { }

/* ── Calc row ────────────────────────────────────────────────── */
#workshopView .calc-row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  overflow: hidden;
}

#workshopView .calc-row:last-child { border-bottom: none; }

#workshopView .calc-row::after {
  content: 'Delete';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 80px;
  background: var(--red);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateX(100%);
  transition: transform 0.22s ease;
  pointer-events: none;
  border-radius: 0 0 0 0;
}

#workshopView .calc-row.swiping::after { transform: translateX(0); }

#workshopView .row-top {
  grid-column: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

#workshopView .row-name-input {
  flex: 1;
  min-width: 0;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  border: none;
  background: transparent;
  outline: none;
  padding: 0;
}

#workshopView .row-name-input::placeholder { color: var(--ink3); font-weight: 500; }

/* ── Parent row ──────────────────────────────────────────────── */
#workshopView .calc-row-parent {
  background: var(--surface);
}

/* ── Child row ───────────────────────────────────────────────── */
#workshopView .calc-row-child {
  background: var(--surface2);
  padding-left: 10px;
  border-left: 3px solid var(--border);
  margin-left: 14px;
  border-radius: 0;
}

#workshopView .calc-row-child .row-name-input {
  font-size: 0.82rem;
  font-weight: 500;
}

#workshopView .child-op-toggle {
  display: flex;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

#workshopView .op-btn {
  width: 28px;
  height: 28px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink3);
  background: var(--surface2);
  transition: all 0.14s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#workshopView .op-btn.active-plus  { background: rgba(104,211,145,0.2); color: #68d391; }
#workshopView .op-btn.active-minus { background: rgba(252,129,129,0.15); color: var(--red); }

#workshopView .row-add-child-btn {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink2);
}

#workshopView .row-subtotal {
  grid-column: 1 / -1;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
  padding: 2px 0 0 0;
  text-align: right;
  display: block;
  min-height: 0;
}

#workshopView .row-actions-top {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  align-self: start;
  padding-top: 2px;
}

#workshopView .row-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--surface2);
  color: var(--ink3);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

#workshopView .row-icon-btn:active { background: var(--surface); }

#workshopView .row-inputs {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* Tappable number fields */
#workshopView .num-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  min-width: 68px;
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s;
  flex-shrink: 0;
}

#workshopView .num-field:active,
#workshopView .num-field.focused {
  border-color: var(--accent);
  background: var(--surface);
}

#workshopView .num-field-label {
  font-size: 0.58rem;
  font-weight: 600;
  color: var(--ink3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 2px;
}

#workshopView .num-field-value {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
}

#workshopView .num-field-value.empty { color: var(--ink3); }

#workshopView .row-sep {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink3);
  flex-shrink: 0;
}

#workshopView .row-result {
  grid-column: 1 / -1;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink2);
  text-align: right;
  padding: 2px 0 0 0;
}

/* Labor method mini-toggle inside row */
#workshopView .labor-method-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  grid-column: 1 / -1;
}

#workshopView .labor-m-btn {
  flex: 1;
  padding: 6px 4px;
  border-radius: 8px;
  font-size: 0.68rem;
  font-weight: 600;
  background: var(--surface2);
  color: var(--ink3);
  border: 1.5px solid var(--border);
  transition: all 0.14s;
}

#workshopView .labor-m-btn.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

/* Perimeter add-length btn */
#workshopView .add-length-btn {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink2);
  background: var(--surface2);
  border: 1.5px dashed var(--ink3);
}

/* ── Add row button ──────────────────────────────────────────── */
#workshopView .add-row-btn {
  width: 100%;
  padding: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink2);
  background: var(--surface2);
  border-top: 1px solid var(--border);
  transition: background 0.14s;
}

#workshopView .add-row-btn svg { width: 16px; height: 16px; }
#workshopView .add-row-btn:active { background: var(--tap-surface); }

/* ── Recorded section ────────────────────────────────────────── */
#workshopView .recorded-wrap {
  margin: 0 16px;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

#workshopView .recorded-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

#workshopView .recorded-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
}

#workshopView .recorded-actions { display: flex; gap: 8px; align-items: center; }

#workshopView .save-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-fg);
  transition: opacity 0.14s;
}

#workshopView .save-btn:disabled,
#workshopView .template-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

#workshopView .template-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 8px;
  background: var(--surface2);
  color: var(--ink);
  border: 1px solid var(--border);
  transition: all 0.14s;
}

#workshopView .save-btn .ws-dev-badge,
#workshopView .template-btn .ws-dev-badge {
  flex-shrink: 0;
  font-size: 0.52rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 5px;
  border-radius: 4px;
  line-height: 1;
}

#workshopView .save-btn .ws-dev-badge {
  background: rgba(26, 32, 44, 0.18);
  color: var(--accent-fg);
}

#workshopView .template-btn .ws-dev-badge {
  background: rgba(104, 211, 145, 0.15);
  color: var(--accent);
  border: 1px solid rgba(104, 211, 145, 0.35);
}

@media (hover: hover) and (pointer: fine) {
#workshopView .template-btn:hover {
  background: var(--surface);
  border-color: var(--accent);
}
}

#workshopView .clear-btn {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ink3);
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
}

#workshopView .recorded-list { }

#workshopView .recorded-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

#workshopView .recorded-item:last-child { border-bottom: none; }

#workshopView .recorded-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

#workshopView .recorded-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

#workshopView .recorded-item-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
}

#workshopView .recorded-item-total {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

#workshopView .recorded-item-meta {
  font-size: 0.65rem;
  color: var(--ink3);
  font-weight: 500;
}

#workshopView .btn-remove-rec {
  width: 24px; height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--ink3);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

@media (hover: hover) and (pointer: fine) {
#workshopView .btn-remove-rec:hover { color: var(--red); border-color: var(--red); }
}

#workshopView .recorded-rows {
  display: flex;
  flex-direction: column;
  gap: 0;
}

#workshopView .rec-parent-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 0 2px;
  border-top: 1px solid var(--border);
}

#workshopView .rec-parent-row:first-child { border-top: none; }

#workshopView .rec-row-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#workshopView .rec-row-val {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--ink2);
  white-space: nowrap;
  flex-shrink: 0;
}

#workshopView .rec-row-detail {
  font-size: 0.62rem;
  color: var(--ink3);
  font-family: var(--mono);
  padding: 0 0 4px 0;
}

#workshopView .rec-child-row {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 3px 0 2px 10px;
}

#workshopView .rec-child-op {
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
  width: 10px;
  text-align: center;
}

#workshopView .rec-op-plus  { color: #68d391; }
#workshopView .rec-op-minus { color: var(--red); }

#workshopView .rec-child-row .rec-row-name { font-weight: 500; color: var(--ink2); }
#workshopView .rec-child-row .rec-row-val  { color: var(--ink3); }
#workshopView .rec-child-detail { padding-left: 25px; }

/* ── Keypad sheet ────────────────────────────────────────────── */
#workshopView .sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.15);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.22s ease;
}

#workshopView .sheet-overlay.visible { opacity: 1; }

#workshopView .keypad-sheet {
  position: fixed;
  /* Sit just above floating-bottom-menu (56px h + 6px gap + safe area) */
  bottom: calc(62px + env(safe-area-inset-bottom, 0px));
  left: 0; right: 0;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  z-index: 1001;
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32,0.72,0,1);
  max-width: 430px;
  margin: 0 auto;
  max-height: 92vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Mobile ≤768px: menu bottom is 0 + safe-area margin, height 56px */
@media (max-width: 768px) {
  #workshopView .keypad-sheet {
    bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  }
}

/* iPad+ ≥769px: menu height becomes 64px, gap 6px */
@media (min-width: 769px) {
  #workshopView .keypad-sheet {
    bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  }
}

#workshopView .keypad-sheet.visible { transform: translateY(0); }

#workshopView .keypad-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#workshopView .keypad-field-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ink3);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

#workshopView .keypad-display-wrap {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

#workshopView .keypad-display {
  font-family: var(--mono);
  font-size: 2.4rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1;
  min-width: 60px;
}

#workshopView .keypad-unit-hint {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink3);
}

#workshopView .keypad-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  overflow: hidden;
}

#workshopView .key {
  background: var(--surface);
  font-family: var(--font);
  font-size: 1.35rem;
  font-weight: 500;
  color: var(--ink);
  padding: 0;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#workshopView .key:active { background: var(--surface2); }

#workshopView .key-action {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink2);
  background: var(--surface2);
}

#workshopView .key-done {
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 1rem;
  font-weight: 700;
  grid-row: span 2;
}

#workshopView .key-done:active { background: #48bb78; }

#workshopView .key-wide {
  grid-column: span 2;
}

/* ── Labor sheet ─────────────────────────────────────────────── */
#workshopView .labor-sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  max-width: 430px;
  margin: 0 auto;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.32,0.72,0,1);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

#workshopView .labor-sheet.visible { transform: translateY(0); }

#workshopView .labor-sheet-inner {
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 20px 16px 8px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#workshopView .labor-sheet-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

#workshopView .labor-opt-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  border: 1.5px solid var(--border);
  text-align: left;
  transition: all 0.14s;
  gap: 2px;
}

#workshopView .labor-opt-btn strong { font-size: 0.9rem; color: var(--ink); }
#workshopView .labor-opt-btn span { font-size: 0.72rem; color: var(--ink3); }
#workshopView .labor-opt-btn.active { border-color: var(--accent); background: var(--accent); }
#workshopView .labor-opt-btn.active strong { color: var(--accent-fg); }
#workshopView .labor-opt-btn.active span { color: rgba(26,32,44,0.55); }

/* ── Utilities ───────────────────────────────────────────────── */
#workshopView .hidden { display: none !important; }

/* Parent input fields hidden when acting as group header */
#workshopView .row-inputs-hidden { display: none; }

/* ── Fraction toggle button ──────────────────────────────────── */
#workshopView .key-frac {
  font-size: 1.2rem;
  color: var(--ink2);
  background: var(--surface2);
}

#workshopView .key-frac.frac-active {
  background: var(--ink);
  color: #fff;
}

/* ── Inline fraction expander ────────────────────────────────── */
#workshopView .frac-expander {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  border-top: 0px solid var(--border);
}

#workshopView .frac-expander.open {
  max-height: 120px;
  border-top: 1px solid var(--border);
}

#workshopView .frac-expander-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface2);
}

/* Fraction chips row */
#workshopView .frac-chips {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  flex: 1;
  min-width: 0;
}

#workshopView .frac-chip {
  height: 44px;
  border-radius: 8px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
  min-width: 0;
}

#workshopView .frac-chip:active {
  background: var(--bg);
}

#workshopView .frac-chip.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

/* ── Calculator mode ─────────────────────────────────────────── */
#workshopView .calc-mode {
  padding: 0 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
#workshopView .calc-mode.hidden { display: none; }

#workshopView .calc-display-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Rounding bar ── */
#workshopView .calc-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px 2px;
}

#workshopView .calc-controls-bar .calc-round-bar {
  flex: 1;
  margin-bottom: 0;
}

#workshopView .calc-round-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

#workshopView .calc-round-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink3);
}

#workshopView .calc-round-control {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 2px 4px;
}

#workshopView .calc-round-chevron {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 5px;
  color: var(--ink2);
  transition: background 0.12s, color 0.12s;
  -webkit-tap-highlight-color: transparent;
}

#workshopView .calc-round-chevron svg {
  width: 14px;
  height: 14px;
}

#workshopView .calc-round-chevron:active {
  background: var(--accent);
  color: var(--accent-fg);
}

#workshopView .calc-round-value {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink);
  min-width: 44px;
  text-align: center;
  user-select: none;
}

#workshopView .calc-expression {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--ink3);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  width: 100%;
  min-height: 1.2em;
}

#workshopView .calc-result {
  font-family: var(--mono);
  font-size: 2.5rem;
  font-weight: 500;
  color: var(--ink);
  text-align: right;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

#workshopView .calc-result::-webkit-scrollbar {
  display: none;
}

#workshopView .calc-result.calc-result--overflow {
  mask-image: linear-gradient(to right, transparent 0, black 28px);
  -webkit-mask-image: linear-gradient(to right, transparent 0, black 28px);
}

/* ── Fraction displays ───────────────────────────────────────── */
#workshopView .frac-display {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  font-size: 0.65em;
  line-height: 0.9;
  text-align: center;
  margin: 0 2px;
}

#workshopView .frac-display sup {
  border-bottom: 1px solid currentColor;
  padding-bottom: 2px;
  margin-bottom: 1px;
  vertical-align: baseline;
  font-size: 1em;
  position: static;
  top: auto;
}

#workshopView .frac-display sub {
  padding-top: 2px;
  margin-top: 1px;
  vertical-align: baseline;
  font-size: 1em;
  position: static;
  bottom: auto;
}

#workshopView .calc-result .frac-display {
  font-size: 0.55em;
  line-height: 1;
  margin: 0 3px;
}

#workshopView .calc-expression .frac-display {
  font-size: 0.75em;
  line-height: 1;
  margin: 0 2px;
}

#workshopView .calc-history-result .frac-display {
  font-size: 0.85em;
  line-height: 1;
  margin: 0 1px;
}

#workshopView .calc-frac-opt .frac-display {
  font-size: 1.1rem;
  line-height: 1;
  margin: 0;
}

#workshopView .frac-inline {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  font-size: 0.85em;
  line-height: 0.9;
  text-align: center;
  margin: 0 1px;
}

#workshopView .frac-inline sup {
  border-bottom: 1px solid currentColor;
  padding-bottom: 1px;
  margin-bottom: 0px;
  line-height: 1;
}

#workshopView .frac-inline sub {
  padding-top: 1px;
  margin-top: 0px;
  line-height: 1;
}

/* ── Calc history ────────────────────────────────────────────── */
#workshopView .calc-history-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px 2px;
}

#workshopView .calc-history {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  max-height: 200px;
  overflow-y: auto;
  display: none;
}
#workshopView .calc-history:not(:empty) { display: block; }

#workshopView .calc-history-item {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--ink2);
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
#workshopView .calc-history-item:last-child { border-bottom: none; }
#workshopView .calc-history-expr { flex: 1; opacity: 0.7; }
#workshopView .calc-history-result { font-weight: 500; color: var(--ink); }

/* ── Calc pad ────────────────────────────────────────────────── */
#workshopView .calc-pad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

#workshopView .calc-display-toggle {
  grid-column: 1 / -1;
  display: flex;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
  margin-bottom: 6px;
}

#workshopView .calc-toggle-opt {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink2);
  background: transparent;
  transition: all 0.2s;
  font-family: var(--font);
}

#workshopView .calc-toggle-opt.active {
  background: var(--accent);
  color: var(--accent-fg);
}

#workshopView .calc-key {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  font-size: 1.3rem;
  font-weight: 500;
  background: var(--surface2);
  color: var(--ink);
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

#workshopView .calc-key:active {
  transform: scale(0.95);
  background: var(--surface);
}

#workshopView .calc-key.calc-op {
  background: var(--accent);
  color: var(--accent-fg);
}
#workshopView .calc-key.calc-op:active {
  background: #48bb78;
}

#workshopView .calc-key.calc-func {
  background: var(--surface2);
  color: var(--ink);
}

#workshopView .calc-key.calc-frac {
  background: var(--surface2);
  color: var(--ink);
  font-size: 1.5rem;
}

#workshopView .calc-key.calc-equals {
  background: var(--green);
  color: var(--accent-fg);
}
#workshopView .calc-key.calc-equals:active {
  background: #48bb78;
}

/* Fraction picker for calculator */
#workshopView .calc-frac-picker {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-top: -6px;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.3s, opacity 0.3s, margin-top 0.3s;
}

#workshopView .calc-frac-picker:not(.hidden) {
  max-height: 500px;
  opacity: 1;
  margin-top: 0;
  overflow: visible;
}

/* Tablet: show fraction picker as compact modal so it doesn't expand
   the left calculator column and trigger nested clipping/scroll. */
#workshopView.ws-tablet .calc-frac-picker.modal-open:not(.hidden) {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  width: min(420px, calc(100vw - 28px));
  max-height: min(52vh, 360px);
  overflow-y: auto;
  z-index: 1102;
  margin-top: 0;
  border: 1px solid var(--border);
  box-shadow: var(--elev-shadow);
}

/* Phone: open fraction picker as compact modal above bottom menu. */
#workshopView.ws-phone .calc-frac-picker.modal-open:not(.hidden) {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  width: min(420px, calc(100vw - 16px));
  max-height: min(42vh, 320px);
  overflow-y: auto;
  z-index: 1102;
  margin-top: 0;
  border: 1px solid var(--border);
  box-shadow: var(--elev-shadow);
}

/* Prevent background calculator column from scrolling behind modal picker. */
#workshopView.ws-frac-modal-open .calc-mode .calc-left-col {
  overflow-y: hidden;
}

#workshopView .calc-frac-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

#workshopView .calc-frac-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink2);
}

#workshopView .calc-precision-toggle {
  display: flex;
  background: var(--surface2);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

#workshopView .calc-precision-opt {
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink2);
  background: transparent;
  transition: all 0.2s;
  font-family: var(--font);
}

#workshopView .calc-precision-opt.active {
  background: var(--accent);
  color: var(--accent-fg);
}

#workshopView .calc-frac-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

#workshopView .calc-frac-opt {
  height: 50px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  border: 1.5px solid var(--border);
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

#workshopView .calc-frac-opt:active {
  transform: scale(0.95);
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

/* Fraction display in calc-frac key */
#workshopView .calc-key.calc-frac .frac-display {
  font-size: 1rem;
  line-height: 1;
  margin: 0;
}

/* Fraction display in precision toggle */
#workshopView .calc-precision-opt .frac-display {
  font-size: 0.8rem;
  line-height: 1;
  margin: 0;
}

/* Fraction display in display mode toggle */
#workshopView .calc-toggle-opt .frac-display {
  font-size: 0.8rem;
  line-height: 1;
  margin: 0 3px 0 0;
  vertical-align: middle;
}

/* ── Feet / inch keys ────────────────────────────────────────── */
#workshopView #feetBtn,
#workshopView #inchBtn {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--surface2);
  letter-spacing: -0.02em;
}

#workshopView #feetBtn:active,
#workshopView #inchBtn:active {
  background: var(--accent);
  color: var(--accent-fg);
}

/* ── Ft / In row ─────────────────────────────────────────────── */
#workshopView .keypad-ftrow {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px 16px 4px;
  border-top: 1px solid var(--border);
}

#workshopView .keypad-ftrow.hidden { display: none; }

#workshopView .key-ft {
  background: var(--surface);
  font-size: 1.35rem;
  font-weight: 500;
  color: var(--ink);
}

#workshopView .key-ft:active {
  background: var(--surface2);
}

#workshopView .key-ft.hidden { display: none; }

/* ── Calc ft/in keys ─────────────────────────────────────────── */
#workshopView .calc-ft-key {
  font-size: 1.4rem;
  font-weight: 700;
}

/* ── Keypad ft-row bottom corners ── */
#workshopView #keypadFtRow:not(.hidden) { border-radius: 0 0 var(--radius-sm) var(--radius-sm); overflow: hidden; }
#workshopView #keypadSheet:has(#keypadFtRow:not(.hidden)) .keypad-grid { border-radius: 0; }

/* ── Settings modal ──────────────────────────────────────────── */
#workshopView .settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  transition: opacity 0.2s;
  opacity: 1;
}
#workshopView .settings-overlay.hidden {
  display: none;
  opacity: 0;
}

#workshopView .settings-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--elev-shadow);
  z-index: 1001;
  width: 90%;
  max-width: 440px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s;
}
#workshopView .settings-modal.hidden {
  display: none;
  opacity: 0;
  transform: translate(-50%, -48%);
}

#workshopView .settings-inner {
  padding: 28px;
}

#workshopView .settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

#workshopView .settings-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
}

#workshopView .settings-close {
  background: transparent;
  border: none;
  color: var(--ink3);
  cursor: pointer;
  padding: 6px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
@media (hover: hover) and (pointer: fine) {
#workshopView .settings-close:hover {
  background: var(--bg);
  color: var(--ink);
}
}

#workshopView .settings-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

#workshopView .settings-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#workshopView .settings-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink3);
  margin-bottom: 2px;
}

#workshopView .settings-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
  opacity: 0.5;
}

/* System toggle buttons inside settings */
#workshopView .settings-section .unit-toggle {
  padding: 3px;
}

#workshopView .settings-section .unit-opt {
  padding: 10px 8px;
  font-size: 0.7rem;
}

/* Toggle row */
#workshopView .settings-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

@media (hover: hover) and (pointer: fine) {
#workshopView .settings-toggle-row:hover {
  background: #1f2937;
}
}

#workshopView .toggle-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

#workshopView .toggle-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.3;
}

#workshopView .toggle-desc {
  font-size: 12px;
  color: var(--ink3);
  line-height: 1.4;
}

/* Toggle switch */
#workshopView .toggle-switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

#workshopView .toggle-switch input[type="checkbox"] {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

#workshopView .toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 28px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

#workshopView .toggle-slider::before {
  content: '';
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#workshopView .toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
}

#workshopView .toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

#workshopView .toggle-switch input:focus + .toggle-slider {
  box-shadow: 0 0 0 3px rgba(104, 211, 145, 0.2);
}

/* ── Touch :active states ────────────────────────────────────── */
#workshopView .unit-opt:active              { background: var(--surface2); color: var(--ink2); }
#workshopView .unit-opt.active:active       { background: #48bb78; }
#workshopView .money-opt:active             { background: rgba(26,32,44,0.35); }
#workshopView .op-btn:active                { background: var(--bg); }
#workshopView .labor-m-btn:active           { background: var(--bg); }
#workshopView .add-length-btn:active        { background: var(--bg); border-color: var(--ink2); }
#workshopView .save-btn:active              { opacity: 0.8; }
#workshopView .template-btn:active          { background: var(--bg); }
#workshopView .clear-btn:active             { background: var(--bg); }
#workshopView .labor-opt-btn:active         { background: var(--bg); border-color: var(--accent); }
#workshopView .calc-toggle-opt:active       { background: var(--border); }
#workshopView .calc-toggle-opt.active:active{ background: #48bb78; }
#workshopView .calc-precision-opt:active    { background: var(--border); }
#workshopView .calc-round-chevron:active    { background: var(--accent); color: var(--accent-fg); }
#workshopView .recorded-head:active         { background: var(--surface2); }

/* ── Recorded collapse (phone only) ──────────────────────────── */
#workshopView .recorded-chevron { display: none; }


/* ══════════════════════════════════════════════════════════════════
   WORKSHOP — Responsive: Phone
   ══════════════════════════════════════════════════════════════════ */

#workshopView.ws-phone .recorded-wrap {
  max-height: 52px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
#workshopView.ws-phone .ws-header { display: none; }
#workshopView.ws-phone .recorded-wrap.rec-open {
  max-height: 70vh;
  overflow-y: auto;
}
#workshopView.ws-phone .recorded-chevron { display: inline-flex; }
#workshopView.ws-phone .recorded-head    { cursor: pointer; }

#workshopView.ws-phone .mode-rail {
  gap: 4px;
  padding: 0 10px 8px;
}

#workshopView.ws-phone .mode-btn {
  flex-direction: row;
  align-items: center;
  gap: 4px;
  padding: 7px 9px;
  font-size: 0.58rem;
  letter-spacing: 0.01em;
  border-radius: 8px;
}

#workshopView.ws-phone .mode-btn svg {
  width: 14px;
  height: 14px;
}

#workshopView.ws-phone .calc-pad {
  margin-top: 4px;
  gap: 5px;
  padding: 8px;
}

#workshopView.ws-phone .calc-key {
  aspect-ratio: unset;
  height: 48px;
  font-size: 1.1rem;
}

#workshopView.ws-phone .keypad-sheet .key {
  height: 42px;
  font-size: 1.1rem;
}

#workshopView.ws-phone .keypad-sheet {
  max-height: 50vh;
  width: calc(100% - 20px);
  max-width: 360px;
  border-radius: 18px 18px 0 0;
}

#workshopView.ws-phone .keypad-header {
  padding: 9px 12px 8px;
}

#workshopView.ws-phone .keypad-display {
  font-size: 1.65rem;
}

#workshopView.ws-phone .keypad-field-label {
  font-size: 0.62rem;
}

#workshopView.ws-phone .keypad-header {
  display: none;
}

#workshopView.ws-phone .keypad-sheet .key-ft {
  display: none;
}

#workshopView.ws-phone .calc-history {
  display: block !important;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  padding: 0 16px;
}
#workshopView.ws-phone .calc-history.hist-open {
  max-height: 40vh;
  overflow-y: auto;
  padding: 12px 16px;
}
#workshopView.ws-phone .calc-history-bar { display: flex !important; cursor: pointer; }

/* Phone: keep calculator content inside visible viewport above bottom menu. */
#workshopView.ws-phone .calc-mode {
  padding: 0 10px calc(8px + env(safe-area-inset-bottom, 0px));
  gap: 10px;
  height: calc(100vh - var(--app-header-h) - 56px - env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#workshopView.ws-phone .calc-left-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#workshopView.ws-phone .calc-display-wrap {
  min-height: 92px;
  padding: 12px;
  gap: 4px;
}

#workshopView.ws-phone .calc-result {
  font-size: 2rem;
}

#workshopView.ws-phone .calc-controls-bar {
  padding: 4px 8px 0;
}

#workshopView.ws-phone .calc-toggle-opt {
  padding: 8px 6px;
  font-size: 0.75rem;
}

#workshopView.ws-phone .unit-opt {
  padding: 9px 4px;
}

#workshopView.ws-phone .row-icon-btn {
  width: 36px;
  height: 36px;
}


/* ══════════════════════════════════════════════════════════════════
   WORKSHOP — Responsive: Tablet
   ══════════════════════════════════════════════════════════════════ */

#workshopView.ws-tablet {
  overflow: hidden;
  height: 100%;
}
#workshopView.ws-tablet .workshop-app {
  max-width: 100%;
  display: grid;
  grid-template-columns: 55fr 45fr;
  grid-template-rows: auto auto auto auto 1fr;
  column-gap: 16px;
  padding: 0 16px 0;
  height: calc(100vh - var(--app-header-h));
  overflow: hidden;
}

#workshopView.ws-tablet .ws-header       { display: none; }
#workshopView.ws-tablet .mode-rail    { grid-column: 1 / 3; grid-row: 1; padding: 12px 0; justify-content: center; }
#workshopView.ws-tablet .total-card   { grid-column: 1;     grid-row: 2; margin: 0; }
#workshopView.ws-tablet .record-btn   { grid-column: 1;     grid-row: 3; margin: 0 0 10px; width: 100%; }
#workshopView.ws-tablet .unit-bar     { grid-column: 1;     grid-row: 4; margin: 0 0 10px; }
#workshopView.ws-tablet .rows-wrap    { grid-column: 1;     grid-row: 5; margin: 0; overflow-y: auto; min-height: 0; padding-bottom: 24px; align-self: start; }
#workshopView.ws-tablet .recorded-wrap {
  grid-column: 2;
  grid-row: 2 / 6;
  margin: 0;
  max-height: calc(100vh - var(--app-header-h) - 60px) !important;
  overflow-y: auto;
  align-self: start;
  position: sticky;
  top: 0;
}

/* Calc mode spans both columns */
#workshopView.ws-tablet .calc-mode:not(.hidden) {
  grid-column: 1 / 3;
  grid-row: 2 / 6;
  display: grid !important;
  grid-template-columns: 55fr 45fr;
  grid-template-rows: calc(100vh - var(--app-header-h) - 60px);
  gap: 16px;
  padding: 0;
  align-items: start;
  overflow: hidden;
}
#workshopView.ws-tablet .calc-mode .calc-left-col,
#workshopView.ws-tablet .calc-mode .calc-right-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - var(--app-header-h) - 60px);
  overflow-y: auto;
  align-self: start;
}
#workshopView.ws-tablet .calc-mode .calc-history {
  max-height: calc(100vh - var(--app-header-h) - 280px) !important;
  display: block !important;
  overflow-y: auto;
  padding: 12px 16px;
}
#workshopView.ws-tablet .calc-mode .calc-history-bar { display: flex !important; }

/* Keypad: centered overlay on tablet */
#workshopView.ws-tablet #keypadSheet {
  left: 50% !important;
  right: auto !important;
  transform: translateX(-50%) translateY(100%);
  max-width: 420px;
  width: 100%;
}
#workshopView.ws-tablet #keypadSheet.visible {
  transform: translateX(-50%) translateY(0) !important;
}


/* ══════════════════════════════════════════════════════════════════
   WORKSHOP — Responsive: Wide (desktop / tablet landscape)
   ══════════════════════════════════════════════════════════════════ */

#workshopView.ws-wide {
  overflow: hidden;
  height: 100%;
}

/* Vertical fixed mode-rail */
#workshopView.ws-wide .mode-rail {
  flex-direction: column;
  width: 72px;
  height: calc(100vh - var(--app-header-h));
  position: fixed;
  left: 0; top: var(--app-header-h);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 6px;
  gap: 4px;
  background: var(--bg);
  scrollbar-width: none;
  z-index: 200;
  align-items: stretch;
}
#workshopView.ws-wide .mode-rail::-webkit-scrollbar { display: none; }
#workshopView.ws-wide .mode-rail .mode-btn {
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 10px 4px;
  border-radius: var(--radius-sm);
  font-size: 0.6rem;
  flex-shrink: 0;
  background: var(--surface);
  color: var(--ink3);
  border-left: none;
  box-shadow: var(--shadow);
}
@media (hover: hover) and (pointer: fine) {
#workshopView.ws-wide .mode-rail .mode-btn:hover {
  color: var(--ink2);
}
}
#workshopView.ws-wide .mode-rail .mode-btn.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-left: none;
}

/* App: 3-col grid */
#workshopView.ws-wide .workshop-app {
  max-width: none;
  margin-left: 72px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: calc(100vh - var(--app-header-h));
  height: calc(100vh - var(--app-header-h));
  overflow: hidden;
  padding: 0;
  column-gap: 0;
  row-gap: 0;
}

#workshopView.ws-wide .ws-header { display: none; }
#workshopView.ws-wide .mode-rail { /* already fixed, taken out of flow */ }

#workshopView.ws-wide .col-keypad,
#workshopView.ws-wide .col-rows { display: flex; }

/* Col 1 background */
#workshopView.ws-wide .workshop-app::before {
  content: '';
  grid-column: 1;
  grid-row: 1 / -1;
  background: var(--bg);
  pointer-events: none;
  z-index: 0;
}

/* Col 1: keypad panel wrapper */
#workshopView.ws-wide .col-keypad {
  grid-column: 1; grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  max-height: calc(100vh - var(--app-header-h));
  padding: 16px 0 20px;
  position: relative; z-index: 1;
  align-self: start;
}
#workshopView.ws-wide .col-keypad .total-card  { margin: 0 14px 0; border-radius: var(--radius) var(--radius) 0 0; }
#workshopView.ws-wide .col-keypad .record-btn  { margin: 0 14px 12px; width: calc(100% - 28px); border-radius: 0 0 var(--radius) var(--radius); }
#workshopView.ws-wide .col-keypad .unit-bar    { margin: 0 14px 12px; }
#workshopView.ws-wide .col-keypad .keypad-sheet {
  position: static !important;
  transform: none !important;
  border-radius: var(--radius) !important;
  max-width: none !important;
  width: auto !important;
  margin: 0 14px;
  box-shadow: none;
  border: 1px solid var(--border);
  padding-bottom: 0 !important;
  flex-shrink: 0;
}

/* Col 2: rows wrapper */
#workshopView.ws-wide .col-rows {
  grid-column: 2; grid-row: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  max-height: calc(100vh - var(--app-header-h));
  padding: 16px 0 0;
  align-self: start;
}
#workshopView.ws-wide .col-rows .rows-wrap {
  margin: 0 16px;
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
}

#workshopView.ws-wide #sheetOverlay { display: none !important; }

/* Col 3: recorded */
#workshopView.ws-wide .recorded-wrap {
  grid-column: 3; grid-row: 1;
  margin: 16px 14px 0;
  max-height: calc(100vh - var(--app-header-h) - 16px) !important;
  overflow-y: auto;
  border-radius: var(--radius);
  box-shadow: none;
  background: var(--surface);
  border-left: none;
  scrollbar-width: thin;
  align-self: start;
}

/* Calc mode: fixed overlay over cols 1-3 */
#workshopView.ws-wide .calc-mode:not(.hidden) {
  position: fixed !important;
  left: 72px; top: var(--app-header-h); right: 0; bottom: 0;
  display: flex !important;
  flex-direction: row;
  gap: 16px;
  padding: 16px;
  z-index: 100;
  background: var(--bg);
  overflow-y: auto;
  align-items: flex-start;
}
#workshopView.ws-wide .calc-mode .calc-left-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 400px;
  flex-shrink: 0;
}
#workshopView.ws-wide .calc-mode .calc-right-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 400px;
  flex-shrink: 0;
}
#workshopView.ws-wide .calc-mode .calc-history {
  max-height: none !important;
  display: block !important;
  overflow-y: auto;
}
#workshopView.ws-wide .calc-mode .calc-history-bar { display: flex !important; }


/* ══════════════════════════════════════════════════════════════════
   WORKSHOP — Keyframe animations
   ══════════════════════════════════════════════════════════════════ */

@keyframes rowIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

#workshopView .calc-row.entering { animation: rowIn 0.22s ease forwards; }

@keyframes bump {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.07); }
  100% { transform: scale(1); }
}

#workshopView .total-value.bump { animation: bump 0.28s cubic-bezier(0.34,1.56,0.64,1); }


/* ══════════════════════════════════════════════════════════════════
   TEMPLATE CREATOR — App shell & views
   ══════════════════════════════════════════════════════════════════ */

#workshopView .template-app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

#workshopView .tc-view {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  max-width: 430px;
  margin: 0 auto;
  width: 100%;
}

#workshopView .tc-view.hidden { display: none; }

/* ── TC Header ───────────────────────────────────────────────── */
#workshopView .tc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: transparent;
  border-bottom: none;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}

#workshopView .tc-header-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  flex: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#workshopView .tc-header-end {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#workshopView .tc-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink2);
  background: none;
  border: none;
  text-decoration: none;
  padding: 6px 2px;
  flex-shrink: 0;
  transition: color 0.14s;
  -webkit-tap-highlight-color: transparent;
}

#workshopView .tc-back-btn:active { color: var(--accent); }

#workshopView .tc-new-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: background 0.14s;
}

#workshopView .tc-new-btn:active { background: #48bb78; }

#workshopView .tc-save-btn {
  padding: 7px 18px;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: background 0.14s;
}

#workshopView .tc-save-btn:active { background: #48bb78; }

/* ── Library ─────────────────────────────────────────────────── */
#workshopView .tc-library-content {
  flex: 1;
  padding: 20px 16px 40px;
}

#workshopView .tc-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  gap: 12px;
}

#workshopView .tc-empty-icon {
  width: 64px;
  height: 64px;
  color: var(--ink3);
  opacity: 0.35;
  margin-bottom: 8px;
}

#workshopView .tc-empty-icon svg { width: 100%; height: 100%; }

#workshopView .tc-empty h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink);
}

#workshopView .tc-empty p {
  font-size: 0.9rem;
  color: var(--ink3);
  line-height: 1.6;
  max-width: 280px;
  margin-bottom: 8px;
}

#workshopView .tc-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 700;
  transition: background 0.14s;
}

#workshopView .tc-action-btn:active { background: #48bb78; }

/* Template grid */
#workshopView .tc-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#workshopView .tc-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: border-color 0.14s;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#workshopView .tc-card:active { border-color: var(--accent); background: var(--surface2); }

#workshopView .tc-card-body {
  flex: 1;
  min-width: 0;
}

#workshopView .tc-card-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#workshopView .tc-card-meta {
  font-size: 0.72rem;
  color: var(--ink3);
  margin-bottom: 8px;
}

#workshopView .tc-card-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

#workshopView .tc-mode-badge {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface2);
  color: var(--ink2);
  border: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#workshopView .tc-mode-badge.area      { background: rgba(104,211,145,0.12); color: #68d391; border-color: rgba(104,211,145,0.3); }
#workshopView .tc-mode-badge.perimeter { background: rgba(99,179,237,0.12);  color: #63b3ed; border-color: rgba(99,179,237,0.3); }
#workshopView .tc-mode-badge.volume    { background: rgba(246,173,85,0.12);  color: #f6ad55; border-color: rgba(246,173,85,0.3); }
#workshopView .tc-mode-badge.materials { background: rgba(252,129,129,0.12); color: #fc8181; border-color: rgba(252,129,129,0.3); }
#workshopView .tc-mode-badge.labor     { background: rgba(183,148,246,0.12); color: #b794f4; border-color: rgba(183,148,246,0.3); }
#workshopView .tc-mode-badge.custom    { background: rgba(160,174,192,0.12); color: #a0aec0; border-color: rgba(160,174,192,0.3); }

#workshopView .tc-card-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

#workshopView .tc-card-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--ink3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.14s;
  -webkit-tap-highlight-color: transparent;
}

#workshopView .tc-card-btn:active { background: var(--bg); color: var(--ink); }
#workshopView .tc-card-btn.danger:active { color: var(--red); border-color: var(--red); }

/* ── Builder ─────────────────────────────────────────────────── */
#workshopView .tc-builder-body {
  flex: 1;
  padding: 20px 16px 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

#workshopView .tc-builder-grid { width: 100%; }
#workshopView .tc-builder-main,
#workshopView .tc-builder-side {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

#workshopView .tc-name-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  overflow: hidden;
  transition: border-color 0.14s;
}

#workshopView .tc-name-wrap:focus-within { border-color: var(--accent); }

#workshopView .tc-name-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 700;
  padding: 16px 18px;
  caret-color: var(--accent);
}

#workshopView .tc-name-input::placeholder { color: var(--ink3); font-weight: 500; }

/* Section blocks */
#workshopView .tc-section-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#workshopView .tc-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 2px;
}

#workshopView .tc-section-hint {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.68rem;
  color: var(--border);
}

/* Rows list */
#workshopView .tc-rows-list {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

#workshopView .tc-row-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  transition: background 0.14s;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

#workshopView .tc-row-item:last-child { border-bottom: none; }
#workshopView .tc-row-item:active { background: var(--surface2); }

#workshopView .tc-row-drag {
  color: var(--border);
  flex-shrink: 0;
  cursor: grab;
  padding: 4px;
  touch-action: none;
}

#workshopView .tc-row-drag:active { cursor: grabbing; }

#workshopView .tc-row-drag svg { display: block; }

#workshopView .tc-row-body {
  flex: 1;
  min-width: 0;
}

#workshopView .tc-row-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#workshopView .tc-row-name.placeholder { color: var(--ink3); font-weight: 400; font-style: italic; }

#workshopView .tc-row-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

/* Section header item */
#workshopView .tc-row-item.is-section {
  background: var(--surface2);
  cursor: default;
}

#workshopView .tc-row-item.is-section .tc-row-name {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink3);
}

#workshopView .tc-row-item.is-section:active { background: var(--surface2); }

/* Empty rows placeholder */
#workshopView .tc-rows-empty {
  padding: 24px 16px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--ink3);
}

/* Add bar */
#workshopView .tc-add-bar {
  display: flex;
  gap: 8px;
}

#workshopView .tc-add-row-btn,
#workshopView .tc-add-section-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.14s;
  border: 1.5px dashed var(--border);
  color: var(--ink2);
  background: transparent;
  -webkit-tap-highlight-color: transparent;
}

#workshopView .tc-add-row-btn:active     { background: var(--surface); border-color: var(--accent); color: var(--accent); }
#workshopView .tc-add-section-btn:active { background: var(--surface); border-color: var(--ink2); }

/* Unit toggle */
#workshopView .tc-unit-toggle {
  display: flex;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--border);
}

#workshopView .tc-unit-opt {
  flex: 1;
  padding: 9px 4px;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 8px;
  color: var(--ink3);
  transition: all 0.14s;
  text-align: center;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
}

#workshopView .tc-unit-opt.active { background: var(--accent); color: var(--accent-fg); }
#workshopView .tc-unit-opt:active { background: var(--surface2); }
#workshopView .tc-unit-opt.active:active { background: #48bb78; }

/* Per-row unit toggle */
#workshopView .tc-row-unit-toggle {
  display: flex;
  background: var(--surface);
  border-radius: 6px;
  padding: 2px;
  gap: 1px;
  border: 1px solid var(--border);
  margin-left: auto;
  flex-shrink: 0;
}

#workshopView .tc-row-unit-opt {
  padding: 4px 6px;
  font-size: 0.65rem;
  font-weight: 600;
  border-radius: 4px;
  color: var(--ink3);
  background: transparent;
  border: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s;
}

#workshopView .tc-row-unit-opt.active { background: var(--accent); color: var(--accent-fg); }
#workshopView .tc-row-unit-opt:active { background: var(--surface2); }

/* Notes */
#workshopView .tc-notes-input {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink);
  font-size: 0.88rem;
  line-height: 1.5;
  padding: 14px 16px;
  resize: none;
  outline: none;
  caret-color: var(--accent);
  transition: border-color 0.14s;
}

#workshopView .tc-notes-input::placeholder { color: var(--ink3); }
#workshopView .tc-notes-input:focus { border-color: var(--accent); }

/* ── Bottom sheet (shared base) ──────────────────────────────── */
#workshopView .tc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.22s ease;
}

#workshopView .tc-overlay.visible { opacity: 1; }

#workshopView .tc-sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  z-index: 100;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32,0.72,0,1);
  max-height: 92vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  max-width: 430px;
  margin: 0 auto;
}

#workshopView .tc-sheet.visible { transform: translateY(0); }

#workshopView .tc-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 0;
}

#workshopView .tc-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}

#workshopView .tc-sheet-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

#workshopView .tc-sheet-cancel {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink3);
  padding: 6px 4px;
  -webkit-tap-highlight-color: transparent;
}

#workshopView .tc-sheet-cancel:active { color: var(--ink); }

#workshopView .tc-sheet-body {
  padding: 12px 16px 20px;
}

/* ── Mode picker list ────────────────────────────────────────── */
#workshopView .tc-mode-picker-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#workshopView .tc-mode-pick-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: left;
  transition: all 0.14s;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
}

#workshopView .tc-mode-pick-btn:active { border-color: var(--accent); background: var(--bg); }

#workshopView .tc-mode-pick-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#workshopView .tc-mode-pick-icon.area      { background: rgba(104,211,145,0.15); color: #68d391; }
#workshopView .tc-mode-pick-icon.perimeter { background: rgba(99,179,237,0.15);  color: #63b3ed; }
#workshopView .tc-mode-pick-icon.volume    { background: rgba(246,173,85,0.15);  color: #f6ad55; }
#workshopView .tc-mode-pick-icon.materials { background: rgba(252,129,129,0.15); color: #fc8181; }
#workshopView .tc-mode-pick-icon.labor     { background: rgba(183,148,246,0.15); color: #b794f4; }
#workshopView .tc-mode-pick-icon.custom    { background: rgba(160,174,192,0.15); color: #a0aec0; }

#workshopView .tc-mode-pick-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#workshopView .tc-mode-pick-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
}

#workshopView .tc-mode-pick-desc {
  font-size: 0.72rem;
  color: var(--ink3);
  font-family: var(--mono);
}

/* ── Inline row card (expanded in builder list) ──────────────── */
#workshopView .tc-row-item.is-expanded {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 12px 14px;
  cursor: default;
  background: var(--surface);
}

#workshopView .tc-row-item.is-expanded:active { background: var(--surface); }

#workshopView .tc-row-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

#workshopView .tc-row-card-name-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  caret-color: var(--accent);
  padding: 0;
}

#workshopView .tc-row-card-name-input::placeholder { color: var(--ink3); font-weight: 500; }

#workshopView .tc-row-card-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* Each field — mirrors .num-field */
#workshopView .tc-inline-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  cursor: pointer;
  border-radius: 10px;
  padding: 6px 10px;
  min-width: 68px;
  flex: 1;
  flex-shrink: 0;
  transition: border-color 0.14s, background 0.14s;
}

#workshopView .tc-inline-field:focus-within {
  border-color: var(--accent);
  background: var(--surface);
}

#workshopView .tc-inline-field label {
  font-size: 0.58rem;
  font-weight: 600;
  color: var(--ink3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 2px;
}

#workshopView .tc-inline-field input,
#workshopView .tc-inline-field .tc-field-value {
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
  width: 100%;
  text-align: center;
  padding: 0;
  caret-color: var(--accent);
  -webkit-appearance: none;
}

#workshopView .tc-inline-field input::placeholder { color: var(--ink3); }
#workshopView .tc-inline-field input.empty { color: var(--ink3); }
#workshopView .tc-inline-field .tc-field-value.empty { color: var(--ink3); }
#workshopView .tc-inline-field .tc-field-value { cursor: pointer; min-height: 1.2em; }

#workshopView .tc-inline-sep {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink3);
  flex-shrink: 0;
}

#workshopView .tc-row-subtotal {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink2);
  text-align: right;
  padding: 4px 0 0 0;
}

/* Labor method bar */
#workshopView .tc-inline-labor-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

#workshopView .tc-inline-labor-btn {
  flex: 1;
  padding: 6px 4px;
  border-radius: 8px;
  font-size: 0.68rem;
  font-weight: 600;
  background: var(--surface2);
  color: var(--ink3);
  border: 1.5px solid var(--border);
  transition: all 0.14s;
  -webkit-tap-highlight-color: transparent;
}

#workshopView .tc-inline-labor-btn.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

#workshopView .tc-inline-labor-btn:active { background: var(--bg); }
#workshopView .tc-inline-labor-btn.active:active { background: #48bb78; }

/* Delete button */
#workshopView .tc-row-delete {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--ink3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.14s;
  -webkit-tap-highlight-color: transparent;
}

#workshopView .tc-row-delete:active { color: var(--red); border-color: var(--red); background: var(--bg); }

/* Perimeter buttons */
#workshopView .tc-perim-btn {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  flex-shrink: 0;
  transition: all 0.14s;
  -webkit-tap-highlight-color: transparent;
}

#workshopView .tc-perim-add {
  color: var(--ink2);
  background: var(--surface2);
  border: 1.5px dashed var(--ink3);
}

#workshopView .tc-perim-rem {
  color: var(--red);
  background: transparent;
  border: 1.5px solid transparent;
}

#workshopView .tc-perim-add:active { border-color: var(--accent); color: var(--accent); }
#workshopView .tc-perim-rem:active { border-color: var(--red); background: rgba(252,129,129,0.08); }

#workshopView .tc-perim-price-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin-top: 4px;
}

/* ── Preview view ────────────────────────────────────────────── */
#workshopView .tc-preview-body {
  flex: 1;
  padding: 16px 16px 100px;
  overflow-y: auto;
}

/* White document card */
#workshopView .tc-estimate-doc {
  background: #fff;
  color: #1a1a1a;
  border-radius: var(--radius);
  padding: 28px 20px;
  font-family: var(--font);
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}

#workshopView .tc-est-title-block { text-align: center; margin-bottom: 16px; }
#workshopView .tc-est-title { font-size: 1.3rem; font-weight: 800; letter-spacing: 0.08em; color: #1a1a1a; margin-bottom: 3px; }
#workshopView .tc-est-subtitle { font-size: 0.75rem; color: #999; }
#workshopView .tc-est-divider { height: 1px; background: #ddd; margin: 0 0 0; }

/* Table header */
#workshopView .tc-est-thead {
  display: grid;
  grid-template-columns: 1fr 60px 72px 62px;
  gap: 4px;
  background: #555;
  color: #fff;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 7px 10px;
}

/* Section header */
#workshopView .tc-est-section {
  background: #f5f5f5;
  color: #888;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 10px;
  margin-top: 4px;
}

/* Each row — 4 columns */
#workshopView .tc-est-row {
  display: grid;
  grid-template-columns: 1fr 60px 72px 62px;
  gap: 4px;
  padding: 9px 10px;
  border-bottom: 1px solid #f0f0f0;
  align-items: start;
}

#workshopView .tc-est-row:last-of-type { border-bottom: none; }

#workshopView .tc-est-row-desc {
  min-width: 0;
  overflow: hidden;
}

#workshopView .tc-est-row-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 5px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#workshopView .tc-est-row-name.empty { color: #bbb; font-style: italic; font-weight: 400; }

#workshopView .tc-est-row-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

#workshopView .tc-est-field-tag {
  font-size: 0.58rem;
  font-family: var(--mono);
  color: #999;
  background: #f5f5f5;
  border: 1px solid #e8e8e8;
  border-radius: 3px;
  padding: 1px 5px;
  white-space: nowrap;
  display: inline-block;
}

#workshopView .tc-est-field-tag.preset {
  color: #2d6a4f;
  background: #f0faf4;
  border-color: #b8e0c8;
  font-weight: 600;
}

#workshopView .tc-est-col-qty,
#workshopView .tc-est-col-price {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 0;
  padding-top: 1px;
  font-size: 0.58rem;
  font-family: var(--mono);
}

#workshopView .tc-est-col-amt {
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 700;
  color: #1a1a1a;
  text-align: right;
  white-space: nowrap;
  padding-top: 1px;
}

#workshopView .tc-blank-line {
  display: block;
  width: 100%;
  height: 1px;
  background: #ddd;
  margin-top: 7px;
}

/* Totals */
#workshopView .tc-est-totals {
  border-top: 1.5px solid #ddd;
  margin-top: 16px;
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#workshopView .tc-est-total-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: #555;
}

#workshopView .tc-est-total-final {
  font-size: 0.92rem;
  font-weight: 700;
  color: #1a1a1a;
  padding-top: 6px;
  border-top: 1.5px solid #ddd;
  margin-top: 2px;
}

/* ── TC toggle switch ────────────────────────────────────────── */
#workshopView .tc-toggle-switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

#workshopView .tc-toggle-switch input[type="checkbox"] {
  opacity: 0; width: 0; height: 0; position: absolute;
}

#workshopView .tc-toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 28px;
  transition: background 0.22s;
}

#workshopView .tc-toggle-slider::before {
  content: '';
  position: absolute;
  height: 22px; width: 22px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.22s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#workshopView .tc-toggle-switch input:checked + .tc-toggle-slider { background: var(--accent); }
#workshopView .tc-toggle-switch input:checked + .tc-toggle-slider::before { transform: translateX(20px); }

/* ── Delete modal ────────────────────────────────────────────── */
#workshopView .tc-modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 200;
  width: calc(100% - 48px);
  max-width: 320px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

#workshopView .tc-modal-inner { padding: 24px 20px 16px; }

#workshopView .tc-modal-msg {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  text-align: center;
  margin-bottom: 20px;
  line-height: 1.5;
}

#workshopView .tc-modal-actions {
  display: flex;
  gap: 8px;
}

#workshopView .tc-modal-cancel,
#workshopView .tc-modal-confirm {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 700;
  transition: all 0.14s;
  -webkit-tap-highlight-color: transparent;
}

#workshopView .tc-modal-cancel  { background: var(--surface2); color: var(--ink2); border: 1px solid var(--border); }
#workshopView .tc-modal-confirm { background: var(--red);      color: #fff; }
#workshopView .tc-modal-cancel:active  { background: var(--bg); }
#workshopView .tc-modal-confirm:active { opacity: 0.85; }

/* ── Sheet dynamic fields ────────────────────────────────────── */
#workshopView .tc-fields-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
}

#workshopView .tc-field-col {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-width: 68px;
}

#workshopView .tc-field-col label {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--ink3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#workshopView .tc-field-col .tc-field-input {
  padding: 11px 10px;
  font-size: 0.9rem;
  text-align: center;
}

#workshopView .tc-field-sep {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink3);
  padding-bottom: 12px;
  flex-shrink: 0;
}

#workshopView .tc-fields-hint {
  font-size: 0.68rem;
  color: var(--border);
  margin-top: 2px;
}

/* Labor method sub-toggle inside sheet */
#workshopView .tc-labor-method-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}

#workshopView .tc-labor-m-btn {
  flex: 1;
  padding: 8px 4px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--surface2);
  color: var(--ink3);
  border: 1.5px solid var(--border);
  transition: all 0.14s;
  -webkit-tap-highlight-color: transparent;
}

#workshopView .tc-labor-m-btn.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

#workshopView .tc-labor-m-btn:active { background: var(--bg); }
#workshopView .tc-labor-m-btn.active:active { background: #48bb78; }

/* ── Drag states ─────────────────────────────────────────────── */
#workshopView .tc-row-item.dragging {
  opacity: 0.45;
}

#workshopView .tc-row-item.drag-over {
  border-top: 2px solid var(--accent);
}


/* ══════════════════════════════════════════════════════════════════
   TEMPLATE CREATOR — Responsive
   ══════════════════════════════════════════════════════════════════ */

#workshopView.ws-phone .tc-view {
  max-width: 430px;
}

#workshopView.ws-tablet .tc-view,
#workshopView.ws-wide .tc-view {
  max-width: 1100px;
  padding-left: 16px;
  padding-right: 16px;
}

/* Library: grid cards on tablet/wide */
#workshopView.ws-tablet #viewLibrary .tc-grid,
#workshopView.ws-wide   #viewLibrary .tc-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

/* Builder: 2 columns on tablet/wide */
#workshopView.ws-tablet #viewBuilder .tc-builder-grid {
  display: grid;
  grid-template-columns: 55fr 45fr;
  gap: 18px;
  align-items: start;
}

#workshopView.ws-wide #viewBuilder .tc-builder-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 18px;
  align-items: start;
}

/* Preview: wider document on tablet/wide */
#workshopView.ws-tablet .tc-estimate-doc,
#workshopView.ws-wide   .tc-estimate-doc {
  max-width: 980px;
  margin-left: auto;
  margin-right: auto;
}


/* ══════════════════════════════════════════════════════════════════
   TEMPLATE CREATOR — Keyframe animations
   ══════════════════════════════════════════════════════════════════ */

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

#workshopView .tc-card { animation: fadeSlideIn 0.22s ease forwards; }
