/* ============================================================================
 * WRITING-MODE.CSS — Writing assistant + Skabeloner sidebar
 * v6: Voice-card inspired tone slider, no tone in template form
 * ============================================================================ */

/* ── Nudge — inline text at placeholder position ── */
.wm-nudge {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 22px 20px 20px 20px;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.wm-nudge.hidden {
  opacity: 0;
  visibility: hidden;
}

.wm-nudge-text {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--color-text-secondary, rgb(60, 60, 58));
  margin: 0;
  pointer-events: none;
}

.wm-nudge-link {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: rgb(19, 19, 19);
  background: none;
  white-space: nowrap;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
  pointer-events: auto;
  transition: opacity 0.2s;
}

.wm-nudge-link:hover {
  opacity: 0.75;
  text-decoration: underline;
}

/* ── Expanded form (left side — generate text) ── */
.wm-form {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 24px;
  background: var(--color-card, #fff);
  overflow-y: auto;
  overflow-x: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.wm-form.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.wm-form-inner {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Form header ── */
.wm-form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 6px;
  border-bottom: none;
  margin-bottom: 0;
}

.wm-form-header span {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 17px;
  font-weight: 650;
  color: var(--color-text-primary, rgb(19, 19, 19));
  letter-spacing: -0.01em;
}

.wm-collapse-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.035);
  color: var(--color-text-secondary, #6d7a8a);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.12s;
}

.wm-collapse-btn:hover {
  background: rgba(0, 0, 0, 0.07);
  transform: scale(1.06);
}
.wm-collapse-btn:active {
  transform: scale(0.94);
}

/* ── Form fields (shared by writing form + sidebar form) ── */
.wm-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.wm-field label {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary, rgb(60, 60, 58));
  text-transform: none;
  letter-spacing: 0.04em;
}

.wm-field input,
.wm-field textarea {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 14px;
  padding: 11px 14px;
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  background: var(--color-card, #fff);
  color: var(--color-text-primary, rgb(19, 19, 19));
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s, height 0.1s ease;
  resize: none;
  overflow: hidden;
  box-sizing: border-box;
  field-sizing: content; /* Progressive: Chrome/Safari auto-grow natively */
}

.wm-field input:focus,
.wm-field textarea:focus {
  border-color: rgba(0, 0, 0, 0.15);
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.03);
}

.wm-field input::placeholder,
.wm-field textarea::placeholder {
  color: var(--color-text-secondary, rgb(60, 60, 58));
  opacity: 0.7;
}

/* Textarea wrapper — positions mic button */
.wm-textarea-wrap {
  position: relative;
}
.wm-textarea-wrap textarea {
  width: 100%;
  padding-right: 44px;
}

/* Mic button — right corner of textarea */
.wm-mic-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--color-text-tertiary, #a1a4b5);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  z-index: 1;
}
.wm-mic-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--color-text-secondary, rgb(60, 60, 58));
}
/* Uses same listening-glow + pulse animation as micButton1 in grammar bot */
.wm-mic-btn .lucide-mic.listening-glow {
  animation: pulse 1s infinite;
}

/* Task textarea — starts at 1 row, grows up to 200px */
#wm-task {
  min-height: 38px;
  max-height: 200px;
}

/* Content textarea — starts at ~3 rows, grows up to 200px */
#wm-content {
  min-height: 80px;
  max-height: 200px;
}

/* Sidebar form fields — more compact, white on gray panel */
.wm-tpl-form-body .wm-field input,
.wm-tpl-form-body .wm-field textarea {
  font-size: 13px;
  padding: 8px 10px;
  background: var(--color-card, #fff);
}

.wm-tpl-form-body .wm-field textarea {
  min-height: 60px;
}

/* ── Fields card — groups inputs like sidebar action list ── */
.wm-fields-card {
  background: var(--color-card, #fff);
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

.wm-fields-card .wm-field {
  padding: 10px 14px;
  gap: 5px;
}

.wm-fields-card .wm-field + .wm-field {
  border-top: 0.5px solid rgba(0, 0, 0, 0.06);
}

/* Inside card: inputs lose their own border — the card provides the container */
.wm-fields-card .wm-field input,
.wm-fields-card .wm-field textarea {
  border: none;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.025);
  padding: 10px 44px 10px 12px;
}

.wm-fields-card .wm-field input:focus,
.wm-fields-card .wm-field textarea:focus {
  background: rgba(0, 0, 0, 0.04);
  box-shadow: none;
}

/* Dark mode card */
[data-theme="dark"] .wm-fields-card {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 2px 8px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .wm-fields-card .wm-field + .wm-field {
  border-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .wm-fields-card .wm-field input,
[data-theme="dark"] .wm-fields-card .wm-field textarea {
  background: rgba(255, 255, 255, 0.04);
}

[data-theme="dark"] .wm-fields-card .wm-field input:focus,
[data-theme="dark"] .wm-fields-card .wm-field textarea:focus {
  background: rgba(255, 255, 255, 0.07);
}

/* ── Section divider — hidden, slider is self-explanatory ── */
.wm-section-divider {
  display: none;
}

[data-theme="dark"] .wm-section-divider {
  color: rgba(207, 211, 236, 0.5);
}

/* ============================================================================
 * TONE SLIDER — matches voice-slider design from Tone tab
 * ============================================================================ */

.wm-tone-card {
  padding: 12px 16px 0;
  text-align: center;
  font-family: 'Nunito Sans', sans-serif;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.wm-tone-label {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary, rgb(60, 60, 58));
  text-align: left;
  margin-bottom: 10px;
  text-transform: none;
  letter-spacing: 0.04em;
}

.wm-tone-current {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 13px;
  font-weight: 650;
  color: var(--color-text-primary, rgb(19, 19, 19));
  margin-bottom: 1px;
  letter-spacing: -0.01em;
}

.wm-tone-desc {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 11px;
  font-weight: 400;
  color: var(--color-text-secondary, rgb(60, 60, 58));
  margin-bottom: 6px;
}

.wm-tone-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: #edeef0;
  border: none;
  cursor: pointer;
  margin: 0 0 8px;
  transition: all 0.3s ease;
}

.wm-tone-track:focus-visible {
  outline: 2px solid rgba(31, 31, 30, 0.3);
  outline-offset: 4px;
}

.wm-tone-track::before {
  display: none;
}

.wm-tone-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: 999px;
  background: #4a5568;
  transition: width 0.15s ease;
  pointer-events: none;
}

.wm-tone-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid #4a5568;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(74, 85, 104, 0.2);
  cursor: grab;
  transition: left 0.15s ease, box-shadow 0.15s ease;
  z-index: 3;
}

.wm-tone-thumb:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(74, 85, 104, 0.25);
}

.wm-tone-thumb:active {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.08);
}

.wm-tone-endpoints {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}

.wm-tone-endpoints span {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-secondary, rgb(60, 60, 58));
  opacity: 0.7;
}

/* ── Submit button (writing form) — charcoal gradient chip ── */
.wm-submit {
  font-family: 'Nunito Sans', sans-serif;
  padding: 11px 16px;
  border: 0.5px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: linear-gradient(135deg, #4f5e6f 0%, #3b4857 50%, #364252 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  text-align: left;
  gap: 12px;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.10),
    0 2px 6px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: box-shadow 0.2s ease, transform 0.2s ease, background 0.25s ease;
}

.wm-submit:hover {
  background: linear-gradient(135deg, #566780 0%, #415264 50%, #3b4d5e 100%);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.15),
    0 8px 24px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}
.wm-submit:active {
  transform: translateY(0) scale(0.985);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.15),
    inset 0 1px 3px rgba(0, 0, 0, 0.1);
  transition-duration: 0.1s;
}
.wm-submit:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

.wm-submit-icon {
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 0.5px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.95;
  transition: opacity 0.2s, background 0.2s, transform 0.2s;
}

.wm-submit:hover .wm-submit-icon {
  opacity: 1;
  background: rgba(255, 255, 255, 0.14);
  transform: scale(1.04);
}

.wm-submit-icon svg {
  width: 16px;
  height: 16px;
  stroke: #fff;
  fill: none;
  stroke-width: 1.8;
}

.wm-submit-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wm-btn-text {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: #fff;
  line-height: 1.2;
}

.wm-submit-desc {
  font-size: 12px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.3;
}

.wm-submit.loading .wm-btn-text { display: none; }
.wm-submit.loading .wm-submit-desc { display: none; }
.wm-submit.loading .wm-btn-loader { display: inline-block; }

.wm-btn-loader {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: wm-spin 0.6s linear infinite;
}

@keyframes wm-spin { to { transform: rotate(360deg); } }

/* ── Back/cancel link (writing form) ── */
.wm-back-link {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 12px;
  color: var(--color-text-secondary, rgb(60, 60, 58));
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-align: center;
  transition: color 0.2s;
}

.wm-back-link:hover {
  color: var(--color-text-primary, rgb(19, 19, 19));
}

/* ============================================================================
 * SIDEBAR TEMPLATES PANEL (Skabeloner)
 * ============================================================================ */

/* Ensure sidebar is a positioning context */
.sidebar-wrapper {
  position: relative !important;
}

/* Fix hardcoded white border-left on sidebar in dark mode */
[data-theme="dark"] #ss.sidebar-wrapper,
[data-theme="dark"] .sidebar-wrapper {
  border-left-color: var(--color-border, #3b3c51) !important;
}

.wm-tpl-panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--color-bg, #FAFAF8);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.wm-tpl-panel.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ── View switching ── */
.wm-tpl-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.wm-tpl-view-hidden {
  display: none !important;
}

/* ── Panel header (list view) ── */
.wm-tpl-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 10px;
  border-bottom: none;
  background: transparent;
  flex-shrink: 0;
}

.wm-tpl-header svg {
  color: var(--color-text-primary, rgb(19, 19, 19));
}

.wm-tpl-header span {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 14px;
  font-weight: 650;
  color: var(--color-text-primary, rgb(19, 19, 19));
}

/* ── Add button ── */
.wm-tpl-add {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.06);
  cursor: pointer;
  flex-shrink: 0;
  width: 100%;
  text-align: left;
  transition: background 0.15s;
}

.wm-tpl-add:hover {
  background: rgba(0, 0, 0, 0.03);
}

.wm-tpl-add svg {
  color: #4a5568;
  flex-shrink: 0;
}

.wm-tpl-add span {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #4a5568;
}

/* ── Templates list ── */
.wm-tpl-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.08) transparent;
}

/* ── Empty state ── */
.wm-tpl-empty {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 13px;
  color: var(--color-text-secondary, rgb(60, 60, 58));
  text-align: center;
  padding: 32px 16px;
}

/* ── Template card ── */
.wm-tpl-card {
  position: relative;
  padding: 14px 16px;
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  background: var(--color-card, #fff);
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
}

.wm-tpl-card:hover {
  border-color: rgba(0, 0, 0, 0.18);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.wm-tpl-card.active {
  border-color: rgba(0, 0, 0, 0.22);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
  background: var(--color-bg, #FAFAF8);
}

.wm-tpl-card-body {
  padding-right: 40px;
}

.wm-tpl-title {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 14px;
  font-weight: 650;
  color: var(--color-text-primary, rgb(19, 19, 19));
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wm-tpl-preview {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 12.5px;
  color: var(--color-text-secondary, rgb(60, 60, 58));
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Card actions (edit/delete) ── */
.wm-tpl-card-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: stretch;
  gap: 0;
  opacity: 0;
  transition: opacity 0.15s;
  background: var(--color-card, #fff);
  border-radius: 8px;
  padding: 2px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* Subtle dividers between action icons — use pseudo-elements for consistent spacing */
.wm-tpl-card-actions .wm-tpl-pin::after,
.wm-tpl-card-actions .wm-tpl-edit::after {
  content: '';
  position: absolute;
  right: -1px;
  top: 5px;
  bottom: 5px;
  width: 1px;
  background: rgba(0, 0, 0, 0.08);
}

.wm-tpl-card:hover .wm-tpl-card-actions {
  opacity: 1;
}

.wm-tpl-pin,
.wm-tpl-edit,
.wm-tpl-delete {
  position: relative;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text-secondary, #6d7a8a);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.wm-tpl-pin svg,
.wm-tpl-edit svg,
.wm-tpl-delete svg {
  display: block;
}

/* Star path sits higher in its viewBox than pencil/trash — nudge down */
.wm-tpl-pin svg {
  transform: translateY(1px);
}

.wm-tpl-edit:hover {
  background: rgba(0, 0, 0, 0.07);
  color: rgb(19, 19, 19);
}

.wm-tpl-delete:hover {
  background: rgba(226, 70, 104, 0.1);
  color: #e24668;
}

/* ============================================================================
 * SIDEBAR FORM VIEW (create/edit template)
 * ============================================================================ */

.wm-tpl-form-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
  background: var(--color-card, #fff);
  flex-shrink: 0;
}

.wm-tpl-back-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text-secondary, #6d7a8a);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.wm-tpl-back-btn:hover {
  background: var(--color-bg, #FAFAF8);
  color: var(--color-text-primary, rgb(19, 19, 19));
}

.wm-tpl-form-header span {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 14px;
  font-weight: 650;
  color: var(--color-text-primary, rgb(19, 19, 19));
}

.wm-tpl-form-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Save button (sidebar form) ── */
.wm-tpl-save-btn {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 13px;
  font-weight: 650;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #4f5e6f 0%, #3b4857 50%, #364252 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  transition: filter 0.2s, transform 0.1s;
  margin-top: 4px;
}

.wm-tpl-save-btn:hover { filter: brightness(1.08); }
.wm-tpl-save-btn:active { transform: scale(0.98); }
.wm-tpl-save-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.wm-tpl-save-btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.wm-tpl-save-btn.loading .wm-tpl-save-text { display: none; }
.wm-tpl-save-btn.loading .wm-tpl-save-loader { display: inline-block; }

.wm-tpl-save-loader {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: wm-spin 0.6s linear infinite;
}

/* ── Tone pill row (template form) ── */
.wm-tpl-tone-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.wm-tpl-tone-pill {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 20px;
  background: var(--color-card, #fff);
  color: var(--color-text-secondary, rgb(60, 60, 58));
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.wm-tpl-tone-pill:hover {
  border-color: rgba(0, 0, 0, 0.2);
  color: var(--color-text-primary, rgb(19, 19, 19));
}

.wm-tpl-tone-pill.active {
  background: #384551;
  border-color: rgb(19, 19, 19);
  color: #fff;
}

[data-theme="dark"] .wm-tpl-tone-pill {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
  color: rgba(207, 211, 236, 0.7);
}

[data-theme="dark"] .wm-tpl-tone-pill:hover {
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(207, 211, 236, 0.9);
}

[data-theme="dark"] .wm-tpl-tone-pill.active {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* ── Optional field label ── */
.wm-field-optional {
  font-weight: 400;
  font-size: 10px;
  color: var(--color-text-secondary, #a1a4b5);
  opacity: 0.7;
}

/* ── Tone badge on template card ── */
.wm-tpl-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.wm-tpl-title-row .wm-tpl-title {
  margin-bottom: 0;
}

.wm-tpl-tone-badge {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--color-text-secondary, rgb(60, 60, 58));
  white-space: nowrap;
  flex-shrink: 0;
}

[data-theme="dark"] .wm-tpl-tone-badge {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(207, 211, 236, 0.6);
}

/* ── Hide top bar + counter when writing form is open ── */
body.wm-form-open .top-controls {
  display: none !important;
}
body.wm-form-open .counter-nav-div {
  display: none !important;
}

/* ============================================================================
 * SPOTLIGHT + PLACEHOLDER
 * ============================================================================ */

/* Dim editor controls when empty */
.grammar-page.editor-empty .top-controls {
  opacity: 0.55 !important;
  pointer-events: none !important;
  transition: opacity 0.4s ease !important;
}
/* EXCEPTION: left-controls (save, STT, paste, upload) must ALWAYS work */
.grammar-page.editor-empty .top-controls .left-controls {
  opacity: 1 !important;
  pointer-events: auto !important;
}

.grammar-page.editor-empty .counter-nav-div {
  opacity: 0.45 !important;
  pointer-events: none !important;
  transition: opacity 0.4s ease !important;
}

/* Sidebar: dim grammar content, NOT the templates panel */
.grammar-page.editor-empty .sidebar-wrapper {
  transition: opacity 0.4s ease !important;
}

/* Dim sidebar controls when editor is empty, but keep language selector active */
.grammar-page.editor-empty .correction-sidebar {
  pointer-events: none !important;
  transition: opacity 0.4s ease !important;
}
.grammar-page.editor-empty .correction-sidebar > *:not(.sidebar-controls) {
  opacity: 0.4 !important;
}
.grammar-page.editor-empty .sidebar-controls {
  opacity: 1 !important;
}
.grammar-page.editor-empty .sidebar-controls > *:not(.dk-translation-box) {
  opacity: 0.4 !important;
  pointer-events: none !important;
}
.grammar-page.editor-empty .sidebar-controls .dk-translation-box {
  opacity: 1 !important;
  pointer-events: auto !important;
}
.grammar-page.editor-empty .sidebar-dropdown-items {
  opacity: 0.4 !important;
  pointer-events: none !important;
  transition: opacity 0.4s ease !important;
}


/* Hide Quill placeholder — our nudge replaces it */
.ql-editor.ql-blank::before {
  display: none !important;
}

/* Restore transitions */
.grammar-page .top-controls,
.grammar-page .counter-nav-div,
.grammar-page .sidebar-wrapper {
  transition: opacity 0.4s ease;
}

/* ============================================================================
 * RESPONSIVE
 * ============================================================================ */

@media (max-width: 768px) {
  /* iOS WebKit: body overflow:hidden blocks touch scroll on ALL descendants,
     even position:fixed. Unlock when writing form is open. */
  body.wm-form-open {
    overflow: auto !important;
    position: fixed !important;
    width: 100% !important;
  }

  .wm-nudge { padding: 16px; }

  .wm-form {
    /* Break free from overflow:hidden parent chain */
    position: fixed;
    inset: 0 0 90px 0; /* 90px = mobile-nav height incl. protruding AI btn */
    /* No centering — start at top, scroll naturally */
    align-items: flex-start;
    justify-content: flex-start;
    padding: 20px 16px;
    overflow-y: scroll;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .wm-tpl-panel { display: none; }

  .wm-form-inner { gap: 16px; }
  .wm-field { gap: 6px; }

  /* Inputs — 16px minimum prevents iOS auto-zoom on focus */
  .wm-field textarea,
  .wm-field input {
    padding: 10px 12px;
    font-size: 16px;
    border-radius: 10px;
  }
  #wm-task { min-height: 36px; }
  #wm-content { min-height: 48px; }

  /* Tone card — even spacing, no extra padding box */
  .wm-tone-card { padding: 4px 0 0; }
  .wm-tone-label { margin-bottom: 8px; }
  .wm-tone-desc { margin-bottom: 10px; }
  .wm-tone-track { margin-bottom: 6px; }
  .wm-tone-endpoints { font-size: 11px; }

  /* Submit — full-width feel */
  .wm-submit {
    border-radius: 16px;
    padding: 15px 24px;
    font-size: 16px;
    min-height: 52px;
  }

  /* Language row — a bit more breathing room */
  .wm-language-row { margin-top: -4px; }
}

/* ============================================================================
 * CONFIRM MODAL
 * ============================================================================ */

.wm-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.wm-confirm-overlay.visible {
  opacity: 1;
}

.wm-confirm-box {
  background: var(--color-card, #fff);
  border-radius: 12px;
  padding: 24px;
  width: 340px;
  max-width: 90vw;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  transform: scale(0.95);
  transition: transform 0.15s ease;
  text-align: center;
}

.wm-confirm-overlay.visible .wm-confirm-box {
  transform: scale(1);
}

.wm-confirm-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: rgba(226, 70, 104, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e24668;
}

.wm-confirm-title {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 16px;
  font-weight: 650;
  color: var(--color-text-primary, rgb(19, 19, 19));
  margin-bottom: 6px;
}

.wm-confirm-desc {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 14px;
  color: var(--color-text-secondary, rgb(60, 60, 58));
  margin-bottom: 20px;
  line-height: 1.5;
}

.wm-confirm-actions {
  display: flex;
  gap: 10px;
}

.wm-confirm-cancel,
.wm-confirm-delete {
  flex: 1;
  padding: 10px 16px;
  border-radius: 8px;
  font-family: 'Nunito Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  min-height: 44px;
  transition: background 0.15s, opacity 0.15s;
}

.wm-confirm-cancel {
  background: var(--color-bg, #FAFAF8);
  color: var(--color-text-primary, rgb(19, 19, 19));
}

.wm-confirm-cancel:hover {
  background: rgba(0, 0, 0, 0.08);
}

.wm-confirm-delete {
  background: #e24668;
  color: #fff;
}

.wm-confirm-delete:hover {
  opacity: 0.9;
}

/* Dark mode confirm */
[data-theme="dark"] .wm-confirm-box {
  background: var(--color-card, #1a2035);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .wm-confirm-cancel {
  background: var(--color-bg, #111727);
}

[data-theme="dark"] .wm-confirm-cancel:hover {
  background: var(--color-border, #3b3c51);
}

/* ============================================================================
 * DARK MODE
 * ============================================================================ */

[data-theme="dark"] .wm-form {
  background: var(--color-card, #2b2c40);
}

[data-theme="dark"] .wm-field input,
[data-theme="dark"] .wm-field textarea {
  background-color: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.10);
  color: var(--color-text-primary, #cfd3ec);
}

[data-theme="dark"] .wm-field input:focus,
[data-theme="dark"] .wm-field textarea:focus {
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.04);
}

[data-theme="dark"] .wm-mic-btn {
  color: var(--color-text-tertiary, #6c6e85);
  background: transparent;
}
[data-theme="dark"] .wm-mic-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-text-secondary, #8e92a8);
}

[data-theme="dark"] .wm-collapse-btn {
  background: rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .wm-collapse-btn:hover {
  background: rgba(255, 255, 255, 0.10);
}

[data-theme="dark"] .wm-form-header {
  border-bottom: none;
}

[data-theme="dark"] .wm-field label {
  color: var(--color-text-secondary, #8a92a6);
}

/* Dark mode submit — subtle gradient on dark, white text */
[data-theme="dark"] .wm-submit {
  background: linear-gradient(135deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0.06) 100%);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.10);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .wm-submit:hover {
  background: linear-gradient(135deg, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0.10) 100%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
[data-theme="dark"] .wm-submit-icon {
  background: rgba(255, 255, 255, 0.10);
}
[data-theme="dark"] .wm-submit-icon svg {
  stroke: #fff;
}
[data-theme="dark"] .wm-btn-text {
  color: #fff;
}
[data-theme="dark"] .wm-submit-desc {
  color: rgba(255, 255, 255, 0.55);
}
[data-theme="dark"] .wm-btn-loader {
  border-color: rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
}

/* Dark mode tone — transparent, no card appearance */
[data-theme="dark"] .wm-tone-card {
  background: transparent;
  border: none;
  box-shadow: none;
}

[data-theme="dark"] .wm-tone-current {
  color: #fff;
}

[data-theme="dark"] .wm-tone-desc {
  color: rgba(207, 211, 236, 0.55);
}

[data-theme="dark"] .wm-tone-endpoints span {
  color: rgba(207, 211, 236, 0.45);
}

[data-theme="dark"] .wm-tone-track {
  background: rgba(255, 255, 255, 0.10);
}

[data-theme="dark"] .wm-tone-progress {
  background: linear-gradient(90deg, rgba(255,255,255,0.25) 0%, rgba(255,255,255,0.4) 100%);
}

[data-theme="dark"] .wm-tpl-panel {
  background: var(--color-bg, #232333);
}

[data-theme="dark"] .wm-tpl-header {
  border-bottom: none;
  background: transparent;
}

[data-theme="dark"] .wm-tpl-header svg {
  color: var(--color-text-primary, #cfd3ec);
}

[data-theme="dark"] .wm-tpl-add {
  border-bottom-color: rgba(255, 255, 255, 0.06);
  background: transparent;
}

[data-theme="dark"] .wm-tpl-add svg {
  color: rgba(207, 211, 236, 0.6);
}

[data-theme="dark"] .wm-tpl-add span {
  color: rgba(207, 211, 236, 0.6);
}

[data-theme="dark"] .wm-tpl-add:hover {
  background: var(--color-bg, #232333);
}

[data-theme="dark"] .wm-tpl-card {
  border-color: var(--color-border, #3b3c51);
}

[data-theme="dark"] .wm-tpl-card:hover {
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .wm-tpl-card.active {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.04);
}

[data-theme="dark"] .wm-tpl-card-actions {
  background: var(--color-card, #2b2c40);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] .wm-tpl-card-actions .wm-tpl-pin::after,
[data-theme="dark"] .wm-tpl-card-actions .wm-tpl-edit::after {
  background: rgba(255, 255, 255, 0.10);
}

[data-theme="dark"] .wm-tpl-pin,
[data-theme="dark"] .wm-tpl-edit,
[data-theme="dark"] .wm-tpl-delete {
  background: transparent;
  color: rgba(207, 211, 236, 0.6);
}

[data-theme="dark"] .wm-tpl-form-header {
  border-color: var(--color-border, #3b3c51);
}

[data-theme="dark"] .wm-tpl-back-btn:hover {
  background: var(--color-bg, #232333);
}

/* Dark mode: tone slider tick marks (hidden — tick marks removed) */
[data-theme="dark"] .wm-tone-track::before {
  display: none;
}

/* Dark mode: tone slider thumb */
[data-theme="dark"] .wm-tone-thumb {
  background: var(--color-card, #2b2c40);
  border-color: #7a8a9e;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(122, 138, 158, 0.25);
}

/* ── Accessibility: focus-visible ── */
.wm-nudge-link:focus-visible,
.wm-collapse-btn:focus-visible,
.wm-submit:focus-visible,
.wm-back-link:focus-visible,
.wm-tpl-add:focus-visible,
.wm-tpl-card:focus-visible,
.wm-tpl-edit:focus-visible,
.wm-tpl-delete:focus-visible,
.wm-tpl-back-btn:focus-visible,
.wm-tpl-save-btn:focus-visible {
  outline: 2px solid rgba(31, 31, 30, 0.3);
  outline-offset: 2px;
}

.wm-field input:focus-visible,
.wm-field textarea:focus-visible {
  outline: none;
}

.wm-field select:focus-visible {
  outline: none;
}

/* ── Dark mode: secondary text contrast fix ── */
[data-theme=dark] .wm-nudge-text,
[data-theme=dark] .wm-tone-desc,
[data-theme=dark] .wm-tone-endpoint,
[data-theme=dark] .wm-back-link,
[data-theme=dark] .wm-tpl-empty,
[data-theme=dark] .wm-tpl-preview {
  color: var(--color-text-secondary, #a3aab5);
}

/* ── Touch target minimums ── */
.wm-submit,
.wm-tpl-save-btn {
  min-height: 44px;
}

.wm-tpl-add {
  min-height: 44px;
}

.wm-collapse-btn,
.wm-tpl-edit,
.wm-tpl-delete,
.wm-tpl-back-btn {
  min-width: 36px;
  min-height: 36px;
}

/* ── Writing mode language selector ── */
.wm-language-row {
  display: flex;
  justify-content: center;
  margin-top: 2px;
  position: relative;
}
.wm-lang-select {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-family: 'Nunito Sans', sans-serif;
  font-weight: 400;
  color: var(--color-text-secondary, #6b7280);
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
}
.wm-lang-select:hover {
  background: var(--color-hover, rgba(105, 108, 255, 0.06));
  color: var(--color-text-primary, rgb(19, 19, 19));
}
.wm-lang-select:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(105, 108, 255, 0.15);
}
.wm-lang-flag {
  display: flex;
  align-items: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.wm-lang-flag svg {
  width: 18px;
  height: 18px;
}
.wm-lang-name {
  white-space: nowrap;
}
.wm-lang-select svg:last-child {
  flex-shrink: 0;
  opacity: 0.5;
}

/* Dropdown */
.wm-lang-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: #fff;
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 2px 4px rgba(0, 0, 0, 0.06);
  min-width: 180px;
  padding: 8px;
  display: none;
}
.wm-lang-dropdown::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: #fff transparent transparent transparent;
}
.wm-lang-dropdown.dk-show {
  display: block;
}
.wm-lang-dropdown.hidden {
  display: none;
}
.wm-lang-list {
  max-height: 264px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}
.wm-lang-list::-webkit-scrollbar {
  width: 4px;
}
.wm-lang-list::-webkit-scrollbar-track {
  background: transparent;
}
.wm-lang-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 2px;
}

.wm-lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 14px;
  font-family: 'Nunito Sans', sans-serif;
  font-weight: 400;
  color: #374151;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
  white-space: nowrap;
}
.wm-lang-option:hover {
  background: rgba(0, 0, 0, 0.04);
}
.wm-lang-option.selected {
  background: rgba(0, 0, 0, 0.04);
  font-weight: 500;
}
.wm-lang-option svg,
.wm-lang-option img {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: cover;
}

/* Search input — matches grammar bot */
.wm-lang-search {
  width: 100%;
  padding: 8px 10px;
  border: 0.5px solid #e5e7eb;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Nunito Sans', sans-serif;
  font-weight: 400;
  outline: none;
  margin-bottom: 6px;
  background: #fff;
  color: #374151;
}
.wm-lang-search:focus {
  border-color: rgb(115, 113, 108);
  box-shadow: 0 0 0 2px rgba(156, 163, 175, 0.1);
}
.wm-lang-search::placeholder {
  color: rgb(115, 113, 108);
}

/* Dark mode */
[data-theme="dark"] .wm-lang-select,
.dark-mode .wm-lang-select {
  background: transparent;
  color: rgba(207, 211, 236, 0.7);
}
[data-theme="dark"] .wm-lang-select:hover,
.dark-mode .wm-lang-select:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #cfd3ec;
}
[data-theme="dark"] .wm-lang-dropdown,
.dark-mode .wm-lang-dropdown {
  background: #2b2c40;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .wm-lang-dropdown::after,
.dark-mode .wm-lang-dropdown::after {
  border-color: #2b2c40 transparent transparent transparent;
}
[data-theme="dark"] .wm-lang-option,
.dark-mode .wm-lang-option {
  color: #cfd3ec;
}
[data-theme="dark"] .wm-lang-option:hover,
[data-theme="dark"] .wm-lang-option.selected,
.dark-mode .wm-lang-option:hover,
.dark-mode .wm-lang-option.selected {
  background: rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .wm-lang-search,
.dark-mode .wm-lang-search {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
  color: #cfd3ec;
}
[data-theme="dark"] .wm-lang-option,
.dark-mode .wm-lang-option {
  color: #cfd3ec;
}
[data-theme="dark"] .wm-lang-option:hover,
.dark-mode .wm-lang-option:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* No focus outline on writing mode inputs — use subtle shadow instead */
.wm-textarea-wrap textarea:focus-visible,
.wm-field input:focus-visible,
.wm-field textarea:focus-visible {
  outline: none !important;
}

/* ============================================================================
 * AI WIZARD — "Beskriv kort" template generator
 * ============================================================================ */

.wm-wizard {
  margin-bottom: 4px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 12px;
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  transition: border-color 0.3s, background 0.3s;
}

.wm-wizard-prompt label {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 13px;
  font-weight: 650;
  color: var(--color-text-primary, rgb(19, 19, 19));
  letter-spacing: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.wm-wizard-prompt label::before {
  content: '✨';
  font-size: 14px;
}

.wm-wizard-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.wm-wizard-input-row input {
  flex: 1;
  font-family: 'Nunito Sans', sans-serif;
  font-size: 13px;
  padding: 10px 12px;
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  background: var(--color-card, #fff);
  color: var(--color-text-primary, rgb(19, 19, 19));
  outline: none;
  text-decoration: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.wm-wizard-input-row input:focus {
  border-color: rgba(0, 0, 0, 0.22);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.04);
}

.wm-wizard-btn {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f5e6f 0%, #3b4857 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.15s, transform 0.1s, box-shadow 0.2s;
  position: relative;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.wm-wizard-btn:hover {
  filter: brightness(1.12);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}
.wm-wizard-btn:active { transform: scale(0.95); }
.wm-wizard-btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

.wm-wizard-btn svg { transition: opacity 0.15s; }
.wm-wizard-btn.loading svg { opacity: 0; }
.wm-wizard-btn.loading .wm-wizard-btn-loader { display: block; }

/* Success checkmark — SVG shown after wizard fills fields */
.wm-wizard-btn .wm-wizard-btn-check {
  display: none;
  position: absolute;
  width: 18px;
  height: 18px;
}
.wm-wizard-btn.success svg.wm-wizard-star { opacity: 0; }
.wm-wizard-btn.success .wm-wizard-btn-check {
  display: block;
  animation: wm-pop 0.35s ease;
}
.wm-wizard-btn.success {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  box-shadow: 0 2px 8px rgba(34,197,94,0.3);
}

@keyframes wm-pop {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); opacity: 1; }
}

.wm-wizard-btn-loader {
  display: none;
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: wm-spin 0.6s linear infinite;
}

/* Subtle hint text below the wizard box */
.wm-wizard-hint {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 11px;
  color: var(--color-text-secondary, #8a92a6);
  margin-top: 6px;
  text-align: center;
  opacity: 0.7;
}

.wm-wizard-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0 8px;
}

.wm-wizard-divider::before,
.wm-wizard-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(0, 0, 0, 0.08);
}

.wm-wizard-divider span {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-secondary, #8a92a6);
  white-space: nowrap;
}

/* Success state: fade the wizard prompt, show green border */
.wm-wizard-done {
  border-color: rgba(34,197,94,0.3);
  background: rgba(34,197,94,0.03);
}
.wm-wizard-done .wm-wizard-prompt {
  opacity: 0.45;
  pointer-events: none;
  transition: opacity 0.4s;
}

/* Fields flash animation after wizard fills them */
@keyframes wm-field-flash {
  0% { background: rgba(0, 0, 0, 0.05); }
  100% { background: transparent; }
}
.wm-field-flash input,
.wm-field-flash textarea {
  animation: wm-field-flash 1.2s ease;
}

/* ============================================================================
 * GALLERY VIEW — Pre-made templates
 * ============================================================================ */

.wm-tpl-gallery-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--color-card, #fff);
  border: none;
  border-top: 0.5px solid rgba(0, 0, 0, 0.08);
  cursor: pointer;
  flex-shrink: 0;
  width: 100%;
  text-align: left;
  transition: background 0.15s;
}

.wm-tpl-gallery-btn:hover { background: var(--color-bg, #FAFAF8); }

.wm-tpl-gallery-btn svg {
  color: #4a5568;
  flex-shrink: 0;
}

.wm-tpl-gallery-btn span {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #4a5568;
}

.wm-gallery-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.08) transparent;
}

.wm-gallery-cat {
  margin-bottom: 16px;
}

.wm-gallery-cat-title {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 12px;
  font-weight: 650;
  color: var(--color-text-secondary, rgb(60, 60, 58));
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 4px 6px;
}

.wm-gallery-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  background: var(--color-card, #fff);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.wm-gallery-card:hover {
  border-color: rgba(0, 0, 0, 0.15);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.wm-gallery-card .wm-tpl-card-body {
  padding-right: 0;
  flex: 1;
  min-width: 0;
}

.wm-gallery-add-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  background: var(--color-bg, #FAFAF8);
  color: #4a5568;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  margin-left: 8px;
}

.wm-gallery-add-btn:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgb(19, 19, 19);
  color: rgb(19, 19, 19);
}

.wm-gallery-add-btn:disabled {
  cursor: default;
  border-color: #28a745;
  background: rgba(40, 167, 69, 0.08);
}

/* ============================================================================
 * PIN + DRAG — Template card enhancements
 * ============================================================================ */

.wm-tpl-drag-handle {
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  color: var(--color-text-secondary, #a1a4b5);
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.wm-tpl-card:hover .wm-tpl-drag-handle {
  opacity: 0.6;
}

.wm-tpl-drag-handle:hover {
  opacity: 1 !important;
  color: var(--color-text-primary, rgb(19, 19, 19));
}

.wm-tpl-card {
  padding-left: 22px;
}

.wm-tpl-card.wm-dragging {
  opacity: 0.4;
}

.wm-tpl-card.wm-drag-over {
  border-color: rgba(0, 0, 0, 0.25);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.wm-tpl-divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.08);
  margin: 4px 0;
}

.wm-tpl-pinned {
  border-color: rgba(240, 180, 41, 0.3);
  background: rgba(240, 180, 41, 0.03);
}

/* .wm-tpl-pin sizing is defined with .wm-tpl-edit, .wm-tpl-delete above */

.wm-tpl-pin:hover {
  background: rgba(240, 180, 41, 0.12);
  color: #f0b429;
}

.wm-tpl-pin.active {
  color: #f0b429;
}

/* ============================================================================
 * MOBILE TEMPLATE CHIPS — Horizontal scroll above form
 * ============================================================================ */

.wm-mobile-chips {
  display: none;
}

@media (max-width: 768px) {
  .wm-mobile-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 2px 0 6px;
    margin-bottom: 0;
  }

  .wm-mobile-chips::-webkit-scrollbar { display: none; }

  .wm-chip {
    font-family: 'Nunito Sans', sans-serif;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 16px;
    border: 0.5px solid rgba(0, 0, 0, 0.08);
    border-radius: 20px;
    background: var(--color-card, #fff);
    color: var(--color-text-primary, rgb(19, 19, 19));
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.15s;
    min-height: 38px;
  }

  .wm-chip:active {
    transform: scale(0.96);
    background: rgba(0, 0, 0, 0.04);
  }

  .wm-chip-all {
    background: rgba(0, 0, 0, 0.04);
    border-color: transparent;
    color: var(--color-text-secondary, rgb(60, 60, 58));
  }
}

/* ============================================================================
 * MOBILE BOTTOM SHEET — Full template list + gallery
 * ============================================================================ */

.wm-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0);
  display: flex;
  align-items: flex-end;
  transition: background 0.3s ease;
}

.wm-sheet-overlay.visible {
  background: rgba(0, 0, 0, 0.45);
}

.wm-sheet {
  width: 100%;
  max-height: 80vh;
  background: var(--color-card, #fff);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.wm-sheet-overlay.visible .wm-sheet {
  transform: translateY(0);
}

.wm-sheet-drag {
  display: flex;
  justify-content: center;
  padding: 10px 0 6px;
}

.wm-sheet-drag-pill {
  width: 36px;
  height: 4px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.15);
}

.wm-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 10px;
}

.wm-sheet-header span {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 16px;
  font-weight: 650;
  color: var(--color-text-primary, rgb(19, 19, 19));
}

.wm-sheet-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.05);
  color: var(--color-text-secondary, #6d7a8a);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wm-sheet-tabs {
  display: flex;
  margin: 0 16px;
  padding: 3px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 10px;
  gap: 2px;
}

.wm-sheet-tab {
  flex: 1;
  padding: 7px 16px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-family: 'Nunito Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary, #8a8d98);
  cursor: pointer;
  transition: all 0.2s;
}

.wm-sheet-tab.active {
  background: #fff;
  color: var(--color-text-primary, rgb(19, 19, 19));
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.wm-sheet-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 16px;
  -webkit-overflow-scrolling: touch;
}

.wm-sheet-card {
  padding: 12px;
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  background: var(--color-card, #fff);
  transition: background 0.15s;
}

.wm-sheet-card:active {
  background: rgba(0, 0, 0, 0.03);
}

.wm-sheet-add-row {
  padding: 8px 16px 16px;
  flex-shrink: 0;
}

.wm-sheet-add-row .wm-tpl-add {
  border-radius: 10px;
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  justify-content: center;
}

/* ============================================================================
 * SMART SUGGESTION TOAST — "Gem som skabelon?"
 * ============================================================================ */

.wm-suggest-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  z-index: 9999;
  background: var(--color-card, #fff);
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 420px;
  width: calc(100% - 32px);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.25s ease;
}

.wm-suggest-toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.wm-suggest-content {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.wm-suggest-content svg {
  flex-shrink: 0;
  color: rgb(19, 19, 19);
}

.wm-suggest-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.wm-suggest-text strong {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 13px;
  font-weight: 650;
  color: var(--color-text-primary, rgb(19, 19, 19));
}

.wm-suggest-text span {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 11px;
  color: var(--color-text-secondary, rgb(60, 60, 58));
}

.wm-suggest-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.wm-suggest-yes {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 12px;
  font-weight: 650;
  padding: 6px 14px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #4f5e6f 0%, #3b4857 100%);
  color: #fff;
  cursor: pointer;
  transition: filter 0.15s;
}

.wm-suggest-yes:hover { filter: brightness(1.1); }

.wm-suggest-no {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--color-text-secondary, rgb(60, 60, 58));
  cursor: pointer;
}

.wm-suggest-no:hover {
  background: rgba(0, 0, 0, 0.04);
}

@media (max-width: 768px) {
  .wm-suggest-toast {
    bottom: 80px; /* above mobile nav */
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px 16px;
  }

  .wm-suggest-actions {
    justify-content: flex-end;
  }
}

/* ============================================================================
 * DARK MODE — New components
 * ============================================================================ */

[data-theme="dark"] .wm-wizard {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .wm-wizard-prompt label {
  color: var(--color-text-primary, #cfd3ec);
}

[data-theme="dark"] .wm-wizard-input-row input {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.10);
  color: var(--color-text-primary, #cfd3ec);
}

[data-theme="dark"] .wm-wizard-input-row input:focus {
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .wm-wizard-divider::before,
[data-theme="dark"] .wm-wizard-divider::after {
  background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .wm-wizard-divider span {
  color: rgba(207, 211, 236, 0.5);
}

[data-theme="dark"] .wm-wizard-done {
  border-color: rgba(34,197,94,0.25);
  background: rgba(34,197,94,0.05);
}

[data-theme="dark"] .wm-tpl-gallery-btn {
  border-color: var(--color-border, #3b3c51);
}

[data-theme="dark"] .wm-tpl-gallery-btn:hover {
  background: var(--color-bg, #232333);
}

[data-theme="dark"] .wm-gallery-card {
  border-color: var(--color-border, #3b3c51);
}

[data-theme="dark"] .wm-gallery-add-btn {
  background: var(--color-bg, #232333);
  border-color: var(--color-border, #3b3c51);
}

[data-theme="dark"] .wm-tpl-pin {
  background: var(--color-bg, #232333);
}

[data-theme="dark"] .wm-tpl-pinned {
  border-color: rgba(240, 180, 41, 0.2);
  background: rgba(240, 180, 41, 0.05);
}

[data-theme="dark"] .wm-tpl-divider {
  background: var(--color-border, #3b3c51);
}

[data-theme="dark"] .wm-sheet {
  background: var(--color-card, #2b2c40);
}

[data-theme="dark"] .wm-sheet-drag-pill {
  background: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .wm-sheet-close {
  background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .wm-sheet-tabs {
  background: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .wm-sheet-tab.active {
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
}

[data-theme="dark"] .wm-sheet-card {
  border-color: var(--color-border, #3b3c51);
}

[data-theme="dark"] .wm-suggest-toast {
  background: var(--color-card, #2b2c40);
  border-color: var(--color-border, #3b3c51);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .wm-chip {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.10);
  color: var(--color-text-primary, #cfd3ec);
}

[data-theme="dark"] .wm-chip-all {
  background: rgba(255, 255, 255, 0.03);
  border-color: transparent;
}
