* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  background: #f4f5f7;
  color: #222;
  -webkit-text-size-adjust: 100%;
}
a { color: #0a66c2; text-decoration: none; }

header {
  position: sticky; top: 0; z-index: 10;
  background: #fff;
  border-bottom: 1px solid #e2e4e9;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px 16px;
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
  display: flex; align-items: center; justify-content: space-between;
}
main {
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
header h1 { font-size: 18px; margin: 0; }
header nav a { font-size: 14px; margin-left: 12px; }

main { padding: 16px; max-width: 960px; margin: 0 auto; }

label {
  display: block; font-size: 13px; color: #555; margin-top: 14px; margin-bottom: 6px;
  font-weight: 600;
}
.row-label { display: flex; align-items: center; justify-content: space-between; }

input[type="text"], textarea {
  width: 100%; padding: 14px; font-size: 16px;
  border: 1px solid #d0d4da; border-radius: 10px; background: #fff;
  font-family: inherit;
}
textarea { min-height: 100px; resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 14px 18px; font-size: 16px; font-weight: 600;
  border: none; border-radius: 10px; cursor: pointer;
  background: #0a66c2; color: #fff;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.98); }
.btn-block { width: 100%; }
.btn-lg { padding: 18px; font-size: 17px; }
.btn-secondary { background: #e2e4e9; color: #222; }
.btn-danger { background: #d93025; color: #fff; }
.btn-mic {
  width: 42px; height: 42px; padding: 0;
  background: #e2e4e9; color: #222; border-radius: 50%;
  font-size: 18px;
}
.btn-mic.recording { background: #d93025; color: #fff; }

.camera-area {
  border: 2px dashed #b8bec7; border-radius: 12px; padding: 24px 16px;
  text-align: center; background: #fff; margin-top: 6px;
}
.camera-area input[type="file"] { display: none; }
.photo-btn-row { display: flex; gap: 10px; }
.camera-area .camera-btn {
  display: inline-flex; align-items: center; justify-content: center;
  flex: 1;
  padding: 22px 10px; font-size: 16px; font-weight: 700;
  background: #0a66c2; color: #fff;
  border: none; border-radius: 12px; cursor: pointer;
}
.camera-area .camera-btn-alt { background: #5b6470; }
.camera-hint { font-size: 12px; color: #666; margin-top: 10px; }

.thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.thumb {
  position: relative; aspect-ratio: 1;
  border-radius: 8px; overflow: hidden; background: #ddd;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .main-badge {
  position: absolute; top: 4px; left: 4px;
  background: #0a66c2; color: #fff; font-size: 10px; padding: 2px 6px;
  border-radius: 4px; font-weight: 700;
}
.thumb .remove {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,0.7); color: #fff; border: none;
  font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}

.field-with-mic { display: flex; gap: 8px; align-items: flex-start; }
.field-with-mic > *:first-child { flex: 1; }

.actions { margin-top: 22px; display: flex; gap: 10px; }
.actions .btn { flex: 1; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #222; color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: 14px; opacity: 0; transition: opacity 0.25s; z-index: 100;
  max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; }

.queue-badge {
  display: inline-block; margin-left: 8px;
  background: #f0b400; color: #222; font-size: 11px;
  padding: 2px 8px; border-radius: 10px; font-weight: 700;
}

.booth-card {
  background: #fff; border: 1px solid #e2e4e9; border-radius: 12px;
  padding: 14px; margin-bottom: 14px;
}
.booth-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.booth-booth-num {
  font-size: 26px; font-weight: 800; color: #0a66c2;
  letter-spacing: 0.5px; line-height: 1.1;
  word-break: break-all;
}
.booth-title { font-size: 15px; font-weight: 600; margin-top: 4px; color: #333; }
.booth-meta { font-size: 12px; color: #777; margin-top: 4px; }
@media (min-width: 720px) {
  .booth-booth-num { font-size: 32px; }
  .booth-title { font-size: 17px; }
}
.camera-btn-card { background: #8e44ad !important; }

.card-block {
  margin-top: 12px; padding: 10px 12px;
  background: #f3e8ff; border: 1px solid #d8b4f0; border-radius: 10px;
}
.card-label {
  font-size: 12px; color: #6a1b9a; font-weight: 700;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.card-thumb { border: 2px solid #c084fc; }

.contact-block {
  margin-top: 10px; padding: 12px 14px;
  background: #e8f5e9; border: 1px solid #a5d6a7; border-radius: 10px;
  font-size: 14px; line-height: 1.6;
}
.contact-name { font-size: 16px; font-weight: 700; color: #1b5e20; margin-bottom: 4px; }
.contact-line { color: #333; }
.contact-line a { color: #0a66c2; }

.memo-block { margin-top: 14px; background: #fffbe6; border: 1px solid #f0d878; border-radius: 10px; padding: 14px 16px; }
.memo-label { font-size: 13px; color: #7a5b00; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; }
.booth-memo { white-space: pre-wrap; font-size: 17px; line-height: 1.6; cursor: pointer; min-height: 60px; color: #222; }
.memo-editor { width: 100%; padding: 12px; font-size: 17px; border: 1px solid #d0d4da; border-radius: 8px; font-family: inherit; line-height: 1.6; min-height: 140px; }
@media (min-width: 720px) {
  .booth-memo { font-size: 15px; min-height: 40px; }
  .memo-editor { font-size: 15px; min-height: 100px; }
}
.booth-main-photo {
  margin-top: 10px; width: 100%; max-height: 360px;
  object-fit: contain; background: #000; border-radius: 8px; cursor: zoom-in;
}
.booth-sub-photos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.booth-sub-photos .thumb { cursor: zoom-in; }

.booth-comments { margin-top: 12px; border-top: 1px solid #eee; padding-top: 10px; }
.comment {
  font-size: 13px; padding: 6px 0;
  display: flex; justify-content: space-between; gap: 8px;
}
.comment-text { flex: 1; white-space: pre-wrap; }
.comment-time { color: #999; font-size: 11px; }
.comment-form { display: flex; gap: 6px; margin-top: 8px; }
.comment-form input { flex: 1; padding: 8px 10px; font-size: 14px; border: 1px solid #d0d4da; border-radius: 8px; }
.comment-form button { padding: 8px 14px; font-size: 13px; }

.booth-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.booth-actions .btn { padding: 8px 12px; font-size: 13px; }

.mini-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px 10px; font-size: 12px; font-weight: 600;
  background: #eef0f3; color: #333;
  border: 1px solid #d0d4da; border-radius: 6px; cursor: pointer;
}
.mini-btn:hover { background: #e2e4e9; }

.known-badge {
  display: inline-block; margin-top: 6px;
  background: #fef3c7; color: #92400e; border: 1px solid #fcd34d;
  font-size: 12px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px;
}

.priority-row {
  display: flex; gap: 6px; margin-top: 10px;
}
.prio-chip {
  flex: 1; padding: 10px 8px; font-size: 14px; font-weight: 700;
  background: #fff; color: #666;
  border: 2px solid #cbd5e0; border-radius: 10px;
  cursor: pointer; user-select: none; transition: all 0.1s;
}
.prio-chip:active { transform: scale(0.97); }
.prio-revisit.active { background: #dc2626; color: #fff; border-color: #dc2626; }
.prio-interested.active { background: #f59e0b; color: #fff; border-color: #f59e0b; }
.prio-good.active { background: #059669; color: #fff; border-color: #059669; }

.filter-chip {
  display: inline-flex; align-items: center;
  padding: 6px 12px; font-size: 13px; font-weight: 600;
  background: #eef0f3; color: #555;
  border: 1px solid #d0d4da; border-radius: 999px;
  cursor: pointer; user-select: none;
}
.filter-chip.active { background: #f0b400; color: #222; border-color: #f0b400; }

.trade-block {
  margin-top: 12px; padding: 12px 14px;
  background: #f0f6ff; border: 1px solid #cce0ff; border-radius: 10px;
  display: flex; flex-direction: column; gap: 10px;
}
.trade-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.trade-label {
  font-size: 13px; font-weight: 700; color: #0a4d9a;
  min-width: 48px; flex-shrink: 0;
}
.chip-group { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.chip-compact { flex-wrap: nowrap; gap: 4px; }
.chip-compact .chip { padding: 7px 10px; font-size: 13px; letter-spacing: -0.2px; white-space: nowrap; }
.chip {
  padding: 8px 14px; font-size: 14px; font-weight: 600;
  background: #fff; color: #666;
  border: 1px solid #cbd5e0; border-radius: 999px;
  cursor: pointer; user-select: none; transition: all 0.1s;
}
.chip:active { transform: scale(0.95); }
.chip.active { background: #0a66c2; color: #fff; border-color: #0a66c2; }
.trade-input {
  flex: 1; min-width: 120px;
  padding: 10px 12px; font-size: 15px;
  border: 1px solid #cbd5e0; border-radius: 8px; background: #fff;
  font-family: inherit;
}
.trade-mini { gap: 6px; }
.trade-label-mini { font-size: 11px !important; color: #8a8f98 !important; min-width: 60px; }
.ref-hint {
  display: inline-block;
  font-size: 9px; color: #aaa; background: #eef0f3;
  padding: 1px 6px; border-radius: 6px; margin-left: 2px;
  font-weight: 600;
}
.trade-input-mini {
  padding: 6px 10px; font-size: 13px; min-width: 100px;
  background: #fafbfc;
}

.search-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.search-bar input { flex: 1; padding: 12px; font-size: 15px; border: 1px solid #d0d4da; border-radius: 10px; }

.empty { text-align: center; color: #888; padding: 48px 16px; }

.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,0.9);
  display: none; align-items: center; justify-content: center; z-index: 200;
  cursor: zoom-out;
}
.lightbox.show { display: flex; }
.lightbox img { max-width: 96vw; max-height: 96vh; }

@media (min-width: 720px) {
  .thumbs { grid-template-columns: repeat(6, 1fr); }
  .booth-sub-photos { grid-template-columns: repeat(6, 1fr); }
  .booth-main-photo { max-height: 500px; }
}
