:root {
  --bg-1: #f4f8fc;
  --bg-2: #dfeaf4;
  --paper: #fafdff;
  --paper-strong: #ffffff;
  --ink: #133046;
  --line: #8aa6bc;
  --line-soft: rgba(88, 126, 152, 0.18);
  --muted: #5b7387;
  --head: #edf4f9;
  --subhead: #5d7990;
  --chip: #ffffff;
  --chip-bank: #eef7ff;
  --chip-border: #7091ab;
  --accent: #2f82c8;
  --accent-dark: #1e5f96;
  --accent-soft: rgba(47, 130, 200, 0.12);
  --drop: #d8ecff;
  --trash: #ffe5e1;
  --radius-xl: 22px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-lg: 0 22px 40px rgba(95, 135, 163, 0.12);
  --shadow-md: 0 10px 24px rgba(95, 135, 163, 0.09);
  color-scheme: light;
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.92), transparent 22%),
    linear-gradient(180deg, var(--bg-1) 0%, #eef5fb 42%, var(--bg-2) 100%);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1600px, calc(100% - 32px));
  margin: 24px auto;
}

.hero,
.board-stage,
.panel {
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-md);
}

.hero {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(250, 253, 255, 0.94);
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  border: 1px solid rgba(47, 130, 200, 0.16);
  border-radius: 12px;
  background: linear-gradient(180deg, #f6fbff, #e6f2fb);
  color: var(--accent-dark);
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.topbar,
.topbar-title,
.topbar-actions,
.panel-head,
.bank-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar {
  justify-content: space-between;
}

.topbar-title {
  flex: 1;
  min-width: 320px;
}

.topbar-actions {
  justify-content: flex-end;
}

.stage-kicker,
.panel-head span {
  margin: 0;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.stage-kicker {
  color: var(--accent);
}

.title-input {
  width: 100%;
  border: 1px solid rgba(88, 126, 152, 0.2);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font-size: clamp(18px, 2vw, 28px);
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.title-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(47, 130, 200, 0.12);
}

.panel-head span {
  color: var(--muted);
}

.action-btn {
  min-height: 40px;
  border: 1px solid rgba(88, 126, 152, 0.2);
  padding: 0 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.action-btn:hover,
.file-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(23, 23, 23, 0.38);
}

.action-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.danger {
  color: var(--accent-dark);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.board-wrap {
  min-width: 0;
}

.board-stage {
  padding: 18px;
  border-radius: 24px;
  background: rgba(250, 253, 255, 0.88);
}

.board-stage-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 14px;
}

.board-stage-head h2 {
  margin: 4px 0 0;
  font-size: 26px;
  line-height: 1;
}

.stage-copy {
  max-width: 360px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}

.board-paper {
  padding: 16px;
  border: 1px solid rgba(88, 126, 152, 0.14);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0)),
    var(--paper-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
  overflow: auto;
  max-height: calc(100vh - 170px);
}

.board-viewport {
  width: 100%;
  overflow: auto;
}

.board-scale {
  transform-origin: top left;
  will-change: transform;
}

.schedule-section + .schedule-section {
  margin-top: 18px;
}

.section-title {
  margin: 0 0 8px;
  padding: 10px 14px;
  border: 1px solid rgba(88, 126, 152, 0.12);
  border-radius: 12px 12px 0 0;
  background: #f2f8fc;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.schedule-grid {
  display: grid;
  grid-template-columns: 76px 54px repeat(var(--role-count), minmax(84px, 1fr));
  border: 1px solid rgba(88, 126, 152, 0.34);
  background: white;
}

.cell {
  min-height: 34px;
  border-right: 1px solid rgba(88, 126, 152, 0.3);
  border-bottom: 1px solid rgba(88, 126, 152, 0.3);
  position: relative;
}

.head-main {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 4px 6px;
  background: var(--head);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  color: #23455f;
}

.head-sub {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 2px 4px;
  background: var(--subhead);
  color: white;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.day-label {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #6f8aa0;
  color: white;
  font-size: 14px;
  font-weight: 900;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.shift-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  text-transform: uppercase;
  background: #f8fbfd;
  color: #49657a;
}

.dropzone {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  align-items: stretch;
  gap: 6px;
  min-height: 38px;
  padding: 6px;
  background: white;
}

.dropzone[data-disabled="true"] {
  background: #f6fafc;
}

.dropzone.drop-target,
.drop-bank.drop-target,
.trash-zone.drop-target {
  background: var(--drop);
}

.trash-zone.drop-target {
  background: var(--trash);
}

.person-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 4px 8px;
  max-width: 100%;
  border: 1px solid rgba(112, 145, 171, 0.65);
  border-radius: 999px;
  background: var(--chip);
  box-shadow: 0 2px 6px rgba(95, 135, 163, 0.1);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
  text-transform: uppercase;
  cursor: grab;
  user-select: none;
  touch-action: none;
  color: #224761;
  white-space: normal;
  word-break: break-word;
  text-align: center;
}

.person-chip[data-origin="bank"] {
  background: var(--chip-bank);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.person-chip[data-origin="slot"] {
  width: 100%;
  border-radius: 12px;
  padding: 6px 8px;
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.person-chip.dragging-origin {
  opacity: 0.22;
}

.drag-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.92;
  transform: translate(-50%, -50%) rotate(-4deg);
}

.panel {
  padding: 18px;
  border-radius: 20px;
  background: rgba(250, 253, 255, 0.92);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 16px;
  align-self: start;
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.panel-head {
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 18px;
}

.person-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px auto;
  gap: 8px;
  margin-bottom: 12px;
}

.person-form input,
.person-form select,
.person-form button {
  min-height: 44px;
  border: 1px solid rgba(88, 126, 152, 0.18);
  border-radius: 12px;
  background: white;
}

.person-form input {
  padding: 0 12px;
}

.person-form select {
  padding: 0 10px;
  color: var(--ink);
}

.person-form button {
  padding: 0 14px;
  font-weight: 800;
  cursor: pointer;
}

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

.bank-card {
  padding: 12px;
  border: 1px solid rgba(88, 126, 152, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.64);
}

.panel-head.mini {
  margin-bottom: 10px;
}

.panel-head.mini h3 {
  margin: 0;
  font-size: 15px;
}

.people-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
  min-height: 220px;
  padding: 12px;
  border: 2px dashed rgba(88, 126, 152, 0.2);
  border-radius: 18px;
  background: rgba(244, 250, 255, 0.9);
}

.bank-footer {
  align-items: stretch;
  justify-content: space-between;
  margin-top: 14px;
}

.trash-zone {
  display: grid;
  place-items: center;
  min-height: 72px;
  min-width: 240px;
  flex: 0 0 280px;
  border: 2px dashed #d19b90;
  border-radius: 18px;
  color: #9a5c51;
  background: #fff8f7;
  font-weight: 900;
  text-transform: uppercase;
}

.tips {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  flex: 1;
}

@media (max-width: 1250px) {
  .topbar {
    display: block;
  }

  .topbar-actions {
    margin-top: 10px;
    justify-content: flex-start;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 16px, 1600px);
    margin: 8px auto 24px;
  }

  .brand-mark {
    width: 88px;
    aspect-ratio: 1;
  }

  .hero,
  .board-stage,
  .panel,
  .bank-panel {
    padding: 16px;
    border-radius: 20px;
  }

  .topbar-title {
    min-width: 0;
  }

  .person-form {
    grid-template-columns: 1fr;
  }

  .bank-columns {
    grid-template-columns: 1fr;
  }

  .board-paper {
    padding: 10px;
    border-radius: 20px;
  }

  .board-stage-head,
  .panel-head {
    display: block;
  }

  .bank-footer {
    display: block;
  }

  .trash-zone {
    min-width: 0;
    width: 100%;
    margin-bottom: 12px;
  }

  .stage-copy {
    max-width: none;
    margin-top: 8px;
    text-align: left;
  }

  .schedule-grid {
    grid-template-columns: 54px 44px repeat(var(--role-count), minmax(70px, 1fr));
  }

  .head-main {
    font-size: 11px;
  }

  .person-chip {
    font-size: 11px;
  }

  .person-chip[data-origin="slot"] {
    padding: 5px 6px;
    font-size: 9px;
  }
}

@media print {
  body {
    background: white;
  }

  .hero,
  .bank-panel,
  .board-stage-head {
    display: none !important;
  }

  .app-shell {
    width: 100%;
    margin: 0;
  }

  .board-stage,
  .board-paper {
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: white;
  }

  .board-viewport,
  .board-scale {
    overflow: visible;
    transform: none !important;
    height: auto !important;
  }
}
