*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
    html { font-size: 16px; direction: rtl; }
    body {
      font-family: 'Vazir', Tahoma, Arial, sans-serif;
      min-height: 100vh;
      color: var(--text);
      line-height: 1.7;
      padding: 16px;
    }
    .app {
      max-width: 960px;
      margin: 0 auto;
      display: flex;
      flex-direction: column;
      gap: 20px;
    }
    header { text-align: center; padding: 24px 0 8px; }
    header h1 {
      font-size: 1.75rem;
      font-weight: 700;
      margin-bottom: 8px;
      color: var(--text);
    }
    header p { color: var(--text-muted); font-size: 0.95rem; }
    .card {
      background: var(--panel);
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      border: 1px solid var(--panel-border);
      border-radius: var(--radius);
      padding: 24px;
      box-shadow: var(--shadow-panel);
      color: var(--text-on-panel);
    }
    html[data-theme="glass"] .card {
      backdrop-filter: blur(var(--glass-blur));
      -webkit-backdrop-filter: blur(var(--glass-blur));
    }
    .mode-badge {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 6px 14px;
      border-radius: var(--radius);
      font-size: 0.85rem;
      background: var(--accent-soft);
      border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
      color: var(--accent);
    }
    .mode-badge.offline {
      background: rgba(251,191,36,0.15);
      border-color: rgba(251,191,36,0.3);
      color: #fbbf24;
    }
    .mode-badge .dot {
      width: 8px; height: 8px;
      border-radius: 50%;
      background: currentColor;
      animation: pulse 2s infinite;
    }
    @keyframes pulse {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.4; }
    }
    .dropzone {
      border: 2px dashed color-mix(in srgb, var(--accent) 40%, transparent);
      border-radius: var(--radius);
      padding: 40px 20px;
      text-align: center;
      cursor: pointer;
      transition: all 0.3s ease;
      position: relative;
      overflow: hidden;
    }
    .dropzone::before {
      content: '';
      position: absolute;
      inset: 0;
      background: radial-gradient(circle at center, var(--accent-glow) 0%, transparent 70%);
      opacity: 0;
      transition: opacity 0.3s;
    }
    .dropzone:hover, .dropzone.dragover {
      border-color: var(--accent);
      transform: translateY(-2px);
      box-shadow: 0 4px 24px var(--accent-glow);
    }
    .dropzone:hover::before, .dropzone.dragover::before { opacity: 1; }
    .dropzone svg { width: 56px; height: 56px; margin-bottom: 12px; opacity: 0.85; }
    .dropzone h3 { font-size: 1.1rem; font-weight: normal; margin-bottom: 6px; }
    .dropzone p { color: var(--text-muted); font-size: 0.88rem; }
    .dropzone .formats { margin-top: 10px; font-size: 0.8rem; color: var(--text-muted); opacity: 0.8; }
    .file-info {
      display: none;
      align-items: center;
      gap: 12px;
      padding: 12px 16px;
      background: rgba(0,0,0,0.2);
      border-radius: 12px;
      margin-top: 16px;
    }
    .file-info.visible { display: flex; }
    .file-info .name { flex: 1; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .file-info .size { color: var(--text-muted); font-size: 0.82rem; }
    .btn {
      font-family: 'Vazir', Tahoma, sans-serif;
    }
    .btn-primary {
      width: 100%;
      margin-top: 16px;
    }
    .btn-primary:hover:not(:disabled) { transform: translateY(-1px); }
    .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
    .btn:focus-visible, .dropzone:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 2px;
    }
    .progress-panel { display: none; }
    .progress-panel.visible { display: block; }
    .progress-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 16px;
    }
    .progress-header h3 { font-size: 1rem; font-weight: normal; }
    .progress-pct { font-size: 1.25rem; color: var(--accent); }
    .progress-track {
      height: 10px;
      background: rgba(0,0,0,0.3);
      border-radius: var(--radius);
      overflow: hidden;
      margin-bottom: 20px;
      position: relative;
    }
    .progress-fill {
      height: 100%;
      width: 0%;
      background: linear-gradient(90deg, var(--accent2), var(--accent));
      border-radius: var(--radius);
      transition: width 0.4s ease;
      position: relative;
    }
    .progress-fill::after {
      content: '';
      position: absolute;
      inset: 0;
      background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
      animation: shimmer 1.5s infinite;
    }
    @keyframes shimmer {
      0% { transform: translateX(-100%); }
      100% { transform: translateX(100%); }
    }
    .stages { display: flex; flex-direction: column; gap: 10px; }
    .stage {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 10px 14px;
      border-radius: 10px;
      background: rgba(0,0,0,0.15);
      font-size: 0.88rem;
      color: var(--text-muted);
      transition: all 0.3s;
    }
    .stage.active { background: var(--accent-soft); color: var(--text); }
    .stage.done { color: var(--success); }
    .stage-icon {
      width: 24px; height: 24px;
      display: flex; align-items: center; justify-content: center;
      flex-shrink: 0;
    }
    .spinner {
      width: 18px; height: 18px;
      border: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
      border-top-color: var(--accent);
      border-radius: 50%;
      animation: spin 0.8s linear infinite;
    }
    @keyframes spin { to { transform: rotate(360deg); } }
    .check { color: var(--success); font-size: 1.1rem; }
    .preview-section { display: none; }
    .preview-section.visible { display: block; }
    .preview-section h3 { font-size: 1rem; font-weight: normal; margin-bottom: 12px; }
    .preview-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      margin-bottom: 12px;
    }
    .preview-header h3 { margin-bottom: 0; flex: 1; min-width: 0; }
    .preview-actions {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 6px;
      flex-shrink: 0;
    }
    .preview-actions .btn-secondary.btn-sm {
      min-height: 34px;
      padding: 0.35em 0.75em;
      font-size: 0.78rem;
      border-radius: var(--radius);
      white-space: nowrap;
    }
    .btn-copy {
      font-family: 'Vazir', Tahoma, sans-serif;
      display: inline-flex;
      align-items: center;
      gap: 0.4em;
      min-height: 34px;
      padding: 0.45em 0.95em;
      background: color-mix(in srgb, var(--accent) 12%, var(--btn-bg));
      border: 1px solid color-mix(in srgb, var(--accent) 38%, transparent);
      color: var(--accent);
      border-radius: var(--radius);
      font-size: 0.82rem;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.15s ease;
      white-space: nowrap;
    }
    .btn-copy:hover {
      background: color-mix(in srgb, var(--accent) 20%, var(--btn-bg));
      box-shadow: 0 2px 10px var(--accent-glow);
    }
    .btn-copy:active { transform: scale(0.97); }
    .btn-copy:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
    .btn-copy.copied { color: var(--success); border-color: rgba(74,222,128,0.4); }
    textarea.preview {
      width: 100%;
      min-height: 200px;
      background: rgba(0,0,0,0.25);
      border: 1px solid var(--card-border);
      border-radius: 12px;
      padding: 16px;
      color: var(--text);
      font-family: 'Vazir', Tahoma, sans-serif;
      font-size: 1rem;
      line-height: 1.9;
      resize: vertical;
      direction: rtl;
      text-align: right;
    }
    textarea.preview:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
    .export-btns {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 10px;
      margin-top: 16px;
    }
    @media (max-width: 480px) {
      .export-btns { grid-template-columns: 1fr; }
      header h1 { font-size: 1.4rem; }
      .card { padding: 18px; }
    }
    .recording-settings { padding: 0; overflow: hidden; }
    .recording-settings-toggle {
      width: 100%;
      padding: 16px 20px;
      border: none;
      background: transparent;
      color: var(--text);
      font-family: 'Vazir', Tahoma, sans-serif;
      font-size: 1rem;
      font-weight: 500;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 10px;
      text-align: right;
      transition: color 0.2s, background 0.2s;
    }
    .recording-settings-toggle:hover {
      color: var(--accent);
      background: var(--accent-soft);
    }
    .recording-settings-toggle[aria-expanded="true"] {
      color: var(--accent);
      border-bottom: 1px solid var(--card-border);
    }
    .recording-settings-toggle:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: -2px;
    }
    .recording-settings-icon {
      width: 24px;
      height: 24px;
      flex-shrink: 0;
    }
    .recording-settings-title {
      flex: 1;
      font-size: 1rem;
      font-weight: 500;
    }
    .recording-settings-chevron {
      width: 20px;
      height: 20px;
      flex-shrink: 0;
      transition: transform 0.25s ease;
    }
    .recording-settings-toggle[aria-expanded="true"] .recording-settings-chevron {
      transform: rotate(180deg);
    }
    .recording-settings-body {
      display: none;
      padding: 4px 20px 20px;
    }
    .recording-settings-body.open { display: block; }
    .recording-settings .note:first-of-type { margin-top: 0; }
    .setting-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 10px 0;
      font-size: 0.9rem;
    }
    .toggle {
      position: relative;
      width: 48px; height: 26px;
      cursor: pointer;
    }
    .toggle input { opacity: 0; width: 0; height: 0; }
    .toggle .slider {
      position: absolute; inset: 0;
      background: rgba(255,255,255,0.15);
      border-radius: var(--radius);
      transition: 0.3s;
    }
    .toggle .slider::before {
      content: '';
      position: absolute;
      width: 20px; height: 20px;
      right: 3px; bottom: 3px;
      background: white;
      border-radius: 50%;
      transition: 0.3s;
    }
    .toggle input:checked + .slider { background: var(--accent2); }
    .toggle input:checked + .slider::before { transform: translateX(-22px); }

    .toast-container {
      position: fixed;
      bottom: calc(var(--page-foot-clearance, 56px) + 8px);
      left: 50%;
      transform: translateX(-50%);
      z-index: 9999;
      display: flex;
      flex-direction: column;
      gap: 8px;
      width: min(90vw, 400px);
    }
    .toast {
      padding: 14px 18px;
      border-radius: 12px;
      font-size: 0.9rem;
      animation: slideUp 0.3s ease;
      box-shadow: var(--shadow);
    }
    .toast.info { background: #1e3a5f; border: 1px solid #3b82f6; }
    .toast.warn { background: #422006; border: 1px solid #f59e0b; }
    .toast.error { background: #450a0a; border: 1px solid var(--danger); }
    .toast.success { background: #052e16; border: 1px solid var(--success); }
    @keyframes slideUp {
      from { opacity: 0; transform: translateY(20px); }
      to { opacity: 1; transform: translateY(0); }
    }
    .hidden { display: none !important; }
    #fileInput { display: none; }
    .cancel-row { margin-top: 16px; text-align: center; }
    .note { font-size: 0.82rem; color: var(--text-muted); margin-top: 12px; line-height: 1.6; }
    .file-banner {
      background: rgba(59,130,246,0.15);
      border: 1px solid rgba(59,130,246,0.35);
      border-radius: 12px;
      padding: 12px 16px;
      font-size: 0.85rem;
      color: #93c5fd;
      line-height: 1.6;
    }
    .file-banner.error {
      background: rgba(248,113,113,0.12);
      border-color: rgba(248,113,113,0.4);
      color: #fca5a5;
    }
    .btn.is-loading { opacity: 0.65; pointer-events: none; }
    .input-tabs {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
      margin-bottom: 18px;
    }
    .input-tab {
      font-family: 'Vazir', Tahoma, sans-serif;
      background: rgba(0,0,0,0.2);
      border: 1px solid var(--card-border);
      color: var(--text-muted);
      border-radius: 12px;
      padding: 10px 12px;
      cursor: pointer;
      transition: all 0.25s ease;
      font-size: 0.9rem;
    }
    .input-tab:focus-visible, .live-mic-btn:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 2px;
    }
    .input-tab.active {
      background: var(--accent-soft);
      border-color: color-mix(in srgb, var(--accent) 45%, transparent);
      color: var(--accent);
    }
    .input-panel.hidden { display: none; }
    .live-mic-area {
      text-align: center;
      padding: 28px 16px 12px;
    }
    .live-mic-wrap {
      position: relative;
      width: 120px;
      height: 120px;
      margin: 0 auto 20px;
    }
    .live-mic-ring {
      position: absolute;
      inset: 0;
      border-radius: 50%;
      border: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
      opacity: 0;
      transform: scale(0.9);
    }
    .live-mic-wrap.recording .live-mic-ring {
      opacity: 1;
      animation: micPulse 1.6s ease-out infinite;
    }
    .live-mic-wrap.recording .live-mic-ring:nth-child(2) { animation-delay: 0.5s; }
    @keyframes micPulse {
      0% { transform: scale(0.85); opacity: 0.7; }
      100% { transform: scale(1.35); opacity: 0; }
    }
    .live-mic-btn {
      position: relative;
      z-index: 1;
      width: 120px;
      height: 120px;
      border-radius: 50%;
      border: none;
      cursor: pointer;
      background: linear-gradient(135deg, var(--accent2), var(--accent));
      color: #042f2e;
      box-shadow: 0 8px 28px var(--accent-glow);
      transition: all 0.25s ease;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .live-mic-btn:hover { transform: scale(1.04); }
    .live-mic-btn.recording {
      background: linear-gradient(135deg, #ef4444, #f87171);
      box-shadow: 0 8px 28px rgba(248,113,113,0.4);
      color: #fff;
    }
    .live-mic-btn svg { width: 44px; height: 44px; }
    .live-status {
      font-size: 1rem;
      margin-bottom: 6px;
      min-height: 1.6em;
    }
    .live-status.listening { color: #f87171; }
    .live-status.ready { color: var(--accent); }
    .live-hint {
      font-size: 0.82rem;
      color: var(--text-muted);
      line-height: 1.6;
    }
    .live-notice {
      margin-top: 14px;
      padding: 10px 12px;
      border-radius: 10px;
      font-size: 0.8rem;
      line-height: 1.65;
      text-align: right;
    }
    .live-notice.warn {
      background: rgba(251,191,36,0.12);
      border: 1px solid rgba(251,191,36,0.3);
      color: #fcd34d;
    }
    .live-notice.info {
      background: rgba(59,130,246,0.12);
      border: 1px solid rgba(59,130,246,0.28);
      color: #93c5fd;
    }
    .live-notice.error {
      background: rgba(248,113,113,0.12);
      border: 1px solid rgba(248,113,113,0.3);
      color: #fca5a5;
    }
    .live-notice.hidden { display: none; }
    .live-mic-btn:disabled {
      opacity: 0.45;
      cursor: not-allowed;
      transform: none;
    }
    #pdfRenderRoot {
      position: fixed;
      left: -9999px;
      top: 0;
      width: 794px;
      padding: 48px;
      font-family: 'Vazir', Tahoma, sans-serif;
      font-size: 18px;
      line-height: 2;
      color: #111;
      white-space: pre-wrap;
      word-wrap: break-word;
      text-align: right;
      direction: rtl;
      background: #fff;
    }
    .live-interim {
      margin-top: 16px;
      padding: 12px 14px;
      border-radius: 12px;
      background: rgba(0,0,0,0.22);
      border: 1px dashed color-mix(in srgb, var(--accent) 35%, transparent);
      min-height: 48px;
      font-size: 0.92rem;
      color: var(--text-muted);
      text-align: right;
      direction: rtl;
      display: none;
    }
    .live-interim.visible { display: block; }
    .live-interim .interim-text { color: var(--text); opacity: 0.75; font-style: italic; }
    .preview.live-active { border-color: rgba(248,113,113,0.45); box-shadow: 0 0 0 3px rgba(248,113,113,0.15); }
