@font-face {
  font-family: 'DM Sans';
  src: url('./assets/fonts/dm-sans.ttf') format('truetype');
  font-weight: 100 1000;
  font-display: swap;
}
@font-face {
  font-family: 'Instrument Serif';
  src: url('./assets/fonts/instrument-serif.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'Instrument Serif';
  src: url('./assets/fonts/instrument-serif-italic.woff2') format('woff2');
  font-style: italic;
  font-display: swap;
}

:root {
  color-scheme: light;
  font: 16px 'DM Sans', system-ui, sans-serif;
  --page: #f9f7f2;
  --panel: #fffdfa;
  --ink: #282531;
  --muted: #6c6572;
  --border: #e4ded8;
  --accent: #513d67;
  --accent-dark: #423052;
  --accent-light: #eee8f4;
  --serif: 'Instrument Serif', Georgia, serif;
  background: var(--page);
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden], .symbol-library { display: none !important; }
body { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { opacity: .46; cursor: default; }
button:focus-visible, input:focus-visible, .viewport:focus-visible {
  outline: 2px solid #875f9e;
  outline-offset: 3px;
}
button, a { -webkit-tap-highlight-color: transparent; }
h1, h2, p { margin: 0; }
.icon {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.site-header { border-bottom: 1px solid var(--border); background: #fcfaf6; }
.header-inner, main { width: min(calc(100% - 96px), 1300px); margin: 0 auto; }
.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 69px;
}
.brand { display: flex; align-items: center; gap: 11px; font-size: 1.15rem; font-weight: 700; letter-spacing: -.045em; }
.brand i { font: italic 1.35em var(--serif); }
.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 10px;
  background: var(--accent);
  color: #fff8ed;
}
.brand-mark .icon { width: 26px; height: 26px; stroke-width: 1.2; }
.privacy { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .8125rem; font-weight: 500; }
.privacy .icon { width: 15px; height: 15px; }

main { padding: 35px 0 20px; }
.intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 27px; }
h1 {
  font: 400 clamp(3.4rem, 5.15vw, 5.125rem)/.95 var(--serif);
  letter-spacing: -.028em;
}
h1 em { color: var(--accent); font-weight: 400; }
.intro p { color: var(--muted); margin-top: 12px; }
.main-actions { display: flex; flex-wrap: wrap; gap: 10px; padding-bottom: 2px; }
.button, .icon-button, .fit, .control-button, .segmented button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  white-space: nowrap;
  transition: background-color .16s, border-color .16s, color .16s;
}
.button {
  min-height: 44px;
  gap: 9px;
  padding: 0 15px;
  background: var(--panel);
  border-color: var(--border);
  font-size: .875rem;
  font-weight: 700;
}
.button .icon { width: 17px; height: 17px; }
.button:not(:disabled):hover, .framed:not(:disabled):hover { background: #f0ebe8; }
.button.primary { color: white; background: var(--accent); border-color: var(--accent); padding-inline: 16px; }
.button.primary:not(:disabled):hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.panel { border: 1px solid var(--border); background: var(--panel); border-radius: 14px; min-width: 0; }
.workspace { display: grid; grid-template-columns: 282px minmax(0, 1fr); gap: 19px; align-items: start; }
.sidebar { display: grid; gap: 15px; min-width: 0; }
.source { padding: 16px; }
.section-label { font-size: .875rem; font-weight: 700; }
.source-picker {
  display: flex;
  align-items: center;
  width: 100%;
  text-align: left;
  margin-top: 12px;
  padding: 7px;
  gap: 11px;
  min-width: 0;
  color: var(--ink);
  background: #f7f4ef;
  border: 1px solid #ece6df;
  border-radius: 9px;
}
.source-picker:hover { border-color: #baa9c8; background: #f4eff6; }
.source-thumb, .study-thumb { display: block; overflow: hidden; background: #e7e1dc; flex: none; }
.source-thumb { width: 48px; height: 48px; border-radius: 5px; }
.source-thumb img, .source-thumb canvas, .study-thumb canvas { display: block; width: 100%; height: 100%; object-fit: cover; }
.source-details, .study-copy { min-width: 0; flex: 1; display: grid; gap: 3px; }
.source-name, .source-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-name { font-size: .875rem; font-weight: 700; }
.source-meta { color: var(--muted); font-size: .765625rem; }
.source-picker > .icon { margin-right: 3px; color: var(--muted); width: 17px; height: 17px; }

.reference-list { padding: 10px; }
.list-header { display: flex; align-items: center; justify-content: space-between; padding: 1px 4px 5px 6px; min-height: 37px; }
.icon-button { width: 33px; height: 33px; color: var(--muted); padding: 0; }
.icon-button:not(:disabled):hover { background: #f0eaf2; color: var(--accent); }
.icon-button[aria-pressed="true"] { color: var(--accent); background: var(--accent-light); }
.icon-button .icon { width: 17px; height: 17px; }
#studies { display: grid; gap: 4px; }
.study-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
  min-height: 60px;
  padding: 6px 8px;
  gap: 11px;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: 9px;
}
.study-item:not([aria-pressed="true"]):hover { background: #f7f3f1; }
.study-item[aria-pressed="true"] { background: var(--accent-light); border-color: #e5dbef; color: var(--accent-dark); }
.study-thumb { width: 43px; height: 46px; border: 1px solid #34273e19; border-radius: 5px; }
.study-thumb canvas { object-position: 50% 38%; }
.study-name { font-size: .875rem; font-weight: 700; line-height: 1.15; }
.study-caption { font-size: .765625rem; color: var(--muted); }
.study-chevron { width: 15px; height: 15px; color: #8f8198; opacity: 0; }
.study-item:is(:hover,[aria-pressed="true"]) .study-chevron { opacity: 1; }

.viewer { overflow: hidden; box-shadow: 0 2px 10px #34273e06; }
.viewer-header, .viewer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 17px 14px 19px;
}
.viewer-header { min-height: 74px; }
.viewer-header h2 { font-size: 1.125rem; line-height: 1.25; letter-spacing: -.025em; }
.viewer-header p { font-size: .875rem; color: var(--muted); margin-top: 4px; }
.viewer-actions { display: flex; gap: 9px; align-items: center; }
.segmented { display: flex; border: 1px solid #ebe4e0; padding: 3px; background: #f4f0ed; border-radius: 8px; }
.segmented button { color: var(--muted); padding: 5px 10px; border-radius: 5px; font-weight: 600; font-size: .8125rem; }
.segmented button[aria-pressed="true"] { color: var(--accent-dark); background: var(--panel); box-shadow: 0 1px 3px #33263816; border-color: #e8e0e6; }
.segmented button:not([aria-pressed="true"]):hover { color: var(--accent); }
.framed { border-color: var(--border); width: 35px; height: 35px; }
.photo-layer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 35px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent-dark);
  font-size: .8125rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.photo-layer input { margin: 0; accent-color: var(--accent); }
.photo-layer:has(input:checked) { background: var(--accent-light); border-color: #e5dbef; }
.photo-layer:has(input:disabled) { opacity: .56; cursor: default; }
.guide-key {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 17px;
  margin: 0;
  padding: 8px 17px 8px 19px;
  border-top: 1px solid #eee8e4;
  background: #faf7f4;
  list-style: none;
  color: var(--muted);
  font-size: .8125rem;
  font-weight: 600;
}
.guide-key li { display: inline-flex; align-items: center; gap: 6px; }
.guide-key li::before { content: ''; width: 14px; border-top: 2px solid var(--guide-colour); }
.guide-key [data-guide="jaw"]::before { border-top-style: dashed; }
.tone-options {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 17px 7px 19px;
  border-top: 1px solid #eee8e4;
  background: #faf7f4;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 600;
}
.tone-count button { min-width: 32px; padding: 4px 7px; }
.tones-legend { display: flex; gap: 3px; margin-left: auto; }
.tones-legend span { width: 16px; height: 16px; border: 1px solid #29202b30; border-radius: 3px; }

.viewport {
  position: relative;
  height: clamp(370px, calc(100dvh - 365px), 780px);
  border-block: 1px solid #e5dfdb;
  overflow: auto;
  background: radial-gradient(circle, #84778648 .75px, transparent .9px) 0 0 / 16px 16px, #efebe6;
}
.image-bed {
  width: max-content;
  min-width: 100%;
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 25px;
}
.artwork { width: 0; height: 0; position: relative; background: #fffdf7; box-shadow: 0 8px 24px #29202b28, 0 1px 4px #29202b20; }
.artwork canvas { display: block; width: 100%; height: 100%; }
.artwork.tracing { cursor: crosshair; touch-action: none; }
.handles { position: absolute; inset: 0; pointer-events: none; }
.handle {
  position: absolute;
  width: 19px;
  height: 19px;
  transform: translate(-50%, -50%);
  border: 2px solid white;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px #2f1e40aa;
  cursor: grab;
  touch-action: none;
  pointer-events: auto;
}
.handle:active { cursor: grabbing; }
.canvas-message {
  max-width: 350px;
  position: absolute;
  inset: auto 12px 12px;
  margin: auto;
  text-align: center;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 2px 6px #29202b12;
  font-size: .8125rem;
}
.drop-message {
  position: sticky;
  inset: 0;
  min-height: 100%;
  margin-top: calc(clamp(370px, 100dvh - 365px, 780px) * -1);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  background: #f4edf5ef;
  border: 2px dashed #977fac;
  color: var(--accent);
  font-weight: 700;
}
.contact-sheet { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 19px; }
.contact-card {
  display: grid;
  gap: 10px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--accent-dark);
  font-weight: 700;
  font-size: .875rem;
  text-align: left;
}
.contact-card:hover { border-color: #987da9; }
.contact-card .tile { display: grid; place-items: center; overflow: hidden; height: clamp(130px, 18vw, 230px); border-radius: 4px; background: #ebe6df; }
.tile canvas { width: 100%; height: 100%; object-fit: contain; min-height: 0; }
.viewer-footer { min-height: 59px; padding-block: 10px; }
.study-controls { display: flex; flex: 1; align-items: center; gap: 8px 13px; flex-wrap: wrap; min-width: 0; color: var(--muted); font-size: .8125rem; }
.study-controls label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.study-controls input[type="range"] { width: clamp(58px, 9vw, 120px); accent-color: var(--accent); }
.study-controls input[type="checkbox"] { margin: 0 3px 0 0; accent-color: var(--accent); }
.study-controls output { min-width: 25px; font-variant-numeric: tabular-nums; }
.control-button { min-height: 30px; padding-inline: 9px; border-color: var(--border); color: var(--accent); font-weight: 700; }
.control-button:not(:disabled):hover { background: var(--accent-light); }
.tone-cutoffs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 109px), 1fr)); gap: 8px 12px; width: min(100%, 580px); }
.tone-cutoffs label { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 6px; }
.tone-cutoffs input[type="range"] { width: 100%; margin: 0; grid-row: 2; }
.tone-cutoffs output { grid-column: 2; grid-row: 2; text-align: right; }
.zoom { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; flex: none; }
.zoom .icon-button { width: 31px; height: 31px; }
.fit { min-width: 52px; padding: 0 6px; height: 31px; gap: 4px; color: var(--muted); font-size: .8125rem; font-weight: 600; }
.fit:hover { background: var(--accent-light); color: var(--accent); }
.fit .icon { height: 13px; width: 13px; }
.workspace-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 13px; font-size: .8125rem; color: var(--muted); }
.drawing-tip { display: flex; align-items: center; gap: 7px; }
.drawing-tip .icon { width: 15px; height: 15px; color: var(--accent); }
#resolution { white-space: nowrap; }
.notice {
  position: fixed;
  z-index: 2;
  bottom: 20px;
  right: 22px;
  max-width: min(400px, calc(100vw - 44px));
  padding: 12px 16px;
  background: var(--accent-dark);
  color: white;
  font-size: .875rem;
  border-radius: 10px;
  box-shadow: 0 4px 18px #29202b33;
}

@media (max-width: 1020px) {
  .header-inner, main { width: calc(100% - 56px); }
  .workspace { grid-template-columns: 234px minmax(0, 1fr); gap: 14px; }
}
@media (max-width: 750px) {
  .header-inner, main { width: calc(100% - 32px); }
  .header-inner { min-height: 53px; }
  main { padding-top: 19px; }
  .intro { align-items: start; flex-direction: column; gap: 12px; margin-bottom: 14px; }
  h1 { font-size: clamp(2.85rem, 9vw, 3.55rem); }
  .intro p { margin-top: 6px; font-size: .9375rem; }
  .button { min-height: 40px; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .sidebar { display: flex; flex-direction: column; gap: 10px; }
  .source { display: flex; align-items: center; gap: 11px; padding: 5px 9px; }
  .source h2 { white-space: nowrap; }
  .source-picker { margin: 0; padding: 3px 5px; }
  .source-thumb { width: 34px; height: 34px; }
  .reference-list { padding: 5px 7px 7px; }
  #studies { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; }
  .study-item { display: grid; justify-items: center; align-content: start; gap: 5px; text-align: center; padding: 5px 2px; height: 100%; }
  .study-caption, .study-chevron { display: none; }
  .study-thumb { width: 33px; height: 35px; }
  .study-name { font-size: .75rem; white-space: normal; }
  .viewer-header, .viewer-footer, .tone-options, .guide-key { padding-inline: 12px; }
  .viewport { height: clamp(300px, 58dvh, 660px); }
  .drop-message { margin-top: calc(clamp(300px, 58dvh, 660px) * -1); }
  .image-bed { padding: 15px; }
  .contact-sheet { gap: 8px; padding: 10px; }
}
@media (max-width: 430px) {
  .privacy { font-size: .72rem; }
  .brand { font-size: 1.05rem; }
  .brand-mark { width: 32px; height: 32px; }
  .viewer-header h2 { font-size: 1rem; }
  .viewer-header p { font-size: .75rem; }
  .viewer-actions { gap: 5px; }
  .segmented button { padding-inline: 6px; font-size: .75rem; }
  .study-controls { gap: 6px; }
  .workspace-footer { align-items: start; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
