:root {
  --bg-primary: #121418;
  --bg-surface: #1a1e24;
  --bg-card: #222730;
  --bg-accent: #2c3340;
  --gold-primary: #e5b342;
  --gold-light: #f7d57f;
  --gold-dark: #b3851d;
  --gold-border: rgba(229, 179, 66, 0.35);
  --text-main: #f0f3f6;
  --text-muted: #9ba7b5;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.55);
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-serif: 'Cinzel', 'Georgia', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Header */
header {
  background: linear-gradient(180deg, #181d24 0%, #121418 100%);
  border-bottom: 1px solid var(--gold-border);
  padding: 1.25rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-crest {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--gold-primary);
  box-shadow: 0 0 12px rgba(229, 179, 66, 0.3);
}

.brand-text h1 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 0.03em;
}

.brand-text p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.language-switch {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.2rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

.language-button {
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  padding: 0.3rem 0.45rem;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.language-button:hover,
.language-button.active {
  border-color: var(--gold-border);
  background: var(--bg-accent);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.btn {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.btn:hover {
  background: var(--bg-accent);
  border-color: var(--gold-border);
  transform: translateY(-1px);
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold-dark) 0%, var(--gold-primary) 100%);
  color: #121418;
  font-weight: 600;
  border: none;
  box-shadow: 0 4px 14px rgba(229, 179, 66, 0.35);
}

.btn-gold:hover {
  background: linear-gradient(135deg, var(--gold-primary) 0%, var(--gold-light) 100%);
  box-shadow: 0 6px 18px rgba(229, 179, 66, 0.5);
}

/* Main Layout */
.app-container {
  display: grid;
  grid-template-columns: 1fr 380px;
  min-height: calc(100vh - 85px);
  gap: 0;
}

html.embedded body {
  min-height: 0;
}

html.embedded .app-container {
  min-height: 0;
}

.app-container.controls-collapsed {
  grid-template-columns: minmax(0, 1fr);
}

.app-container.controls-collapsed .controls-sidebar {
  display: none;
}

@media (max-width: 1080px) {
  .app-container {
    grid-template-columns: 1fr;
  }
}

/* Viewport Area */
.viewport-area {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background-color: #0b0d10;
  overflow: hidden;
}

/* Background Mode Styles */
.viewport-area.bg-dark {
  background: radial-gradient(circle at center, #1c222b 0%, #0c0e12 100%);
}

.viewport-area.bg-transparent {
  background-color: #15181e;
  background-image: linear-gradient(45deg, #1c2028 25%, transparent 25%),
                    linear-gradient(-45deg, #1c2028 25%, transparent 25%),
                    linear-gradient(45deg, transparent 75%, #1c2028 75%),
                    linear-gradient(-45deg, transparent 75%, #1c2028 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0px;
}

.viewport-area.bg-parchment {
  background: radial-gradient(circle at center, #3d3528 0%, #1f1a14 100%);
}

/* HUD Overlay */
.hud-overlay {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  background: rgba(18, 22, 28, 0.92);
  backdrop-filter: blur(14px);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.25rem;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.7);
  z-index: 20;
  max-width: 380px;
  pointer-events: auto;
}

.hud-date {
  font-family: var(--font-serif);
  font-size: 1.18rem;
  color: var(--gold-light);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.hud-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.hud-saint {
  margin-top: 0.5rem;
  border-top: 1px solid rgba(229, 179, 66, 0.25);
  padding-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.hud-saint-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.dom-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: rgba(229, 179, 66, 0.18);
  border: 1px solid var(--gold-primary);
  color: var(--gold-light);
  font-size: 0.78rem;
  font-weight: 700;
  font-family: var(--font-serif);
}

.inscr-text {
  font-size: 0.95rem;
  color: #ffffff;
  font-family: var(--font-serif);
}

.variant-tag {
  font-size: 0.72rem;
  color: #a0aec0;
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 6px;
  border-radius: 3px;
}

.hud-saint-sub {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  flex-wrap: wrap;
}

.cisio-badge {
  background: rgba(229, 179, 66, 0.15);
  color: var(--gold-light);
  border: 1px solid rgba(229, 179, 66, 0.45);
  padding: 1px 8px;
  border-radius: 12px;
}

.modern-badge {
  background: rgba(80, 160, 255, 0.15);
  color: #90cdf4;
  border: 1px solid rgba(80, 160, 255, 0.35);
  padding: 1px 8px;
  border-radius: 12px;
}

.hud-verse {
  font-size: 0.72rem;
  color: #9ca3af;
  line-height: 1.35;
  border-left: 2px solid var(--gold-dark);
  padding-left: 0.5rem;
  margin-top: 0.15rem;
}

/* 365 Saints Tab Styling */
.saints-search-bar {
  margin-bottom: 0.75rem;
}

.search-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition-fast);
}

.search-input:focus {
  border-color: var(--gold-primary);
  box-shadow: 0 0 0 2px rgba(229, 179, 66, 0.2);
}

.saints-list-container {
  max-height: 520px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-right: 0.25rem;
}

.saint-list-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  transition: var(--transition-fast);
}

.saint-list-item:hover {
  background: var(--bg-surface-hover);
  border-color: var(--gold-border);
}

.saint-list-item.active {
  background: rgba(229, 179, 66, 0.15);
  border-color: var(--gold-primary);
  box-shadow: 0 0 10px rgba(229, 179, 66, 0.2);
}

.saint-item-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.saint-item-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  width: 54px;
  flex-shrink: 0;
}

.saint-item-name {
  font-family: var(--font-serif);
  font-size: 0.875rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saint-item-right {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

/* Dial Stage */
.dial-stage-wrapper {
  position: relative;
  width: min(80vh, 700px);
  height: min(80vh, 700px);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Golden Indicator Needle */
.top-pointer {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 110px;
  z-index: 30;
  pointer-events: none;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.7));
}

.top-pointer img, .top-pointer svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Dial Container */
.dial-container {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  cursor: grab;
  user-select: none;
  touch-action: none;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.8),
              0 0 80px rgba(229, 179, 66, 0.12);
  transition: box-shadow 0.3s ease;
}

.dial-container:active {
  cursor: grabbing;
}

/* Rotating Dial Layer */
.dial-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  pointer-events: none;
  transform-origin: center center;
}

.dial-rotating {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
  display: block;
  transform-origin: center center;
}

/* Stationary Non-Rotating Center Emblem (Seal of Prague + Ring of Crosses) */
.dial-fixed-center {
  position: absolute;
  top: 50%;
  left: 50%;
  /* Exact ratio: 2000px / 7472px = 26.767% */
  width: 26.98%;
  height: 26.98%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  z-index: 15;
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(0, 0, 0, 0.6);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.dial-fixed-center:hover {
  box-shadow: 0 0 24px rgba(229, 179, 66, 0.45);
}

/* Hotspots overlay */
.hotspots-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  pointer-events: auto;
}

.hotspot {
  position: absolute;
  border-radius: 50%;
  border: 2px dashed rgba(229, 179, 66, 0);
  background: rgba(229, 179, 66, 0);
  transform: translate(-50%, -50%);
  cursor: pointer;
  transition: all 0.2s ease;
}

.hotspots-visible .hotspot {
  border-color: rgba(229, 179, 66, 0.5);
  background: rgba(229, 179, 66, 0.12);
}

.hotspot:hover {
  border-color: var(--gold-light) !important;
  background: rgba(229, 179, 66, 0.3) !important;
  transform: translate(-50%, -50%) scale(1.08);
}

/* Quick Dial Controls floating at bottom */
.stage-controls {
  margin-top: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(26, 30, 36, 0.85);
  backdrop-filter: blur(10px);
  padding: 0.6rem 1.25rem;
  border-radius: 40px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
  z-index: 20;
}

.stage-btn {
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.35rem 0.6rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.stage-btn:hover {
  color: var(--gold-light);
  background: rgba(255, 255, 255, 0.08);
}

/* Side Controls Panel */
.controls-sidebar {
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  border: 1px solid var(--border-subtle);
}

.panel-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--gold-light);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.control-group {
  margin-bottom: 1rem;
}

.control-group:last-child {
  margin-bottom: 0;
}

.control-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.control-slider {
  width: 100%;
  accent-color: var(--gold-primary);
  height: 6px;
  background: #343c4a;
  border-radius: 3px;
  cursor: pointer;
}

/* Toggle Checkboxes */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.85rem;
}

.toggle-row:last-child {
  border-bottom: none;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-round {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #353d49;
  transition: .3s;
  border-radius: 22px;
}

.slider-round:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider-round {
  background-color: var(--gold-primary);
}

input:checked + .slider-round:before {
  transform: translateX(18px);
}

/* Tabs */
.tabs-nav {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1rem;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}

.tab-btn.active {
  color: var(--gold-light);
  border-bottom-color: var(--gold-primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Medallion Thumbnails Grid */
.medallions-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.medallion-thumb {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.4rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.medallion-thumb:hover, .medallion-thumb.active {
  border-color: var(--gold-primary);
  background: var(--bg-accent);
  transform: translateY(-2px);
}

.medallion-thumb img {
  width: 100%;
  aspect-ratio: 1/1;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.medallion-thumb span {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: block;
  margin-top: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Code Snippet Block */
.code-box {
  background: #0d1015;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  font-family: 'Fira Code', monospace;
  font-size: 0.75rem;
  color: #c9d1d9;
  overflow-x: auto;
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-muted);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  cursor: pointer;
}

.copy-btn:hover {
  background: var(--gold-primary);
  color: #121418;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-lg);
  max-width: 640px;
  width: 100%;
  padding: 2rem;
  position: relative;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--gold-light);
}

.modal-body {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.5rem;
  align-items: center;
}

@media (max-width: 600px) {
  .dial-stage-wrapper {
    width: min(80vw, 700px);
    height: min(80vw, 700px);
  }

  .stage-controls {
    max-width: 100%;
    flex-wrap: wrap;
    justify-content: center;
    border-radius: var(--radius-md);
  }

  .modal-body {
    grid-template-columns: 1fr;
    text-align: center;
  }
}

.modal-image {
  width: 100%;
  aspect-ratio: 1/1;
  border-radius: 50%;
  border: 3px solid var(--gold-primary);
  box-shadow: 0 0 20px rgba(229, 179, 66, 0.3);
  object-fit: cover;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: var(--gold-light);
}

.modal-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.modal-desc {
  font-size: 0.875rem;
  color: #d1d9e2;
  line-height: 1.6;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
}
