:root {
  --bg0: #f5f9ff;
  --bg1: #ffffff;
  --panel: #ffffff;
  --panel-soft: #f3f7fc;
  --ink: #162233;
  --muted: #5c6f88;
  --line: #d6e1ee;
  --line-strong: #c3d2e5;
  --accent: #0f6ad6;
  --accent-soft: #dcecff;
  --success: #0a8a5a;
  --topbar-offset: 82px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Avenir Next", "Hiragino Sans", "Yu Gothic", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 560px at -15% -20%, rgb(77 148 255 / 0.16), transparent 62%),
    radial-gradient(900px 420px at 115% -15%, rgb(255 190 106 / 0.14), transparent 60%),
    linear-gradient(170deg, var(--bg0), var(--bg1) 62%, #f7fbff 100%);
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 0.88);
  backdrop-filter: blur(12px);
}

.brand {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.04em;
  font-weight: 700;
  color: #1b2c42;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

label {
  display: grid;
  gap: 4px;
  min-width: 120px;
  font-size: 0.72rem;
  color: var(--muted);
}

select,
input,
button {
  font: inherit;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: var(--ink);
  padding: 8px 10px;
}

select {
  min-height: 38px;
}

input::placeholder {
  color: #8da0b8;
}

button {
  cursor: pointer;
  background: linear-gradient(180deg, #1f7be8, #0f62c8);
  border-color: #2f78cb;
  color: #fafdff;
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 14px rgb(13 90 177 / 0.18);
  filter: brightness(1.03);
}

#timeEditToggle {
  background: #eef2f7;
  color: #26374c;
  border-color: #c6d2e2;
}

#timeEditToggle.isOn {
  background: linear-gradient(180deg, #1f7be8, #0f62c8);
  color: #fafdff;
  border-color: #2f78cb;
}

.quickAddForm {
  display: inline-grid;
  grid-template-columns: minmax(140px, 220px) auto;
  gap: 6px;
}

.quickAddForm input {
  min-height: 38px;
}

.app {
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 10px;
  align-items: start;
}

.boardPane,
.poolPane {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #f9fcff 62%, #f4f8fd 100%);
  box-shadow: 0 12px 32px rgb(58 96 148 / 0.1);
}

.boardPane {
  padding: 10px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
  min-height: calc(100vh - 95px);
}

.boardHead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.boardHead h2 {
  margin: 0;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  color: #21324a;
}

.boardMeta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.summary {
  color: var(--muted);
  font-size: 0.75rem;
}

.posterLink {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: #0f5fb8;
  border: 1px solid #b8cfeb;
  border-radius: 999px;
  background: #f4f9ff;
  font-size: 0.72rem;
  line-height: 1;
  padding: 6px 10px;
}

.posterLink.isDisabled {
  opacity: 0.45;
  pointer-events: none;
}

.board {
  overflow: auto;
  border: 1px solid #d9e3ef;
  border-radius: 12px;
  background: linear-gradient(180deg, #fbfdff, #f7fbff);
  padding: 8px;
}

.dayBanner {
  margin: 0 0 7px;
  color: #6e7f97;
  font-size: 0.76rem;
  letter-spacing: 0.03em;
}

.timelineShell {
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  gap: 0;
  min-width: 900px;
}

.timeAxis {
  position: relative;
  border-right: 1px solid #d6e1ed;
  background: #f2f7fd;
}

.timeAxis.isRight {
  border-right: 0;
  border-left: 1px solid #d6e1ed;
}

.timeTick {
  position: absolute;
  left: 4px;
  width: calc(100% - 8px);
  font-size: 0.67rem;
  color: #72839d;
  line-height: 1;
}

.timeAxis.isRight .timeTick {
  text-align: left;
  left: 6px;
}

.stageTimelineGrid {
  display: grid;
  gap: 0;
  border-top: 1px solid #d6e1ed;
  border-bottom: 1px solid #d6e1ed;
}

.stageLane {
  border-right: 1px solid #d6e1ed;
  background: #ffffff;
  overflow: hidden;
}

.stageLane:last-child {
  border-right: 0;
}

.stageLaneHead {
  min-height: 72px;
  padding: 8px 8px 0;
  display: grid;
  grid-template-rows: auto auto auto;
  justify-items: center;
  align-content: start;
  background: linear-gradient(180deg, #f6faff, #edf4fd);
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.stageLaneHead:active {
  cursor: grabbing;
}

.stageLaneDot {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 3px solid #7d8897;
  background: #fff;
  margin-top: 1px;
}

.stageLaneNameWrap {
  margin-top: 3px;
  text-align: center;
  min-height: 24px;
}

.stageLaneName {
  margin: 0;
  color: #1f3149;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  line-height: 1.1;
}

.stageLaneSubtitle {
  margin: 2px 0 0;
  color: #5f7491;
  font-size: 0.63rem;
  line-height: 1.1;
}

.stageLaneVenue {
  margin: 3px 0 0;
  color: #6b7d95;
  font-size: 0.61rem;
  line-height: 1.1;
  min-height: 14px;
  text-align: center;
}

.stageLaneAccent {
  width: calc(100% + 16px);
  height: 4px;
  margin: 6px -8px 0;
}

.stageLane.draggingStage {
  opacity: 0.72;
}

.stageLane.dropActive,
.slot.dropActive,
.poolPane.dropActive .pool {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

.stageLaneBody {
  position: relative;
  background: #fbfdff;
}

.hourGuide {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid rgb(128 151 184 / 0.24);
  pointer-events: none;
}

.slot {
  position: absolute;
  left: 3px;
  right: 3px;
  border: 1px solid #c7d4e6;
  border-radius: 8px;
  background: #edf3fb;
  padding: 4px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  box-shadow: 0 4px 10px rgb(39 70 111 / 0.08);
}

.slotTime {
  position: absolute;
  top: 3px;
  left: 6px;
  font-size: 0.61rem;
  line-height: 1;
  color: #5f7087;
  margin: 0;
}

.slotTimeButton {
  background: transparent;
  border: 0;
  border-radius: 4px;
  width: auto;
  padding: 0;
  color: inherit;
}

.slotTimeButton.isLocked {
  opacity: 0.6;
  cursor: not-allowed;
}

.slotBody {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.slotBody.isEmpty {
  opacity: 0;
}

.artistTag {
  border: 1px solid #aec2db;
  background: #f5f9ff;
  color: #1d2a3d;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.83rem;
  line-height: 1.2;
  cursor: grab;
  touch-action: none;
}

.artistTag.inSlot {
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: #11161c;
  width: 100%;
  text-align: center;
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.poolPane {
  padding: 10px;
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: calc(100vh - 95px);
  max-height: calc(100vh - var(--topbar-offset) - 10px);
  gap: 8px;
  position: sticky;
  top: var(--topbar-offset);
  align-self: start;
}

.pool {
  min-height: 120px;
  border: 1px dashed #b9cade;
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  overflow: auto;
  background: #f7fbff;
}

.slotPlaceholder {
  color: #72839a;
  font-size: 0.74rem;
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 4px;
}

.message {
  min-height: 1em;
  margin: 0;
  color: var(--success);
  font-size: 0.72rem;
}

.slot.draggingTime {
  z-index: 9;
  box-shadow: 0 12px 24px rgb(32 64 104 / 0.25);
}

.touchGhost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.94;
  box-shadow: 0 12px 24px rgb(35 67 109 / 0.22);
}

@media (max-width: 1080px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }

  .boardPane,
  .poolPane {
    min-height: auto;
  }

  .poolPane {
    top: 72px;
    max-height: 42vh;
    z-index: 20;
  }

  .timelineShell {
    min-width: 700px;
    grid-template-columns: 46px 1fr 46px;
  }
}

@media (max-width: 720px) {
  .topbar {
    padding: 10px;
  }

  .brand {
    font-size: 1rem;
  }

  .controls {
    width: 100%;
    justify-content: flex-start;
  }

  label {
    min-width: 0;
    flex: 1 1 calc(33% - 6px);
  }

  .quickAddForm {
    width: 100%;
    grid-template-columns: 1fr auto;
  }

  .quickAddForm input,
  .quickAddForm button,
  select,
  #exportImageBtn {
    min-height: 40px;
  }

  .app {
    grid-template-columns: 1fr;
    grid-template-areas:
      "pool"
      "board";
  }

  .boardPane {
    grid-area: board;
  }

  .poolPane {
    grid-area: pool;
    top: 66px;
    max-height: 38vh;
  }

  .timelineShell {
    min-width: 630px;
  }
}
