/* === Text to Handwriting Converter — WP Plugin (scoped) === */

/* Force full-width: break out of WP content container */
.tthc-wrapper {
  --bg: #0b1220;
  --surface: #161f30;
  --surface2: #1e293b;
  --border: rgba(255, 255, 255, .15);
  --text: #ffffff;
  --muted: #cbd5e1;
  --muted2: #94a3b8;
  --shadow: 0 18px 50px rgba(0, 0, 0, .50);
  --shadow2: 0 10px 24px rgba(0, 0, 0, .35);
  --brand: #683bf9;
  --brand2: #18c9ff;
  --focus: rgba(124, 92, 255, .55);
  --radius: 16px;
  --radius2: 12px;
  --max: 100%;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";

  /* Break out of WP content container — full width centered */
  width: 100%;
  max-width: 100%;
  margin: 0;
  position: relative;
  overflow: visible;

  font-family: var(--sans);
  background:
    radial-gradient(1200px 800px at 10% 0%, rgba(124, 92, 255, .22), transparent 55%),
    radial-gradient(900px 700px at 95% 15%, rgba(24, 201, 255, .18), transparent 55%),
    var(--bg);
  color: var(--text);
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

.tthc-wrapper * {
  box-sizing: border-box
}

.tthc-wrapper a {
  color: inherit;
  text-decoration: none
}

.tthc-wrapper a:hover {
  text-decoration: underline
}

.tthc-container {
  max-width: 100%;
  margin: 0 auto;
  padding: 0 15px;
}



.tthc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-weight: 700;
  font-size: 14px;
  background: var(--surface);
  color: var(--text) !important;
  box-shadow: var(--shadow2);
  cursor: pointer;
  user-select: none;
  font-family: inherit;
}

.tthc-btn:hover {
  filter: brightness(1.06)
}

.tthc-btn:active {
  transform: translateY(1px)
}

.tthc-btn:focus {
  outline: 2px solid var(--focus);
  outline-offset: 2px
}

.tthc-btn-primary {
  background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand2) 70%, var(--brand)));
  border-color: transparent;
}

.tthc-btn-ghost {
  background: transparent;
  box-shadow: none;
}

.tthc-btn-sm {
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 10px
}

.tthc-btn-icon {
  font-family: var(--mono);
  opacity: .9
}

.tthc-btn-text {
  display: none
}

.tthc-muted {
  color: var(--muted)
}

.tthc-app-main {
  padding: 18px 0 26px
}

.tthc-tool {
  padding: 0
}

.tthc-app-shell {
  border-radius: calc(var(--radius) + 2px);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  box-shadow: var(--shadow);
  overflow: visible;
  /* CLS Fix: reserve minimum height so the shell never collapses to 0 */
  min-height: 820px;
  contain: layout style;
}


.tthc-app-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0
}

.tthc-panel {
  padding: 12px
}

.tthc-panel-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow2);
  position: relative
}

.tthc-preview-card {
  min-height: 600px;
  display: flex;
  flex-direction: column;
  contain: layout style;
}

.tthc-panel+.tthc-panel {
  border-top: 1px solid var(--border)
}

.tthc-panel-header {
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface2) 70%, transparent);
  flex-wrap: wrap;
}

.tthc-panel-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text) !important;
}

.tthc-panel-hint {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px
}

.tthc-panel-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap
}

.tthc-panel-body {
  padding: 14px;
  flex: 1;
  overflow: visible;
}

.tthc-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px
}

.tthc-field-label {
  font-size: 13px;
  color: var(--text) !important;
  font-weight: 700;
  opacity: 0.95;
}

.tthc-field-help {
  font-size: 12px;
  color: var(--muted2)
}

.tthc-input,
.tthc-select,
.tthc-textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border) !important;
  background: var(--surface2) !important;
  color: var(--text) !important;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
}

.tthc-input:focus,
.tthc-select:focus,
.tthc-textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--focus);
}

.tthc-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%2394a3b8%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 14px center !important;
  background-size: 10px auto !important;
  padding-right: 32px !important;
}

.tthc-select option {
  background: #1e293b !important;
  color: #ffffff !important;
  padding: 8px !important;
}

.tthc-select optgroup {
  background: #161f30 !important;
  color: var(--brand2) !important;
  font-weight: 800 !important;
  font-size: 12px !important;
  text-transform: uppercase !important;
  letter-spacing: 0.05em !important;
  padding: 10px 4px !important;
}

.tthc-editor-container {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tthc-toolbar {
  display: flex;
  align-items: center;
  padding: 6px;
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  border-bottom: 1px solid var(--border);
  gap: 4px;
  flex-wrap: wrap;
}

.tthc-toolbar-group {
  display: flex;
  gap: 2px;
}

.tthc-toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.tthc-toolbar-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: var(--text);
  font-family: "Inter", sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  padding: 0;
}

.tthc-toolbar-btn:hover {
  background: var(--surface);
  border-color: var(--brand2);
  color: var(--brand2);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.tthc-toolbar-btn:active {
  transform: translateY(0);
}

.tthc-toolbar-btn.active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 12px rgba(178, 255, 46, 0.2);
}

.tthc-bold {
  font-weight: 800;
}

.tthc-italic {
  font-style: italic;
}

.tthc-underline {
  text-decoration: underline;
}

.tthc-strike {
  text-decoration: line-through;
}

.tthc-textarea {
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  /* CLS Fix: lock height to match rows=12 so it doesn't reflow */
  min-height: 280px;
  height: 280px;
  padding: 16px;
  resize: vertical;
}

/* Robust Range Slider with Fill Support */
.tthc-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: var(--surface2);
  border-radius: 10px;
  margin: 15px 0;
  cursor: pointer;
  border: 1px solid var(--border);
  outline: none;
  display: block;
}

.tthc-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: #ffffff;
  border: 2px solid var(--brand);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

.tthc-range::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  background: var(--brand2);
}

.tthc-range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: #ffffff;
  border: 2px solid var(--brand);
  border-radius: 50%;
  cursor: pointer;
}

/* Premium Color Picker */
.tthc-input-color {
  -webkit-appearance: none;
  appearance: none;
  height: 48px !important;
  padding: 5px !important;
  background: var(--surface2) !important;
  border: 1px solid var(--border) !important;
  border-radius: 12px !important;
  cursor: pointer;
  box-shadow: var(--shadow2);
}

.tthc-input-color::-webkit-color-swatch-wrapper {
  padding: 0;
}

.tthc-input-color::-webkit-color-swatch {
  border: none;
  border-radius: 8px;
}

.tthc-grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.tthc-export-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap
}

.tthc-list-btn-wrapper {
  display: flex;
  align-items: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: all 0.2s ease;
}

.tthc-list-btn-wrapper:hover {
  border-color: var(--brand2);
}

.tthc-list-btn-wrapper .tthc-toolbar-btn {
  border: none;
  background: transparent;
  width: 34px;
}

.tthc-dropdown-trigger {
  width: 16px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--muted2);
  cursor: pointer;
  border-left: 1px solid var(--border);
  transition: all 0.2s ease;
  user-select: none;
}

.tthc-dropdown-trigger:hover {
  background: var(--surface);
  color: var(--brand2);
}

/* Dropdown Base */
.tthc-dropdown {
  position: relative;
  display: inline-block;
}

.tthc-dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  min-width: 160px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: none;
  flex-direction: column;
  padding: 6px;
  z-index: 100;
  overflow: hidden;
  animation: tthc-fade-in 0.2s ease-out;
}

.tthc-dropdown-menu.active {
  display: flex !important;
}

.tthc-toolbar-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.tthc-panel-actions {
  position: relative;
  z-index: 110;
}

/* Ensure dropdown menu is never clipped by any parent */
.tthc-panel-header,
.tthc-panel-card,
.tthc-preview-card,
.tthc-app-shell,
.tthc-panel {
  overflow: visible !important;
}

.tthc-dropdown-menu {
  z-index: 9999 !important;
}

.tthc-dropdown-item {
  background: transparent;
  border: none;
  padding: 10px 14px;
  text-align: left;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s ease;
}

.tthc-dropdown-item:hover {
  background: var(--brand);
  color: #fff;
}

/* Picker Specifics */
.tthc-picker-dropdown {
  min-width: 210px;
  padding: 12px;
}

.tthc-picker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.tthc-picker-item {
  aspect-ratio: 1.2 / 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  transition: all 0.2s ease;
  padding: 6px;
}

.tthc-picker-item:hover {
  border-color: var(--brand2);
  background: rgba(255, 255, 255, 0.05);
  transform: scale(1.05);
}

@keyframes tthc-fade-in {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tthc-callout {
  margin-top: 12px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--surface2) 62%, transparent);
  color: var(--muted);
  font-size: 13px;
}

.tthc-preview-card .tthc-panel-body {
  padding: 12px
}

.tthc-preview-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px
}

.tthc-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
}

.tthc-pages {
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
  padding: 16px 0;
  overflow-y: visible;
  /* CLS Fix: reserve space for the A4 page preview */
  min-height: 580px;
}

.tthc-page {
  border: 1px solid var(--border);
  border-radius: 2px;
  background: color-mix(in srgb, var(--bg) 18%, white);
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0, 0, 0, 0.12);
  margin: 0 auto;
  width: 100%;
  max-width: 100%;
}

.tthc-page canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* Pagination controls */
.tthc-pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (min-width: 780px) {
  .tthc-btn-text {
    display: inline
  }

  .tthc-grid-2 {
    grid-template-columns: 1fr 1fr
  }
}

@media (min-width: 1020px) {
  .tthc-app-grid {
    grid-template-columns: 1.5fr 2.5fr
  }

  .tthc-panel+.tthc-panel {
    border-top: none;
    border-left: 1px solid var(--border)
  }

  /* CLS Fix: desktop needs more height reserved */
  .tthc-app-shell {
    min-height: 960px;
  }
}

/* === Style Sections (Boxes) === */
.tthc-style-section {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
}

.tthc-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brand2);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tthc-section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.tthc-section-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px 20px;
}

@media (min-width: 768px) {
  .tthc-section-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1100px) {
  .tthc-section-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* === Skeleton Loading and CLS Fix === */
.tthc-skeleton-page {
  aspect-ratio: 595 / 842;
  width: 100%;
  max-width: 100%;
  background: #ffffff !important;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0, 0, 0, 0.12);
  padding: 40px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: tthc-shimmer 1.5s infinite ease-in-out;
  border: 1px solid var(--border);
  border-radius: 2px;
  /* Ensure skeleton occupies same space as rendered canvas page */
  contain: layout size style;
}

.tthc-skeleton-line {
  height: 14px;
  background: #e2e8f0;
  border-radius: 4px;
  opacity: 0.6;
}

@keyframes tthc-shimmer {
  0% {
    opacity: 0.6;
  }
  50% {
    opacity: 0.85;
  }
  100% {
    opacity: 0.6;
  }
}