:root {
  --obsidian: #0F141C;
  --obsidian-card: rgba(20, 27, 38, 0.92);
  --obsidian-deep: #090D13;
  --ducat-gold: #F59E0B;
  --ducat-bright: #FBBF24;
  --emerald-seal: #10B981;
  --crimson-wax: #DC2626;
  --parchment-ink: #F8FAFC;
  --muted-slate: #94A3B8;
  --border-gold: rgba(245, 158, 11, 0.35);
  --font-serif: 'Newsreader', Georgia, serif;
  --font-sans: 'Public Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--obsidian);
  color: var(--parchment-ink);
  font-family: var(--font-sans);
  overflow: hidden;
}

.vault-bg {
  position: fixed;
  inset: 0;
  background: url('bg.jpg') center center / cover no-repeat;
  opacity: 0.28;
  z-index: 0;
  pointer-events: none;
}

.vault-vignette {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 25%, rgba(15, 20, 28, 0.45) 0%, rgba(9, 13, 19, 0.94) 100%);
  z-index: 1;
  pointer-events: none;
}

.app-shell {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  height: 100%;
  margin: 0 auto;
  padding: 10px 12px 12px;
  gap: 8px;
}

/* Header */
.mint-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--obsidian-card);
  border: 1px solid var(--border-gold);
  border-left: 4px solid var(--ducat-gold);
  border-radius: 3px;
  padding: 8px 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 9px;
}

.seal-crest-wrap {
  width: 38px;
  height: 38px;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid var(--ducat-gold);
  clip-path: polygon(29% 0%, 71% 0%, 100% 29%, 100% 71%, 71% 100%, 29% 100%, 0% 71%, 0% 29%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-crest-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.mint-sub {
  display: block;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--ducat-gold);
  font-weight: 700;
}

.mint-title {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--parchment-ink);
  line-height: 1.1;
}

.header-metrics {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ledger-slip-stat {
  background: rgba(9, 13, 19, 0.85);
  border: 1px solid rgba(245, 158, 11, 0.28);
  border-radius: 3px;
  padding: 4px 8px;
  text-align: right;
}

.stat-lbl {
  display: block;
  font-size: 10px;
  color: var(--muted-slate);
  font-weight: 600;
  letter-spacing: 0.06em;
}

.stat-val {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.gold-txt {
  color: var(--ducat-bright);
}

.emerald-txt {
  color: var(--emerald-seal);
}

/* Wax-Seal Octagon Buttons (NEVER 999px pills!) */
.oct-btn {
  appearance: none;
  border: 1px solid var(--ducat-gold);
  background: linear-gradient(180deg, #1E293B 0%, #0F172A 100%);
  color: var(--parchment-ink);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 9px 14px;
  cursor: pointer;
  white-space: nowrap;
  clip-path: polygon(8px 0%, calc(100% - 8px) 0%, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0% calc(100% - 8px), 0% 8px);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.oct-btn:active {
  transform: scale(0.95);
}

.oct-btn.gold-oct {
  background: linear-gradient(180deg, #F59E0B 0%, #B45309 100%);
  color: #090D13;
  border-color: #FDE68A;
}

.oct-btn.emerald-oct {
  background: linear-gradient(180deg, #10B981 0%, #047857 100%);
  color: #052E16;
  border-color: #6EE7B7;
}

.oct-btn.sm-oct {
  padding: 6px 11px;
  font-size: 12px;
}

.oct-btn.icon-oct {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  clip-path: polygon(28% 0%, 72% 0%, 100% 28%, 100% 72%, 72% 100%, 28% 100%, 0% 72%, 0% 28%);
}

/* 4-Section Navigation Bar (Strict 3px Bank Slips) */
.section-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.nav-slip {
  appearance: none;
  background: rgba(15, 20, 28, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-bottom: 3px solid rgba(245, 158, 11, 0.3);
  border-radius: 3px;
  color: var(--muted-slate);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  padding: 9px 4px;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-slip.active {
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.22) 0%, rgba(15, 20, 28, 0.95) 100%);
  color: var(--ducat-bright);
  border-color: var(--ducat-gold);
  border-bottom: 3px solid var(--ducat-bright);
}

/* Workspace & Panes */
.workspace-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 8px;
}

.tab-pane {
  display: none;
  flex-direction: column;
  gap: 10px;
}

.tab-pane.active {
  display: flex;
}

.ledger-desk-card {
  background: var(--obsidian-card);
  border: 1px solid var(--border-gold);
  border-radius: 3px;
  padding: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.card-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.folio-tag {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ducat-gold);
  margin-bottom: 2px;
}

.section-heading {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--parchment-ink);
}

.checksum-badge {
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid var(--emerald-seal);
  border-radius: 3px;
  color: #6EE7B7;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 4px 8px;
  white-space: nowrap;
}

/* Artifact Selector */
.artifact-selector {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.artifact-tile {
  background: rgba(9, 13, 19, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 3px;
  padding: 7px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--muted-slate);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.artifact-tile img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.artifact-tile span {
  white-space: nowrap;
  overflow: hidden;
  overflow-wrap: break-word;
  max-width: 100%;
}

.artifact-tile.selected {
  border-color: var(--ducat-gold);
  background: rgba(245, 158, 11, 0.16);
  color: var(--parchment-ink);
}

/* Inputs */
.ledger-inputs-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.input-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-field label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted-slate);
  letter-spacing: 0.04em;
}

.input-field input,
.input-field select,
.support-box textarea {
  background: #090D13;
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 3px;
  color: var(--parchment-ink);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 7px 8px;
  width: 100%;
  user-select: text;
}

.ledger-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Filter Bar & Cashbook Entries */
.filter-bar,
.karat-preset-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  margin-bottom: 10px;
}

.filter-slip {
  background: #090D13;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 3px;
  color: var(--muted-slate);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 4px;
  cursor: pointer;
  white-space: nowrap;
}

.filter-slip.active {
  background: rgba(245, 158, 11, 0.22);
  border-color: var(--ducat-gold);
  color: var(--ducat-bright);
}

.cashbook-entries {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
}

.cashbook-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(9, 13, 19, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-left: 3px solid var(--ducat-gold);
  border-radius: 3px;
  padding: 7px 9px;
  gap: 8px;
}

.cashbook-row-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cashbook-row-left img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.batch-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--parchment-ink);
}

.batch-meta {
  font-size: 12px;
  color: var(--muted-slate);
  font-variant-numeric: tabular-nums;
}

.seal-hash-tag {
  font-size: 12px;
  font-weight: 700;
  color: var(--emerald-seal);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 3px;
  padding: 3px 6px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* SECTION 2: CIPHER LOCK */
.cipher-top-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--obsidian-card);
  border: 1px solid var(--border-gold);
  border-radius: 3px;
  padding: 8px 10px;
}

.level-nav-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cipher-level-title {
  text-align: center;
  min-width: 170px;
}

.cipher-moves-box {
  background: #090D13;
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 3px;
  padding: 4px 10px;
  text-align: right;
}

.cipher-clue-ledger {
  background: var(--obsidian-card);
  border: 1px solid var(--border-gold);
  border-radius: 3px;
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.clue-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.18);
  padding-bottom: 4px;
}

.clue-badge {
  font-weight: 700;
  color: var(--ducat-gold);
  font-size: 12px;
}

.clue-text {
  color: var(--parchment-ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.clue-sum-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 3px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.lock-state-tag {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 3px;
  background: rgba(245, 158, 11, 0.18);
  color: var(--ducat-bright);
  border: 1px solid var(--ducat-gold);
}

.lock-state-tag.unlocked {
  background: rgba(16, 185, 129, 0.22);
  color: #6EE7B7;
  border-color: var(--emerald-seal);
}

.canvas-vault-frame {
  position: relative;
  width: 100%;
  max-width: 340px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  background: radial-gradient(circle, rgba(20, 27, 38, 0.95) 0%, rgba(9, 13, 19, 0.98) 100%);
  border: 2px solid var(--border-gold);
  border-radius: 3px;
  box-shadow: inset 0 0 28px rgba(0, 0, 0, 0.8), 0 8px 24px rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
}

#cipherCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: pointer;
}

.cipher-controls-bar {
  background: var(--obsidian-card);
  border: 1px solid var(--border-gold);
  border-radius: 3px;
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ring-selector-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.ring-step-btns {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  gap: 6px;
}

/* SECTION 3: ASSAY CALC */
.assay-results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.assay-metric-box {
  background: #090D13;
  border: 1px solid rgba(245, 158, 11, 0.28);
  border-radius: 3px;
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.assay-metric-box.full-span {
  grid-column: 1 / -1;
}

.assay-big-val {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.assay-note {
  font-size: 12px;
  color: var(--muted-slate);
}

/* SECTION 4: VAULT */
.vault-seals-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.vault-seal-tile {
  background: #090D13;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 3px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.vault-seal-tile.unlocked {
  border-color: var(--emerald-seal);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.14) 0%, #090D13 100%);
}

.vault-seal-tile img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  filter: grayscale(1) opacity(0.45);
}

.vault-seal-tile.unlocked img {
  filter: none;
}

.seal-tile-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--parchment-ink);
}

.seal-tile-status {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted-slate);
}

.vault-seal-tile.unlocked .seal-tile-status {
  color: var(--emerald-seal);
}

.assay-cert-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

/* Wax Stamp Burst */
.wax-stamp-burst {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transform: scale(1.6);
  transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.wax-stamp-burst.show {
  opacity: 1;
  transform: scale(1);
}

.wax-octagon-inner {
  width: 132px;
  height: 132px;
  background: radial-gradient(circle, #EF4444 0%, #991B1B 100%);
  border: 3px solid #FDE68A;
  clip-path: polygon(29% 0%, 71% 0%, 100% 29%, 100% 71%, 71% 100%, 29% 100%, 0% 71%, 0% 29%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.8);
}

.wax-octagon-inner img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.wax-octagon-inner span {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  color: #FEF08A;
  letter-spacing: 0.08em;
}

/* Toast */
.vault-toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #090D13;
  border: 1px solid var(--ducat-gold);
  border-left: 4px solid var(--emerald-seal);
  border-radius: 3px;
  color: var(--parchment-ink);
  font-size: 12px;
  font-weight: 700;
  padding: 9px 14px;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.75);
}

.vault-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Settings Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.85);
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-ledger-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  background: #121824;
  border: 1px solid var(--ducat-gold);
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.85);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(245, 158, 11, 0.25);
  background: #090D13;
}

.modal-body {
  padding: 12px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-body.hidden {
  display: none;
}

.settings-group {
  background: rgba(9, 13, 19, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 3px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.group-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ducat-gold);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.setting-row p {
  font-size: 12px;
  color: var(--muted-slate);
}

.support-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}

.star-rating-row {
  display: flex;
  gap: 4px;
}

.star-btn {
  background: #090D13;
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 3px;
  color: var(--muted-slate);
  font-size: 16px;
  width: 30px;
  height: 30px;
  cursor: pointer;
}

.star-btn.active {
  color: var(--ducat-bright);
  border-color: var(--ducat-gold);
}

.legal-btns-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.legal-scroll-box {
  background: #090D13;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 3px;
  padding: 10px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted-slate);
  max-height: 52vh;
  overflow-y: auto;
}


/* === 2026 STUDIO POLISH & ZERO-ELLIPSIS AUTO-FIT === */
button, .tab-btn, [role="tab"], .skew-btn, .hex-btn, .plaque-btn, .jewel-btn, .jewel-tab,
.chevron-btn, .chevron-tab, .bead-key, .pebble-btn, .ticket-btn, .stamp-btn, .program-btn,
.fletch-btn, .dist-plate, .concave-btn, .brut-btn, .oct-btn, .nav-slip, .filter-slip,
.awning-btn, .kermis-tab {
  font-size: clamp(11px, 3.1vw, 14px);
  line-height: 1.2;
  overflow-wrap: break-word;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 8px 20px rgba(0, 0, 0, 0.35);
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

button:active, .tab-btn:active, [role="tab"]:active, .hex-btn:active, .plaque-btn:active,
.jewel-btn:active, .jewel-tab:active, .chevron-btn:active, .chevron-tab:active,
.bead-key:active, .pebble-btn:active, .ticket-btn:active, .stamp-btn:active,
.program-btn:active, .fletch-btn:active, .dist-plate:active, .concave-btn:active,
.medallion-btn:active, .brut-btn:active, .oct-btn:active, .nav-slip:active,
.filter-slip:active, .awning-btn:active, .kermis-tab:active {
  transform: scale(0.95);
}

header, .top-bar, .hud-bar, .card, .glass-panel, .modal-card, .settings-group,
.stat-pill, .hud-pill, .badge, .toast, #toast {
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 8px 20px rgba(0, 0, 0, 0.35);
}

p, .subtitle, .banner-text, .desc, .toast, #toast, .hint-box, .clue-text, .status-banner {
  white-space: normal;
  overflow-wrap: break-word;
}


/* === 2026 STUDIO PREMIUM UI POLISH === */
button, .btn, [role="button"], .mode-btn, .nav-plaque, .vessel-tile {
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.22s ease, filter 0.18s ease !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), inset 0 -1px 0 rgba(0, 0, 0, 0.38), 0 6px 18px -4px rgba(0, 0, 0, 0.45);
}
button:hover, .btn:hover, .mode-btn:hover, .nav-plaque:hover {
  filter: brightness(1.07);
}
button:active, .btn:active, [role="button"]:active, .mode-btn:active, .nav-plaque:active, .vessel-tile:active {
  transform: scale(0.95) translateY(1px) !important;
  filter: brightness(1.12);
}
@keyframes studioScorePop2026 {
  0% { transform: scale(1); }
  40% { transform: scale(1.22); filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.75)); }
  100% { transform: scale(1); }
}
.studio-score-pop {
  display: inline-block;
  animation: studioScorePop2026 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
