:root {
  color-scheme: light;
  font-family: "DM Sans", "Segoe UI", sans-serif;
  color: #202823;
  background: #f7f2e8;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #202823;
  --muted: #858c84;
  --line: #e7e5de;
  --green: #37735c;
  --green-dark: #285b47;
  --part: #e36a5c;
  --common: #2d9a9b;
  --paper: #fffdf7;
  --wine: #5b304a;
  --wine-dark: #412236;
  --display: "Instrument Serif", Georgia, serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, select { font: inherit; }
[hidden] { display: none !important; }

.topbar {
  min-height: 68px; padding: 12px max(22px, calc((100% - 1200px) / 2));
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: var(--paper); border-bottom: 1px solid #ded5c6;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px; color: var(--ink);
  font-size: 17px; font-weight: 700; text-decoration: none; white-space: nowrap;
}
.brand-mark { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; color: white; background: var(--wine); font-size: 18px; }
.landing-nav { display: flex; align-items: center; gap: 26px; }
.landing-nav a, .guide-link, .privacy-note a, .landing-footer a { color: var(--wine); text-underline-offset: 4px; }
.landing-nav a { font-size: 14px; font-weight: 600; text-decoration: none; }
.landing-nav a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--wine); outline-offset: 3px; }
.top-actions { display: flex; align-items: center; gap: 7px; margin-left: auto; margin-right: 18px; }
.edit-actions { display: flex; align-items: center; gap: inherit; flex-shrink: 0; white-space: nowrap; }
.top-button { height: 34px; padding: 0 12px; border: 1px solid #e3e5dd; border-radius: 8px; color: #526057; background: white; cursor: pointer; font-size: 11px; }
.top-button:hover { background: #f6f7f2; }
.top-button-primary { border-color: var(--wine); color: white; background: var(--wine); }
.top-button-primary:hover { background: var(--wine-dark); }
.top-button-export { border-color: #e8d7b7; color: #795826; background: #fbf4e6; font-weight: 600; }
.top-button-export:hover { background: #f7ecd7; }
.top-button:disabled { opacity: .6; cursor: wait; }
#undo-edit:disabled, #redo-edit:disabled { cursor: default; }
.workspace { min-height: calc(100vh - 68px); padding: 22px; }

.landing { max-width: 1200px; margin: 0 auto; color: #292329; }
.hero {
  min-height: 505px; display: grid; grid-template-columns: 1.12fr 1fr;
  align-items: center; gap: clamp(26px, 6vw, 90px); padding: 44px 0 58px;
}
.section-kicker {
  color: var(--wine); font-size: .76rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
}
.hero h1 {
  margin: 14px 0 18px; font: 400 clamp(64px, 6.65vw, 105px) / .94 var(--display);
  letter-spacing: -.018em;
}
.hero em { color: var(--wine); }
.welcome-copy, .practice p:not(.section-kicker) { max-width: 51ch; color: #5d555a; font-size: 1.04rem; line-height: 1.65; }
.guide-link { display: inline-flex; gap: 12px; align-items: center; font-size: .92rem; font-weight: 700; margin-top: 10px; }
.welcome-card {
  padding: clamp(22px, 3.4vw, 42px); border: 1px solid #dcd1c3;
  border-radius: 18px; background: var(--paper); box-shadow: 0 12px 32px #49302412;
}
.welcome-card h2 { margin: 0; font: 400 38px / 1.1 var(--display); }
.card-intro { margin: 8px 0 22px; color: #5d555a; font-size: .92rem; }
.dropzone {
  min-height: 175px; padding: 16px 10px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; border: 1px dashed #ab829d; border-radius: 10px;
  background: #f7eef4; cursor: pointer; transition: background .18s ease;
}
.dropzone:hover, .dropzone.dragging { border-color: var(--wine); background: #f0e1eb; }
.dropzone:focus-within { outline: 2px solid var(--wine); outline-offset: 3px; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-icon {
  width: 38px; height: 38px; display: grid; place-items: center; margin-bottom: 13px;
  border: 1px solid #ded0db; border-radius: 50%; color: var(--wine); background: white; font-size: 23px;
}
.drop-title { color: #3b2838; font-size: .95rem; font-weight: 700; }
.drop-subtitle { margin-top: 6px; color: #64545f; font-size: .8rem; }
.selected-file { max-width: 85%; overflow: hidden; margin-top: 10px; color: var(--wine); font-size: .8rem; text-overflow: ellipsis; white-space: nowrap; }
.primary-button {
  width: 100%; min-height: 48px; margin-top: 14px; display: flex; align-items: center; justify-content: center;
  gap: 12px; border: 0; border-radius: 8px; color: white; background: var(--wine); cursor: pointer;
  font-size: .94rem; font-weight: 700;
}
.primary-button:hover { background: var(--wine-dark); }
.primary-button:disabled { opacity: .65; cursor: wait; }
.status { min-height: 17px; margin: 11px 0 0; color: #a1453e; text-align: center; font-size: 12px; }
.status:empty { display: none; }
.privacy-note { margin: 15px 0 0; color: #61565e; text-align: center; font-size: .78rem; }
.workflow { padding: clamp(24px, 4vw, 52px); border-radius: 14px; background: #382534; color: #fff7ed; }
.workflow h2, .practice h2, .faq h2 { margin: 0 0 18px; font: 400 clamp(34px, 4.2vw, 57px) / 1 var(--display); }
.workflow ol { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(20px, 4vw, 56px); margin: 26px 0 0; padding: 0; list-style: none; counter-reset: steps; }
.workflow li { padding-top: 15px; border-top: 1px solid #8b6f83; counter-increment: steps; }
.workflow li::before { content: counter(steps, decimal-leading-zero); color: #f0afbf; font-size: .78rem; letter-spacing: .08em; }
.workflow h3 { margin: 9px 0 5px; font-size: 1rem; }
.workflow p { margin: 0; color: #eadbe3; font-size: .92rem; line-height: 1.55; }
.practice { display: grid; grid-template-columns: 1.12fr 1fr; align-items: center; gap: clamp(24px, 6vw, 85px); padding: clamp(40px, 7vw, 92px) 0; }
.practice .section-kicker { margin: 0 0 12px; }
.practice kbd { border: 1px solid #b9a8b4; border-radius: 4px; padding: 1px 5px; color: var(--wine); background: var(--paper); }
.notation-example { margin: 0; padding: clamp(18px, 3vw, 32px); border: 1px solid #dcd1c3; border-radius: 12px; background: var(--paper); }
.notation-label { margin-bottom: 10px; color: #5d555a; font-size: .77rem; font-weight: 700; }
.notation-row { padding: 9px 13px; margin-bottom: 14px; border: 1px solid #d9b8cb; border-radius: 6px; background: #f8eef2; }
.example-staff { display: grid; grid-template-columns: 3.3em minmax(0, 1fr); align-items: end; font-size: .8rem; }
.example-staff > span { line-height: 27px; }
.source-notation .example-staff + .example-staff { margin-top: 9px; }
.part-notation { border-color: #d6c8a8; background: #f9f3e3; }
.rehearsal-letter { display: inline-grid; place-items: center; width: 21px; height: 21px; margin-left: 19%; margin-bottom: 3px; border: 1px solid var(--wine); color: var(--wine); font: 700 .72rem "DM Sans", sans-serif; }
.staff-motif { height: 27px; overflow: hidden; padding-left: 19%; background: repeating-linear-gradient(to bottom, #6b6268 0 1px, transparent 1px 6.5px); color: #382534; font: 25px / 26px Georgia, serif; white-space: nowrap; }
.notation-example figcaption { color: #5d555a; font-size: .78rem; line-height: 1.5; }
.faq { max-width: 780px; margin: 0 auto; padding: 6px 0 62px; }
.faq h2 { text-align: center; margin-bottom: 28px; }
.faq details { padding: 14px 0; border-top: 1px solid #d9cfbf; scroll-margin-top: 24px; }
.faq details:last-child { border-bottom: 1px solid #d9cfbf; }
.faq summary { color: #382534; cursor: pointer; font-weight: 700; }
.faq p { margin: 10px 0 0; color: #5d555a; line-height: 1.6; }
.landing-footer { display: flex; justify-content: space-between; gap: 14px; padding: 20px 0; border-top: 1px solid #d9cfbf; color: #5d555a; font-size: .86rem; }

.editor { width: min(100%, 1800px); min-height: calc(100vh - 112px); margin: 0 auto; display: grid; grid-template-columns: 292px minmax(0, 1fr); gap: 14px; }
.sidebar, .canvas-panel { border: 1px solid #e7e5de; border-radius: 13px; background: #fffefa; }
.sidebar { align-self: start; max-height: calc(100vh - 112px); overflow-y: auto; }
.side-section { padding: 14px 14px 13px; border-bottom: 1px solid #efeee8; }
.section-heading { min-height: 22px; display: flex; align-items: center; justify-content: space-between; color: #59665d; font-size: 11px; font-weight: 650; }
.subtle-count { color: #999e96; font-weight: 400; }
.text-action { padding: 3px 4px; border: 0; color: var(--green); background: transparent; cursor: pointer; font-size: 10px; font-weight: 600; }
.text-action:hover { color: var(--green-dark); }
.page-list { display: flex; gap: 5px; margin-top: 9px; overflow-x: auto; padding: 0 0 2px; }
.page-choice { flex: 0 0 auto; min-width: 32px; height: 31px; padding: 0 7px; border: 1px solid #e7e7e0; border-radius: 7px; color: #6e786f; background: white; cursor: pointer; font-size: 10px; }
.page-choice:hover { background: #f6f7f2; }
.page-choice[aria-current="page"] { border-color: #c6dbca; color: var(--green-dark); background: #eaf2e9; font-weight: 600; }
.part-list { display: grid; gap: 6px; margin-top: 8px; }
.part-row { display: grid; grid-template-columns: 14px minmax(0, 1fr) 24px; align-items: center; gap: 7px; }
.part-row[data-active="true"] .part-name { border-color: #dfe7de; color: #304438; background: #f3f7f1; font-weight: 600; }
.part-color { width: 10px; height: 10px; border-radius: 4px; }
.part-select { min-width: 0; height: 29px; padding: 0 8px; overflow: hidden; border: 1px solid transparent; border-radius: 6px; color: #667169; background: transparent; text-align: left; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; font-size: 11px; }
.part-select:hover { background: #f5f5f0; }
.part-select[aria-pressed="true"] { border-color: #dfe7de; color: #304438; background: #f3f7f1; font-weight: 600; }
.part-name { width: 100%; height: 28px; padding: 0 7px; border: 1px solid transparent; border-radius: 6px; outline: none; color: inherit; background: transparent; font-size: 11px; }
.part-name:hover, .part-name:focus { border-color: #dfe3dc; background: white; }
.remove-part { width: 24px; height: 24px; border: 0; border-radius: 6px; color: #a4a9a1; background: transparent; cursor: pointer; font-size: 14px; }
.remove-part:hover:not(:disabled) { color: #a94d43; background: #fbefec; }
.remove-part:disabled { opacity: .35; cursor: default; }
.mode-list { display: grid; gap: 4px; margin-top: 8px; }
.mode-button { height: 32px; padding: 0 8px; display: flex; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: 7px; color: #69736b; background: transparent; text-align: left; cursor: pointer; font-size: 11px; }
.mode-button:hover { background: #f5f5f0; }
.mode-button[aria-pressed="true"] { border-color: #dfe7de; color: #33463a; background: #f3f7f1; font-weight: 600; }
.mode-swatch { width: 10px; height: 10px; border-radius: 3px; }
.swatch-part { background: var(--part); }.swatch-common { background: var(--common); }.swatch-additional { border: 1px dashed var(--part); }
.common-targets { padding: 10px 8px 2px 26px; color: #667169; }
.target-heading { margin-bottom: 6px; color: #8b9189; font-size: 9px; }
#target-list { display: grid; gap: 4px; }
.target-option { display: flex; align-items: center; gap: 6px; font-size: 10px; }
.target-option input { accent-color: var(--common); }
.system-list { display: grid; gap: 4px; margin-top: 8px; }
.system-choice { min-height: 31px; width: 100%; padding: 0 8px; display: flex; align-items: center; justify-content: space-between; border: 1px solid transparent; border-radius: 7px; color: #69736b; background: transparent; cursor: pointer; font-size: 10px; }
.system-choice:hover { background: #f5f5f0; }
.system-choice[aria-pressed="true"] { border-color: #dfe7de; color: #33463a; background: #f3f7f1; font-weight: 600; }
.system-count { color: #9aa097; font-weight: 400; }
.delete-button { padding: 4px 7px; border: 0; border-radius: 5px; color: #a84b41; background: #fbefec; cursor: pointer; font-size: 10px; }
.delete-button:disabled { color: #a7aaa4; background: #f3f2ee; cursor: default; }
.selection-label { min-height: 26px; margin: 6px 0 9px; color: #858d85; font-size: 10px; line-height: 1.45; }
.copy-controls { padding-top: 9px; border-top: 1px solid #f0efe9; }
.copy-controls > label { display: block; margin-bottom: 6px; color: #879087; font-size: 9px; }
.copy-row { display: flex; gap: 5px; }
.copy-row select { min-width: 0; flex: 1; height: 29px; padding: 0 6px; border: 1px solid #e7e7e0; border-radius: 6px; color: #606b62; background: white; font-size: 10px; }
.small-button { height: 29px; padding: 0 9px; border: 1px solid #dfe8dc; border-radius: 6px; color: var(--green-dark); background: #f3f8f1; cursor: pointer; font-size: 10px; }
.small-button:disabled { color: #a4aaa2; background: #f5f4f0; cursor: default; }
.editor-status { min-height: 16px; margin: 8px 14px 3px; color: #59705f; font-size: 9px; line-height: 1.45; }
.editor-status.error { color: #a1453e; }
.coordinate-note { padding: 0 14px 12px; color: #9a9f97; font-size: 9px; }

.canvas-panel { min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.canvas-toolbar { min-height: 52px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid #eeece6; }
.canvas-title { min-width: 0; display: flex; align-items: center; gap: 9px; }
.canvas-toolbar { flex-wrap: wrap; padding-block: 6px; }
.page-navigation { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: 12px; white-space: nowrap; }
.pdf-badge { flex: 0 0 auto; padding: 4px 6px; border-radius: 5px; color: #9b5b4e; background: #f8eee8; font-size: 9px; font-weight: 700; letter-spacing: .04em; }
.filename { max-width: min(28vw, 280px); overflow: hidden; color: #4b554d; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.toolbar-divider { height: 16px; width: 1px; background: #e6e5df; }
.system-name { overflow: hidden; color: #717b72; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.canvas-tools { color: #9a9f97; font-size: 9px; white-space: nowrap; }
.canvas-wrap { min-height: 300px; flex: 1; position: relative; overflow: auto; display: flex; align-items: flex-start; justify-content: center; background: #eeede8; }
.canvas-host { width: 100%; min-height: 100%; display: flex; justify-content: center; align-items: flex-start; }
.canvas-host .konvajs-content { background: white; box-shadow: 0 2px 15px #30352a16; }
.canvas-empty { position: absolute; z-index: 2; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #747f75; background: #f7f6f1; text-align: center; }
.canvas-empty strong { color: #4d5a50; font-size: 13px; }
.canvas-empty span { color: #90978f; font-size: 10px; }
.empty-icon { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid #dce6da; border-radius: 10px; color: var(--green); background: white; font-size: 20px; }
.canvas-footer { min-height: 34px; padding: 0 13px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid #eeece6; color: #8d948c; font-size: 9px; }
.legend { display: flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; display: inline-block; margin-left: 6px; border-radius: 2px; }.legend i:first-child { margin-left: 0; }
.legend-part { background: var(--part); }.legend-common { background: var(--common); }

#preview {
  width: min(860px, calc(100% - 24px));
  height: min(920px, calc(100% - 24px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--ink);
  background: #fffefa;
}
#preview[open] { display: flex; flex-direction: column; }
#preview::backdrop { background: #20282399; }
.preview-header, .preview-controls, .preview-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 10px 14px;
}
.preview-header { justify-content: space-between; border-bottom: 1px solid var(--line); }
.preview-header h2 { margin: 0; font-size: 16px; }
.preview-controls, .preview-footer { font-size: 12px; }
.preview-pagination { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.preview-controls select, .preview-controls input, .preview-footer select {
  max-width: 180px;
  min-height: 30px;
  border: 1px solid #dfe3dc;
  border-radius: 6px;
  color: var(--ink);
  background: white;
}
#preview-gap { width: 60px; }
.preview-paper { flex: 1; min-height: 0; overflow: auto; padding: 14px; background: #eeede8; }
#preview-image { display: block; width: min(100%, 620px); height: auto; margin: auto; box-shadow: 0 2px 12px #30352a26; }
.preview-feedback { text-align: center; }
#preview-message { margin: 10px auto; font-size: 13px; }
#preview-message.error { color: #a1453e; }
#preview-message:empty, #preview-status:empty { display: none; }
#preview-status { margin: 0; flex-basis: 100%; }
.preview-footer { justify-content: space-between; border-top: 1px solid var(--line); }
#export-button { margin-left: auto; }

@media (max-width: 920px) {
  .workspace { padding: 12px; }
  .editor { min-height: calc(100vh - 92px); grid-template-columns: 245px minmax(0, 1fr); gap: 9px; }
  .sidebar { max-height: calc(100vh - 92px); }
}
@media (max-width: 700px) {
  .topbar { min-height: 56px; padding: 10px 12px; flex-wrap: wrap; }
  .top-actions { gap: 5px; margin: 0; flex-wrap: wrap; }
  .top-button { height: 31px; padding: 0 7px; font-size: 9px; }
  .landing-nav { gap: 12px; }
  .landing-nav a { font-size: .78rem; }
  .workspace { min-height: calc(100vh - 56px); padding: 10px; }
  .landing { padding: 0 8px; }
  .hero, .practice { grid-template-columns: 1fr; }
  .hero { min-height: auto; padding: 20px 0 34px; gap: 26px; }
  .hero h1 { font-size: clamp(51px, 10vw, 76px); }
  .welcome-card { padding: 23px; }
  .workflow ol { grid-template-columns: 1fr; gap: 17px; }
  .workflow li { padding-top: 10px; }
  .faq { padding-bottom: 34px; }
  .editor { min-height: auto; grid-template-columns: 1fr; }
  .sidebar { max-height: none; display: grid; grid-template-columns: 1fr 1fr; overflow: visible; }
  .side-section { padding: 11px; }
  .page-section, .system-section { grid-column: span 2; }
  .page-list { max-width: calc(100vw - 50px); }
  .canvas-panel { min-height: 70vh; }
  .canvas-wrap { min-height: 60vh; }
  .canvas-toolbar { padding: 0 10px; }
  .canvas-tools { display: none; }
  .filename { max-width: 36vw; }
}

#assignment label { display: block; margin: .5rem 0; font-size: .85rem; }
#assignment select { max-width: 100%; }
#make-common { margin-top: .4rem; }

