/* 타일맵 쇼룸 — 화면 스타일.
   조작판은 색이 없는 회색만 쓴다. 화면에서 색을 가진 것은 타일뿐이어야 타일 색을 제대로 볼 수 있다.
   고른 것은 흰 테두리나 흰 바탕으로 표시한다. */
:root {
  --chrome: #2b2b2b;
  --chrome-2: #363636;
  --chrome-3: #444444;
  --line: #4c4c4c;
  --ink: #f3f3f1;
  --ink-2: #bdbdbb;
  --ink-3: #969694;
  --paper: #f3f3f1;
  --paper-ink: #1b1b1b;
  --danger: #ffa091;
  --float: rgba(27, 27, 27, 0.8);
  --panel-w: 404px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI",
    "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
  background: #1c1c1c;
  color: var(--ink);
  font: 400 15px/1.5 var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
p,
ul,
dl,
dd {
  margin: 0;
  padding: 0;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

input {
  font: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ── 거실 화면 ─────────────────────────────────────────── */

.room {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #1c1c1c;
}

.room__view {
  position: absolute;
  inset: 0;
}

.room__view canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

.room__view canvas:active {
  cursor: grabbing;
}

.room__top {
  position: absolute;
  inset: 0 0 auto 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  pointer-events: none;
}

.brand {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 11px 6px 8px;
  border-radius: 6px;
  background: var(--float);
  backdrop-filter: blur(6px);
  color: #fff;
  font-weight: 650;
  font-size: 14px;
  text-decoration: none;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: #1b1b1f;
  color: #c2512e; /* 타일맵의 표시 색. 조작판에서 색을 쓰는 곳은 여기뿐이다. */
}

.status {
  position: relative;
  min-width: 168px;
  padding: 7px 12px 9px;
  border-radius: 6px;
  background: var(--float);
  backdrop-filter: blur(6px);
  overflow: hidden;
  font-size: 13px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.status:empty {
  display: none;
}

/* 다듬기가 얼마나 됐는지 보여 주는 가는 줄 */
.status::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: var(--progress, 0%);
  background: #fff;
  transition: width 0.25s linear;
}

.room__message {
  position: absolute;
  left: 16px;
  top: 58px;
  max-width: min(560px, calc(100% - 32px));
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--float);
  backdrop-filter: blur(6px);
  font-size: 13px;
  line-height: 1.55;
}

.room__actions {
  position: absolute;
  left: 16px;
  bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quiet {
  padding: 8px 13px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: var(--float);
  backdrop-filter: blur(6px);
  font-size: 13px;
}

.quiet:hover {
  border-color: rgba(255, 255, 255, 0.5);
}

.quiet[aria-pressed="true"] {
  background: var(--paper);
  border-color: transparent;
  color: var(--paper-ink);
  font-weight: 600;
}

.quiet:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── 조작판 ───────────────────────────────────────────── */

.board {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 20px 20px 32px;
  background: var(--chrome);
  border-left: 1px solid #171717;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--chrome-3) transparent;
}

.board__title {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.board__lead {
  margin-top: 2px;
  font-size: 13px;
  color: var(--ink-3);
}

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

.group h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
}

.group > h2 {
  margin-bottom: 10px;
}

.link {
  font-size: 13px;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--ink-3);
}

.link:hover {
  text-decoration-color: var(--ink);
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row + .row,
.seg + .row,
.row + .seg,
.seg + .seg {
  margin-top: 8px;
}

.row__label {
  flex: 0 0 44px;
  font-size: 13px;
  color: var(--ink-3);
}

.row > .seg,
.row > .sticks {
  flex: 1;
  min-width: 0;
}

.seg {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--chrome-2);
  overflow: hidden;
}

.seg button {
  flex: 1;
  min-width: 0;
  padding: 8px 6px;
  border-left: 1px solid var(--line);
  font-size: 14px;
  color: var(--ink-2);
  white-space: nowrap;
}

.seg button:first-child {
  border-left: 0;
}

.seg button:hover {
  background: var(--chrome-3);
  color: var(--ink);
}

.seg button[aria-pressed="true"] {
  background: var(--paper);
  color: var(--paper-ink);
  font-weight: 600;
}

.seg button:focus-visible {
  outline-offset: -3px;
}

.seg button[aria-pressed="true"]:focus-visible {
  outline-color: var(--paper-ink);
}

/* 타일 견본판: 모든 견본을 같은 축척으로 한 줄 위에 세운다. 크기 차이가 그대로 보인다. */
.shelf {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 7px;
}

.chip {
  position: relative;
  width: 85px;
}

.chip__pick {
  display: block;
  width: 100%;
  text-align: left;
}

.chip__stand {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 96px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

/* 타일은 모서리가 반듯하므로 견본도 둥글리지 않는다 */
.chip__face {
  display: block;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14);
  object-fit: fill;
}

.chip--on .chip__face {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.chip__size {
  display: block;
  margin-top: 7px;
  font-size: 14px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--ink-2);
}

.chip--on .chip__size {
  color: #fff;
}

.chip__name,
.chip__finish {
  display: block;
  font-size: 12px;
  line-height: 1.35;
  color: var(--ink-3);
  overflow-wrap: anywhere;
}

.chip--on .chip__name {
  color: var(--ink-2);
}

.chip__remove {
  position: absolute;
  right: 0;
  top: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--chrome-3);
  color: var(--ink-2);
  font-size: 13px;
  line-height: 22px;
  text-align: center;
}

.chip__remove:hover {
  background: var(--paper);
  color: var(--paper-ink);
}

.confirm {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
}

.confirm p {
  flex: 1 1 160px;
}

/* 크기별로 골라 보기 */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.tag {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

.tag span {
  color: var(--ink-3);
}

.tag:hover {
  border-color: var(--ink-2);
  color: var(--ink);
}

.tag[aria-pressed="true"] {
  border-color: transparent;
  background: var(--paper);
  color: var(--paper-ink);
  font-weight: 600;
}

.tag[aria-pressed="true"] span {
  color: #5a5a5a;
}

.field--search {
  margin-bottom: 12px;
}

/* 타일이 많으면 견본판 안에서만 넘겨 본다 */
.shelf {
  max-height: 452px;
  overflow-y: auto;
  padding: 4px 4px 4px 5px;
  margin: 0 -4px 0 -5px;
  scrollbar-color: var(--chrome-3) transparent;
}

/* 고른 타일의 내용 */
.spec {
  display: grid;
  gap: 3px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.spec div {
  display: flex;
  gap: 10px;
}

.spec dt {
  flex: 0 0 62px;
  color: var(--ink-3);
}

.spec dd {
  min-width: 0;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.link--quiet {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-3);
}

/* 메지 색 막대: 매장의 메지 색 견본 막대처럼 세워 둔다 */
.sticks {
  display: flex;
  align-items: flex-end;
  gap: 7px;
}

.stick {
  width: 24px;
  height: 44px;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.stick[aria-pressed="true"] {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.stick--custom {
  position: relative;
  overflow: hidden;
  background: var(--chrome-2);
  color: var(--ink-2);
  font-size: 16px;
  line-height: 44px;
  text-align: center;
}

.stick--custom input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.note {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-3);
}

.field {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--chrome-2);
}

.field:focus-within {
  border-color: #fff;
}

.field input {
  width: 100%;
  min-width: 0;
  padding: 8px 0;
  border: 0;
  background: none;
  outline: none;
  font-variant-numeric: tabular-nums;
}

.field input::-webkit-inner-spin-button {
  display: none;
}

.field__unit {
  font-size: 12px;
  color: var(--ink-3);
}

.field--narrow {
  flex: 0 0 84px;
}

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

.caption {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--ink-3);
}

.btn {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--chrome-2);
  font-size: 14px;
}

.btn:hover {
  background: var(--chrome-3);
}

.btn--main {
  border-color: transparent;
  background: var(--paper);
  color: var(--paper-ink);
  font-weight: 600;
}

.btn--main:hover {
  background: #fff;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--wide {
  width: 100%;
  margin-top: 10px;
}

/* 수량 */
.tally {
  display: grid;
  gap: 14px;
}

.tally__line {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.tally__name {
  font-size: 14px;
  font-weight: 600;
}

.tally__where {
  font-size: 12px;
  color: var(--ink-3);
}

.tally__numbers {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.tally__numbers div {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.tally__numbers dt {
  font-size: 12px;
  color: var(--ink-3);
}

.tally__numbers dd {
  font-size: 17px;
  font-weight: 650;
}

.tally__total {
  font-size: 13px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

/* ── 타일 등록 ─────────────────────────────────────────── */

.sheet {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--chrome);
  color: var(--ink);
  overflow: auto;
}

.sheet::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.sheet__form {
  display: grid;
  gap: 18px;
  padding: 22px 24px 20px;
}

.sheet__title {
  font-size: 19px;
  font-weight: 650;
}

.sheet .caption,
.sheet legend {
  display: block;
  margin-bottom: 6px;
  padding: 0;
  font-size: 13px;
  color: var(--ink-2);
}

.sheet fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

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

.drop {
  display: block;
  padding: 16px;
  border: 1px dashed var(--ink-3);
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-2);
  text-align: center;
  cursor: pointer;
}

.drop:hover,
.drop:focus-within {
  border-color: #fff;
  color: var(--ink);
}

.drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.faces {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.faces__item {
  position: relative;
}

.faces__item img {
  display: block;
  height: 84px;
  width: auto;
  max-width: 168px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.faces__item button {
  position: absolute;
  right: -7px;
  top: -7px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--paper);
  color: var(--paper-ink);
  font-size: 13px;
  line-height: 22px;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 14px;
}

.check input {
  width: 17px;
  height: 17px;
  margin: 2px 0 0;
  accent-color: #fff;
}

.check small {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
}

.sheet__error {
  font-size: 13px;
  color: var(--danger);
}

.sheet__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 6px;
  background: var(--paper);
  color: var(--paper-ink);
  font-size: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  z-index: 10;
}

/* ── 좁은 화면: 거실이 위, 조작판이 아래 ───────────────── */

@media (max-width: 900px) {
  body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 52vh minmax(0, 1fr);
  }

  .board {
    border-left: 0;
    border-top: 1px solid #171717;
    padding: 18px 16px 28px;
  }

  .status {
    min-width: 0;
  }

  .room__actions {
    left: 12px;
    bottom: 12px;
    gap: 6px;
  }

  .quiet {
    padding: 7px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .status::after {
    transition: none;
  }
}
