:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #111111;
  --muted: #5d6674;
  --border: #dce2ea;
}

@font-face {
  font-family: "Sloan";
  src: url("./src/assets/fonts/Sloan.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: block;
}

@font-face {
  font-family: "OpticianSans";
  src: url("./src/assets/fonts/Optician-Sans.woff") format("woff");
  font-style: normal;
  font-weight: 400;
  font-display: block;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background: linear-gradient(120deg, #eef3f9, #fdfefe);
}

.app {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
}

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

.display {
  background: #fff;
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  --edge-label-zone: clamp(78px, 10vw, 170px);
}

.display-canvas {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  overflow: hidden;
}

.display.safe-edge-frame .display-canvas {
  left: var(--edge-label-zone);
  right: var(--edge-label-zone);
}

.display-meta {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 900;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 18px;
  font-size: clamp(12px, 1.1vw, 20px);
  font-weight: 700;
  color: #111;
  pointer-events: none;
}

.display-meta span {
  display: inline-block;
  width: var(--edge-label-zone);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#displayLogmar {
  text-align: left;
}

#displayDecimal {
  text-align: right;
}

.controls {
  position: fixed;
  top: 56px;
  right: 12px;
  bottom: 12px;
  width: min(360px, calc(100vw - 24px));
  z-index: 1300;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
}

.toggle-controls {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1500;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: #111;
  cursor: pointer;
}

.quick-actions {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1000;
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 200px;
}

.quick-actions button {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  color: #111;
  font-weight: 600;
}

#guideAction {
  grid-column: 1 / -1;
}

.guide-modal[hidden] {
  display: none;
}

.guide-modal {
  position: fixed;
  inset: 0;
  z-index: 1400;
}

.guide-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 17, 28, 0.55);
}

.guide-card {
  position: relative;
  width: min(560px, calc(100vw - 28px));
  margin: 8vh auto 0;
  background: #fff;
  border: 1px solid #d8e0ea;
  border-radius: 14px;
  box-shadow: 0 22px 50px rgba(15, 23, 42, 0.28);
  overflow: hidden;
}

.guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #e5ebf2;
}

.guide-head h2 {
  margin: 0;
  font-size: 18px;
}

.guide-close {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  font-size: 24px;
  line-height: 1;
  padding: 0;
}

.guide-body {
  padding: 14px 16px 8px;
}

.guide-body p {
  margin: 0 0 10px;
  font-size: 14px;
}

.guide-foot {
  padding: 12px 16px 16px;
  display: flex;
  justify-content: flex-end;
}

.guide-foot button {
  min-width: 96px;
  font-weight: 600;
}

h1 {
  margin: 0 0 8px 0;
  font-size: 20px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

input, select, button {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

button {
  cursor: pointer;
}

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

#meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.chart-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.line {
  display: flex;
  align-items: center;
  justify-content: center;
}

.glyph {
  width: var(--size);
  height: var(--size);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}

.glyph svg {
  display: block;
  shape-rendering: geometricPrecision;
  overflow: hidden;
}

.glyph svg text,
.duo-glyph svg text {
  text-rendering: geometricPrecision;
  font-synthesis: none;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.optotype-text.optotype-sloan {
  font-family: "Sloan";
}

.optotype-text.optotype-number {
  font-family: "OpticianSans";
}

.sloan-warning-screen {
  padding: 24px;
}

.sloan-warning {
  max-width: 540px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: #111;
}

.duo {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.duo-plate {
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.duo-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}

.duo-glyph-row {
  display: flex;
  align-items: center;
  justify-content: center;
}

.duo-digit {
  display: inline-block;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  font-weight: 700;
  line-height: 1;
  color: #111;
  font-variant-numeric: lining-nums;
  letter-spacing: 0;
}

.dots {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.worth {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
}

.worth-bg {
  position: absolute;
  inset: 0;
  background: #111;
  z-index: 0;
}

.worth svg {
  position: relative;
  z-index: 1;
}

.princess-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}

.superhero-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}

.princess-image {
  width: min(35vw, 390px);
  max-width: 62vmin;
  height: auto;
  animation: princess-wave 4s cubic-bezier(0.42, 0, 0.58, 1) infinite;
  user-select: none;
  pointer-events: none;
}

.superhero-image {
  width: min(36vw, 430px);
  max-width: 66vmin;
  height: auto;
  animation: superhero-fly 4s cubic-bezier(0.42, 0, 0.58, 1) infinite;
  user-select: none;
  pointer-events: none;
}

@keyframes princess-wave {
  0% {
    transform: translateY(0);
  }
  20% {
    transform: translateY(-14px);
  }
  40% {
    transform: translateY(-28px);
  }
  60% {
    transform: translateY(8px);
  }
  80% {
    transform: translateY(-18px);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes superhero-fly {
  0% {
    transform: translateY(0);
  }
  20% {
    transform: translateY(-18px);
  }
  40% {
    transform: translateY(-34px);
  }
  60% {
    transform: translateY(10px);
  }
  80% {
    transform: translateY(-22px);
  }
  100% {
    transform: translateY(0);
  }
}

@media (max-width: 960px) {
  .controls {
    top: 56px;
    right: 8px;
    left: 8px;
    bottom: 8px;
    width: auto;
  }
  .quick-actions {
    width: 170px;
  }
}
