:root { --nav-h: 60px; --tine-h: 200px; }
body { font-family: 'IBM Plex Sans Thai', -apple-system, system-ui, sans-serif; line-height: 1.5; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
body.no-nav { padding-bottom: 0; }
body.no-nav .bottom-nav { display: none; }
body.in-player #install-banner { display: none !important; }
h1, h2, h3, h4, .font-heading { font-family: 'IBM Plex Sans Thai', -apple-system, system-ui, sans-serif; }
button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid #A9603F; outline-offset: 2px; }

/* kalimba: walnut body with silver tines */
.kalimba-body { background: linear-gradient(180deg, #7A5440 0%, #6B4936 55%, #5E3F2E 100%); border: 1px solid #4E3426; box-shadow: 0 8px 22px rgba(58, 64, 47, .16); }
.kal-hint, .kal-hint * { color: rgba(242, 237, 226, .82) !important; }
#kalimba-hole-label { color: rgba(242, 237, 226, .35) !important; }
.sound-hole { background: #3B281D; border: 1px solid #4E3426; box-shadow: inset 0 3px 8px rgba(0, 0, 0, .35); }
.metal-bridge { background: linear-gradient(180deg, #E3E6EA 0%, #9AA2AD 100%); }
.kalimba-tine { position: relative; flex: 1 1 0; min-width: 0; max-width: 88px; --tip: 46px; border-radius: 0 0 999px 999px; box-shadow: inset 2px 0 0 rgba(255, 255, 255, .22), inset -2px 0 0 rgba(0, 0, 0, .06); transition: transform 0.05s ease, filter 0.05s ease; transform-origin: top center; }
/* a soft glow at the tip when a tine is played */
.kalimba-tine::after { content: ''; position: absolute; inset: auto 0 0 0; height: 45%; border-radius: inherit; background: radial-gradient(ellipse at 50% 100%, rgba(255, 255, 255, .8), transparent 70%); opacity: 0; transition: opacity .3s; pointer-events: none; }
.kalimba-tine.active::after { opacity: 1; transition: none; }
.tl { pointer-events: none; display: flex; flex-direction: column; align-items: center; line-height: 1; }
.tl-dots { font-size: 9px; height: 7px; letter-spacing: -1px; }
.tl-num { font-size: 13px; font-weight: 700; }
.tl-name { font-size: 10px; font-weight: 600; margin-top: 2px; }
.kalimba-tine.active { transform: scaleY(0.985); filter: brightness(1.08); }
.kalimba-tine.guide-target { box-shadow: 0 0 0 3px #FFF9F0, 0 0 16px 5px rgba(255, 249, 240, .85); animation: pulse 0.7s infinite alternate; z-index: 1; }
.kalimba-tine.wrong { box-shadow: 0 0 0 3px #A24F3E; z-index: 1; }
@keyframes pulse { from { filter: brightness(1); } to { filter: brightness(1.2); } }
.kal-compact { --tine-h: 110px; }
.kal-compact .kalimba-tine { --tip: 28px; }
.kal-compact .tl-num { font-size: 12px; } .kal-compact .tl-name { font-size: 9px; }
.kal-compact .kal-hole, .kal-compact .kal-hint { display: none; }
.kal-compact .kalimba-body { padding: 0.375rem 0.375rem 0.25rem; border-radius: 0 0 22px 22px; border-top: 0; }
.kal-compact .metal-bridge { height: 10px; margin-bottom: 2px; }

/* Play page: a full-screen kalimba, tines from the top edge, a big sound hole, two round buttons */
#section-play { --H: calc(100dvh - var(--nav-h) - env(safe-area-inset-bottom)); position: relative; overflow: hidden; height: var(--H); width: 100%;
  background: radial-gradient(120% 70% at 50% 78%, #7A5440 0%, #5E3F2E 60%, #4E3426 100%); }
#section-play.hidden { display: none; }
body.on-play header.app-header { display: none; }
#section-play [data-kslot="play"] { position: absolute; inset: 0 0 auto 0; --tine-h: calc(var(--H) * 0.58 - 30px); }
#section-play .kalimba-body { background: none; border: 0; box-shadow: none; border-radius: 0; padding: 0 3px; }
#section-play .metal-bridge, #section-play .kal-hole { display: none; }
#section-play .kalimba-tine { padding-bottom: 14px; --tip: 52px; }
#section-play .tl-num { font-size: 18px; } #section-play .tl-name { font-size: 12px; } #section-play .tl-dots { font-size: 11px; height: 9px; }
.play-card { position: absolute; z-index: 5; top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px; }
.play-hole { position: absolute; z-index: 2; left: 50%; top: calc(var(--H) * 0.64); width: min(40vw, 21dvh); aspect-ratio: 1; transform: translateX(-50%); border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #3B281D 0%, #2A1C14 72%); box-shadow: inset 0 6px 16px rgba(0, 0, 0, .45), 0 1px 0 rgba(255, 255, 255, .08);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: #F2EDE2; }
#active-note-display .an-dots { font-size: 12px; height: 10px; letter-spacing: -1px; color: #E6B49D; }
#active-note-display .an-num { font-size: 42px; font-weight: 600; line-height: 1; }
#active-note-display .an-name { font-size: 13px; color: #E9D9C6; margin-top: 4px; }
.play-fab { position: absolute; z-index: 3; bottom: 16px; width: 56px; height: 56px; border-radius: 50%; background: #F2EDE2; color: #3A402F;
  display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(0, 0, 0, .25); font-weight: 700; font-size: 18px; line-height: 1; }
.play-fab small { font-size: 9px; font-weight: 600; margin-top: 2px; }
.fab-lines { display: flex; flex-direction: column; gap: 4px; } .fab-lines i { display: block; width: 22px; height: 3px; border-radius: 2px; background: #3A402F; }

/* bottom navigation */
.bottom-nav { padding-bottom: env(safe-area-inset-bottom); }
.nav-btn { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--nav-h); font-size: 11px; font-weight: 500; color: #5F6652; transition: color .15s; }
.nav-btn[aria-current="page"] { color: #9E5636; }
.nav-btn[aria-current="page"]::before { content: ''; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; border-radius: 0 0 2px 2px; background: #9E5636; }

/* segmented controls and toggles */
.seg-on { background: #5B634B; color: #F2EDE2; font-weight: 600; }
.seg-off { color: #5F6652; }
.tog-on { border-color: #9E5636 !important; color: #9E5636 !important; }
#pl-mic.tog-on { background: #A9603F; color: #FFF9F0 !important; }

/* player fills the space between the header and the bottom nav */
#section-player:not(.hidden) { display: flex; height: calc(100dvh - var(--hdr, 60px) - var(--nav-h) - env(safe-area-inset-bottom)); }
#section-player .kalimba-body { border-radius: 0 0 22px 22px; }

/* portrait only: on a phone turned sideways the screen is too short to see the notes and the keys at once */
#rotate-note { display: none; }
@media (orientation: landscape) and (max-height: 540px) { #rotate-note { display: flex; } }

/* song sheet: numbers over lyrics, like the kalimba tabs people share online */
.sh-line { display: flex; flex-wrap: wrap; row-gap: 14px; }
.sh-bar { display: flex; align-items: flex-start; padding: 0 4px; border-left: 1px solid #E0D8C8; }
.sh-n { display: flex; flex-direction: column; align-items: center; min-width: 1.85rem; padding: 2px 3px 3px; border-radius: 10px; transition: background .1s; }
.sh-up, .sh-dn { height: 8px; font-size: 10px; line-height: 8px; letter-spacing: -1px; color: #9E5636; }
.sh-d { font-size: 21px; font-weight: 600; line-height: 1.15; color: #3A402F; font-variant-numeric: tabular-nums; }
.sh-d small { font-size: 12px; font-weight: 500; }
.sh-l { font-size: 12px; line-height: 18px; min-height: 18px; color: #5F6652; white-space: nowrap; }
.sh-n.done .sh-d { color: #C3BBA9; }
.sh-n.sh-tie { min-width: 1.2rem; padding-left: 0; padding-right: 0; }
.sh-n.hit .sh-d { color: #4F7A3A; }
.sh-n.hit .sh-l { color: #4F7A3A; }
.sh-rest { display: flex; flex-direction: column; align-items: center; min-width: 1.85rem; padding: 2px 3px 3px; }
.sh-rest .sh-d { color: #C3BBA9; font-weight: 400; }
.sh-c { display: block; min-height: 14px; font-size: 10px; line-height: 14px; font-weight: 600; color: #B0382E; white-space: nowrap; }
.sh-n.sel { box-shadow: inset 0 0 0 1.5px #A9603F; }
.sh-n.on { background: #A9603F; }
.sh-n.on .sh-d, .sh-n.on .sh-l, .sh-n.on .sh-up, .sh-n.on .sh-dn { color: #FFF9F0; }

/* sheet practice: the note to play now, and the mini kalimba */
.sh-n.target { background: #F0D7CB; box-shadow: inset 0 0 0 2px #A9603F; }
.sh-n.wrong { background: #F5E0DC; box-shadow: inset 0 0 0 2px #A24F3E; }
.sh-n.wrong .sh-d { color: #A24F3E; }
.sh-n.miss .sh-d { color: #A24F3E; text-decoration: line-through; }
.ms-t { flex: 1 1 0; max-width: 24px; min-height: 30px; border-radius: 0 0 8px 8px; background: #E0D8C8; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 3px; transition: background .12s; }
.ms-t span { font: 600 9px ui-monospace, Menlo, monospace; color: #5F6652; }
.ms-t.target { background: #C47A5C; } .ms-t.target span { color: #FFF9F0; }
.ms-t.hint { background: #E6B49D; }
.ms-t.hit { background: #A7B59C; }
.ms-t.bad { background: #A24F3E; } .ms-t.bad span { color: #FFF9F0; }

/* tuner tine strip */
.tu-tine { width: 14px; border-radius: 0 0 6px 6px; background: #E0D8C8; transition: background .2s; }
.tu-tine.ok { background: #A7B59C; }
.tu-tine.off { background: #C47A5C; }
.tu-tine.now { outline: 2px solid #3A402F; outline-offset: 1px; }

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
/* M2: inputs must stay editable under the body's user-select:none (iOS), 16px avoids focus-zoom */
input, textarea, select { -webkit-user-select: text; user-select: text; font-size: 16px; }
select#select-label-mode, select#select-note-system { font-size: 13px; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; }
header.app-header { padding-top: max(0.5rem, env(safe-area-inset-top)); }
.strip-key { background: #E0D8C8; transition: background .08s, transform .08s; }
.strip-key.lit { background: #C47A5C; transform: scaleY(1.12); }
.mcard.playing { box-shadow: 0 0 0 2px #A9603F; }
.chip { min-width: 1.9rem; }
.chip.sel { outline: 2px solid #C77A52; outline-offset: 1px; }
/* one line of the source photo, pinned under the play bar while its measures scroll by */
.rv-strip { position: sticky; top: calc(var(--hdr, 60px) + var(--rvbar, 84px)); z-index: 10; overflow: hidden; background: #fff;
  border: 1px solid #D8CDBE; border-radius: 10px; box-shadow: 0 2px 6px rgba(60, 40, 20, .12); }
.rv-strip img { position: absolute; max-width: none; height: auto; }
#keypad button { touch-action: manipulation; }
@media (prefers-reduced-motion: reduce) { .kalimba-tine.guide-target { animation: none; } * { transition: none !important; } }
.moved-bar { background: #FFF3D6; color: #4A3A22; border-bottom: 1px solid #E2C98F; padding: 10px 16px; font-size: 13px; line-height: 1.45; display: flex; flex-direction: column; gap: 6px; }
.moved-bar b { font-size: 14px; }
.moved-bar div { display: flex; gap: 8px; flex-wrap: wrap; }
.moved-bar button, .moved-bar a { padding: 6px 12px; border-radius: 8px; font-weight: 600; text-decoration: none; }
.moved-bar button { background: #fff; border: 1px solid #C9A85E; color: #4A3A22; }
.moved-bar a { background: #B0382E; color: #fff; }
