/*
 * ami-board style.css — v3 (cream / brown redesign)
 * 팔레트: 와이어프레임 키트 기반 크림 + 번트 엄버
 * 기존 DOM 구조 / 클래스명 전부 유지 — CSS만 교체
 */

/* ─── 디자인 토큰 ──────────────────────────────────── */
:root {
  --bg: #F7F1E8;
  --bg-inset: #EFE7DA;
  --surface: #FFFDF8;
  --cream: #FFF8EC;

  --ink: #2E1F12;        /* 본문 / 다크버튼 배경 */
  --ink-2: #4A3424;      /* 서브 텍스트 */
  --muted: #8A7560;      /* 캡션 / 힌트 */

  --line: #E7DCC9;       /* 얇은 구분선 */
  --line-2: #D9CBB2;     /* 입력 테두리 */

  --accent: oklch(0.56 0.12 45);
  --accent-dark: oklch(0.44 0.11 40);
  --accent-soft: oklch(0.94 0.045 55);
  --accent-fg: #FFF8EC;

  --danger: #B33A26;
  --danger-soft: oklch(0.97 0.025 30);

  --radius-card: 18px;
  --radius-control: 12px;
  --radius-chip: 999px;

  --shadow-card: 0 1px 0 rgba(62,42,29,.02), 0 6px 20px -14px rgba(62,42,29,.18);
  --shadow-primary: 0 1px 0 rgba(255,255,255,.15) inset, 0 4px 12px -4px oklch(0.48 0.1 45 / .5);

  --tap: 44px;
}

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

/* ─── 바디 / 컨테이너 ──────────────────────────────── */
body {
  font-family: "Noto Sans KR", "Apple SD Gothic Neo", -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  font-feature-settings: "tnum" 1;
}

.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px;
}

/* ─── 타이포 ──────────────────────────────────────── */
h1 {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.7px;
  color: var(--ink);
  margin-bottom: 20px;
}

h2 {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--ink);
  margin-bottom: 12px;
  padding-left: 14px;
  position: relative;
  border-left: none; /* 기존 파란 바 제거 */
}
h2::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  width: 6px; height: 6px;
  border-radius: 999px;
  background: var(--accent);
  transform: translateY(-50%);
}

/* ─── 카드 ────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 16px;
  margin-bottom: 14px;
}

/* ─── 폼 ─────────────────────────────────────────── */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.form-row:last-child { margin-bottom: 0; }

label {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: -0.1px;
  color: var(--ink-2);
}

input[type="text"],
input[type="date"],
select,
textarea {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  background: var(--bg-inset);
  border: 1.5px solid var(--line-2);
  border-radius: var(--radius-control);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.2px;
  font-family: inherit;
  color: var(--ink);
  transition: border-color 0.15s, background 0.15s;
}
textarea { height: auto; padding: 12px 14px; min-height: 72px; }

input[type="text"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

input[type="text"]:disabled,
input[type="date"]:disabled,
select:disabled {
  background: var(--bg-inset);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.7;
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none'><path d='M6 9l6 6 6-6' stroke='%238A7560' stroke-width='2.2' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

/* ─── GPS 행 ─────────────────────────────────────── */
.input-with-btn {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.input-with-btn input { grid-column: 1 / -1; }
.input-with-btn #btn-gps,
.input-with-btn #btn-open-map {
  grid-row: 2;
}
.input-with-btn #btn-gps { grid-column: 1; }
.input-with-btn #btn-open-map { grid-column: 2; }

.gps-status {
  font-size: 12px;
  color: var(--accent-dark);
  min-height: 16px;
  font-weight: 500;
}

/* ─── 버튼 공통 ──────────────────────────────────── */
button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-control);
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -0.2px;
  padding: 0 18px;
  height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.08s ease, background 0.15s, border-color 0.15s, opacity 0.15s;
  user-select: none;
}
button:active:not(:disabled) { transform: scale(0.98); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border: 1.5px solid var(--accent-dark);
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-primary:disabled {
  background: var(--line-2);
  color: var(--muted);
  border-color: var(--line-2);
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.7;
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--line-2);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-inset);
  border-color: var(--ink-2);
}
.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-sm {
  font-size: 13px;
  padding: 0 12px;
  height: 38px;
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1.5px solid oklch(0.82 0.08 30);
}
.btn-danger:hover:not(:disabled) {
  background: oklch(0.94 0.04 25);
}

/* ─── 썸네일 / 프리뷰 ────────────────────────────── */
.thumb {
  width: 100px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  display: block;
  background: var(--bg-inset);
}

.preview-wrap {
  min-height: 88px;
  border: 1.5px dashed var(--line-2);
  border-radius: var(--radius-control);
  padding: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-inset);
}

.empty-hint {
  color: var(--muted);
  font-size: 13px;
  padding: 4px 8px;
  font-weight: 500;
}

/* ─── 합성 결과 ──────────────────────────────────── */
.compose-result-area { margin-top: 12px; }

.preview-item { margin-bottom: 16px; }

.preview-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.preview-full {
  width: 100%;
  max-width: 100%;
  border-radius: var(--radius-control);
  border: 1.5px solid var(--ink);
  display: block;
  background: var(--bg-inset);
}

.warn {
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 600;
}

/* ─── 구분선 ─────────────────────────────────────── */
hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}

/* ─── 세션 복사 버튼 (숨김 유지) ─────────────────── */
.session-copy-row { display: none; }
.session-hint { font-size: 12px; color: var(--muted); }

/* ─── 조 관리 (숨김 유지) ────────────────────────── */
#section-crews { display: none; }
.crew-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.crew-actions select { flex: 1; min-width: 140px; }
.crew-list { display: flex; flex-direction: column; gap: 6px; }
.crew-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-inset);
  border-radius: 10px;
  flex-wrap: wrap;
}
.crew-name { font-weight: 700; font-size: 14px; min-width: 60px; color: var(--ink); }
.crew-members { flex: 1; font-size: 13px; color: var(--ink-2); min-width: 80px; }

/* ─── 공유 (Phase D) ─────────────────────────────── */
.btn-share { min-width: 120px; }

.share-status {
  margin-top: 8px;
  font-size: 13px;
  color: var(--ink-2);
  min-height: 20px;
  font-weight: 500;
}

.share-fallback { margin-top: 12px; }
.share-fallback .warn { margin-bottom: 10px; line-height: 1.6; }

#share-download-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.download-link {
  display: inline-block;
  text-align: center;
  text-decoration: none;
  padding: 10px 14px;
  border-radius: var(--radius-control);
  background: var(--bg-inset);
  color: var(--ink);
  border: 1.5px solid var(--line-2);
  font-weight: 700;
}

/* ─── 페이지 헤더 ────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.page-header h1 { margin-bottom: 0; }

/* ─── 설정 페이지 ────────────────────────────────── */
.settings-section { margin-bottom: 16px; }

.settings-subheading {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.2px;
  color: var(--ink);
  margin-bottom: 10px;
  padding-left: 14px;
  position: relative;
}
.settings-subheading::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  width: 6px; height: 6px;
  border-radius: 999px;
  background: var(--accent);
  transform: translateY(-50%);
}

.settings-list {
  list-style: none;
  padding: 0;
  margin: 0 0 10px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  min-height: 48px;
}

.settings-item-num {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  min-width: 22px;
  flex-shrink: 0;
  letter-spacing: 0;
}

.settings-item-name {
  flex: 1;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--ink);
}

.btn-icon {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  font-size: 12px;
  padding: 0;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-2);
  flex-shrink: 0;
  transition: background 0.12s;
}
.btn-icon:hover:not(:disabled) { background: var(--bg-inset); }
.btn-icon:disabled { opacity: 0.3; cursor: not-allowed; }

.btn-danger-text {
  color: var(--danger);
  border-color: oklch(0.82 0.08 30);
}
.btn-danger-text:hover:not(:disabled) {
  background: var(--danger-soft);
}

.settings-add-row {
  display: flex;
  gap: 8px;
}
.settings-add-row input { flex: 1; }

.settings-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.settings-actions button { flex: 1; height: 54px; font-size: 16px; }

/* ─── 사업소 힌트 ────────────────────────────────── */
.office-fixed-hint {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 4px;
}

/* ─── 작업원 칩 ──────────────────────────────────── */
.worker-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
}

.worker-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 36px;
  border: 1.5px solid var(--line-2);
  border-radius: var(--radius-chip);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.1px;
  cursor: pointer;
  background: var(--surface);
  color: var(--ink-2);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  user-select: none;
}

.worker-chip input[type="checkbox"] {
  width: 0;
  height: 0;
  margin: 0;
  opacity: 0;
  position: absolute;
  pointer-events: none;
}

.worker-chip:hover:not(:has(input:checked)) {
  border-color: var(--ink-2);
}

.worker-chip:has(input:checked) {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--cream);
  font-weight: 700;
}

/* ─── "기존과 동일" 배너 ─────────────────────────── */
.match-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--accent-soft);
  border: 1px solid oklch(0.85 0.08 55);
  border-radius: 14px;
  padding: 10px 12px 10px 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.1px;
  color: var(--accent-dark);
  margin-bottom: 12px;
}
.match-banner::before {
  content: "ⓘ";
  font-size: 15px;
  flex-shrink: 0;
}
.match-banner .btn-sm {
  margin-left: auto;
  background: rgba(62,42,29,0.07);
  color: var(--accent-dark);
  border: none;
  font-weight: 700;
  padding: 0 10px;
  height: 32px;
}
.match-banner .btn-sm:hover {
  background: rgba(62,42,29,0.12);
}

/* ─── 지도 모달 ──────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(46, 31, 18, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.22s ease;
}
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0.4; }
  to { transform: translateY(0); opacity: 1; }
}
.modal::before {
  content: "";
  display: block;
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--line-2);
  margin: 8px auto 4px;
  flex-shrink: 0;
}

.modal__header {
  padding: 10px 16px 8px;
}
.modal__title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--ink);
}
.modal__hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 500;
}

.map-modal__map {
  flex: 1;
  min-height: 320px;
  background: var(--bg-inset);
  margin: 0 16px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.map-modal__preview {
  padding: 12px 16px;
  margin: 10px 16px 0;
  background: var(--bg-inset);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  min-height: 40px;
}

.modal__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 14px 16px 24px;
}
.modal__actions button { width: 100%; height: 48px; }

/* ─── 자동 입히기 ────────────────────────────────── */
.btn-autofill {
  width: 100%;
  height: 54px;
  padding: 0 18px;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
}

#autofill-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#autofill-actions-loaded {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
#btn-autofill-cancel {
  width: auto;
  align-self: flex-start;
}

.autofill-prompt {
  background: var(--accent-soft);
  border: 1px solid oklch(0.85 0.08 55);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.autofill-prompt__text {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--accent-dark);
  margin-bottom: 10px;
  letter-spacing: -0.2px;
}
.autofill-prompt__actions {
  display: flex;
  gap: 8px;
}

/* ─── 미리보기 그리드 ────────────────────────────── */
.preview-grid { margin-top: 12px; }

.preview-grid__title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.2px;
  color: var(--ink);
  margin-bottom: 10px;
  padding-left: 14px;
  position: relative;
  border-left: none;
}
.preview-grid__title::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  width: 6px; height: 6px;
  border-radius: 999px;
  background: var(--accent);
  transform: translateY(-50%);
}

.preview-grid__items {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 14px;
}

.preview-grid-item {
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-control);
  overflow: hidden;
  box-shadow: 0 4px 12px -4px rgba(62,42,29,.25);
}

.preview-grid-item__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-inset);
  border-bottom: 1px solid var(--line);
}

.preview-grid-item__label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--ink);
}

.preview-grid-item__img {
  width: 100%;
  display: block;
  max-height: 260px;
  object-fit: contain;
  background: var(--bg-inset);
}

.btn-save-band {
  width: 100%;
  height: 54px;
  padding: 0 18px;
  font-size: 16px;
  font-weight: 700;
}

.btn-save-band:disabled {
  background: var(--line-2);
  color: var(--muted);
  border-color: var(--line-2);
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.7;
}

/* ─── 슬롯 카드 (Phase F) ────────────────────────── */
.slot-assign-ui { margin-top: 12px; }

.slot-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.slot-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  background: var(--surface);
  border: 1.5px solid var(--line-2);
  border-radius: var(--radius-control);
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: border-color 0.15s, opacity 0.15s;
}
.slot-card:active { cursor: grabbing; }

.slot-card.sortable-ghost { opacity: 0.4; }
.slot-card.sortable-drag {
  opacity: 0.95;
  box-shadow: 0 8px 20px -6px rgba(62,42,29,0.3);
  border-color: var(--accent);
  transition: none !important;
}
.sortable-fallback { transition: none !important; }

.slot-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: -0.1px;
  color: var(--ink-2);
  text-align: left;
  padding: 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}
.slot-label::before {
  content: "⋮⋮";
  font-family: "JetBrains Mono", monospace;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: -2px;
  flex-shrink: 0;
}

.slot-thumb {
  width: 100%;
  aspect-ratio: 4/3;
  background: var(--bg-inset);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slot-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.slot-thumb-empty {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  padding: 4px;
}

.slot-remove-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  border-radius: 50%;
  background: var(--danger);
  color: var(--cream);
  border: none;
  cursor: pointer;
  z-index: 1;
  box-shadow: 0 2px 6px rgba(62,42,29,.25);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.slot-remove-btn:hover { background: #8B2818; }

.slot-add-btn {
  width: 100%;
  height: 44px;
  padding: 0;
  margin-bottom: 10px;
  background: transparent;
  border: 1.5px dashed var(--line-2);
  color: var(--ink-2);
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: -0.2px;
}
.slot-add-btn:hover:not(:disabled) {
  border-color: var(--ink-2);
  background: var(--bg-inset);
}
.slot-add-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── 밴드 열기 ──────────────────────────────────── */
.btn-open-band {
  width: 100%;
  margin-top: 8px;
  background: var(--ink);
  color: var(--cream);
  border: 1.5px solid var(--ink);
}
.btn-open-band:hover:not(:disabled) { background: #1a120a; }

/* ─── 내용 토글 (오전/오후) ──────────────────────── */
.content-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-inset);
  border: 1.5px solid var(--line-2);
  border-radius: var(--radius-control);
  padding: 4px;
  gap: 4px;
  height: 48px;
}

.btn-toggle {
  height: 100%;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.2px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  box-shadow: none;
}
.btn-toggle:hover { background: rgba(62,42,29,0.04); }

.btn-toggle.active,
.btn-toggle[aria-pressed="true"] {
  background: var(--ink);
  color: var(--cream);
  border: none;
}

/* ─── 작은 화면 대응 ─────────────────────────────── */
@media (max-width: 480px) {
  .container { padding: 12px; }
  h1 { font-size: 20px; }
  h2 { font-size: 14.5px; }
  .thumb { width: 80px; height: 64px; }
  .crew-actions { flex-direction: column; align-items: stretch; }
  .crew-actions select { width: 100%; }
}

/* ─── Safe area (iOS) ────────────────────────────── */
@supports (padding: env(safe-area-inset-bottom)) {
  .container {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
}
