:root {
  --bg-dark: #0a0a0c;
  --bg-darker: #050507;
  --ornament-color: #f5f1e6;
  --ornament-color-dim: rgba(245, 241, 230, 0.72);
  --ornament-color-faint: rgba(245, 241, 230, 0.42);
  --rule-color: rgba(245, 241, 230, 0.2);
  --frame-shadow: rgba(0, 0, 0, 0.35);
  --font-display: 'Fraunces', 'Cormorant Garamond', 'Didot', serif;
  --font-serif: 'Cormorant Garamond', 'EB Garamond', 'Garamond', serif;
}

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

html, body {
  width: 100%;
  height: 100%;
}

body {
  background: radial-gradient(circle at center, var(--bg-dark), var(--bg-darker));
  color: var(--ornament-color);
  font-family: var(--font-serif);
  overflow: hidden;
}

.page {
  position: relative;
  width: 100vw;
  height: 100vh;
}

.ornament-stage {
  position: absolute;
  inset: 0;
  pointer-events: none;
  filter: drop-shadow(0 20px 40px var(--frame-shadow));
  z-index: 1;
}

.ornament-stage > svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.content-frame-wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(86vw, 880px);
  height: min(76vh, 620px);
  z-index: 2;
}

.content-frame-stage {
  position: absolute;
  inset: -22px;
  width: calc(100% + 44px);
  height: calc(100% + 44px);
  pointer-events: none;
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.35));
  z-index: 1;
}

.content-frame-stage > svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.content-mask {
  position: absolute;
  inset: 0;
  background: rgba(5, 5, 7, 0.01);
  z-index: 2;
}

.content-box {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 91%;
  height: 64%;
  padding: clamp(14px, 1.8vw, 22px) clamp(16px, 2vw, 26px);
  background: rgba(5, 5, 12, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  text-align: left;
  overflow-y: auto;
  isolation: isolate;
  z-index: 3;
  border: 1px solid var(--rule-color);
  font-family: var(--font-serif);
  font-weight: 400;
  color: var(--ornament-color-dim);

  scrollbar-width: thin;
  scrollbar-color: var(--rule-color) transparent;
}

.content-box::-webkit-scrollbar {
  width: 6px;
}
.content-box::-webkit-scrollbar-thumb {
  background: var(--rule-color);
  border-radius: 3px;
}

.content-body {
  position: relative;
  z-index: 1;
}

.cv-header {
  text-align: center;
  margin-bottom: clamp(14px, 2.4vh, 22px);
  padding-bottom: clamp(10px, 1.4vh, 14px);
  border-bottom: 1px solid var(--rule-color);
}

.content-box h1 {
  font-family: var(--font-serif);
  font-weight: 500;
  font-style: normal;
  font-size: clamp(1.45rem, 2.4vw, 1.85rem);
  letter-spacing: 0;
  line-height: 1.15;
  text-transform: none;
  color: var(--ornament-color);
  margin-bottom: 4px;
}

.cv-contact {
  --icon-color: #7e9bba;
  --icon-color-hover: #b8cee4;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  margin-top: 6px;
  color: var(--icon-color);
}

.content-box .cv-contact a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  border: none;
  text-decoration: none;
  padding: 4px;
  transition: color 160ms ease, transform 160ms ease;
}

.content-box .cv-contact a:hover {
  color: var(--icon-color-hover);
  transform: translateY(-1px);
  border: none;
}

.content-box .cv-contact a:focus-visible {
  outline: 1px solid var(--icon-color-hover);
  outline-offset: 3px;
  border-radius: 4px;
}

.cv-contact svg {
  width: 20px;
  height: 20px;
  display: block;
}

.cv-section {
  margin-bottom: clamp(14px, 2.2vh, 22px);
}

.cv-section h2 {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(0.7rem, 0.92vw, 0.78rem);
  text-transform: uppercase;
  letter-spacing: 0.42em;
  text-align: center;
  color: var(--ornament-color);
  margin-bottom: clamp(10px, 1.4vh, 14px);
  padding-bottom: 6px;
  position: relative;
  margin-left: 0.21em;
}

.cv-section h2::after {
  content: '';
  display: block;
  width: 24px;
  height: 1px;
  background: var(--ornament-color-faint);
  margin: 6px auto 0;
}

.content-box p {
  font-family: var(--font-serif);
  font-size: clamp(0.9rem, 1.05vw, 1rem);
  font-weight: 400;
  line-height: 1.4;
  color: var(--ornament-color-dim);
  letter-spacing: 0.005em;
  margin-bottom: clamp(6px, 0.9vh, 10px);
  text-indent: 0;
  hyphens: auto;
}

.content-box p em {
  font-style: italic;
  color: rgba(245, 241, 230, 0.85);
}

.content-box a {
  color: var(--ornament-color);
  text-decoration: none;
  border-bottom: 1px solid var(--ornament-color-faint);
  padding-bottom: 1px;
  transition: border-color 160ms ease;
}

.content-box a:hover {
  border-bottom-color: var(--ornament-color);
}

.debug-toggle {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(8, 8, 10, 0.7);
  color: var(--ornament-color);
  font-size: 0.9rem;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 10;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.debug-toggle:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.4);
}

.controls-panel {
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(8, 8, 10, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 18px;
  min-width: 240px;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 20;
}

.controls-panel[hidden] {
  display: none;
}

.admin-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.admin-label {
  font-size: 0.85rem;
  color: var(--ornament-color-dim);
}

.admin-input {
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ornament-color);
  font-size: 0.9rem;
}

.controls-panel h3 {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 12px;
  color: var(--ornament-color);
}

.motif-controls {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.motif-controls h4 {
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 10px;
  color: var(--ornament-color);
}

.motif-filter {
  width: 100%;
  padding: 6px 8px;
  margin-bottom: 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ornament-color);
}

.motif-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 6px;
  margin-bottom: 10px;
}

.motif-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px;
  font-size: 0.75rem;
  color: var(--ornament-color-dim);
}

.motif-item input {
  margin: 0;
}

.motif-admin {
  max-width: 1100px;
  margin: 40px auto;
  padding: 20px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

.motif-admin__header h1 {
  font-size: 1.6rem;
  margin-bottom: 6px;
}

.motif-admin__header p {
  color: var(--ornament-color-dim);
  margin-bottom: 18px;
}

.motif-admin__section {
  margin-bottom: 24px;
}

.motif-admin__section h2 {
  font-size: 1.1rem;
  margin-bottom: 6px;
}

.motif-admin__section p {
  color: var(--ornament-color-dim);
  margin-bottom: 12px;
}

.motif-admin__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
  align-items: center;
}

.motif-admin__controls .motif-filter {
  flex: 1 1 220px;
}

.motif-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.element-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.variant-groups {
  display: grid;
  gap: 16px;
}

.variant-group h3 {
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.variant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.variant-card {
  display: grid;
  gap: 6px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.78rem;
  color: var(--ornament-color);
  cursor: pointer;
}

.variant-card__preview {
  display: grid;
  place-items: center;
  height: 72px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}

.variant-card__title {
  font-weight: 500;
}

.variant-card__meta {
  color: var(--ornament-color-dim);
  font-size: 0.7rem;
}

.motif-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.8rem;
  color: var(--ornament-color);
  cursor: pointer;
}

.motif-card__preview {
  display: grid;
  place-items: center;
  height: 54px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}

.motif-card input {
  justify-self: start;
}

.motif-card__title {
  font-weight: 500;
}

.motif-card__meta {
  color: var(--ornament-color-dim);
  font-size: 0.7rem;
}

.controls-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--ornament-color);
  text-decoration: none;
  font-size: 0.8rem;
  opacity: 0.85;
}

.control-group {
  margin-bottom: 14px;
}

.control-group label {
  display: block;
  font-size: 0.72rem;
  color: var(--ornament-color-dim);
  margin-bottom: 6px;
}

.control-group input[type='range'] {
  width: 100%;
}

.control-group select {
  width: 100%;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--ornament-color);
}

.btn-group {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.btn {
  flex: 1;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ornament-color);
  cursor: pointer;
  font-size: 0.8rem;
}

.btn--primary {
  background: var(--ornament-color);
  color: var(--bg-dark);
  border-color: var(--ornament-color);
}
