/* ==========================================================================
   RulePDF V11 Dedicated Document Studio Stylesheet (/studio/)
   Drafting Instrument Precision: Sliding Obsidian Tool Dock, Millimeter Page
   Ruler, 4-Corner FigmaFrame Selection Handles, & Pressure Fountain-Pen Pad
   ========================================================================== */

.st-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper-canvas);
  color: var(--ink-obsidian);
}

/* -------------------- TOP STUDIO COMMAND BAR -------------------- */
.st-topbar {
  height: 58px;
  padding: 0 1rem;
  background: var(--paper-ivory);
  border-bottom: 1px solid var(--rule-strong);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 55;
}

.st-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.st-doc-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.st-docname {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink-obsidian);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 195px;
}

.st-page-pill {
  padding: 2px 7px;
  border-radius: var(--r-2xs);
  background: var(--paper-parchment);
  border: 1px solid var(--rule-strong);
  font-family: var(--font-mono);
  font-size: 0.69rem;
  font-weight: 600;
  color: var(--ink-muted);
  white-space: nowrap;
}

/* Center Precision Tool Dock (#46476 Obsidian Active Pill + Keyboard Hints) */
.st-ribbon {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--paper-parchment);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm);
  box-shadow: inset 0 1px 1px rgba(17, 19, 24, 0.04);
}

.st-tool-btn {
  min-height: 34px;
  padding: 0.3rem 0.64rem;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-body);
  font-size: 0.79rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 130ms ease, color 130ms ease, box-shadow 130ms ease;
}

.st-tool-btn:hover {
  color: var(--ink-obsidian);
  background: var(--paper-white);
}

.st-tool-btn kbd {
  font-family: var(--font-mono);
  font-size: 0.63rem;
  font-weight: 600;
  opacity: 0.55;
  margin-left: 1px;
}

.st-tool-btn.is-active {
  background: var(--ink-obsidian);
  color: var(--paper-white);
  box-shadow: var(--bevel-obsidian);
}

.st-tool-btn.is-active kbd {
  opacity: 0.78;
}

/* Right History + Zoom + Single Primary Export CTA */
.st-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.st-icon-group {
  display: inline-flex;
  align-items: center;
  background: var(--paper-white);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-xs);
  padding: 2px;
}

.st-ic-btn {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-obsidian);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 700;
}

.st-ic-btn:hover:not(:disabled) {
  background: var(--paper-parchment);
}

.st-ic-btn:disabled {
  opacity: 0.34;
  cursor: not-allowed;
}

.st-zoom-lbl {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0 0.38rem;
  min-width: 44px;
  text-align: center;
  color: var(--ink-obsidian);
  cursor: pointer;
}

/* -------------------- CONTEXTUAL STATUS & FORMAT SUB-BAR -------------------- */
.st-subbar {
  min-height: 40px;
  padding: 0.32rem 1rem;
  background: var(--paper-white);
  border-bottom: 1px solid var(--rule-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.st-hint {
  font-size: 0.79rem;
  line-height: 1.4;
  color: var(--ink-body);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.st-hint strong {
  color: var(--ink-obsidian);
}

.st-kbd-pill {
  display: inline-block;
  padding: 1px 5px;
  border-radius: var(--r-2xs);
  background: var(--paper-parchment);
  border: 1px solid var(--rule-strong);
  font-family: var(--font-mono);
  font-size: 0.67rem;
  font-weight: 600;
  color: var(--ink-body);
}

.st-format-bar {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  background: var(--paper-ivory);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-xs);
  padding: 2px 6px;
  box-shadow: var(--shadow-xs);
}

.st-color-dot {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  border: 2px solid var(--paper-white);
  box-shadow: 0 0 0 1px var(--rule-strong);
  cursor: pointer;
  padding: 0;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.st-color-dot.is-active {
  box-shadow: 0 0 0 2px var(--ink-obsidian);
  transform: scale(1.12);
}

.st-fmt-sep {
  width: 1px;
  height: 16px;
  background: var(--rule-strong);
  margin: 0 2px;
}

/* -------------------- 3-COLUMN STUDIO WORKSPACE -------------------- */
.st-workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 178px minmax(0, 1fr) 318px;
  min-height: 0;
}

/* Left Page Thumbnails Rail */
.st-thumbs-rail {
  background: var(--paper-ivory);
  border-right: 1px solid var(--rule-strong);
  padding: 0.8rem 0.68rem;
  overflow-y: auto;
  max-height: calc(100dvh - 98px);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.st-rail-head {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ink-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--rule-line);
}

.st-thumb-card {
  width: 100%;
  text-align: left;
  padding: 0.38rem;
  border-radius: var(--r-xs);
  border: 1px solid var(--rule-strong);
  background: var(--paper-white);
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.st-thumb-card:hover {
  border-color: var(--ink-body);
}

.st-thumb-card.is-active {
  border-color: var(--ink-obsidian);
  box-shadow: 0 0 0 1.5px var(--ink-obsidian);
}

.st-thumb-card.is-deleted {
  opacity: 0.38;
  border-style: dashed;
}

.st-thumb-frame {
  height: 114px;
  background: var(--paper-parchment);
  border: 1px solid var(--rule-line);
  border-radius: 4px;
  margin-bottom: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.st-thumb-frame img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.st-thumb-meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--ink-body);
}

/* Center Scrollable Drafting Stage */
.st-stage-scroll {
  overflow: auto;
  max-height: calc(100dvh - 98px);
  padding: 1rem clamp(0.75rem, 2.2vw, 2rem) 4.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-image:
    radial-gradient(rgba(17, 19, 24, 0.08) 1px, transparent 1px);
  background-size: 18px 18px;
}

.st-stage-controls-row {
  width: 760px;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.st-pager-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--paper-white);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-xs);
  padding: 2px 5px;
  box-shadow: var(--shadow-xs);
}

.st-ruler-bar {
  width: 760px;
  max-width: 100%;
  height: 18px;
  background: var(--paper-ivory);
  border: 1px solid var(--rule-strong);
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 8px 2px;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--ink-muted);
  position: relative;
  overflow: hidden;
}

.st-ruler-bar::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 7px;
  background-image:
    repeating-linear-gradient(90deg, var(--ink-obsidian) 0, var(--ink-obsidian) 1px, transparent 1px, transparent 36px),
    repeating-linear-gradient(90deg, var(--rule-strong) 0, var(--rule-strong) 1px, transparent 1px, transparent 6px);
  opacity: 0.65;
}

/* Active PDF Sheet Container */
.st-pdf-sheet {
  position: relative;
  width: 760px;
  max-width: 100%;
  background: #FFFFFF;
  border: 1px solid var(--rule-strong);
  border-radius: 0 0 3px 3px;
  box-shadow: 0 8px 28px rgba(17, 19, 24, 0.11), 0 1px 3px rgba(17, 19, 24, 0.06);
  user-select: none;
  transform-origin: top center;
}

.st-pdf-sheet[data-cursor="crosshair"] { cursor: crosshair; }
.st-pdf-sheet[data-cursor="text"] { cursor: text; }

.st-pdf-img {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
}

.st-lines-layer,
.st-ops-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.st-shell[data-tool="edit-text"] .st-lines-layer {
  pointer-events: auto;
}

.st-line-box {
  position: absolute;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 2px;
  background: transparent;
  cursor: text;
  transition: background-color 80ms ease, border-color 80ms ease;
}

.st-shell[data-tool="edit-text"] .st-line-box {
  border-color: rgba(29, 68, 242, 0.24);
  background: rgba(29, 68, 242, 0.035);
}

.st-shell[data-tool="edit-text"] .st-line-box:hover {
  border-color: var(--accent-cobalt);
  background: rgba(29, 68, 242, 0.13);
  z-index: 3;
}

/* Placed Interactive Vector Annotations (#17069 FigmaFrame Selection) */
.st-op {
  position: absolute;
  pointer-events: auto;
  border: 1.5px solid transparent;
  cursor: grab;
  display: flex;
  align-items: center;
  touch-action: none;
  z-index: 5;
  will-change: left, top;
}

.st-op:hover {
  border-color: rgba(29, 68, 242, 0.55);
}

.st-op.is-selected {
  border: 1.5px solid var(--accent-cobalt);
  background-color: rgba(29, 68, 242, 0.03);
  z-index: 14;
}

.st-op:active {
  cursor: grabbing;
}

/* 4 Square Vector Corner Handles when Selected */
.st-op-corner {
  position: absolute;
  width: 7px;
  height: 7px;
  background: #FFFFFF;
  border: 1.5px solid var(--accent-cobalt);
  display: none;
  pointer-events: none;
}
.st-op-corner.tl { top: -4.5px; left: -4.5px; }
.st-op-corner.tr { top: -4.5px; right: -4.5px; }
.st-op-corner.bl { bottom: -4.5px; left: -4.5px; }

.st-op.is-selected .st-op-corner {
  display: block;
}

.st-op.is-sig img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  display: block;
}

.st-op.is-sig-typed {
  font-family: var(--font-sig);
  font-weight: 600;
  white-space: nowrap;
  padding: 1px 6px;
  line-height: 1.05;
}

.st-op.is-rewrite,
.st-op.is-text {
  background: #FFFFFF;
  padding: 0 3px;
}

.st-op.is-text:not(.is-selected) {
  background: rgba(255, 255, 255, 0.9);
}

.st-op-inp {
  width: 100%;
  min-width: 64px;
  border: 0;
  background: transparent;
  font-family: Helvetica, Arial, sans-serif;
  font-weight: 600;
  padding: 1px 2px;
  outline: none;
  line-height: 1.2;
}

.st-op.is-check {
  justify-content: center;
}

.st-op.is-check svg {
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.st-op.is-whiteout {
  background: #FFFFFF;
  border-color: #CBD5E1;
}

.st-op.is-redact {
  background: #111318;
}

.st-op-del {
  position: absolute;
  top: -11px;
  right: -11px;
  width: 21px;
  height: 21px;
  border-radius: 4px;
  border: 1.5px solid #FFFFFF;
  background: var(--ink-obsidian);
  color: #FFFFFF;
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
}

.st-op-del:hover {
  background: var(--signal-crimson);
}

.st-op:hover .st-op-del,
.st-op.is-selected .st-op-del {
  display: inline-flex;
}

.st-op-resize {
  position: absolute;
  right: -5.5px;
  bottom: -5.5px;
  width: 11px;
  height: 11px;
  background: var(--accent-cobalt);
  border: 1.5px solid #FFFFFF;
  cursor: nwse-resize;
  display: none;
  touch-action: none;
}

.st-op.is-selected .st-op-resize,
.st-op:hover .st-op-resize {
  display: block;
}

/* -------------------- RIGHT INSPECTOR PANEL (@uvain Signature Pad + Controls) -------------------- */
.st-inspector {
  background: var(--paper-ivory);
  border-left: 1px solid var(--rule-strong);
  padding: 0.9rem;
  overflow-y: auto;
  max-height: calc(100dvh - 98px);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.st-card {
  padding: 0.88rem;
  border-radius: var(--r-md);
  background: var(--paper-white);
  border: 1px solid var(--rule-line);
  box-shadow: var(--shadow-xs);
}

.st-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.55rem;
}

.st-card-head h3 {
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.st-sig-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 3px;
  background: var(--paper-parchment);
  border: 1px solid var(--rule-line);
  border-radius: var(--r-xs);
  margin-bottom: 0.55rem;
}

.st-sig-tab {
  min-height: 29px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--ink-body);
  cursor: pointer;
}

.st-sig-tab.is-active {
  background: var(--paper-white);
  color: var(--ink-obsidian);
  box-shadow: var(--shadow-xs);
}

.st-ink-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--ink-muted);
}

/* Tactile Fountain-Pen Pad (#26945 Adapted) */
.st-pad-wrap {
  position: relative;
  background: #FFFFFF;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-xs);
  margin-bottom: 0.6rem;
  overflow: hidden;
}

#st-sig-canvas {
  width: 100%;
  height: 112px;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.st-pad-baseline {
  position: absolute;
  inset-inline: 14px;
  bottom: 24px;
  border-bottom: 1px dashed var(--rule-strong);
  pointer-events: none;
}

.st-pad-placeholder {
  position: absolute;
  inset-inline: 14px;
  bottom: 6px;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  color: var(--ink-muted);
  text-align: center;
  pointer-events: none;
  transition: opacity 150ms ease;
}

.st-pad-wrap.has-ink .st-pad-placeholder {
  opacity: 0;
}

.rp-type-preview {
  min-height: 58px;
  padding: 0.5rem 0.75rem;
  border-radius: var(--r-xs);
  border: 1px solid var(--rule-line);
  background: var(--paper-ivory);
  font-family: var(--font-sig);
  font-size: 1.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.st-upload-sig-box {
  border: 1px dashed var(--rule-strong);
  border-radius: var(--r-xs);
  background: var(--paper-ivory);
  padding: 0.85rem;
  text-align: center;
  margin-bottom: 0.6rem;
}

.rp-side-btn-stack {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 0.45rem;
}

.rp-ai-note {
  padding: 0.55rem 0.65rem;
  border-radius: var(--r-xs);
  background: var(--paper-ivory);
  border: 1px solid var(--rule-line);
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--ink-body);
  margin-bottom: 0.4rem;
}

.rp-ai-note:last-child { margin-bottom: 0; }

.st-empty-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: var(--paper-ivory);
}

/* Mobile Bottom Studio Bar & Sheet */
.rp-sheet-scrim {
  position: fixed;
  inset: 0;
  background: rgba(17, 19, 24, 0.42);
  z-index: 70;
}

.rp-sheet-mobile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--rule-line);
}

.rp-mobile-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 65;
  height: 60px;
  background: var(--paper-ivory);
  border-top: 1px solid var(--rule-strong);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 4px 6px;
}

.rp-mob-tab {
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--ink-body);
  font-size: 0.68rem;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
}

.rp-mob-tab.is-active {
  background: var(--ink-obsidian);
  color: var(--paper-white);
}

@media (max-width: 1024px) {
  .st-ribbon,
  .st-thumbs-rail,
  .st-ruler-bar {
    display: none !important;
  }

  .st-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .st-stage-scroll {
    max-height: none;
    padding: 0.75rem 0.6rem 5.5rem;
  }

  .st-inspector {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 75;
    border-left: 0;
    border-top: 1px solid var(--rule-strong);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -16px 40px rgba(17, 19, 24, 0.22);
    max-height: 84dvh;
    transform: translateY(105%);
    transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .st-inspector.is-open {
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .st-docname { max-width: 118px; font-size: 0.79rem; }
  .st-page-pill { display: none; }
  .st-zoom-group { display: none !important; }
}
