body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0,111,238,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,111,238,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* 폭은 공용 셸(bodyWidth="medium" → .app-main)이 정한다 */
.wrap {
  position: relative;
  z-index: 1;
}

/* 외부 카드 래퍼 */
.file-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  overflow: hidden;
}

/* 카드 바디 */
.card-body {
  padding: 1.5rem;
  overflow: hidden;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  padding: 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--fg-muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  min-height: 48px;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tab-btn:hover {
  color: var(--fg);
}

.panel { display: none; }
.panel.active { display: block; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 1rem;
  padding: 2.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--bg);
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--primary);
  background: rgba(0,111,238,0.04);
}
.dropzone-icon { font-size: 2rem; margin-bottom: 0.5rem; color: var(--fg-muted); }
.dropzone-label { font-weight: 600; }
.dropzone-hint { font-size: 0.78rem; color: var(--fg-muted); margin-top: 0.4rem; }

.file-list {
  margin: 1rem 0;
  font-size: 0.85rem;
}
.file-list-item {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.file-list-item:last-child { border-bottom: none; }
/* 공백 없는 긴 파일 이름도 줄바꿈해서 × 버튼을 밀어내지 않게 */
.file-list-item .name { flex: 1; min-width: 0; overflow-wrap: anywhere; word-break: break-all; }
.file-list-item .meta { flex: none; color: var(--fg-muted); font-size: 0.78rem; white-space: nowrap; display: inline-flex; align-items: center; gap: 0.25rem; }
.file-list-remove {
  background: none;
  border: none;
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0 0.25rem;
}
.file-list-remove:hover { color: #ef4444; }

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.875rem;
  margin: 1.25rem 0;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
}

.opt-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.opt-field label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.opt-field input[type="number"],
.opt-field input[type="text"],
.opt-field select {
  padding: 0.4rem 0.6rem;
  border-radius: 0.4rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.85rem;
}
.opt-field input[type="range"] { width: 100%; }
.opt-field .range-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.opt-field .range-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--fg);
  min-width: 4.2rem;
  text-align: right;
}
.opt-field .range-ends { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--fg-muted); }
.opt-note { font-size: 0.8rem; color: var(--fg-muted); line-height: 1.55; margin: 0.35rem 0 0; }
.opt-note:empty { display: none; }

.toggle-group { display: flex; gap: 0.25rem; }
.toggle-group button {
  flex: 1;
  padding: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg-muted);
  cursor: pointer;
  font-family: inherit;
  border-radius: 0.4rem;
}
.toggle-group button.active {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(0,111,238,0.08);
}

.estimate {
  font-size: 0.82rem;
  color: var(--fg-muted);
  padding: 0.6rem 0.875rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  margin-bottom: 0.75rem;
}
.estimate strong { color: var(--fg); }
.estimate .ic, .result .ic { vertical-align: -0.18em; }

.action-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.action-btn {
  flex: 1;
  padding: 0.7rem 1rem;
  font-size: 0.9rem;
  font-weight: 700;
  border: none;
  border-radius: 0.55rem;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s, background 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.action-btn:hover:not(:disabled) { opacity: 0.9; }
.action-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.action-btn.secondary {
  background: transparent;
  color: var(--fg-muted);
  border: 1px solid var(--border);
}

.progress {
  margin-top: 1rem;
  font-size: 0.82rem;
}
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 0.4rem;
}
.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  width: 0;
  transition: width 0.2s;
}
.progress-msg { color: var(--fg-muted); }

.result {
  margin-top: 1rem;
  padding: 0.875rem 1rem;
  background: rgba(34,197,94,0.08);
  border: 1px solid rgba(34,197,94,0.3);
  border-radius: 0.55rem;
  font-size: 0.85rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.result .res-head { font-weight: 700; }
.result .res-note { display: block; margin-top: 0.35rem; }
.result.warning .res-note { color: #a15c00; }
[data-theme="dark"] .result.warning .res-note { color: #fbbf24; }
.result.error {
  background: rgba(239,68,68,0.08);
  border-color: rgba(239,68,68,0.3);
}
.result.warning {
  background: rgba(249,115,22,0.08);
  border-color: rgba(249,115,22,0.4);
}

#toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--fg);
  color: var(--bg);
  padding: 0.6rem 1.25rem;
  border-radius: 2rem;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 600px) {
  .options-grid { grid-template-columns: 1fr 1fr; }
}
