:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f6f6f4;
  color: #1f2933;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: #f6f6f4;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

.app {
  min-height: 100vh;
  padding: 14px;
}

.shell {
  width: min(100%, 920px);
  margin: 0 auto;
}

.header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.title {
  margin: 0;
  font-size: clamp(22px, 4vw, 34px);
  line-height: 1.1;
}

.summary {
  color: #5b6472;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

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

.panel {
  background: #ffffff;
  border: 1px solid #dddeda;
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(31, 41, 51, 0.07);
}

.panel-body {
  padding: 14px;
}

.stack {
  display: grid;
  gap: 12px;
}

.case-panel .field-grid {
  display: none;
}

.size-details {
  display: block;
}

.size-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 0 14px;
  color: #364152;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  list-style: none;
}

.size-toggle::-webkit-details-marker {
  display: none;
}

.size-toggle::after {
  content: "変更";
  flex: 0 0 auto;
  border: 1px solid #d7d9dc;
  border-radius: 6px;
  padding: 5px 8px;
  color: #5b6472;
  background: #fafafa;
  font-size: 12px;
  font-weight: 800;
}

.size-details[open] .size-toggle {
  border-bottom: 1px solid #eceeeb;
}

.size-details[open] .size-toggle::after {
  content: "閉じる";
}

.size-value {
  margin-left: auto;
  color: #1f2933;
  white-space: nowrap;
}

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

.field {
  display: grid;
  gap: 5px;
  color: #364152;
  font-size: 13px;
  font-weight: 700;
}

.input {
  width: 100%;
  height: 42px;
  border: 1px solid #c8ccd1;
  border-radius: 6px;
  padding: 0 10px;
  color: #1f2933;
  background: #ffffff;
}

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

.case-button {
  min-height: 54px;
  border: 2px solid;
  border-radius: 7px;
  padding: 8px 5px;
  color: var(--case-text);
  background: var(--case-bg);
  border-color: var(--case-border);
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.case-button:hover:not(:disabled) {
  box-shadow: 0 7px 15px rgba(31, 41, 51, 0.12);
}

.case-button:active:not(:disabled) {
  transform: scale(0.97);
}

.case-button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.notice {
  padding: 10px 12px;
  border-radius: 7px;
  color: #874500;
  background: #fff3d6;
  font-size: 14px;
  font-weight: 700;
}

.layout-warning {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid #f4b4a6;
  border-radius: 7px;
  color: #8f1d1d;
  background: #fff1ed;
  font-size: 13px;
  line-height: 1.45;
}

.layout-warning[hidden] {
  display: none;
}

.layout-warning strong {
  font-size: 14px;
}

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

.board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 0;
}

.section-title {
  margin: 0;
  font-size: 18px;
}

.board-scroll {
  margin: 12px 14px 14px;
  overflow: auto;
  border: 1px solid #d7d9dc;
  border-radius: 8px;
  background: #eeeeeb;
  padding: 10px;
}

.board-frame {
  display: inline-block;
  padding: 0;
  border: 4px solid #323946;
  border-radius: 7px;
  background: #323946;
}

.board {
  position: relative;
  overflow: hidden;
  border-radius: 2px;
  background-color: #fbfbf8;
  background-image:
    linear-gradient(to right, rgba(31, 41, 51, 0.07) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(31, 41, 51, 0.07) 1px, transparent 1px);
  touch-action: none;
}

.case-item {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid;
  border-radius: 6px;
  color: var(--case-text);
  background: var(--case-bg);
  border-color: var(--case-border);
  box-shadow: 0 2px 5px rgba(31, 41, 51, 0.13);
  cursor: grab;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  user-select: none;
  touch-action: none;
}

.case-item.selected {
  z-index: 2;
  outline: 4px solid #1f2933;
  outline-offset: -4px;
}

.case-item.dragging {
  cursor: grabbing;
  opacity: 0.9;
}

.actions {
  display: grid;
  gap: 9px;
}

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 6px;
  padding: 9px 12px;
  color: #1f2933;
  background: #edf0f2;
  font-weight: 800;
  cursor: pointer;
}

.button:hover:not(:disabled) {
  background: #e2e7eb;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.button.danger {
  color: #ffffff;
  background: #c93535;
}

.button.danger:hover:not(:disabled) {
  background: #a92d2d;
}

.button.ghost {
  color: #5b6472;
  background: transparent;
  border: 1px solid #d7d9dc;
}

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

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

.confirm-text {
  grid-column: 1 / -1;
  font-weight: 800;
}

.icon {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

@media (max-width: 760px) {
  .app {
    padding: 10px;
  }

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

  .board-panel {
    order: -1;
  }

  .header {
    display: block;
  }

  .summary {
    margin-top: 4px;
  }
}
