* {
  box-sizing: border-box;
}

:root {
  --ink: #27303a;
  --line: #e2e6ec;
  --bg: #f7f7f8;
  --panel: #ffffff;
}

body {
  margin: 0;
  font-family: Arial, "Noto Sans KR", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button {
  font: inherit;
  cursor: pointer;
}

input,
select {
  font: inherit;
}

.topbar {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 8px 12px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topbar strong {
  font-size: 17px;
}

.ghost-button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 5px 10px;
  font-size: 13px;
}

.save-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  flex-wrap: wrap;
}

.save-tools input,
.save-tools select {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 5px 8px;
  font: inherit;
  font-size: 13px;
}

.save-tools input {
  width: 120px;
}

.save-tools select {
  width: 106px;
}

.app {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 4px 12px 16px;
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 8px;
}

.palette {
  align-self: start;
  display: grid;
  gap: 6px;
}

.palette h1 {
  margin: 0;
  color: #8a929d;
  font-size: 13px;
  text-align: center;
}

.template-block {
  min-height: 46px;
  border: 0;
  border-radius: 3px;
  padding: 7px;
  color: #fff;
  text-align: left;
  font-size: 14px;
  font-weight: 800;
  box-shadow: inset 0 -22px 0 rgba(0, 0, 0, 0.04);
}

.ai-panel {
  border-top: 1px solid var(--line);
  padding-top: 8px;
  display: grid;
  gap: 6px;
}

.ai-panel h2 {
  margin: 0;
  color: #8a929d;
  font-size: 13px;
  text-align: center;
}

.ai-panel input,
.ai-panel textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 7px;
  font: inherit;
  font-size: 12px;
}

.ai-panel textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.35;
}

.ai-panel p {
  margin: 0;
  color: #6b7280;
  font-size: 11px;
  line-height: 1.35;
}

.board {
  min-width: 0;
  overflow: hidden;
  background: var(--panel);
}

.timetable {
  --row-height: 22px;
  display: grid;
  grid-template-columns: 34px repeat(7, minmax(78px, 1fr));
  grid-template-rows: 34px repeat(40, var(--row-height));
  overflow-x: auto;
  background: #fff;
}

.day-head,
.time-label,
.day-column {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.day-head {
  background: #fff;
  color: #8a929d;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 800;
}

.time-head {
  grid-column: 1;
}

.time-label {
  grid-column: 1;
  color: #8a929d;
  background: #fff;
  padding: 2px 4px 0 0;
  font-size: 13px;
  text-align: right;
}

.day-column {
  position: relative;
  grid-row: 2 / -1;
  min-width: 78px;
  background:
    repeating-linear-gradient(
      to bottom,
      #fff 0,
      #fff calc(var(--row-height) - 1px),
      #eef1f5 calc(var(--row-height) - 1px),
      #eef1f5 var(--row-height)
    );
}

.day-column.drag-over {
  background:
    linear-gradient(rgba(40, 90, 235, 0.08), rgba(40, 90, 235, 0.08)),
    repeating-linear-gradient(
      to bottom,
      #fff 0,
      #fff calc(var(--row-height) - 1px),
      #eef1f5 calc(var(--row-height) - 1px),
      #eef1f5 var(--row-height)
    );
}

.placed-block {
  position: absolute;
  left: 1px;
  right: 1px;
  border: 0;
  border-radius: 2px;
  color: #fff;
  padding: 13px 5px 4px;
  display: grid;
  align-content: start;
  gap: 3px;
  overflow: hidden;
  text-align: left;
  user-select: none;
  box-shadow: inset 0 -26px 0 rgba(0, 0, 0, 0.035);
  cursor: move;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.28);
}

.placed-block.compact {
  padding-top: 12px;
}

.placed-block.compact strong {
  font-size: 11px;
  line-height: 1.05;
}

.placed-block.compact span {
  display: none;
}

.placed-block strong {
  font-size: 12px;
  line-height: 1.15;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.placed-block span {
  color: rgba(255, 255, 255, 0.9);
  font-size: 11px;
  line-height: 1.15;
}

.placed-block small {
  color: rgba(255, 255, 255, 0.78);
  font-size: 9px;
}

.block-delete,
.block-copy {
  position: absolute;
  top: 3px;
  width: 15px;
  height: 15px;
  border: 0;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  line-height: 1;
  opacity: 0.7;
  font-size: 10px;
  padding: 0;
}

.block-delete {
  right: 3px;
}

.block-copy {
  right: 20px;
}

.block-delete:hover,
.block-copy:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.45);
}

.resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  cursor: ns-resize;
  z-index: 3;
  display: block;
  background: rgba(255, 255, 255, 0.45);
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
  opacity: 1;
}

.bubble-editor {
  position: fixed;
  z-index: 20;
  width: 196px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.bubble-editor::before {
  content: "";
  position: absolute;
  top: 14px;
  left: -7px;
  width: 12px;
  height: 12px;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
  transform: rotate(45deg);
}

.bubble-editor label {
  display: grid;
  gap: 4px;
}

.bubble-editor span {
  color: #6b7280;
  font-size: 11px;
  font-weight: 800;
}

.bubble-editor input,
.bubble-editor select {
  min-width: 0;
  width: 100%;
  border: 1px solid #c8d0dc;
  border-radius: 6px;
  padding: 6px 7px;
  font: inherit;
  font-size: 12px;
}

.bubble-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.bubble-time-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.name-guide {
  margin-top: -5px;
  border: 1px solid #c8d0dc;
  border-radius: 0 0 6px 6px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.name-guide:empty {
  display: none;
}

.name-guide-item {
  padding: 7px 8px;
  color: #374151;
  font-size: 12px;
  cursor: pointer;
}

.name-guide-item:hover {
  background: #f1f5f9;
}

.hidden {
  display: none;
}

.coral {
  background: #ef7e72;
}

.violet {
  background: #9a7bdc;
}

.mint {
  background: #77cab9;
}

.yellow {
  background: #eac563;
}

.blue {
  background: #75a1e4;
}

.orange {
  background: #ffa85c;
}

.green {
  background: #9ec86a;
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .save-tools {
    justify-content: flex-start;
  }

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

  .palette {
    grid-template-columns: 72px 1fr;
    align-items: center;
  }

  .template-block {
    min-height: 54px;
  }

  .timetable {
    grid-template-columns: 38px repeat(7, 94px);
  }
}
