/* ═══ VARIABLES ═══ */
:root {
  --bg: #0f1117;
  --bg2: #161b27;
  --bg3: #1e2535;
  --border: #2a3244;
  --text: #e8ecf4;
  --text2: #8892a4;
  --text3: #5a6478;
  --accent: #4f7cff;
  --accent-hover: #3d6aed;
  --accent-light: rgba(79,124,255,0.12);
  --green: #22c55e;
  --green-light: rgba(34,197,94,0.12);
  --red: #ef4444;
  --red-light: rgba(239,68,68,0.12);
  --yellow: #f59e0b;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
}
[data-theme="light"] {
  --bg: #f0f2f7;
  --bg2: #ffffff;
  --bg3: #e8ecf4;
  --border: #d0d7e8;
  --text: #1a2033;
  --text2: #5a6478;
  --text3: #8892a4;
  --accent: #3d6aed;
  --accent-hover: #2d5ad3;
  --accent-light: rgba(61,106,237,0.1);
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
}

/* ═══ RESET ═══ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea { font-family: inherit; }

/* ═══ NAVBAR ═══ */
.navbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 60px;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.nav-brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 18px; font-weight: 700; color: var(--accent);
}
.nav-actions { display: flex; align-items: center; gap: 8px; }

/* ═══ BUTTONS ═══ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; transition: all .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-danger { color: var(--red); border: 1px solid transparent; }
.btn-danger:hover { background: var(--red-light); border-color: var(--red); }
.btn-icon { padding: 6px; border-radius: var(--radius-sm); color: var(--text2); }
.btn-icon:hover { background: var(--bg3); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }

/* ═══ MAIN ═══ */
.main { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }

/* Stats bar */
.stats-bar {
  display: flex; gap: 16px; margin-bottom: 32px;
}
.stat-card {
  flex: 1; background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 24px;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-value { font-size: 28px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 13px; color: var(--text2); }

/* ═══ ROTATORS GRID ═══ */
.rotators-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px;
}

/* ═══ ROTATOR CARD ═══ */
.rotator-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.rotator-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }

.card-header {
  padding: 16px 20px 12px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.card-meta { font-size: 12px; color: var(--text2); }
.card-actions { display: flex; gap: 4px; flex-shrink: 0; }

.card-url-row {
  padding: 0 20px 12px;
  display: flex; align-items: center; gap: 8px;
}
.card-url {
  flex: 1; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px;
  font-size: 12px; color: var(--text2); font-family: monospace;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.btn-copy {
  flex-shrink: 0; padding: 7px 10px; border-radius: var(--radius-sm);
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); font-size: 12px;
  display: flex; align-items: center; gap: 5px;
  transition: all .15s;
}
.btn-copy:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }
.btn-copy.copied { background: var(--green-light); color: var(--green); border-color: var(--green); }

.card-stats {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-click-count {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text2);
}
.click-badge {
  font-size: 18px; font-weight: 700; color: var(--text);
}

.card-links-preview {
  padding: 0 20px 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.link-preview-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 6px 10px;
  background: var(--bg3); border-radius: var(--radius-sm);
  font-size: 12px;
}
.link-preview-label {
  color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.link-preview-pct {
  font-size: 11px; color: var(--text3); background: var(--bg);
  border-radius: 4px; padding: 1px 5px; flex-shrink: 0;
}
.link-preview-clicks {
  display: flex; align-items: center; gap: 4px;
  color: var(--accent); font-weight: 600; white-space: nowrap; flex-shrink: 0;
}

/* ═══ VIEW CONTROLS ═══ */
.view-controls {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 4px; margin-bottom: 12px;
}
.btn-view {
  padding: 6px 8px; border-radius: var(--radius-sm);
  color: var(--text3); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.btn-view:hover { color: var(--text); background: var(--bg3); }
.btn-view.active { color: var(--accent); background: var(--accent-light); border-color: var(--accent); }

/* ═══ LIST VIEW ═══ */
.rotators-list { display: flex; flex-direction: column; gap: 8px; }
.rotator-row {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 20px;
  display: grid; grid-template-columns: 200px 1fr 110px auto;
  align-items: center; gap: 16px;
  transition: border-color .15s, box-shadow .15s;
}
.rotator-row:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.row-title { font-size: 15px; font-weight: 600; }
.row-meta { font-size: 12px; color: var(--text2); margin-top: 2px; }
.row-url { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row-clicks { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; flex-shrink: 0; }

/* ═══ EMPTY STATE ═══ */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 80px 24px; text-align: center;
}
.empty-state p { font-size: 18px; font-weight: 600; color: var(--text2); margin-top: 16px; }
.empty-state span { font-size: 14px; color: var(--text3); }

/* ═══ MODAL ═══ */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; padding: 24px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow);
  width: 100%; max-width: 520px; max-height: 88vh;
  display: flex; flex-direction: column;
  animation: modalIn .18s ease;
}
.modal-wide { max-width: 680px; }
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 { font-size: 18px; font-weight: 700; }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 16px 24px; border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ═══ FORM ═══ */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 8px; }
.label-hint { font-weight: 400; color: var(--text3); }
.form-group input[type="text"],
.form-group input[type="url"] {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px;
  font-size: 14px; color: var(--text); outline: none;
  transition: border-color .15s;
}
.form-group input:focus { border-color: var(--accent); }
.form-group input::placeholder { color: var(--text3); }

/* Link rows in form */
.links-col-headers {
  display: grid; grid-template-columns: 20px 120px 1fr 60px 32px; gap: 6px;
  margin-bottom: 4px;
}
.links-col-headers span {
  font-size: 11px; color: var(--text3); font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; padding: 0 2px;
}

.link-row {
  display: grid; grid-template-columns: 20px 120px 1fr 60px 32px; gap: 6px;
  align-items: center; margin-bottom: 8px;
}
.link-row input { margin: 0; }
.link-weight {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 8px;
  font-size: 14px; color: var(--text); outline: none; text-align: center;
  -moz-appearance: textfield; transition: border-color .15s;
}
.link-weight::-webkit-inner-spin-button,
.link-weight::-webkit-outer-spin-button { -webkit-appearance: none; }
.link-weight:focus { border-color: var(--accent); }
.btn-remove-link {
  width: 32px; height: 36px; border-radius: var(--radius-sm);
  color: var(--text3); display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.btn-remove-link:hover { background: var(--red-light); color: var(--red); }

.weight-total-row {
  display: flex; align-items: center; gap: 4px;
  font-size: 13px; color: var(--text2); margin-top: 4px; justify-content: flex-end;
}
.weight-total-val { font-weight: 700; }
.weight-total-val.ok  { color: var(--green); }
.weight-total-val.bad { color: var(--red); }

/* ═══ STATS MODAL ═══ */
.stats-summary {
  display: flex; gap: 12px; margin-bottom: 24px;
}
.stats-mini-card {
  flex: 1; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px;
  text-align: center;
}
.stats-mini-val { font-size: 24px; font-weight: 700; color: var(--accent); }
.stats-mini-label { font-size: 12px; color: var(--text2); margin-top: 2px; }

.stats-table-wrap { overflow-x: auto; }
.stats-table {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
.stats-table th {
  text-align: left; padding: 10px 12px;
  font-size: 12px; font-weight: 600; color: var(--text2);
  border-bottom: 1px solid var(--border);
}
.stats-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  color: var(--text);
}
.stats-table tr:last-child td { border-bottom: none; }
.stats-table tr:hover td { background: var(--bg3); }
.stats-url {
  font-size: 12px; color: var(--text2); font-family: monospace;
  max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: block;
}
.progress-bar-wrap { display: flex; align-items: center; gap: 8px; }
.progress-bar { flex: 1; height: 6px; background: var(--bg3); border-radius: 99px; min-width: 60px; }
.progress-bar-fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }
.stats-section-title {
  font-size: 13px; font-weight: 600; color: var(--text2);
  margin: 20px 0 10px; text-transform: uppercase; letter-spacing: .05em;
}
.stats-reset-row {
  display: flex; justify-content: flex-end; margin-top: 20px;
}

/* ═══ TOAST ═══ */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
.toast {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 16px;
  font-size: 13px; box-shadow: var(--shadow);
  animation: toastIn .2s ease;
  display: flex; align-items: center; gap: 8px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--accent); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ═══ TEAM PANEL ═══ */
.team-add-form {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 24px;
}
.team-add-title {
  font-size: 13px; font-weight: 600; color: var(--text2);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 12px;
}
.team-add-fields {
  display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 8px; align-items: center;
}
.team-add-fields input,
.team-add-fields select {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px;
  font-size: 13px; color: var(--text); outline: none;
  font-family: inherit; transition: border-color .15s;
}
.team-add-fields input:focus,
.team-add-fields select:focus { border-color: var(--accent); }
.team-add-fields input::placeholder { color: var(--text3); }
.team-add-fields select option { background: var(--bg2); }

.team-section-title {
  font-size: 13px; font-weight: 600; color: var(--text2);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 10px;
}
.team-list { display: flex; flex-direction: column; gap: 8px; }
.team-member {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px;
}
.team-member-info { display: flex; align-items: center; gap: 12px; }
.team-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-light); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.team-email { font-size: 14px; font-weight: 500; }
.team-meta { font-size: 12px; color: var(--text2); margin-top: 2px; }
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600;
}
.badge-admin  { background: var(--accent-light); color: var(--accent); }
.badge-member { background: var(--bg); color: var(--text2); border: 1px solid var(--border); }

/* ═══ FOLDER BAR ═══ */
.folder-bar {
  display: flex; align-items: center; gap: 4px;
  margin-bottom: 16px; overflow-x: auto; flex-wrap: nowrap;
  border-bottom: 1px solid var(--border); padding-bottom: 12px;
  scrollbar-width: none;
}
.folder-bar::-webkit-scrollbar { display: none; }

.folder-tab {
  padding: 5px 14px; border-radius: 99px;
  font-size: 13px; font-weight: 500; color: var(--text2);
  border: 1px solid transparent; white-space: nowrap;
  transition: all .15s; flex-shrink: 0;
}
.folder-tab:hover { color: var(--text); background: var(--bg3); }
.folder-tab.active {
  color: var(--accent); background: var(--accent-light); border-color: var(--accent);
}
.folder-add-btn { margin-left: auto; flex-shrink: 0; white-space: nowrap; }
.folder-empty {
  grid-column: 1 / -1; text-align: center; color: var(--text3);
  padding: 40px 0; font-size: 14px;
}

/* ═══ FOLDER TAB WITH INLINE ACTIONS (hover — no gap issues) ═══ */
.folder-tab-dyn { display: inline-flex; align-items: center; gap: 4px; }
.folder-tab-label { flex-shrink: 0; }
.folder-tab-actions {
  display: none; align-items: center; gap: 1px;
}
.folder-tab-dyn:hover .folder-tab-actions { display: inline-flex; }
.folder-tab-btn-rename,
.folder-tab-btn-delete {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 4px;
  cursor: pointer; transition: background .12s, color .12s;
  color: inherit; flex-shrink: 0;
}
.folder-tab-btn-rename:hover { background: rgba(255,255,255,0.15); }
.folder-tab-btn-delete:hover { background: rgba(239,68,68,0.2); color: var(--red, #ef4444); }
[data-theme="light"] .folder-tab-btn-rename:hover { background: rgba(0,0,0,0.08); }
.folder-tab-rename-input {
  padding: 5px 10px; border-radius: 99px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--accent); background: var(--bg3);
  color: var(--text); outline: none; width: 130px; font-family: inherit;
}

/* ═══ FOLDER HOME TILES ═══ */
.folder-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 28px 20px; border-radius: var(--radius);
  background: var(--bg2); border: 1px solid var(--border);
  cursor: pointer; text-align: center;
  transition: border-color .15s, background .15s, transform .12s;
  user-select: none;
}
.folder-tile:hover {
  border-color: var(--accent); background: var(--accent-light);
  transform: translateY(-2px);
}
.folder-tile-icon { color: var(--accent); }
.folder-tile-name {
  font-size: 15px; font-weight: 600; color: var(--text);
}
.folder-tile-count { font-size: 12px; color: var(--text3); }
.folder-tile-uncat .folder-tile-icon { color: var(--text3); }
.folder-tile-uncat:hover { border-color: var(--border); background: var(--bg3); }

/* ═══ INLINE FOLDER CREATION (in bar) ═══ */
.folder-inline-create {
  display: flex; align-items: center; gap: 4px; flex-shrink: 0;
}
.folder-inline-create input {
  padding: 5px 12px; border-radius: 99px; font-size: 13px;
  border: 1px solid var(--accent); background: var(--bg3);
  color: var(--text); outline: none; width: 170px; font-family: inherit;
  transition: border-color .15s;
}
.folder-inline-create input::placeholder { color: var(--text3); }
.btn-folder-confirm, .btn-folder-cancel {
  width: 26px; height: 26px; border-radius: 50%; border: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: opacity .15s;
}
.btn-folder-confirm { background: var(--accent); color: #fff; }
.btn-folder-confirm:hover { opacity: .85; }
.btn-folder-cancel { background: var(--bg3); color: var(--text2); }
.btn-folder-cancel:hover { background: var(--border); }

/* ═══ CARD FOLDER ROW (quick folder assignment) ═══ */
.card-folder-row {
  display: flex; align-items: center; gap: 6px;
  padding-top: 10px; margin-top: 10px;
  border-top: 1px solid var(--border);
  color: var(--text3);
}
.card-folder-select {
  flex: 1; background: transparent; border: none;
  color: var(--text2); font-size: 12px; cursor: pointer;
  padding: 2px 4px; border-radius: 4px; outline: none; font-family: inherit;
  transition: background .15s;
}
.card-folder-select:hover { background: var(--bg3); color: var(--text); }
.card-folder-select:focus { background: var(--bg3); outline: 1px solid var(--accent); }
.card-folder-select option { background: var(--bg2); }

/* Row view folder inline */
.row-folder-wrap {
  display: inline-flex; align-items: center; gap: 3px;
  color: var(--text3); vertical-align: middle;
}
.row-folder-select {
  max-width: 120px; flex: none;
}

/* ═══ FOLDER SELECT IN ROTATOR FORM ═══ */
.folder-select {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px;
  font-size: 14px; color: var(--text); font-family: inherit;
  outline: none; transition: border-color .15s;
}
.folder-select:focus { border-color: var(--accent); }
.folder-select option { background: var(--bg2); }

/* ═══ SCHEDULE MODE — link rows ═══ */
.link-row-schedule {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 10px 10px 8px;
  margin-bottom: 8px;
}
.link-row-main {
  display: grid; grid-template-columns: 20px 120px 1fr 32px; gap: 6px; align-items: center;
}
.link-row-main input { margin: 0; }
.link-row-schedule-opts {
  display: flex; align-items: center; gap: 12px; padding-left: 26px; flex-wrap: wrap;
}

/* Day toggle buttons */
.schedule-days { display: flex; gap: 4px; flex-wrap: wrap; }
.day-btn {
  padding: 4px 8px; border-radius: 99px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); color: var(--text3);
  background: var(--bg2); cursor: pointer; transition: all .15s;
  user-select: none; font-family: inherit;
}
.day-btn:hover { border-color: var(--accent); color: var(--accent); }
.day-btn.active {
  background: var(--accent); border-color: var(--accent);
  color: #fff;
}

/* Time range inputs */
.schedule-times {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.schedule-times input[type="time"] {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 8px;
  font-size: 13px; color: var(--text); outline: none;
  font-family: inherit; transition: border-color .15s;
  width: 100px;
}
.schedule-times input[type="time"]:focus { border-color: var(--accent); }
.schedule-sep { color: var(--text3); font-size: 14px; font-weight: 600; }

/* link-preview-schedule inside card */
.link-preview-schedule {
  font-size: 11px; color: var(--accent); background: var(--accent-light);
  border-radius: 4px; padding: 1px 5px; flex-shrink: 0;
  text-align: center; line-height: 1.4;
}
.link-preview-schedule small { color: var(--text2); }

/* Hide weight-only elements in schedule mode */
#stepForm.mode-schedule .weight-only     { display: none !important; }
#stepForm.mode-schedule #linksColHeaders { display: none !important; }

/* Show schedule-only elements only in schedule mode */
.schedule-only { display: none !important; }
#stepForm.mode-schedule .schedule-only { display: block !important; }

/* Timezone badge */
.tz-badge {
  color: var(--text2); background: var(--bg3);
  border: 1px solid var(--border);
}

/* ═══ DRAG HANDLE & DND ═══ */
.drag-handle {
  display: flex; align-items: center; justify-content: center;
  color: var(--text3); cursor: grab; user-select: none;
  width: 20px; padding: 2px; border-radius: 4px;
  transition: color .15s;
}
.drag-handle:hover { color: var(--text2); }
.drag-handle:active { cursor: grabbing; }
.link-row.dragging { opacity: 0.4; }
.link-row.drag-over { box-shadow: 0 -2px 0 var(--accent); }

/* ═══ MODE PICKER (Step 1) ═══ */
.step-mode-body { padding-bottom: 32px; }

.mode-picker-title {
  font-size: 17px; font-weight: 700; color: var(--text);
  text-align: center; margin-bottom: 6px;
}
.mode-picker-sub {
  font-size: 13px; color: var(--text3);
  text-align: center; margin-bottom: 28px;
}
.mode-cards {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
.mode-card {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; padding: 28px 18px 24px;
  background: var(--bg3); border: 2px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
  transition: border-color .18s, transform .18s, box-shadow .18s;
  text-align: center;
}
.mode-card:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  transform: translateY(-3px);
  box-shadow: var(--shadow-sm);
}
.mode-card-icon {
  width: 56px; height: 56px; border-radius: 14px;
  background: var(--accent-light); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.mode-card-name {
  font-size: 15px; font-weight: 700; color: var(--text);
}
.mode-card-desc {
  font-size: 12px; color: var(--text2); line-height: 1.55;
}
.mode-card-example {
  display: block; margin-top: 6px;
  font-weight: 700; color: var(--accent); letter-spacing: .02em;
}

/* ═══ MODE SELECTOR PILLS (Step 2 / Edit) ═══ */
.mode-selector-row {
  display: flex; gap: 4px; padding: 4px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 20px;
}
.mode-pill {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 12px; border-radius: calc(var(--radius) - 3px);
  font-size: 13px; font-weight: 500; color: var(--text2);
  transition: all .15s;
}
.mode-pill:hover { color: var(--text); background: var(--bg2); }
.mode-pill.active {
  background: var(--bg2); color: var(--accent);
  box-shadow: 0 1px 6px rgba(0,0,0,0.18);
}

/* ═══ STEP FORM FLEX WRAPPER ═══ */
#stepForm {
  display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden;
}
#stepForm .modal-body { flex: 1; overflow-y: auto; }

/* ═══ MODE-EQUAL: hide weight-only elements ═══ */
#stepForm.mode-equal .weight-only { display: none !important; }
#stepForm.mode-equal .links-col-headers {
  grid-template-columns: 20px 120px 1fr 32px;
}
#stepForm.mode-equal .link-row {
  grid-template-columns: 20px 120px 1fr 32px;
}
#stepForm.mode-weighted .links-col-headers {
  grid-template-columns: 20px 120px 1fr 60px 32px;
}
#stepForm.mode-weighted .link-row {
  grid-template-columns: 20px 120px 1fr 60px 32px;
}

/* ═══ MODE BADGE (on cards) ═══ */
.mode-badge {
  display: inline-flex; align-items: center;
  padding: 1px 6px; border-radius: 99px;
  font-size: 10px; font-weight: 600;
  vertical-align: middle; margin-left: 4px;
}
.mode-badge.equal {
  color: var(--green); background: var(--green-light);
}
.mode-badge.weighted {
  color: var(--accent); background: var(--accent-light);
}
.mode-badge.schedule {
  color: var(--yellow); background: rgba(245,158,11,0.12);
}

/* ═══ SHORT LINKS ═══ */
.short-create-form {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 24px;
}
.short-create-fields {
  display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 8px; align-items: center;
}
.short-create-fields input {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px;
  font-size: 13px; color: var(--text); outline: none;
  font-family: inherit; transition: border-color .15s;
}
.short-create-fields input:focus { border-color: var(--accent); }
.short-create-fields input::placeholder { color: var(--text3); }
.short-create-hint { font-size: 12px; color: var(--text3); margin-top: 8px; }

.short-link-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 8px;
  transition: border-color .15s;
}
.short-link-item:hover { border-color: var(--accent); }
.short-link-info { flex: 1; min-width: 0; }
.short-link-label { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.short-link-short-url {
  font-size: 13px; font-weight: 600; color: var(--accent);
  font-family: monospace; margin-bottom: 2px;
}
.short-link-dest {
  font-size: 12px; color: var(--text2); font-family: monospace;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px;
}
.short-link-meta { font-size: 11px; color: var(--text3); }
.short-link-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.short-empty {
  text-align: center; color: var(--text3); padding: 32px 0;
  font-size: 14px; line-height: 1.6;
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 600px) {
  .stats-bar { flex-direction: column; gap: 8px; }
  .rotators-grid { grid-template-columns: 1fr; }
  .links-col-headers { display: none; }
  .link-row { grid-template-columns: 20px 1fr 60px 32px; grid-template-rows: auto auto; }
  .link-row .link-label { grid-column: 2 / -1; }
  #stepForm.mode-equal .link-row { grid-template-columns: 20px 1fr 32px; }
  .folder-bar { gap: 6px; padding-bottom: 8px; }
  .folder-tab { padding: 4px 10px; font-size: 12px; }
  .folder-inline-create input { width: 130px; }
  .rotator-row { grid-template-columns: 1fr auto; grid-template-rows: auto auto; gap: 8px; }
  .row-url { grid-column: 1 / -1; }
  .row-clicks { justify-content: flex-start; }
  .short-create-fields { grid-template-columns: 1fr; }
  .short-link-item { flex-direction: column; align-items: flex-start; }
  .short-link-actions { width: 100%; justify-content: flex-end; }
  .navbar { padding: 0 16px; }
  .main { padding: 24px 16px; }
  .mode-cards { grid-template-columns: 1fr; gap: 10px; }
  .mode-card { flex-direction: row; text-align: left; padding: 18px 16px; gap: 14px; }
  .mode-card-icon { flex-shrink: 0; width: 44px; height: 44px; }
  .mode-selector-row { flex-direction: column; }
  .link-row-main { grid-template-columns: 20px 1fr 32px; }
  .link-row-main .link-label { display: none; }
  .link-row-schedule-opts { padding-left: 0; flex-direction: column; align-items: flex-start; }
  .schedule-times input[type="time"] { width: 88px; }
}
