:root {
  color-scheme: light;
  --bg: #f7f5f0;
  --panel: #ffffff;
  --ink: #1c2326;
  --muted: #627074;
  --line: #d8d3c8;
  --accent: #0d6b75;
  --accent-strong: #07515a;
  --left: #af3f43;
  --right: #2d7050;
  --warn: #b66b17;
  --shadow: 0 12px 32px rgba(26, 31, 34, 0.08);
  --font-ui: "Atkinson Hyperlegible", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-family: var(--font-ui);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(13, 107, 117, 0.08), rgba(13, 107, 117, 0) 360px),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 0.72rem 0.95rem;
  border-radius: 6px;
  cursor: pointer;
  min-height: 2.7rem;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  border-color: #b9c1c3;
  background: #cbd2d4;
  cursor: not-allowed;
}

.secondary-button {
  background: #fff;
  color: var(--accent);
}

.secondary-button:hover {
  background: color-mix(in srgb, var(--accent) 8%, #fff);
}

.secondary-button:disabled {
  border-color: #b9c1c3;
  background: #cbd2d4;
  color: #7e8a8d;
}

label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0.66rem 0.75rem;
  min-height: 2.7rem;
}

textarea {
  resize: vertical;
  min-height: 5.5rem;
  line-height: 1.4;
}

.app {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 42px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-size: clamp(1.65rem, 2.4vw, 2.35rem);
  line-height: 1.05;
  letter-spacing: 0;
}

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

.brand-icon {
  width: 1.12em;
  height: 1.12em;
  flex: 0 0 auto;
}

.status {
  color: var(--muted);
  font-size: 0.95rem;
  text-align: right;
}

.drop-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.drop-card {
  border: 2px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  padding: 16px;
  min-height: 142px;
  display: grid;
  align-content: center;
  gap: 12px;
  box-shadow: var(--shadow);
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.drop-card[data-slot="0"] {
  --slot-color: var(--left);
}

.drop-card[data-slot="1"] {
  --slot-color: var(--right);
}

.drop-card.dragging,
.drop-card:focus-within {
  border-color: var(--slot-color);
  background: #fff;
  transform: translateY(-1px);
}

.drop-card.loaded {
  border-style: solid;
  border-color: color-mix(in srgb, var(--slot-color) 64%, var(--line));
}

.drop-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--ink);
}

.slot-name {
  min-width: 0;
  font-size: clamp(1.55rem, 2.2vw, 2.35rem);
  font-weight: 400;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.slot-mark {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  color: #fff;
  background: var(--slot-color);
  font-weight: 800;
}

.drop-meta {
  color: var(--muted);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.file-button {
  width: fit-content;
  border: 1px solid var(--slot-color);
  color: var(--slot-color);
  background: #fff;
  padding: 0.58rem 0.76rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
}

.file-button:hover {
  background: color-mix(in srgb, var(--slot-color) 8%, #fff);
}

.file-input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.controls {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr 0.78fr 0.8fr auto auto;
  gap: 12px;
  align-items: end;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}

.size-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.size-value {
  min-width: 4ch;
  color: var(--ink);
  font-weight: 760;
  text-align: right;
}

.summary-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.summary {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 150px;
  box-shadow: var(--shadow);
}

.summary h2 {
  margin: 0 0 10px;
  font-size: 1rem;
  letter-spacing: 0;
}

.summary-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.91rem;
  line-height: 1.35;
}

.summary-list strong {
  color: var(--ink);
  font-weight: 720;
}

.view-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin: 4px 0 14px;
}

.tab-button {
  border-color: transparent;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--muted);
  min-height: 2.45rem;
  padding: 0.58rem 0.82rem;
}

.tab-button:hover,
.tab-button.active {
  background: #fff;
  color: var(--ink);
}

.tab-button.active {
  border-color: var(--line);
  border-bottom-color: #fff;
  transform: translateY(1px);
}

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

.coverage {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 1.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.58rem;
  color: var(--muted);
  background: #fbfaf7;
  font-size: 0.78rem;
  font-weight: 680;
  white-space: nowrap;
}

.preview {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.preview textarea {
  font-size: 1.18rem;
  line-height: 1.45;
  min-height: clamp(10rem, 24vh, 18rem);
}

.preview-output {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.preview-line {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  min-height: clamp(180px, 24vh, 300px);
  overflow: auto;
}

.preview-label {
  color: var(--muted);
  font: 700 0.78rem/1.2 var(--font-ui);
  margin-bottom: 6px;
}

.preview-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.18;
  font-size: clamp(1.55rem, var(--preview-size), 3.6rem);
}

.grid-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 20px 0 10px;
}

.grid-head h2 {
  margin: 0;
  font-size: 1.16rem;
}

.grid-count {
  color: var(--muted);
  font-weight: 650;
}

.glyph-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  align-items: stretch;
}

.glyph-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 156px;
  padding: 10px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
  cursor: zoom-in;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.glyph-card:hover,
.glyph-card:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 46%, var(--line));
  box-shadow: 0 8px 24px rgba(26, 31, 34, 0.1);
  outline: none;
  transform: translateY(-1px);
}

.glyph-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 720;
  min-height: 1.2rem;
}

.glyph-details {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.glyph-details span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.glyph-codepoint {
  color: color-mix(in srgb, var(--muted) 45%, #fff);
  font-weight: 400;
}

.glyph-presence {
  display: inline-flex;
  align-items: center;
  gap: 0.36rem;
  flex: 0 0 auto;
}

.presence-dot {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: currentColor;
}

.presence-dot.a {
  color: var(--left);
}

.presence-dot.b {
  color: var(--right);
}

.presence-dot.missing {
  opacity: 0.18;
}

.glyph-pair {
  display: grid;
  gap: 8px;
  min-height: 84px;
}

.glyph-pair.side-by-side {
  grid-template-columns: 1fr 1fr;
}

.glyph-pair.overlap {
  grid-template-columns: 1fr;
}

.glyph-pane {
  border: 1px solid #e7e2d8be;
  border-radius: 6px;
  display: grid;
  place-items: center;
  min-width: 0;
  overflow: hidden;
  background: #fff;
  position: relative;
}

.glyph-pane.overlap {
  min-height: 94px;
}

.glyph-render {
  font-size: var(--glyph-size);
  line-height: 1;
  max-width: 100%;
  padding: 8px;
  text-align: center;
  transform: translate(var(--glyph-offset-x, 0), var(--glyph-offset-y, 0));
}

.overlap-glyph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 8px;
  font-size: var(--glyph-size);
  line-height: 1;
  text-align: center;
  mix-blend-mode: multiply;
  transform: translate(var(--glyph-offset-x, 0), var(--glyph-offset-y, 0));
}

.overlap-glyph.left {
  color: red;
  opacity: 0.5;
}

.overlap-glyph.right {
  color: #000;
  opacity: 0.8;
}

.missing-badge {
  position: absolute;
  right: 7px;
  bottom: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--left);
  padding: 0.16rem 0.44rem;
  font: 700 0.68rem/1 var(--font-ui);
}

.glyph-pane.missing {
  background:
    linear-gradient(145deg, transparent 48%, rgba(98, 112, 116, 0.24) 49%, rgba(98, 112, 116, 0.24) 51%, transparent 52%),
    #f4f1ea;
  color: var(--muted);
}

.glyph-pane.missing .glyph-render {
  font: 700 0.72rem/1.2 var(--font-ui);
  text-transform: uppercase;
  letter-spacing: 0;
}

.glyph-name {
  color: var(--muted);
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.66);
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

body.overlay-open {
  overflow: hidden;
}

.glyph-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
}

.glyph-overlay[hidden] {
  display: none;
}

.glyph-overlay-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: rgba(28, 35, 38, 0.46);
  cursor: zoom-out;
}

.glyph-overlay-backdrop:hover {
  background: rgba(28, 35, 38, 0.46);
}

.glyph-inspector {
  position: relative;
  z-index: 1;
  width: min(1160px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto minmax(320px, 1fr);
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(18, 24, 27, 0.28);
  padding: 14px;
}

.glyph-inspector-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.glyph-inspector h2 {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.glyph-inspector-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.glyph-inspector-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.glyph-action {
  min-height: 2.25rem;
  padding: 0.48rem 0.68rem;
  font-size: 0.88rem;
  white-space: nowrap;
}

.glyph-action[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}

.glyph-action[aria-pressed="true"]:hover {
  background: var(--accent-strong);
}

.glyph-close {
  width: 2.25rem;
  height: 2.25rem;
  min-height: 2.25rem;
  padding: 0;
  display: grid;
  place-items: center;
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 1.45rem;
  line-height: 1;
}

.glyph-close:hover {
  background: #f4f1ea;
}

.glyph-inspector-canvas {
  width: 100%;
  height: min(64vh, 620px);
  min-height: 320px;
  border-radius: 6px;
  background: #fbfaf7;
}

@media (max-width: 980px) {
  .controls,
  .summary-row,
  .preview {
    grid-template-columns: 1fr;
  }

  .controls {
    align-items: stretch;
  }
}

@media (max-width: 720px) {
  .app {
    width: min(100% - 20px, 1500px);
    padding-top: 14px;
  }

  .topbar,
  .grid-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .status {
    text-align: left;
  }

  .drop-row {
    grid-template-columns: 1fr;
  }

  .glyph-grid {
    grid-template-columns: 1fr;
  }

  .glyph-overlay {
    padding: 10px;
  }

  .glyph-inspector {
    max-height: calc(100vh - 20px);
    grid-template-rows: auto minmax(300px, 1fr);
    padding: 10px;
  }

  .glyph-inspector-head {
    flex-direction: column;
  }

  .glyph-inspector-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .glyph-inspector-canvas {
    height: min(70vh, 560px);
  }
}
