:root {
  --hot-pink: #fb6ba7;
  --soft-pink: #ffd8e7;
  --ink: #050505;
  --paper: #ffffff;
  --main-row-height: 9.2mm;
  --main-row-font: 12pt;
  --main-song-font: 18pt;
  --staff-row-height: 6mm;
  --staff-row-font: 9.2pt;
  --staff-song-font: 13.2pt;
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(251, 107, 167, 0.08), rgba(255, 255, 255, 0) 260px),
    #f4f4f6;
  color: #171717;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid #cfcfd6;
  border-radius: 8px;
  background: #ffffff;
  color: #151515;
  cursor: pointer;
  font-weight: 800;
}

button:hover {
  border-color: #8b8b96;
}

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

.app-shell {
  display: grid;
  grid-template-columns: minmax(360px, 520px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  max-width: 1680px;
  margin: 0 auto;
  padding: 24px;
}

.control-panel {
  position: sticky;
  top: 24px;
  display: grid;
  gap: 18px;
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 22px;
  border: 1px solid #dedee5;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.08);
}

.panel-heading {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--hot-pink);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.15;
  letter-spacing: 0;
}

.print-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.print-actions button:not(.primary-button) {
  padding: 0 12px;
}

.primary-button {
  flex: 0 0 auto;
  border-color: var(--ink);
  background: var(--ink);
  color: var(--hot-pink);
  padding: 0 13px;
}

.tab-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.tab-button.is-active {
  border-color: var(--hot-pink);
  background: #fff0f6;
  color: #c72e72;
}

.panel-view {
  display: none;
  gap: 16px;
}

.panel-view.is-active {
  display: grid;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 7px;
  font-weight: 800;
}

label span {
  font-size: 13px;
}

input,
textarea {
  width: 100%;
  border: 1px solid #cfcfd6;
  border-radius: 8px;
  background: #ffffff;
  color: #111111;
}

input {
  height: 40px;
  padding: 0 10px;
}

textarea {
  min-height: 170px;
  padding: 12px;
  resize: vertical;
  line-height: 1.55;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.summary-strip div {
  display: grid;
  gap: 3px;
  padding: 12px;
  border: 1px solid #dedee5;
  border-radius: 8px;
  background: #fafafa;
}

.summary-strip span {
  color: #676773;
  font-size: 12px;
  font-weight: 800;
}

.summary-strip strong {
  color: #111111;
  font-size: 18px;
  line-height: 1.1;
}

.toggle-row {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  width: fit-content;
  padding: 10px 12px;
  border: 1px solid #f2b5d0;
  border-radius: 999px;
  background: #fff4f9;
  color: #151515;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--hot-pink);
}

.toggle-row span {
  font-size: 13px;
}

.file-import {
  width: fit-content;
}

.file-import input {
  height: auto;
  padding: 9px;
}

.compact-import {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 40px;
  border: 1px solid #cfcfd6;
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
}

.compact-import:hover {
  border-color: #8b8b96;
}

.compact-import span {
  font-size: inherit;
}

.compact-import input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.hint {
  margin: 0;
  color: #565660;
  font-size: 13px;
  line-height: 1.5;
}

.edit-table-wrap,
.data-table-wrap {
  max-height: 42vh;
  overflow: auto;
  border: 1px solid #dedee5;
  border-radius: 8px;
}

.edit-table,
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  font-size: 13px;
}

.edit-table th,
.edit-table td,
.data-table th,
.data-table td {
  border-bottom: 1px solid #ececf1;
  padding: 7px;
  vertical-align: middle;
}

.edit-table th,
.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #111111;
  color: var(--hot-pink);
  text-align: left;
}

.edit-table input,
.data-table input {
  height: 34px;
  border-radius: 6px;
  font-size: 13px;
}

.edit-table .row-number {
  width: 34px;
  text-align: center;
  font-weight: 900;
}

.edit-table th:nth-child(4),
.edit-table td:nth-child(4) {
  width: 76px;
  white-space: nowrap;
}

.edit-table th:nth-child(6),
.edit-table td:nth-child(6) {
  width: 44px;
}

.delete-button {
  width: 34px;
  min-height: 34px;
  padding: 0;
}

.data-toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.data-table {
  min-width: 1320px;
}

.data-table input[data-field="title"] {
  min-width: 180px;
}

.data-table input[data-field="number"],
.data-table input[data-field="time"] {
  min-width: 90px;
}

.data-table input[data-field="lighting"] {
  min-width: 360px;
}

body.database-mode .app-shell {
  grid-template-columns: 1fr;
  max-width: none;
}

body.database-mode .control-panel {
  position: static;
  max-height: none;
}

body.database-mode .preview-wrap {
  display: none;
}

body.database-mode .data-table-wrap {
  max-height: calc(100vh - 330px);
}

.wide-action-button {
  width: 100%;
  min-height: 46px;
  border-color: var(--ink);
  background: var(--ink);
  color: var(--hot-pink);
}

.prompter-missing {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #dedee5;
  border-radius: 8px;
  background: #fafafa;
  color: #3a3a42;
  font-size: 13px;
  line-height: 1.45;
}

.missing-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.missing-chip-row button {
  min-height: 32px;
  padding: 0 10px;
  border-color: #f2b5d0;
  background: #fff4f9;
  color: #a31515;
  font-size: 13px;
}

.prompter-editor {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid #dedee5;
  border-radius: 8px;
  background: #ffffff;
}

.prompter-preview {
  display: grid;
  gap: 12px;
}

.prompter-empty,
.prompter-card {
  border-radius: 8px;
  background: #050505;
  color: #ffffff;
}

.prompter-empty {
  padding: 28px;
  color: #fbbed7;
  font-weight: 800;
  text-align: center;
}

.prompter-card {
  position: relative;
  display: grid;
  min-height: 220px;
  place-items: center;
  overflow: hidden;
  padding: 26px;
  text-align: center;
}

.prompter-card > span {
  position: absolute;
  top: 12px;
  right: 14px;
  color: var(--hot-pink);
  font-size: 12px;
  font-weight: 900;
}

.prompter-card h3 {
  margin: 0;
  color: var(--hot-pink);
  font-size: clamp(34px, 5vw, 72px);
  line-height: 1.05;
  letter-spacing: 0;
  word-break: keep-all;
}

.prompter-card small {
  position: absolute;
  top: 12px;
  left: 14px;
  max-width: calc(100% - 80px);
  overflow: hidden;
  color: var(--hot-pink);
  font-size: 13px;
  font-weight: 900;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prompter-card p {
  margin: 0;
}

.title-slide p {
  margin-top: 10px;
  color: var(--hot-pink);
  font-size: 18px;
  font-weight: 900;
}

.lyric-slide p {
  font-size: clamp(28px, 5.8vw, 64px);
  font-weight: 900;
  line-height: 1.22;
  letter-spacing: 0;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.preview-wrap {
  display: grid;
  gap: 28px;
  min-width: 0;
  overflow: auto;
  padding-bottom: 32px;
  -webkit-overflow-scrolling: touch;
}

.sheet {
  margin: 0 auto;
  display: grid;
  overflow: hidden;
  background: var(--hot-pink);
  color: var(--ink);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.18);
}

.main-sheet {
  width: 210mm;
  height: 297mm;
  grid-template-rows: 41.8mm 1fr;
}

.staff-sheet {
  width: 297mm;
  height: 210mm;
  grid-template-rows: 25.6mm 1fr;
}

.sheet-header {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-bottom: 0.45mm solid var(--hot-pink);
  background: #000000;
}

.logo {
  width: min(118mm, 75%);
  height: auto;
  display: block;
  transform: translateY(-1mm);
}

.staff-logo {
  width: 76mm;
  transform: translateY(-0.7mm);
}

.event-line {
  position: absolute;
  right: 5mm;
  bottom: 2.4mm;
  max-width: 104mm;
  color: var(--hot-pink);
  font-size: 15pt;
  font-weight: 800;
  line-height: 1.05;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.staff-event-line {
  right: 4mm;
  bottom: 4.2mm;
  max-width: 112mm;
  font-size: 13.5pt;
}

.cue-area {
  min-height: 0;
  padding: 4.2mm 5.3mm 5.2mm;
}

.staff-cue-area {
  min-height: 0;
  padding: 3.4mm 4.8mm 4.4mm;
}

.cue-table {
  width: 100%;
  height: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  border: 0.35mm solid var(--ink);
  background: var(--paper);
}

.cue-table th,
.cue-table td {
  border: 0.25mm solid var(--ink);
  text-align: center;
  vertical-align: middle;
}

.cue-table td[contenteditable="true"] {
  cursor: text;
  outline: none;
}

.cue-table td[contenteditable="true"]:focus {
  box-shadow: inset 0 0 0 0.7mm rgba(251, 107, 167, 0.45);
}

.cue-table th {
  background: var(--ink);
  color: var(--hot-pink);
  font-weight: 900;
}

.cue-table tbody tr:nth-child(even) td {
  background: var(--soft-pink);
}

.main-table thead tr {
  height: 9.6mm;
}

.main-table th {
  font-size: 13.5pt;
}

.main-table tbody tr {
  height: var(--main-row-height);
}

.main-table td {
  padding: 0 1.5mm;
  font-size: var(--main-row-font);
  font-weight: 800;
  line-height: 1.05;
}

.main-table .song-cell {
  font-size: var(--main-song-font);
  font-weight: 900;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.main-table .time-cell {
  font-weight: 700;
}

.main-table td:nth-child(2),
.main-table td:nth-child(5) {
  font-size: calc(var(--main-row-font) * 0.88);
}

.main-col-no {
  width: 5%;
}

.main-col-note {
  width: 10.4%;
}

.main-col-song {
  width: 59.4%;
}

.main-col-time {
  width: 12.6%;
}

.main-col-setting {
  width: 12.6%;
}

.staff-table thead tr {
  height: 7mm;
}

.staff-table th {
  font-size: 10.4pt;
}

.staff-table tbody tr {
  height: var(--staff-row-height);
}

.staff-table td {
  padding: 0 1mm;
  font-size: var(--staff-row-font);
  font-weight: 800;
  line-height: 1.06;
}

.staff-table .staff-song-cell {
  font-size: var(--staff-song-font);
  font-weight: 900;
  overflow-wrap: anywhere;
}

.staff-table .staff-lighting-cell {
  font-size: calc(var(--staff-row-font) * 0.98);
  font-weight: 900;
  overflow-wrap: anywhere;
}

.staff-table tfoot tr {
  height: 7.4mm;
  background: var(--ink);
}

.staff-table tfoot td {
  border-color: var(--ink);
  color: var(--hot-pink);
  font-size: 12pt;
  font-weight: 900;
}

.staff-col-no {
  width: 3.2%;
}

.staff-col-song {
  width: 29%;
}

.staff-col-time {
  width: 7.4%;
}

.staff-col-setting {
  width: 10.6%;
}

.staff-col-stage {
  width: 7.6%;
}

.staff-col-sound {
  width: 5.4%;
}

.staff-col-lighting {
  width: 36.8%;
}

.is-missing {
  color: #a31515;
}

.manual-cell {
  text-decoration: underline;
  text-decoration-color: rgba(251, 107, 167, 0.55);
  text-underline-offset: 2px;
}

.manual-cell::after {
  content: " *";
  color: #c72e72;
  font-weight: 900;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .control-panel {
    position: static;
    max-height: none;
  }

  .preview-wrap {
    margin-inline: -14px;
    padding-inline: 14px;
    justify-items: start;
  }

  .main-sheet {
    width: 210mm;
    height: 297mm;
  }

  .staff-sheet {
    width: 297mm;
    height: 210mm;
  }
}

@media (max-width: 640px) {
  .field-grid.two,
  .summary-strip,
  .data-toolbar {
    grid-template-columns: 1fr;
  }

  .tab-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-heading {
    display: grid;
  }
}

@media print {
  @page {
    margin: 0;
  }

  html,
  body {
    margin: 0;
    padding: 0;
    background: var(--hot-pink) !important;
    overflow: hidden;
  }

  .app-shell {
    display: block;
    margin: 0;
    padding: 0;
    max-width: none;
    overflow: hidden;
    position: relative;
  }

  .control-panel {
    display: none;
  }

  .preview-wrap {
    display: block;
    overflow: hidden;
    padding: 0;
    margin: 0;
    position: relative;
  }

  .sheet {
    position: absolute;
    left: -0.3mm;
    top: -0.3mm;
    margin: 0;
    box-shadow: none;
    break-after: auto;
    page-break-after: auto;
    page-break-before: avoid;
    page-break-inside: avoid;
    transform: none;
  }

  body.print-main .staff-sheet,
  body.print-staff .main-sheet {
    display: none;
  }

  body.print-main .main-sheet {
    width: 210.6mm;
    height: 297.6mm;
  }

  body.print-staff .staff-sheet {
    width: 297.6mm;
    height: 210.6mm;
  }

  body.print-main,
  body.print-main .app-shell,
  body.print-main .preview-wrap {
    width: 210mm;
    height: 297mm;
    max-height: 297mm;
  }

  body.print-staff,
  body.print-staff .app-shell,
  body.print-staff .preview-wrap {
    width: 297mm;
    height: 210mm;
    max-height: 210mm;
  }

  .manual-cell {
    text-decoration: none;
  }

  .manual-cell::after {
    content: "";
  }

  .cue-table td[contenteditable="true"]:focus {
    box-shadow: none;
  }
}
