:root {
  --paper: #ECECEA; --ink: #232321; --green: #1F4D36; --teal: #19AEC2; --graphite: #77756F; --rose: #E26A86; --brown: #8C6B3F;
  --hand: 'Bradley Hand', 'Noteworthy', 'Segoe Print', cursive;
  --script: 'Savoye LET', 'Snell Roundhand', 'Apple Chancery', cursive;
  --serif: 'Iowan Old Style', Palatino, Georgia, serif;
  --wobble: 255px 15px 225px 15px / 15px 225px 15px 255px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); font-family: var(--serif); }
#app { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 30vw); height: 100dvh;
       border-top: 3px solid var(--rose); border-bottom: 3px solid var(--rose); }
#viewer { position: relative; min-height: 0; border-right: 1.5px solid var(--brown); }
#stage { position: absolute; inset: 0; touch-action: none; }
#stage canvas { display: block; width: 100%; height: 100%; }
.inked { border: 1.6px solid var(--ink); border-radius: var(--wobble); background: rgba(244, 244, 241, .92); }
#tag { position: absolute; left: 18px; top: 16px; padding: 6px 20px 8px 16px; max-width: calc(100% - 36px); pointer-events: none; }
#tag-name { font-family: var(--script); font-size: 40px; line-height: 1; color: var(--green); }
#tag-latin { font-family: var(--hand); font-weight: bold; font-size: 13px; color: var(--graphite); margin-top: 2px; }
#hint { position: absolute; right: 16px; top: 20px; font-family: var(--hand); font-weight: bold; font-size: 12px; color: var(--graphite); }
#controls { position: absolute; left: 14px; right: 14px; bottom: 12px; display: flex; flex-direction: column; gap: 7px; pointer-events: none; }
#controls .row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
#controls .lab { font-family: var(--hand); font-weight: bold; font-size: 12px; color: var(--graphite); width: 38px; }
.chip { font-family: var(--hand); font-weight: bold; font-size: 12.5px; color: var(--graphite); background: rgba(236, 236, 234, .85);
        border: 1.4px solid var(--graphite); border-radius: var(--wobble); padding: 4px 12px; cursor: pointer; pointer-events: auto; }
.chip.on { color: var(--paper); background: var(--green); border-color: var(--green); }
.chip.go { border-style: dashed; }
.chip.go.on { color: var(--green); background: rgba(236, 236, 234, .85); border-style: solid; border-color: var(--green); }
.chip.loading { opacity: .55; }
#side { overflow-y: auto; padding: 14px 18px 24px; }
#drawing { margin-top: 22px; }
#drawing summary { font-family: var(--hand); font-weight: bold; font-size: 14px; color: var(--graphite); cursor: pointer; margin-bottom: 8px; }
#drawing img { display: block; width: 100%; border-radius: 8px; box-shadow: 2px 4px 12px rgba(40, 30, 20, .15); }
#panel { margin-top: 2px; }
#panel .regionlist { list-style: none; padding: 0; margin: 10px 0 0; font-size: 14px; }
#panel .regionlist li { display: flex; justify-content: space-between; border-bottom: 1px solid rgba(119,117,111,.28); padding: 4px 0; }
#panel .regionlist .n { font-family: var(--hand); font-weight: bold; color: var(--graphite); font-size: 12.5px; }
#panel p.intro { font-size: 14px; line-height: 1.45; margin: 4px 0 8px; }
#panel h1 { font-family: var(--script); font-weight: normal; font-size: 44px; line-height: 1; color: var(--green); margin: 0; }
#panel .where { font-family: var(--hand); font-weight: bold; font-size: 13px; color: var(--graphite); margin: 2px 0 12px; }
.lens { border: 1.5px solid var(--c); border-radius: var(--wobble); margin-bottom: 9px; background: rgba(244, 244, 241, .7); }
.lens summary { list-style: none; cursor: pointer; padding: 8px 14px; display: flex; align-items: center; gap: 10px;
                font-family: var(--hand); font-weight: bold; font-size: 15px; }
.lens summary::-webkit-details-marker { display: none; }
.lens summary::before { content: ''; flex: none; width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--c);
                        background: color-mix(in srgb, var(--c) 25%, transparent); }
.lens summary .n { margin-left: auto; font-size: 12px; color: var(--graphite); }
.lens .lines { padding: 0 14px 10px 37px; font-size: 14px; line-height: 1.42; }
.lens .line { margin: 0 0 9px; }
.lens .line b { font-family: var(--hand); color: var(--c); filter: brightness(.8); }
.lens .line .src { display: block; font-family: var(--hand); font-weight: bold; font-size: 11.5px; color: var(--graphite); margin-top: 1px; }
.lens .sub { font-family: var(--hand); font-weight: bold; font-size: 12px; color: var(--graphite); margin: 6px 0 5px; }
.lens .none { color: var(--graphite); font-style: italic; font-size: 13px; }
.draft { font-family: var(--hand); font-weight: bold; font-size: 12px; color: #8E1B2B; margin: 4px 0 12px; }
#credit { font-size: 11px; color: var(--graphite); margin: 18px 0 0; line-height: 1.4; }
@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 68dvh auto; height: auto; min-height: 100dvh; }
  #viewer { border-right: 0; border-bottom: 1.5px solid var(--brown); }
  #side { overflow: visible; }
  #hint { display: none; }
  #tag-name { font-size: 34px; }
  #drawing:not([open]) img { display: none; }
}

.lens .line .other { display: block; font-size: 12px; font-style: italic; color: var(--graphite); margin-top: 2px; }
