/* =============================================
   app.css — 전체 스타일 (tokens.css 변수 참조)
   ============================================= */

/* ===== Reset & Base ===== */
* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html, body { height:100%; overflow:hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  display:flex; flex-direction:column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ============================== 쉘 ============================== */

#appHeader {
  display:flex; align-items:center; justify-content:space-between;
  padding: var(--sp-md) var(--sp-lg);
  background: var(--c-primary); color:white;
  font-size: var(--fs-heading); font-weight: var(--fw-bold);
  flex-shrink:0; z-index:10;
}
#settingsBtn { background:none; border:none; color:white; font-size:20px; cursor:pointer; padding: var(--sp-xs); }

#tabContent { flex:1; overflow:hidden; position:relative; }
.tab-panel { display:none; position:absolute; top:0; left:0; right:0; bottom:0; }
.tab-panel.active { display:flex; flex-direction:column; }
.tab-scroll { flex:1; overflow-y:auto; overflow-x:hidden; -webkit-overflow-scrolling:touch; }

#tabBar {
  display:flex; border-top:1px solid var(--c-border);
  background: var(--c-bg-card); flex-shrink:0;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-btn {
  flex:1; padding: var(--sp-sm) 0 6px; text-align:center;
  background:none; border:none; cursor:pointer;
  color: var(--c-text-muted); font-weight: var(--fw-semibold);
  display:flex; flex-direction:column; align-items:center; gap:1px;
  transition:color 0.15s;
}
.tab-btn.active { color: var(--c-primary); }
.tab-icon { font-size:20px; line-height:1; }
.tab-label { font-size: var(--fs-small); }

/* 오버레이 */
.overlay {
  position:fixed; top:0; left:0; right:0; bottom:0;
  background:rgba(0,0,0,0.5); z-index:100;
  display:flex; justify-content:center; align-items:flex-end;
}
.overlay.hidden { display:none; }
.overlay-panel {
  background: var(--c-bg-card); border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  width:100%; max-height:85vh;
  display:flex; flex-direction:column;
  animation:slideUp 0.25s ease;
}
@keyframes slideUp { from{transform:translateY(100%)} to{transform:translateY(0)} }
.overlay-header {
  display:flex; align-items:center; justify-content:space-between;
  padding:14px var(--sp-lg);
  border-bottom:1px solid var(--c-border);
  font-size: var(--fs-heading); font-weight: var(--fw-bold); flex-shrink:0;
}
.overlay-close { background:none; border:none; font-size:20px; color:#666; cursor:pointer; padding: var(--sp-xs) var(--sp-sm); }
.overlay-body { flex:1; overflow-y:auto; padding: var(--sp-lg); }

/* ============================== 설정 ============================== */

.settings-section { margin-bottom: var(--sp-xl); }
.settings-section h3 { font-size: var(--fs-subheading); font-weight: var(--fw-bold); margin-bottom:6px; color: var(--c-text); }
.settings-desc { font-size: var(--fs-secondary); color: var(--c-text-light); margin-bottom:10px; line-height:1.5; }
.file-upload-btn {
  display:inline-block; padding:10px var(--sp-xl);
  background: var(--c-primary); color:white;
  border-radius: var(--r-lg); font-size: var(--fs-body); font-weight: var(--fw-semibold);
  cursor:pointer; transition:background 0.15s;
}
.file-upload-btn:active { background: var(--c-primary-dark); }
.import-status { margin-top: var(--sp-sm); font-size: var(--fs-secondary); line-height:1.6; min-height:20px; }
.import-status.success { color: var(--c-success); }
.import-status.error { color: var(--c-danger); }
.import-status.loading { color: var(--c-warning); }
.data-stats { font-size: var(--fs-body); color: var(--c-text-muted); line-height:1.8; padding:10px var(--sp-md); background: var(--c-bg); border-radius: var(--r-lg); }
.text-input { width:100%; padding:10px var(--sp-md); border:1px solid #d0d7de; border-radius: var(--r-lg); font-size: var(--fs-body); margin-bottom: var(--sp-sm); outline:none; }
.text-input:focus { border-color: var(--c-primary); }
.btn-secondary { padding: var(--sp-sm) var(--sp-lg); background: var(--c-bg); border:1px solid #d0d7de; border-radius: var(--r-lg); font-size: var(--fs-secondary); font-weight: var(--fw-semibold); color: var(--c-text); cursor:pointer; }
.btn-danger { padding: var(--sp-sm) var(--sp-lg); background:#fef2f2; border:1px solid #fecaca; border-radius: var(--r-lg); font-size: var(--fs-secondary); font-weight: var(--fw-semibold); color: var(--c-danger); cursor:pointer; }

/* ============================== 공유: 빈 상태 ============================== */

.empty-state { display:flex; flex-direction:column; align-items:center; justify-content:center; padding:60px 20px; text-align:center; }
.empty-state .empty-icon { font-size:48px; margin-bottom: var(--sp-md); }
.empty-state .empty-title { font-size: var(--fs-heading); font-weight: var(--fw-bold); color: var(--c-text); margin-bottom:6px; }
.empty-state .empty-desc { font-size: var(--fs-secondary); color: var(--c-text-light); line-height:1.6; max-width:260px; }
.empty-state .empty-btn { margin-top: var(--sp-lg); padding:10px var(--sp-xl); background: var(--c-primary); color:white; border:none; border-radius: var(--r-lg); font-size: var(--fs-body); font-weight: var(--fw-semibold); cursor:pointer; }

/* ============================== 공유: 시간대 뱃지 ============================== */

.badge-time { display:inline-flex; align-items:center; gap:2px; font-size: var(--fs-caption); font-weight: var(--fw-bold); padding:2px var(--sp-sm); border-radius: var(--r-sm); }
.badge-time.day   { background: var(--c-day-tag-bg); color: var(--c-day); }
.badge-time.night { background: var(--c-night-tag-bg); color: var(--c-night); }

/* ============================== 달력 ============================== */

.cal-dow-row { display:grid; grid-template-columns:repeat(7,1fr); padding:0 6px var(--sp-xs); }
.cal-dow { text-align:center; font-size: var(--fs-small); color: var(--c-text-faint); font-weight: var(--fw-semibold); padding:2px 0; }
.cal-dow:first-child { color: var(--c-danger); }
.cal-dow:last-child  { color: var(--c-primary); }
.cal-grid { display:grid; grid-template-columns:repeat(7,1fr); padding:0 6px; gap:3px; }
.cal-cell {
  border-radius: var(--r-lg); padding:3px 2px var(--sp-xs);
  min-height:58px; cursor:pointer;
  display:flex; flex-direction:column; align-items:center;
  background: var(--c-bg-card); border:1px solid var(--c-border-light);
  transition:all 0.15s;
}
.cal-cell:active { transform:scale(0.96); }
.cal-cell.empty { background:transparent; border-color:transparent; cursor:default; min-height:0; visibility:hidden; }
.cal-cell.no-show { background:#fafafa; border-color:#f5f5f5; cursor:default; opacity:0.45; }
.cal-cell.selected { border-color: var(--c-primary); box-shadow:0 0 0 2px var(--c-primary-fade); background: var(--c-primary-light); }
.cal-cell.today .cal-day-num { background: var(--c-primary); color:white !important; border-radius: var(--r-full); width:22px; height:22px; display:flex; align-items:center; justify-content:center; }
.cal-day-num { font-size: var(--fs-secondary); font-weight: var(--fw-bold); color: var(--c-text); margin-bottom:2px; line-height:1; }
.cal-cell:nth-child(7n+1) .cal-day-num { color: var(--c-danger); }
.cal-cell:nth-child(7n)   .cal-day-num { color: var(--c-primary); }
.cal-cell.selected .cal-day-num { color: var(--c-primary); }
.cal-cell.today.selected .cal-day-num { color:white; }
.cal-cell.no-show .cal-day-num { color: var(--c-text-hint); }
.cal-slots { display:flex; flex-direction:column; gap:1px; width:100%; padding:0 2px; }
.cal-mini-badge { display:flex; align-items:center; justify-content:center; gap:2px; font-size: var(--fs-mini); font-weight: var(--fw-bold); padding:1px 3px; border-radius:3px; line-height:1.4; letter-spacing:-0.3px; }
.cal-mini-badge.day-slot   { background: var(--c-day-bg); color: var(--c-day); border:0.5px solid var(--c-day-border); }
.cal-mini-badge.night-slot { background: var(--c-night-bg); color: var(--c-night); border:0.5px solid var(--c-night-border); }

.detail-area { padding:10px var(--sp-md) var(--sp-md); }
.detail-header { display:flex; align-items:baseline; gap: var(--sp-sm); margin-bottom:10px; padding-bottom: var(--sp-sm); border-bottom:1px solid var(--c-border-cell); }
.detail-date-big { font-size: var(--fs-title); font-weight: var(--fw-heavy); color: var(--c-primary); }
.detail-date-sub { font-size: var(--fs-body); color: var(--c-text-muted); font-weight: var(--fw-semibold); }
.detail-date-meta { font-size: var(--fs-caption); color: var(--c-text-faint); margin-left:auto; }

.show-slot { margin-bottom: var(--sp-sm); padding:10px var(--sp-md); border-radius: var(--r-xl); border:1px solid #e8e8e8; }
.show-slot.day   { background: var(--c-day-slot-bg); border-left:3px solid var(--c-day-slot-bd); }
.show-slot.night { background: var(--c-night-slot-bg); border-left:3px solid var(--c-night-slot-bd); }
.slot-header { display:flex; align-items:center; gap:6px; margin-bottom:6px; }
.slot-cast { font-size: var(--fs-body); font-weight: var(--fw-semibold); color: var(--c-text); }
.section-label { font-size: var(--fs-caption); font-weight: var(--fw-bold); color: var(--c-text-muted); margin:6px 0 3px; }
.slot-items { display:flex; flex-direction:column; gap: var(--sp-xs); }

.item-row { display:flex; align-items:center; gap: var(--sp-sm); padding:6px var(--sp-sm); background: var(--c-bg-card); border-radius: var(--r-md); border:1px solid var(--c-border-cell); font-size: var(--fs-body); cursor:pointer; }
.item-row:active { background:#f5f5f5; }
.item-seat { font-weight: var(--fw-bold); color: var(--c-item); flex:1; }
.item-user { font-size: var(--fs-caption); color: var(--c-text-light); max-width:80px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.item-demand { font-size: var(--fs-small); padding:2px 6px; border-radius:10px; font-weight: var(--fw-bold); white-space:nowrap; }
.item-demand.hot { background:#f3e8ff; color: var(--c-accent); }
.item-demand.none { background:#f5f5f5; color: var(--c-text-faint); }
.price-row { display:flex; align-items:center; gap: var(--sp-sm); padding:6px var(--sp-sm); background: var(--c-price-bg); border-radius: var(--r-md); border:1px solid var(--c-price-border); font-size: var(--fs-body); }
.price-seat { font-weight: var(--fw-semibold); color: var(--c-price); flex:1; }
.price-user { font-size: var(--fs-caption); color: var(--c-day); max-width:80px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.empty-slot-msg { font-size: var(--fs-secondary); color: var(--c-text-disabled); padding: var(--sp-xs) var(--sp-sm); font-style:italic; }

/* ============================== 분석 ============================== */

.an-header-area { position:sticky; top:0; z-index:5; background: var(--c-bg); }
.an-header { padding:10px 14px 4px; font-size: var(--fs-secondary); color: var(--c-text-muted); font-weight: var(--fw-semibold); }

/* 필터 칩 */
.an-filter-row { display:flex; gap:6px; padding:2px 14px 8px; flex-wrap:wrap; }
.an-filter-chip {
  font-size: var(--fs-small); padding:3px 10px; border-radius:20px;
  background: var(--c-bg-card); border:1px solid var(--c-border);
  color: var(--c-text-muted); cursor:pointer; user-select:none;
}
.an-filter-chip b { font-weight: var(--fw-heavy); color: var(--c-text); }
.an-filter-chip.active {
  background: var(--c-primary); border-color: var(--c-primary); color:white;
}
.an-filter-chip.active b { color:white; }
.an-filter-clear { background:transparent; border:1px dashed var(--c-border); color: var(--c-text-light); }
.an-filter-fail { border-color:#fca5a5; color: var(--c-danger); }
.an-filter-fail b { color: var(--c-danger); }
.an-filter-fail.active { background: var(--c-danger); border-color: var(--c-danger); color:white; }
.an-filter-fail.active b { color:white; }

/* 일괄삭제 바 */
.an-bulk-bar {
  display:flex; align-items:center; gap:10px; justify-content:center;
  padding: var(--sp-sm) var(--sp-md); margin:0 10px 6px;
  background:#fff0f0; border:1px solid #fca5a5; border-radius: var(--r-lg);
  font-size: var(--fs-secondary); color: var(--c-danger);
  animation: fadeIn 0.15s ease;
}
.an-bulk-yes {
  font-weight: var(--fw-bold); color:white; background: var(--c-danger);
  padding:3px 12px; border-radius: var(--r-md); cursor:pointer;
}
.an-bulk-yes:active { opacity:0.7; }
.an-bulk-no {
  font-weight: var(--fw-bold); color: var(--c-text-muted); background: var(--c-border-light);
  padding:3px 12px; border-radius: var(--r-md); cursor:pointer;
}
.an-card { margin: var(--sp-sm) 10px; border-radius: var(--r-xl); border:1px solid var(--c-border); background: var(--c-bg-card); overflow:hidden; position:relative; }
.an-card-failed { border-color:#fecaca; }

/* 그리드 보기 트리거 */
.an-grid-trigger {
  font-size: var(--fs-small); color: var(--c-primary); text-align:center; padding:8px;
  border-top:1px solid var(--c-border-light); margin-top: var(--sp-xs);
  cursor:pointer;
}
.an-grid-trigger:active { background: var(--c-primary-light); }
.an-card-header { display:flex; align-items:center; gap: var(--sp-sm); padding:10px var(--sp-md) 6px; }
.an-user { font-weight: var(--fw-bold); font-size: var(--fs-body); color: var(--c-text); flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.an-handle { font-weight: var(--fw-normal); color: var(--c-text-light); font-size: var(--fs-secondary); }
.an-link { color: var(--c-primary); text-decoration:none; font-size: var(--fs-body); flex-shrink:0; padding:2px var(--sp-xs); }
.an-text { margin:0 var(--sp-md) var(--sp-sm); padding: var(--sp-sm) 10px; font-size: var(--fs-secondary); color: var(--c-text-muted); line-height:1.6; background: var(--c-bg-inset); border-radius: var(--r-md); white-space:pre-wrap; word-break:break-word; }
.an-fail-bar { margin:0 var(--sp-md) 10px; padding: var(--sp-sm) 10px; background:#fff0f0; border-radius: var(--r-md); font-size: var(--fs-secondary); color: var(--c-danger); display:flex; align-items:center; justify-content:space-between; }
.an-fail-bar:has(.an-tag-btn) { background: var(--c-day-bg); color: var(--c-day); }
.an-tag-btn { color: var(--c-primary); font-weight: var(--fw-bold); cursor:pointer; padding: 2px 6px; }
.an-tag-btn:active { opacity:0.7; }
.an-tag-batch { background: var(--c-primary) !important; color: white !important; border-color: var(--c-primary) !important; cursor:pointer; }
.an-tag-batch:active { background: var(--c-primary-dark) !important; }
.an-section-label { font-size: var(--fs-caption); font-weight: var(--fw-bold); padding: var(--sp-xs) var(--sp-md) 2px; }
.an-item-label { color: var(--c-item-label); }
.an-price-label { color: var(--c-danger); }
.an-unconf-label { color: var(--c-warning); }
.an-entry { display:flex; align-items:center; gap:5px; margin:2px 10px; padding:6px var(--sp-sm); border-radius: var(--r-md); font-size: var(--fs-secondary); }
.an-entry-item { background: var(--c-item-bg); border:1px solid var(--c-item-border); }
.an-entry-price { background: var(--c-price-bg); border:1px solid var(--c-price-border); }
.an-entry-unconf { background: var(--c-unconf-bg); border:1px solid var(--c-unconf-border); }
.an-e-date { font-weight: var(--fw-semibold); color: var(--c-text); white-space:nowrap; font-size: var(--fs-caption); }
.an-e-time { font-size: var(--fs-small); white-space:nowrap; }
.an-e-time.day { color: var(--c-day); }
.an-e-time.night { color: var(--c-night); }
.an-e-cast { font-size: var(--fs-small); color: var(--c-text-light); white-space:nowrap; }
.an-e-seat { font-weight: var(--fw-bold); color: var(--c-item); font-size: var(--fs-secondary); flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.an-entry-price .an-e-seat { color: var(--c-price); }
.an-e-discount { font-size:9px; padding:1px 5px; border-radius: var(--r-md); background:#f3e8ff; color: var(--c-accent); font-weight: var(--fw-semibold); }
.an-e-text { font-size: var(--fs-caption); color:#666; flex:1; }
.an-e-reason { font-size: var(--fs-small); color: var(--c-warning); }
.an-dot { width:7px; height:7px; border-radius: var(--r-full); flex-shrink:0; }
.an-dot-ok { background: var(--c-success); }
.an-dot-similar { background: var(--c-accent); }
.an-dot-any { background: var(--c-primary); }
.an-dot-fail { background: var(--c-warning); }
.an-e-del { font-size:16px; color:#ddd; cursor:pointer; flex-shrink:0; padding:0 2px; line-height:1; }
.an-e-del:active { color: var(--c-danger); }

/* 트윗 삭제 버튼 */
.an-card-del { font-size:14px; cursor:pointer; opacity:0.3; padding:0 4px; }
.an-card-del:active { opacity:1; }

/* 삭제 확인바 */
.del-confirm-bar {
  position:absolute; left:0; right:0; bottom:0; top:0;
  background:rgba(255,255,255,0.95);
  display:flex; align-items:center; justify-content:center; gap:12px;
  border-radius:inherit; z-index:5;
  animation: fadeIn 0.1s ease;
}
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
.del-confirm-text { font-size: var(--fs-secondary); color: var(--c-text-muted); }
.del-confirm-yes {
  font-size: var(--fs-secondary); font-weight: var(--fw-bold);
  color:white; background: var(--c-danger);
  padding: var(--sp-xs) var(--sp-md); border-radius: var(--r-md);
  cursor:pointer;
}
.del-confirm-yes:active { opacity:0.7; }
.del-confirm-no {
  font-size: var(--fs-secondary); font-weight: var(--fw-bold);
  color: var(--c-text-muted); background: var(--c-border-light);
  padding: var(--sp-xs) var(--sp-md); border-radius: var(--r-md);
  cursor:pointer;
}
.del-confirm-no:active { background: var(--c-border); }

/* 편집 가능 표시 */
.an-editable { cursor:pointer; border-bottom:1px dashed transparent; transition:border-color 0.15s; }
.an-editable:active { border-bottom-color: var(--c-primary); }

/* 인라인 입력 */
.an-inline-input {
  border:none; border-bottom:2px solid var(--c-primary);
  background:transparent; outline:none;
  font:inherit; color:inherit; font-weight:inherit;
  padding:0 2px; margin:0;
}
/* ============================== 전체화면 그리드 패널 ============================== */

.grid-panel {
  position:absolute; top:0; left:0; right:0; bottom:0;
  background: var(--c-bg);
  z-index:20;
  display:flex; flex-direction:column;
  animation: slideInRight 0.2s ease;
}
.grid-panel.hidden { display:none; }
@keyframes slideInRight { from{transform:translateX(100%)} to{transform:translateX(0)} }

.grid-panel-header {
  display:flex; align-items:center; gap: var(--sp-sm);
  padding:10px var(--sp-md);
  background: var(--c-primary); color:white; flex-shrink:0;
}
.grid-panel-back {
  background:rgba(255,255,255,0.2); border:none; color:white;
  padding: var(--sp-xs) var(--sp-md); border-radius: var(--r-lg);
  font-size: var(--fs-secondary); cursor:pointer;
}
.grid-panel-title { font-weight: var(--fw-bold); font-size: var(--fs-body); }
.grid-panel-body { flex:1; overflow-y:auto; padding: var(--sp-sm); }

/* 항목별 그리드 카드 */
.grid-entry {
  margin-bottom: var(--sp-md); border-radius: var(--r-lg);
  border:1px solid var(--c-border-light); background: var(--c-bg-card);
  overflow:hidden;
}
.grid-entry-item .grid-entry-label { border-left:3px solid var(--c-item); }
.grid-entry-price .grid-entry-label { border-left:3px solid var(--c-price); }

.grid-entry-label {
  display:flex; align-items:center; gap:6px; flex-wrap:wrap;
  padding: var(--sp-sm) var(--sp-md);
  font-size: var(--fs-caption); color: var(--c-text-muted);
  background: var(--c-bg-inset);
}
.grid-entry-type { font-weight: var(--fw-bold); }
.grid-entry-seat { font-weight: var(--fw-bold); color: var(--c-text); }
.grid-entry-item .grid-entry-seat { color: var(--c-item); }
.grid-entry-price .grid-entry-seat { color: var(--c-price); }

.grid-entry-text {
  padding: var(--sp-md);
  font-size: var(--fs-secondary); color: var(--c-text-light);
  text-align:center; font-style:italic;
}

/* ============================== 3컬럼 좌석 그리드 ============================== */

.grid-floor { padding: var(--sp-sm) var(--sp-xs); }
.grid-floor-label { font-size: var(--fs-caption); font-weight: var(--fw-bold); color: var(--c-text); padding:2px 0 2px 24px; }

/* 고속도로 (I-J열 사이 갭) */
.grid-highway { height:6px; margin:2px 0; border-bottom:1px dashed var(--c-border); }

/* 섹션 접기/펼치기 */
.grid-section-hdr {
  display:flex; align-items:center; justify-content:space-between;
  padding:4px 8px 4px 24px; cursor:pointer; user-select:none;
  font-size: var(--fs-small); color: var(--c-text-muted); font-weight: var(--fw-semibold);
}
.grid-section-hdr:active { background: var(--c-bg-inset); border-radius: var(--r-sm); }
.grid-toggle-arrow { font-size: var(--fs-small); color: var(--c-text-light); }
.grid-section-body.collapsed { display:none; }

.grid-row {
  display:flex; align-items:center; gap:0; margin-bottom:1px;
}
.grid-row-label {
  width:22px; text-align:right; padding-right:3px;
  font-size: var(--fs-mini); font-weight: var(--fw-bold); color: var(--c-text-faint); flex-shrink:0;
}

.grid-block {
  display:grid; gap:1px; flex-shrink:0;
}
.grid-block-side { margin:0 2px; }
.grid-block-center { }

/* 좌석 셀 */
.gc {
  width:14px; height:14px; border-radius:1.5px;
  font-size:6.5px; text-align:center; line-height:14px;
  color: var(--c-text-hint);
}
.grid-block-side .gc { background: var(--c-grid-side); }
.grid-block-center .gc { background: var(--c-grid-center); }
.gc-empty { background:transparent !important; }

/* 하이라이트 */
.gc-hl-item { background: var(--c-item) !important; color:white !important; }
.gc-hl-price { background: var(--c-warning) !important; color:white !important; }

/* 드래그 미리보기 */
.gc-drag-preview { outline:2px solid var(--c-accent); outline-offset:-1px; opacity:0.7; }

/* 수정모드 */
.grid-editing .gc { cursor:pointer; }
.grid-editing .gc:not(.gc-empty):active { outline:2px solid var(--c-accent); transform:scale(1.3); z-index:1; }

.grid-edit-bar {
  display:flex; align-items:center; justify-content:space-between;
  padding: var(--sp-sm) var(--sp-md);
  background: var(--c-accent); color:white; border-radius: var(--r-md);
  margin-bottom: var(--sp-sm); font-size: var(--fs-caption);
  position:sticky; top:0; z-index:5;
}
.grid-edit-done {
  background:white; color: var(--c-accent); border:none;
  padding: var(--sp-xs) var(--sp-md); border-radius: var(--r-lg);
  font-size: var(--fs-secondary); font-weight: var(--fw-bold); cursor:pointer;
}

/* ===== 항목 롱탭 팝업 ===== */
.entry-popup {
  position:fixed; z-index:100;
  background:white; border-radius: var(--r-lg);
  box-shadow:0 4px 20px rgba(0,0,0,0.18);
  min-width:200px; max-width:280px;
  padding: var(--sp-xs) 0;
  animation: popupIn 0.12s ease-out;
}
@keyframes popupIn {
  from { opacity:0; transform:translateY(-4px); }
  to { opacity:1; transform:translateY(0); }
}
.entry-popup-btn {
  padding:10px 16px;
  font-size: var(--fs-secondary); color: var(--c-text);
  cursor:pointer; user-select:none;
}
.entry-popup-btn:active { background: var(--c-bg-inset); }
.entry-popup-btn.disabled {
  color: var(--c-text-hint); cursor:default;
  pointer-events:none;
}

/* ===== 내 티켓 탭 ===== */
.mt-input-area {
  padding: var(--sp-md);
  border-bottom: 1px solid var(--c-border);
}
.mt-hint {
  font-size: var(--fs-caption);
  color: var(--c-text-hint);
  margin-bottom: var(--sp-xs);
  line-height: 1.4;
}
.mt-textarea {
  width: 100%;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: var(--sp-sm);
  font-size: var(--fs-secondary);
  font-family: inherit;
  resize: vertical;
  box-sizing: border-box;
  line-height: 1.4;
  background: var(--c-bg-card);
  color: var(--c-text);
}
.mt-textarea:focus {
  outline: none;
  border-color: var(--c-accent);
}
.mt-btn-row {
  margin-top: var(--sp-xs);
  display: flex;
  gap: var(--sp-sm);
  align-items: center;
}
.mt-btn-add {
  padding: 5px 16px;
  background: var(--c-accent);
  color: white;
  border: none;
  border-radius: var(--r-md);
  font-size: var(--fs-secondary);
  font-weight: var(--fw-bold);
  cursor: pointer;
}
.mt-btn-add:active { opacity: 0.8; }
.mt-btn-clear {
  padding: 5px 10px;
  background: var(--c-bg-card);
  color: var(--c-danger);
  border: 1px solid var(--c-danger);
  border-radius: var(--r-md);
  font-size: var(--fs-caption);
  cursor: pointer;
}
.mt-btn-clear:active { opacity: 0.8; }
.mt-result-msg {
  font-size: var(--fs-caption);
  margin-left: var(--sp-xs);
}
.mt-result-msg.success { color: var(--c-confirm); }
.mt-result-msg.error { color: var(--c-danger); }

.mt-list { padding: var(--sp-md); }
.mt-count {
  font-size: var(--fs-caption);
  color: var(--c-text-hint);
  margin-bottom: var(--sp-sm);
}

.mt-card {
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-sm) var(--sp-md);
  margin-bottom: var(--sp-xs);
}
.mt-card-main {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
}
.mt-card-date {
  font-weight: var(--fw-bold);
  font-size: var(--fs-secondary);
  color: var(--c-text);
  flex-shrink: 0;
}
.mt-card-seat {
  color: var(--c-accent);
  font-weight: var(--fw-bold);
  font-size: var(--fs-secondary);
}
.mt-editable {
  cursor: pointer;
  border-bottom: 1px dashed var(--c-accent-light, #bde0fe);
  padding-bottom: 1px;
}
.mt-card-cast {
  color: var(--c-text-hint);
  font-size: var(--fs-caption);
  flex-shrink: 0;
}
.mt-card-spacer { flex: 1; }
.mt-card-del {
  color: var(--c-text-hint);
  font-size: var(--fs-body);
  padding: var(--sp-xs) var(--sp-sm);
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
}
.mt-card-del:active { color: var(--c-danger); }

.mt-card-parse {
  font-size: var(--fs-caption);
  margin-top: var(--sp-xs);
  color: var(--c-text-light);
}
.mt-parse-ok { color: var(--c-confirm); }
.mt-parse-fail { color: var(--c-danger); }

.mt-card-raw {
  font-size: var(--fs-caption);
  color: var(--c-text-hint);
  margin-top: 2px;
}

.mt-seat-input {
  width: 120px;
  font-size: var(--fs-secondary);
  padding: 2px 6px;
  border: 1px solid var(--c-accent);
  border-radius: var(--r-sm);
  outline: none;
  font-family: inherit;
  background: var(--c-bg-card);
  color: var(--c-text);
}

/* ===== 토스트 알림 ===== */
.toast {
  position: fixed;
  bottom: calc(60px + env(safe-area-inset-bottom) + var(--sp-md));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
  color: white;
  white-space: nowrap;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast-success { background: var(--c-success); }
.toast-error { background: var(--c-danger); }
.toast-info { background: var(--c-text-muted); }

/* ===== 대기열 배너 ===== */
.pending-banner {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  margin: var(--sp-sm) var(--sp-md) 0;
  background: var(--c-unconf-bg);
  border: 1px solid var(--c-unconf-border);
  border-radius: var(--r-lg);
  font-size: var(--fs-secondary);
  color: var(--c-text);
}
.pending-banner-icon { font-size: 18px; flex-shrink: 0; }
.pending-banner-text { flex: 1; }
.pending-banner-btn {
  padding: 6px 14px;
  background: var(--c-warning);
  color: white;
  border: none;
  border-radius: var(--r-lg);
  font-size: var(--fs-secondary);
  font-weight: var(--fw-bold);
  cursor: pointer;
  flex-shrink: 0;
}
.pending-banner-btn:active { opacity: 0.8; }
.pending-items {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.pending-item {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(255,255,255,0.7);
  border-radius: var(--r-sm);
  padding: 2px 6px;
  font-size: var(--fs-caption);
}
.pending-item-id { color: var(--c-text-muted); font-family: monospace; }
.pending-item-del {
  cursor: pointer;
  color: var(--c-text-light);
  font-size: 10px;
  padding: 0 2px;
}
.pending-item-del:active { color: var(--c-danger); }

/* ============================== 수동 태깅 오버레이 ============================== */

.tag-overlay {
  position: fixed; top:0; left:0; right:0; bottom:0;
  z-index: 200;
  background: var(--c-bg);
  display: flex; flex-direction: column;
  animation: slideUp 0.2s ease;
}
.tag-overlay.hidden { display:none; }

/* 헤더 */
.tag-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px var(--sp-lg);
  background: var(--c-primary); color: white;
  flex-shrink: 0;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.tag-header-left { display:flex; align-items:center; gap:8px; }
.tag-back { background:none; border:none; color:white; font-size:18px; cursor:pointer; padding:4px; }
.tag-progress { font-size: var(--fs-body); font-weight: var(--fw-semibold); }
.tag-skip { background:rgba(255,255,255,0.2); border:none; color:white; padding:6px 12px; border-radius: var(--r-lg); font-size: var(--fs-secondary); font-weight: var(--fw-semibold); cursor:pointer; }

/* 원문 영역 */
.tag-source-wrap {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 4px var(--sp-lg) 8px;
  min-height: 0;
  touch-action: none; /* 핵심: 없으면 Chrome이 touchmove를 스크롤로 가져감 → 드래그 불가 */
}
.tag-user-row {
  padding: 8px var(--sp-lg) 2px;
  font-size: var(--fs-caption); color: var(--c-text-muted); font-weight: var(--fw-semibold);
  flex-shrink: 0;
}

/* 글자 드래그 형광펜 — 런(연속 같은 타입) 단위 */
.tag-cline {
  padding: 1px 8px;
  font-size: var(--fs-body); line-height: 1.9;
  min-height: 1.9em;
  user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.tag-cline-empty { min-height: 8px; }
.tag-cline-blank { opacity: 0; font-size: 4px; }
.tag-cline-bias { background: rgba(139,92,246,0.06); border-radius: 3px; }

/* 런: 연속 같은 타입 글자 하나의 span — 자연스러운 텍스트 흐름 */
.tag-run {
  border-radius: 3px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tag-r-item { background: rgba(29,155,240,0.18); }
.tag-r-price { background: rgba(230,126,0,0.18); }
.tag-r-item.tag-r-focused { background: rgba(29,155,240,0.40); }
.tag-r-price.tag-r-focused { background: rgba(230,126,0,0.40); }

/* 뱃지 달린 런 */
.tag-run-badge { position: relative; }

/* 항목 번호 동그라미 — 텍스트 끝 바깥에 absolute 배치, 공간 안 차지 */
.tag-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%;
  font-size: 9px; font-weight: 700; line-height: 1;
  color: white; pointer-events: none;
  position: absolute; top: -6px;
}
.tag-badge:first-of-type { left: calc(100% + 1px); }
.tag-badge:nth-of-type(2) { left: calc(100% + 15px); }
.tag-badge:nth-of-type(3) { left: calc(100% + 29px); }
.tag-badge:nth-of-type(4) { left: calc(100% + 43px); }
.tag-badge-item { background: var(--c-item); }
.tag-badge-price { background: var(--c-price); }
.tag-badge-bias { background: rgba(139,92,246,0.7); font-size: 8px; }

/* 선택 모드: 꼬리↔항목 연결 */
.tag-select-tail {
  outline: 2px dashed rgba(99,102,241,0.8);
  outline-offset: 1px;
  background: rgba(99,102,241,0.15) !important;
}
.tag-select-linked {
  outline: 2px solid rgba(34,197,94,0.7);
  outline-offset: 0;
}
.tag-select-linkable {
  outline: 2px dashed rgba(156,163,175,0.5);
  outline-offset: 0;
  opacity: 0.65;
}
.tag-select-hint {
  padding: 4px 12px; font-size: 12px; color: #6366f1;
  background: rgba(99,102,241,0.08); border-radius: 6px;
  margin: 4px 8px 0; text-align: center;
}

/* 구분선 */
.tag-divider {
  height: 1px; background: var(--c-border); flex-shrink: 0;
}

/* 도구바 */
.tag-toolbar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px var(--sp-lg);
  background: var(--c-bg-card);
  border-top: 1px solid var(--c-border);
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}
.tag-tool {
  padding: 6px 12px; border-radius: var(--r-lg);
  font-size: var(--fs-secondary); font-weight: var(--fw-semibold);
  border: 1.5px solid var(--c-border); background: var(--c-bg-card);
  color: var(--c-text); cursor: pointer;
  transition: all 0.15s;
}
.tag-tool.active-item { background: rgba(29,155,240,0.12); border-color: var(--c-item); color: var(--c-item); }
.tag-tool.active-price { background: rgba(230,126,0,0.12); border-color: var(--c-price); color: var(--c-price); }
.tag-tool.active-select { background: rgba(0,0,0,0.06); border-color: var(--c-text-muted); color: var(--c-text); }
.tag-tool-reset { margin-left: auto; color: var(--c-text-muted); }

/* 결과 영역 */
.tag-results-wrap {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: var(--sp-sm) var(--sp-lg);
  min-height: 0;
}

/* 항목 카드 */
.tag-entry {
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.tag-entry-item { border-left: 3px solid var(--c-item); }
.tag-entry-price { border-left: 3px solid var(--c-price); }
.tag-entry-focused { box-shadow: 0 0 0 2px var(--c-primary); }

.tag-empty-msg {
  padding: 24px 16px; text-align: center;
  color: var(--c-text-light); font-size: var(--fs-secondary);
  line-height: 1.6;
}

.tag-entry-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.tag-entry-title {
  font-size: var(--fs-secondary); font-weight: var(--fw-bold); color: var(--c-text);
}
.tag-entry-del {
  background: none; border: none; color: var(--c-text-light);
  font-size: 16px; cursor: pointer; padding: 2px 4px;
}
.tag-entry-del:active { color: var(--c-danger); }
.tag-type-toggle {
  font-size: var(--fs-caption); color: var(--c-text-muted);
  padding: 2px 8px; border-radius: var(--r-sm);
  border: 1px solid var(--c-border); background: var(--c-bg);
  cursor: pointer; margin-left: auto;
}
.tag-type-toggle:active { background: var(--c-border-light); }

/* 필드 행 */
.tag-field-row {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 4px; min-height: 28px;
}
.tag-field-label {
  font-size: var(--fs-caption); color: var(--c-text-muted);
  width: 36px; flex-shrink: 0; text-align: right;
}
.tag-field-value {
  flex: 1; display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
}

/* 인라인 입력 */
.tag-input {
  border: 1px solid var(--c-border); border-radius: var(--r-sm);
  padding: 3px 6px; font-size: var(--fs-secondary);
  background: var(--c-bg-card); outline: none;
  min-width: 0;
}
.tag-input:focus { border-color: var(--c-primary); }
.tag-input-date { width: 70px; }
.tag-input-seat { flex: 1; }
.tag-input-disc { width: 100px; }

/* 시간 토글 */
.tag-time-toggle {
  padding: 3px 8px; border-radius: var(--r-sm);
  font-size: var(--fs-secondary); cursor: pointer;
  border: 1px solid var(--c-border); background: var(--c-bg-card);
}
.tag-time-toggle.day { background: var(--c-day-bg); border-color: var(--c-day-border); color: var(--c-day); }
.tag-time-toggle.night { background: var(--c-night-bg); border-color: var(--c-night-border); color: var(--c-night); }

/* flexible 토글 */
.tag-flex-toggle {
  padding: 3px 10px; border-radius: var(--r-sm);
  font-size: var(--fs-secondary); cursor: pointer;
  border: 1px solid var(--c-border); background: var(--c-bg);
  color: var(--c-text-muted);
}
.tag-flex-toggle.active {
  background: rgba(139,92,246,0.12); border-color: rgba(139,92,246,0.5);
  color: #7c3aed;
}

/* 캐스팅 칩 */
.tag-cast-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.tag-cast-chip {
  padding: 2px 8px; border-radius: 12px;
  font-size: var(--fs-caption); cursor: pointer;
  border: 1px solid var(--c-border); background: var(--c-bg);
  color: var(--c-text-muted);
  transition: all 0.12s;
}
.tag-cast-chip.selected {
  background: var(--c-primary); border-color: var(--c-primary);
  color: white;
}

/* 푸터 */
.tag-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 10px var(--sp-lg);
  background: var(--c-bg-card);
  border-top: 1px solid var(--c-border);
  flex-shrink: 0;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
}
.tag-add-btn {
  padding: 6px 12px; border-radius: var(--r-lg);
  font-size: var(--fs-secondary); font-weight: var(--fw-semibold);
  border: 1px dashed var(--c-border); background: var(--c-bg);
  color: var(--c-text-muted); cursor: pointer;
}
.tag-add-btn:active { background: var(--c-border-light); }
.tag-complete-btn {
  flex: 1;
  padding: 10px; border: none; border-radius: var(--r-lg);
  background: var(--c-primary); color: white;
  font-size: var(--fs-body); font-weight: var(--fw-bold);
  cursor: pointer;
}
.tag-complete-btn:active { background: var(--c-primary-dark); }
