*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

@font-face {
  font-family: "Twemoji Country Flags";
  unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E0063, U+E0065-E0067, U+E006C, U+E006E, U+E0073-E0074, U+E0077, U+E007F;
  src: url("https://cdn.jsdelivr.net/npm/country-flag-emoji-polyfill@2.0/dist/TwemojiCountryFlags.woff2") format("woff2");
}

    :root {
      --bg: #0b0c0e;
      --surface: #111318;
      --border: #1f2229;
      --border-bright: #2e3340;
      --accent: #e8ff47;
      --accent-dim: rgba(232,255,71,0.12);
      --accent-glow: rgba(232,255,71,0.25);
      --text: #e4e6ed;
      --text-muted: #5a6072;
      --text-dim: #8890a4;
      --danger: #ff4d4d;
      --success: #47ffa3;
      --mono: 'Space Mono', monospace;
      --sans: 'Syne', sans-serif;
      --radius: 4px;
    }

    html, body {
      height: 100%;
      background: var(--bg);
      color: var(--text);
      font-family: var(--sans);
      -webkit-font-smoothing: antialiased;
    }

    body {
      display: flex;
      flex-direction: column;
      min-height: 100vh;
      padding: 0 24px 48px;
    }

    /* ── Noise overlay ── */
    body::before {
      content: '';
      position: fixed;
      inset: 0;
      background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
      pointer-events: none;
      z-index: 0;
    }

    /* ── Header ── */
    header {
      position: relative;
      z-index: 1;
      display: flex;
      align-items: center;
      justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
      padding: 28px 0 32px;
      border-bottom: 1px solid var(--border);
    }

    .logo {
      display: flex;
      align-items: baseline;
      gap: 10px;
  flex-wrap: wrap;
    }

    .logo-mark {
      font-family: var(--sans);
      font-size: 22px;
      font-weight: 800;
      letter-spacing: -0.5px;
      color: var(--text);
    }

    .logo-mark span {
      color: var(--accent);
    }

    .logo-sub {
      font-family: var(--mono);
      font-size: 11px;
      color: var(--text-muted);
      letter-spacing: 0.08em;
      text-transform: uppercase;
    }

    .status-badge {
      font-family: var(--mono);
      font-size: 11px;
      padding: 5px 10px;
      border: 1px solid var(--border-bright);
      border-radius: 2px;
      color: var(--text-muted);
      letter-spacing: 0.06em;
      text-transform: uppercase;
      transition: all 0.3s;
    }
    .status-badge.running {
      color: var(--accent);
      border-color: var(--accent);
      background: var(--accent-dim);
      animation: pulse-badge 1.5s ease-in-out infinite;
    }
    .status-badge.done {
      color: var(--success);
      border-color: var(--success);
      background: rgba(71,255,163,0.1);
    }
    .status-badge.error {
      color: var(--danger);
      border-color: var(--danger);
      background: rgba(255,77,77,0.1);
    }

    @keyframes pulse-badge {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.5; }
    }

    /* ── Main layout ── */
    main {
      position: relative;
      z-index: 1;
      display: grid;
      grid-template-columns: 340px 1fr;
      gap: 24px;
      margin-top: 40px;
      flex: 1;
    }

    /* ── Left panel ── */
    .panel-left { display: flex; flex-direction: column; gap: 20px; }

    /* ── Drop Zone ── */
    .drop-zone {
      position: relative;
      border: 1.5px dashed var(--border-bright);
      border-radius: var(--radius);
      padding: 40px 24px;
      text-align: center;
      cursor: pointer;
      transition: border-color 0.2s, background 0.2s;
      background: var(--surface);
      overflow: hidden;
    }

    .drop-zone::before {
      content: '';
      position: absolute;
      inset: 0;
      background: radial-gradient(ellipse at 50% 0%, var(--accent-glow) 0%, transparent 65%);
      opacity: 0;
      transition: opacity 0.3s;
    }

    .drop-zone:hover::before,
    .drop-zone.drag-over::before { opacity: 1; }
    .drop-zone:hover,
    .drop-zone.drag-over {
      border-color: var(--accent);
      border-style: solid;
    }

    .drop-zone.drag-over { background: #131508; }

    .drop-icon {
      width: 48px;
      height: 48px;
      margin: 0 auto 16px;
      border: 1.5px solid var(--border-bright);
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-muted);
      transition: border-color 0.2s, color 0.2s;
    }

    .drop-zone:hover .drop-icon,
    .drop-zone.drag-over .drop-icon {
      border-color: var(--accent);
      color: var(--accent);
    }

    .drop-title {
      font-size: 14px;
      font-weight: 600;
      color: var(--text);
      margin-bottom: 6px;
    }

    .drop-sub {
      font-family: var(--mono);
      font-size: 11px;
      color: var(--text-muted);
      line-height: 1.6;
    }

    #file-input { display: none; }

    /* ── Language Select ── */
    .language-select-wrap {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 12px;
      background: var(--surface);
      border: 1px solid var(--border-bright);
      border-radius: var(--radius);
      padding: 12px 16px;
    }
    .language-select-wrap label {
      font-family: var(--mono);
      font-size: 11px;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.06em;
    }
    #language-select,
    #format-select,
    #model-select {
      flex: 1;
      background: var(--bg);
      color: var(--text);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 6px 8px;
      font-family: "Twemoji Country Flags", var(--sans), "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Android Emoji", sans-serif;
      font-size: 13px;
      outline: none;
      cursor: pointer;
    }
    #language-select:focus,
    #format-select:focus,
    #model-select:focus {
      border-color: var(--accent);
    }

    /* ── Custom Select for Emojis on Windows ── */
    .custom-select-wrapper {
      position: relative;
      user-select: none;
    }
    .custom-select-wrapper.flex-1 {
      flex: 1;
    }
    .custom-select-wrapper.disabled {
      opacity: 0.5;
      pointer-events: none;
    }
    .custom-select-trigger {
      background: var(--bg);
      color: var(--text);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 6px 8px;
      font-family: "Twemoji Country Flags", var(--sans), "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Android Emoji", sans-serif;
      font-size: 13px;
      cursor: pointer;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 12px;
    }
    .custom-select-wrapper.header-select .custom-select-trigger {
      padding: 4px 8px;
      font-size: 12px;
    }
    .custom-select-options {
      position: absolute;
      display: none;
      top: calc(100% + 4px);
      left: 0;
      right: 0;
      background: var(--bg);
      border: 1px solid var(--border-bright);
      border-radius: var(--radius);
      z-index: 99;
      max-height: 250px;
      overflow-y: auto;
      box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    }
    .custom-select-options.open { display: block; }
    .custom-select-options::-webkit-scrollbar { width: 6px; }
    .custom-select-options::-webkit-scrollbar-track { background: var(--bg); border-radius: var(--radius); }
    .custom-select-options::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: var(--radius); }
    .custom-select-options::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
    .custom-option { padding: 8px 12px; cursor: pointer; font-family: "Twemoji Country Flags", var(--sans), "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Android Emoji", sans-serif; font-size: 13px; color: var(--text); border-bottom: 1px solid var(--border); }
    .custom-select-wrapper.header-select .custom-option { font-size: 12px; padding: 6px 10px; }
    .custom-option:last-child { border-bottom: none; }
    .custom-option:hover { background: var(--surface); color: var(--accent); }
    .custom-option.selected { background: var(--accent-dim); color: var(--accent); }

    /* ── File info card ── */
    .file-card {
      display: none;
      background: var(--surface);
      border: 1px solid var(--border-bright);
      border-radius: var(--radius);
      padding: 16px;
      gap: 12px;
      align-items: center;
      transition: background 0.2s, border-color 0.2s;
    }
    .file-card.needs-credits {
      background: rgba(255, 77, 77, 0.05);
      border-color: rgba(255, 77, 77, 0.3);
    }
    .file-card.visible { display: flex; }

    .file-icon {
      width: 36px;
      height: 36px;
      background: var(--accent-dim);
      border-radius: var(--radius);
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--accent);
      flex-shrink: 0;
    }

    .file-info { flex: 1; min-width: 0; }
    .file-name {
      font-size: 13px;
      font-weight: 600;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      color: var(--text);
    }
    .file-size {
      font-family: var(--mono);
      font-size: 11px;
      color: var(--text-muted);
      margin-top: 2px;
    }

    .file-remove {
      background: none;
      border: none;
      color: var(--text-muted);
      cursor: pointer;
      padding: 4px;
      border-radius: var(--radius);
      transition: color 0.2s;
      line-height: 0;
    }
    .file-remove:hover { color: var(--danger); }

    /* ── Progress ── */
    .progress-wrap {
      display: none;
      flex-direction: column;
      gap: 8px;
    }
    .progress-wrap.visible { display: flex; }

    .progress-label {
      display: flex;
      justify-content: space-between;
      font-family: var(--mono);
      font-size: 11px;
      color: var(--text-muted);
    }

    .progress-bar-track {
      height: 3px;
      background: var(--border);
      border-radius: 99px;
      overflow: hidden;
    }
    .progress-bar-fill {
      height: 100%;
      background: var(--accent);
      border-radius: 99px;
      transition: width 0.2s;
      width: 0%;
      box-shadow: 0 0 8px var(--accent-glow);
    }

    /* ── Transcribe button ── */
    .btn-transcribe {
      width: 100%;
      padding: 14px;
      background: var(--accent);
      color: #0b0c0e;
      border: none;
      border-radius: var(--radius);
      font-family: var(--sans);
      font-size: 14px;
      font-weight: 800;
      letter-spacing: 0.04em;
      cursor: pointer;
      transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
      text-transform: uppercase;
    }
    .btn-transcribe:hover:not(:disabled) {
      background: #f5ff7a;
      box-shadow: 0 0 20px var(--accent-glow);
    }
    .btn-transcribe:active:not(:disabled) { transform: scale(0.99); }
    .btn-transcribe:disabled {
      background: var(--border-bright);
      color: var(--text-muted);
      cursor: not-allowed;
    }

    /* ── Info block ── */
    .info-block {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 16px;
      font-family: var(--mono);
      font-size: 11px;
      color: var(--text-muted);
      line-height: 1.8;
    }
    .info-block strong { color: var(--text-dim); font-weight: 400; }

    /* ── Tabs ── */
    .tab-nav {
      display: flex;
      gap: 8px;
      margin-bottom: 4px;
      flex-wrap: wrap;
    }
    .tab-btn {
      font-family: var(--mono);
      font-size: 12px;
      padding: 8px 16px;
      background: transparent;
      border: 1px solid transparent;
      border-radius: var(--radius);
      color: var(--text-muted);
      cursor: pointer;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      transition: all 0.2s;
    }
    .tab-btn:hover {
      color: var(--text);
      background: rgba(255, 255, 255, 0.05);
    }
    .tab-btn.active {
      color: var(--accent);
      background: var(--accent-dim);
      border: 1px solid var(--accent);
    }
    .tab-content {
      display: none;
      flex-direction: column;
      gap: 16px;
      flex: 1;
    }
    .tab-content.active {
      display: flex;
    }
    .home-hero {
      background: var(--surface);
      border: 1px solid var(--border-bright);
      border-radius: var(--radius);
      padding: 32px;
      line-height: 1.8;
      color: var(--text-muted);
    }
    .home-hero h2 {
      color: var(--text);
      font-family: var(--sans);
      font-size: 20px;
      margin-bottom: 16px;
    }
    .home-hero strong { color: var(--text-dim); }
    .home-hero ul { margin-left: 20px; margin-top: 8px; }

    /* ── Right panel: output ── */
    .panel-right {
      display: flex;
      flex-direction: column;
      gap: 16px;
    }

    .output-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    .output-label {
      font-family: var(--mono);
      font-size: 11px;
      color: var(--text-muted);
      letter-spacing: 0.08em;
      text-transform: uppercase;
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .dot {
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: var(--text-muted);
    }
    .dot.live {
      background: var(--accent);
      animation: pulse-dot 1s ease-in-out infinite;
    }
    .dot.done { background: var(--success); animation: none; }
    .dot.error { background: var(--danger); animation: none; }

    @keyframes pulse-dot {
      0%, 100% { opacity: 1; transform: scale(1); }
      50% { opacity: 0.4; transform: scale(0.7); }
    }

    .output-actions { display: flex; gap: 8px; }

    .btn-action {
      font-family: var(--mono);
      font-size: 11px;
      padding: 6px 12px;
      background: none;
      border: 1px solid var(--border-bright);
      border-radius: var(--radius);
      color: var(--text-muted);
      cursor: pointer;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      transition: all 0.2s;
    }
    .btn-action:hover {
      border-color: var(--accent);
      color: var(--accent);
      background: var(--accent-dim);
    }
    .btn-action.copied,
    .btn-action.ready,
    .btn-action.copied:hover,
    .btn-action.ready:hover {
      border-color: var(--success);
      color: var(--success);
      background: rgba(71,255,163,0.1);
    }

    .transcript-box {
      flex: 1;
      width: 100%;
      min-height: 520px;
      background: var(--surface);
      border: 1px solid var(--border-bright);
      border-radius: var(--radius);
      padding: 24px;
      font-family: var(--mono);
      font-size: 13px;
      line-height: 1.8;
      color: var(--text);
      resize: vertical;
      outline: none;
      transition: border-color 0.2s;
      white-space: pre-wrap;
      word-break: break-word;
      overflow-y: auto;
    }
    .transcript-box:focus { border-color: var(--accent); }

    /* Placeholder state */
    .transcript-box:empty::before {
      content: attr(data-placeholder);
      color: var(--text-muted);
      pointer-events: none;
      display: block;
    }

    /* ── Error message ── */
    .error-msg {
      display: none;
      font-family: var(--mono);
      font-size: 12px;
      color: var(--danger);
      padding: 10px 14px;
      border: 1px solid rgba(255,77,77,0.3);
      border-radius: var(--radius);
      background: rgba(255,77,77,0.05);
    }
    .error-msg.visible { display: block; }

    /* ── Modal ── */
    .modal-overlay {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(11, 12, 14, 0.85);
      z-index: 100;
      align-items: center;
      justify-content: center;
      backdrop-filter: blur(2px);
    }
    .modal-overlay.visible { display: flex; }
    .modal-content {
      background: var(--surface);
      border: 1px solid var(--border-bright);
      border-radius: var(--radius);
      padding: 24px;
      max-width: 320px;
      text-align: center;
    }
    .modal-content p {
      margin-bottom: 24px;
      font-size: 14px;
      line-height: 1.5;
    }
    .modal-actions {
      display: flex;
      gap: 12px;
      justify-content: center;
    }

    /* ── Word counter ── */
    .word-count {
      font-family: var(--mono);
      font-size: 11px;
      color: var(--text-muted);
      text-align: right;
    }

    #btn-copy-guid:hover,
    #btn-save-email:hover {
      border-color: var(--accent) !important;
      color: var(--accent) !important;
      background: var(--accent-dim) !important;
    }

    /* ── Responsive ── */
    @media (max-width: 800px) {
      main { grid-template-columns: 1fr; }
    }