/* Modal */
.backdrop { position: fixed; inset: 0; background: rgba(17,24,39,.45); display: none; align-items: center; justify-content: center; z-index: 50; padding:20px; }
.modal { width: 100%; max-width: 1200px; background:#fff; border-radius: 16px; border:1px solid var(--line); overflow: hidden; display: grid; grid-template-rows: auto 1fr auto; height: 80vh; }
.modal-head { padding: 16px 20px; border-bottom:1px solid var(--line); display:flex; align-items:center; justify-content: space-between; gap:20px; }
.modal-title { font-weight:700; font-size:18px; }
.credits-balance { font-size:14px; color:var(--muted); margin-left:auto; }
.modal-content { display:grid; grid-template-columns: 340px 1fr; overflow:hidden; }
.settings-panel { padding: 16px 20px; overflow-y:auto; border-right:1px solid var(--line); clip-path: none; }
.results-panel { padding: 20px; overflow-y:auto; display:flex; flex-direction: column; }
.results-placeholder { text-align: center; color: var(--muted); padding: 40px 20px; font-size:14px; }
.modal-foot { padding: 16px 20px; border-top:1px solid var(--line); display:flex; gap:10px; justify-content:flex-end; }

.grid-2 { display:grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stack { display:grid; gap:10px; }
.field { display:grid; gap:6px; }
.label-sm { font-size: 13px; color:#374151; font-weight:600; }
.subnote { font-size:12px; color:#6b7280; }
.input, select { border:1px solid var(--line); border-radius:10px; padding:10px 12px; }
.checkbox { display:flex; align-items:flex-start; gap:10px; }
.accent-box { background:#f0f9ff; border:1px solid #bae6fd; border-radius:12px; padding:10px 12px; }

.btn-secondary { border: 1px solid var(--line); background:#fff; border-radius: 10px; padding: 8px 12px; cursor: pointer; }
.btn-ghost { border:1px solid var(--line); background:#fff; border-radius:10px; padding:8px 12px; }

/* Variants list */
.variants-list { display:grid; gap:12px; }
.variants-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.variant-card { border:1px solid var(--line); border-radius:12px; padding:12px; display:grid; gap:10px; cursor:pointer; transition: all 0.2s ease; }
.variant-card:hover { border-color: var(--primary); background: var(--primary-50); }
.variant-card.selected { border-color: var(--primary); border-width: 2px; background: var(--primary-50); padding:11px; }

.variant-header { display:flex; justify-content:space-between; align-items:center; }
.variant-title { font-weight:600; font-size:14px; color:var(--text); }
.variant-words { font-size:12px; color:var(--muted); }

.variant-text { font-size:14px; color:var(--text); line-height:1.5; }
.variant-text.collapsed { max-height: 100px; overflow: hidden; position: relative; }
.variant-text.collapsed:after { content: ''; position:absolute; inset: auto 0 0 0; height:40px; background: linear-gradient(transparent, #fff); }

/* Variant metadata tags */
.variant-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.tag { font-size: 11px; background: var(--primary-50); color: var(--primary); border: 1px solid var(--primary-50); border-radius: 4px; padding: 3px 8px; font-weight: 500; }

.variant-actions { display:flex; gap:8px; align-items:center; }
.expand-btn { font-size:12px; color:var(--primary); cursor:pointer; padding:4px 8px; border:none; background:none; text-decoration:underline; }
.regen-btn { font-size:12px; padding:6px 12px; border:1px solid var(--primary); color:var(--primary); background:#fff; border-radius:6px; cursor:pointer; transition: all 0.2s ease; }
.regen-btn:hover { background:var(--primary); color:#fff; }

/* Show another variant button */
.show-another-btn { width: 100%; padding: 10px 14px; border: 1px solid var(--line); background: #fff; border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text); transition: all 0.2s ease; margin-top: 8px; }
.show-another-btn:hover { background: var(--primary-50); border-color: var(--primary); color: var(--primary); }
.show-another-btn:active { transform: scale(0.98); }

/* Link button */
.link-btn { background:none; border:none; color:var(--primary); font-size:14px; cursor:pointer; padding:0; text-decoration:underline; }
.link-btn:hover { text-decoration:none; }

/* Label text */
.label-text { font-size:14px; color:var(--text); font-weight:500; }

.toolbar-row { display:flex; align-items:center; gap:10px; margin-bottom:12px; }
.switch { display:inline-flex; align-items:center; gap:8px; }
.switch input { width: 36px; height: 20px; }

.skeleton { display:grid; gap:10px; }
.skeleton .bar { height: 14px; background: #f3f4f6; border-radius: 6px; animation: pulse 1.3s ease-in-out infinite; }
.bar.w40 { width: 40%; } .bar.w90 { width: 90%; } .bar.h80 { height: 80px; }
@keyframes pulse { 0%{opacity:.7} 50%{opacity:.35} 100%{opacity:.7} }

/* Input sections styling */
.input-section { display: grid; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); overflow: visible; }
.input-section:last-child { border-bottom: none; padding-bottom: 0; }

.section-header { display: flex; align-items: center; gap: 6px; position: relative; z-index: 10; overflow: visible; }
.section-title { font-size: 13px; font-weight: 600; color: var(--text); }
.tooltip-trigger {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--primary-50);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  position: relative;
}
.tooltip-trigger:hover::after {
  content: attr(title);
  position: fixed;
  background: #1f2937;
  color: white;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 99999;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
}

/* Input items */
.inputs-list { display: grid; gap: 6px; }
.input-item { display: flex; align-items: center; gap: 8px; }
.input-item input[type="checkbox"] { cursor: pointer; }
.input-item label { font-size: 13px; color: var(--text); cursor: pointer; }

/* Select field */
.select-field {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  background: white;
  cursor: pointer;
}
.select-field:focus { outline: 2px solid #bfdbfe; border-color: #93c5fd; }

/* Length options */
.length-options { display: grid; gap: 6px; }
.length-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: background 0.2s ease;
}
.length-option:hover { background: var(--primary-50); }
.length-option input[type="radio"] { cursor: pointer; }

/* Variants container */
.variants-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  height: 100%;
}

/* Variant window */
.variant-window {
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  transition: all 0.2s ease;
  cursor: pointer;
}
.variant-window.selected {
  border-color: var(--primary);
  border-width: 2px;
  box-shadow: 0 0 0 3px var(--primary-50);
}
.variant-window:hover:not(.selected) {
  border-color: #d1d5db;
}

.variant-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #fafafa;
}
.variant-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.variant-label strong { font-size: 16px; }

.variant-content {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  position: relative;
  background: white;
}

.variant-placeholder {
  font-size: 72px;
  color: #e5e7eb;
  font-weight: 300;
  line-height: 1;
}

.variant-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  overflow-y: auto;
  padding: 8px 0;
}

.variant-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: #fafafa;
  display: flex;
  gap: 8px;
}

.variant-footer .btn-secondary { flex: 1; }

/* Responsive */
@media (max-width: 900px) {
  .modal-content { grid-template-columns: 1fr; }
  .settings-panel { border-right: none; border-bottom: 1px solid var(--line); }
  .variants-container { grid-template-columns: 1fr; }
  .modal { max-width: 95vw; height: auto; max-height: 90vh; }
}
