:root {
  color-scheme: light;
  --bg: #f4f2ec;
  --panel: #fffdf8;
  --ink: #202124;
  --muted: #6b6f76;
  --line: #ddd6c8;
  --accent: #1f6feb;
  --accent-weak: #e7f0ff;
  --danger: #c62828;
  --shadow: 0 16px 45px rgba(32, 33, 36, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 980px;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(circle at top left, #fff8df, var(--bg) 36rem);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink);
  background: white;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
  background: var(--accent-weak);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:disabled:hover {
  border-color: var(--line);
  background: white;
}

button.danger {
  color: white;
  border-color: var(--danger);
  background: var(--danger);
}

button.danger-outline {
  color: var(--danger);
  border-color: rgba(198, 40, 40, 0.35);
  background: #fff7f7;
}

button.danger-outline:hover {
  border-color: var(--danger);
  background: #ffecec;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink);
  background: white;
}

input + .field-label,
select + .field-label,
.two-column {
  margin-top: 10px;
}

.app-shell {
  padding: 24px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-weight: 700;
}

h2 {
  margin-bottom: 14px;
  font-size: 16px;
}

.status {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.68);
}

.layout {
  display: grid;
  grid-template-columns: 320px minmax(620px, 1fr);
  gap: 20px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - 112px);
  overflow: auto;
  padding-right: 4px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 10px;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.palette {
  display: grid;
  gap: 16px;
}

.palette-group summary {
  margin: 0 0 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  list-style-position: inside;
}

.palette-group details:not([open]) summary {
  margin-bottom: 0;
}

.palette-group details[open] {
  display: grid;
  gap: 8px;
}

.custom-add,
.repeat-duplicate,
.diff-preview {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.custom-add h3,
.repeat-duplicate h3,
.diff-preview h3 {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.custom-palette-list {
  display: grid;
  gap: 8px;
}

.custom-palette-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.add-item-button {
  min-height: 42px;
  padding: 8px;
  font-size: 13px;
}

.full-width-button {
  width: 100%;
  margin-top: 10px;
}

.empty-state,
.muted-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.lock-message {
  margin: 12px 0 0;
  border: 1px solid #f2bd4d;
  border-radius: 12px;
  padding: 10px;
  color: #6b4300;
  background: #fff4d7;
  line-height: 1.5;
}

.selection-editor {
  display: grid;
  gap: 10px;
}

.inventory-list {
  display: grid;
  gap: 14px;
}

.inventory-group {
  display: grid;
  gap: 4px;
}

.inventory-group h3 {
  margin: 0;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.inventory-row {
  display: grid;
  grid-template-columns: 1fr 72px 72px;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid rgba(221, 214, 200, 0.72);
  padding: 7px 0;
  font-size: 13px;
}

.inventory-row strong {
  text-align: right;
}

.inventory-header {
  color: var(--muted);
  font-weight: 800;
}

.changeover-editor {
  display: grid;
  gap: 10px;
}

.notes-list {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.diff-preview {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.6);
}

.diff-row {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
}

.diff-row strong {
  color: var(--muted);
}

.note-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: white;
}

.note-card p {
  margin: 4px 0;
  line-height: 1.5;
}

.note-card small {
  color: var(--muted);
  line-height: 1.4;
}

.small-button {
  padding: 6px 8px;
  font-size: 12px;
}

.plan-panel {
  display: grid;
  gap: 10px;
}

.plan-card {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: white;
}

.plan-card.current {
  border-color: var(--accent);
  background: var(--accent-weak);
}

.plan-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.plan-note,
.legal-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.output-actions {
  display: grid;
  gap: 8px;
}

.output-message {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.ad-panel {
  box-shadow: none;
}

.ad-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ad-slot {
  display: grid;
  place-items: center;
  min-height: 96px;
  border: 1px dashed #b6aa98;
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.54);
  font-size: 13px;
}

.legal-panel a,
.legal-document a {
  color: var(--accent);
}

.legal-page {
  min-width: 0;
  background: var(--bg);
}

.legal-document {
  max-width: 760px;
  margin: 48px auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.legal-document p {
  color: var(--muted);
  line-height: 1.8;
}

.stage-area {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 253, 248, 0.8);
  box-shadow: var(--shadow);
}

.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
}

.stage-toolbar strong {
  color: var(--ink);
  font-size: 18px;
}

.stage {
  position: relative;
  height: calc(100vh - 150px);
  min-height: 600px;
  margin: 18px;
  overflow: hidden;
  border: 2px solid #c8bca9;
  border-radius: 18px;
  background:
    linear-gradient(rgba(60, 60, 60, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(60, 60, 60, 0.045) 1px, transparent 1px),
    #fffaf0;
  background-size: 32px 32px;
}

.stage-label {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(32, 33, 36, 0.16);
  font-size: 72px;
  font-weight: 900;
  letter-spacing: 0.08em;
  pointer-events: none;
}

.stage-direction {
  position: absolute;
  z-index: 1;
  border: 1px solid rgba(84, 72, 55, 0.2);
  border-radius: 999px;
  padding: 6px 12px;
  color: rgba(68, 55, 36, 0.78);
  background: rgba(255, 253, 248, 0.78);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.03em;
  pointer-events: none;
}

.stage-direction--upstage {
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
}

.stage-direction--shimote {
  top: 18px;
  left: 18px;
}

.stage-direction--kamite {
  top: 18px;
  right: 18px;
}

.stage-direction--audience {
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
}

.stage-item {
  position: absolute;
  display: grid;
  place-items: center;
  width: 92px;
  min-height: 44px;
  border: 2px solid #30343b;
  border-radius: 12px;
  padding: 5px;
  color: #17191d;
  background: #ffffff;
  box-shadow: 0 6px 14px rgba(32, 33, 36, 0.12);
  cursor: grab;
  user-select: none;
  touch-action: none;
  z-index: 2;
  font-size: 0.82rem;
  line-height: 1;
}

.stage-item:active {
  cursor: grabbing;
}

.stage-item.is-selected {
  border-color: var(--accent);
  outline: 4px solid rgba(31, 111, 235, 0.2);
  z-index: 5;
}

.rotation-handle {
  position: absolute;
  top: -24px;
  left: 50%;
  display: grid;
  width: 22px;
  height: 22px;
  border: 2px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  background: #ffffff;
  box-shadow: 0 6px 14px rgba(32, 33, 36, 0.18);
  cursor: grab;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  place-items: center;
  transform: translateX(-50%);
  touch-action: none;
}

.rotation-handle:active {
  cursor: grabbing;
}

.stage-item--chair {
  width: 46px;
  min-height: 40px;
  border-radius: 10px;
  background: #fff;
}

.stage-item--chair .item-label,
.stage-item--stand .item-label {
  max-width: 38px;
}

.stage-item--stand {
  width: 28px;
  min-height: 28px;
  border-color: #6f7782;
  border-radius: 999px;
  padding: 2px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 4px 12px rgba(32, 33, 36, 0.1);
  font-size: 0.82rem;
}

.stage-item--conductor {
  width: 64px;
  min-height: 42px;
  border-color: #8d3b00;
  color: #5e2600;
  background: #ffe3bd;
}

.stage-item--podium {
  width: 76px;
  min-height: 52px;
  border-color: #7a5a31;
  background: #ecd7b8;
}

.stage-item--piano {
  width: 62px;
  min-height: 62px;
  border-color: #111827;
  border-radius: 999px;
  color: white;
  background: #20242c;
}

.stage-item--piano .item-kind {
  color: rgba(255, 255, 255, 0.72);
}

.stage-item--equipment {
  border-color: #667085;
  background: #f8fafc;
}

.stage-item--woodwind {
  width: 56px;
  min-height: 56px;
  border-color: #246b8f;
  border-radius: 999px;
  background: #e7f6ff;
}

.stage-item--brass {
  width: 56px;
  min-height: 56px;
  border-color: #a46600;
  border-radius: 999px;
  background: #fff0c7;
}

.stage-item--strings {
  width: 56px;
  min-height: 56px;
  border-color: #8a4f2a;
  border-radius: 999px;
  background: #fff1e8;
}

.stage-item--text {
  width: 112px;
  min-height: 32px;
  border-color: rgba(31, 111, 235, 0.35);
  border-style: dashed;
  color: #1f3a5f;
  background: rgba(255, 255, 255, 0.28);
  box-shadow: none;
}

.stage-item--text .item-kind {
  display: none;
}

.stage-item--percussion {
  width: 104px;
  min-height: 58px;
  border-color: #6b3d91;
  background: #f1e6ff;
}

.stage-item--timpani {
  width: 108px;
  min-height: 60px;
  border-color: #6b3d91;
  border-radius: 999px;
  background:
    radial-gradient(circle at 25% 55%, rgba(255, 255, 255, 0.95) 0 17%, transparent 18%),
    radial-gradient(circle at 48% 62%, rgba(255, 255, 255, 0.95) 0 18%, transparent 19%),
    radial-gradient(circle at 70% 47%, rgba(255, 255, 255, 0.95) 0 22%, transparent 23%),
    #f1e6ff;
}

.stage-item--drum-set {
  width: 92px;
  min-height: 54px;
  border-color: #e54861;
  border-radius: 999px;
  background: #fff4f6;
}

.stage-item--percussion-round {
  width: 46px;
  min-height: 46px;
  border-color: #6b3d91;
  border-radius: 999px;
  background: #f8f1ff;
}

.stage-item--percussion-block {
  width: 78px;
  min-height: 48px;
  border-color: #1f2937;
  border-radius: 8px;
  background: #ffffff;
}

.stage-item--small-mallet,
.stage-item--mallet,
.stage-item--large-mallet {
  border-color: #1f2937;
  border-radius: 10px;
  background: #ffffff;
}

.stage-item--small-mallet {
  width: 82px;
  min-height: 42px;
}

.stage-item--mallet {
  width: 110px;
  min-height: 54px;
}

.stage-item--large-mallet {
  width: 132px;
  min-height: 60px;
}

.stage-item--chimes {
  width: 64px;
  min-height: 38px;
  border-style: dashed;
  border-color: #1f2937;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.76);
}

.stage-item--large-instrument {
  width: 104px;
  min-height: 58px;
  border-color: #375a2c;
  background: #eaf6e6;
}

.stage-item--instrument {
  width: 56px;
  min-height: 56px;
  border-color: #30343b;
  border-radius: 999px;
  background: #ffffff;
}

.item-kind {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.item-kind:empty {
  display: none;
}

.item-label {
  overflow: hidden;
  max-width: 100%;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.stage-item--woodwind .item-label,
.stage-item--brass .item-label,
.stage-item--strings .item-label,
.stage-item--instrument .item-label,
.stage-item--percussion-round .item-label {
  font-size: 0.75rem;
}

.stage-item--small-mallet .item-label,
.stage-item--mallet .item-label,
.stage-item--large-mallet .item-label {
  font-size: 0.72rem;
  letter-spacing: -0.04em;
}
