/* =========================
     CONTROLS BAR (TTS)
  ========================= */

  .controls {
    align-items: flex-end;
  }
  
  .controls-left {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    min-width: 0;
  }
  
  .controls-right {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-wrap: nowrap;
    white-space: nowrap;
  }
  
  .field-label {
    min-height: 14px;
    line-height: 14px;
  }
  
  .field-inline {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  
  /* Upload label as button */
  .file-btn {
    cursor: pointer;
  }
  
  /* =========================
       GRID + PANELS
    ========================= */
  
  .editor-grid #ttsInput {
    resize: none; /* или both / horizontal */
    scrollbar-gutter: stable;
  }
  
  /* Toolbar above textarea */
  .tts-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(30, 64, 175, 0.6);
    background: rgba(15, 23, 42, 0.65);
  }
  
  .tts-hint {
    margin-left: auto;
    font-size: 11px;
    color: var(--muted);
    opacity: 0.9;
  }
  
  .tts-meta {
    margin-top: auto; /* прибиваем к низу */
    padding: 10px 12px 12px;
    font-size: 11px;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    gap: 6px;
  }
  
  /* Output & history */
  .tts-output {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 14px;
  }
  
  /* =========================
     CHIPS / PILLS
  ========================= */
  .pause-chips {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
  }
  
  .pause-chip {
    height: var(--control-h);
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: rgba(15, 23, 42, 0.9);
    color: var(--text);
    border-radius: 999px;
    padding: 0 12px;
    font-size: 12px;
    cursor: pointer;
    transition:
      background 0.15s ease,
      border-color 0.15s ease,
      transform 0.1s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  
  .pause-chip:hover {
    border-color: var(--accent);
    background: rgba(15, 23, 42, 1);
    transform: translateY(-1px);
  }
  
  .pause-chip:active {
    transform: translateY(0);
  }
  
  /* =========================
     TTS HISTORY (styling)
  ========================= */
  
  .tts-history .section-title {
    font-size: 13px;
    font-weight: 650;
    letter-spacing: 0.02em;
    margin: 8px 0 10px;
    color: var(--text);
  }
  
  .tts-history-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  
  /* each row */
  .tts-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(15, 23, 42, 0.55);
  }
  
  .tts-history-left {
    min-width: 0; /* важно для ellipsis */
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  
  .tts-history-title {
    font-size: 13px;
    font-weight: 650;
    color: var(--text);
    line-height: 1.2;
  
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
  
  /* small meta line under title */
  .tts-history-sub {
    font-size: 11px;
    color: var(--muted);
    line-height: 1.2;
  
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.95;
  }
  
  /* actions */
  .tts-history-item-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }
  
  /* smaller buttons just for history */
  .btn.tts-mini {
    height: 28px; /* меньше чем общий control-h */
    padding: 0 10px;
    font-size: 12px;
    border-radius: 999px;
  }
  
  /* subtle danger outline */
  .btn.tts-mini.danger {
    border-color: rgba(249, 115, 115, 0.55);
    color: rgba(249, 115, 115, 0.95);
  }
  
  .btn.tts-mini.danger:hover {
    border-color: rgba(249, 115, 115, 0.85);
    color: rgba(249, 115, 115, 1);
  }
  
  /* nice hover for whole row */
  .tts-history-item:hover {
    border-color: rgba(56, 189, 248, 0.35);
    background: rgba(15, 23, 42, 0.62);
  }
  
  /* empty state stays pretty */
  .tts-history-empty {
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px dashed rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.45);
    color: var(--muted);
    font-size: 12px;
  }
  /* =========================
     TTS HISTORY ICON BUTTONS
    ========================= */
  /* ICON buttons by data-action (no JS changes) */
  .btn.tts-mini[data-action] {
    width: 30px;
    height: 28px;
    padding: 0;
    font-size: 0; /* скрываем текст Play/Download/Delete */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    position: relative;
  }
  
  .btn.tts-mini[data-action]::before {
    font-size: 13px;
    line-height: 1;
    color: var(--muted);
    transition:
      color 0.15s ease,
      transform 0.15s ease;
  }
  
  /* play */
  .btn.tts-mini[data-action="play"]::before {
    content: "▶";
    margin-left: 1px;
  }
  
  /* download */
  .btn.tts-mini[data-action="download"]::before {
    content: "⬇";
  }
  
  /* delete */
  .btn.tts-mini[data-action="delete"]::before {
    content: "✕";
  }
  
  .btn.tts-mini[data-action]:hover::before {
    color: var(--accent);
    transform: scale(1.1);
  }
  
  /* danger delete */
  .btn.tts-mini.danger[data-action="delete"]::before {
    color: rgba(249, 115, 115, 0.9);
  }
  .btn.tts-mini.danger[data-action="delete"]:hover::before {
    color: rgba(249, 115, 115, 1);
  }
  
  /* =========================
       RESPONSIVE
    ========================= */
  
  @media (max-width: 900px) {
    .controls {
      flex-direction: column;
      align-items: stretch;
    }
  
    .controls-right {
      justify-content: flex-start;
      flex-wrap: wrap;
      white-space: normal;
    }
  
    .pause-chips {
      flex-wrap: wrap;
    }
  
    /* Prevent overflow on tablets / small laptops */
    .controls-left,
    .controls-right {
      width: 100%;
    }
  
    .field {
      min-width: 0;
      flex: 1 1 220px;
    }
  
    .field-inline {
      flex-wrap: wrap;
    }
  
    .field-inline .select {
      flex: 1 1 220px;
      min-width: 0;
    }
  
    /* Audio control shouldn't overflow */
    #ttsAudioPlayer {
      max-width: 100%;
      width: 100%;
    }
  }
  
  /* Phones */
  @media (max-width: 520px) {
    .controls-left {
      width: 100%;
      flex-direction: column;
      align-items: stretch;
    }
  
    .field {
      width: 100%;
      flex: 1 1 auto;
    }
  
    .pause-chips {
      width: 100%;
      flex-wrap: wrap;
    }
  
    .controls-right {
      width: 100%;
      flex-wrap: wrap;
    }
  
    .tts-history-item {
      flex-direction: column;
      align-items: stretch;
      gap: 10px;
    }
  
    .tts-history-item-actions {
      width: 100%;
      justify-content: flex-end;
      flex-wrap: wrap;
    }
  
    /* Remove textarea resize handle on mobile (it causes layout jumps) */
    textarea {
      resize: none;
    }
  
    /* Dropdown menu should fit viewport */
    .user-menu {
      width: min(230px, calc(100vw - 32px));
      right: 16px;
    }
  }
  
  @media (max-width: 750px) {
    .tts-hint {
      display: none;
    }
  }
  
/* =========================
   TTS: iPad layout (2 rows)
   Row1: Language | Voice | Preview
   Row2: Pause | Upload | Generate | Ready
   ========================= */
   @media (min-width: 768px) and (max-width: 1179px) and (hover: none){

    /* make controls a 2-row grid */
    .controls{
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      gap: 12px;
      align-items: end;
    }
  
    /* ROW 1 */
    .controls-left{
      display: grid;
      grid-template-columns: minmax(220px, 1fr) minmax(260px, 1.2fr) auto;
      gap: 12px;
      align-items: end;
    }
  
    /* keep voice select + preview inline */
    .field-inline{
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 10px;
      align-items: center;
    }
  
    /* ROW 2 */
    .controls-right{
      display: grid;
      grid-template-columns: minmax(260px, 1fr) auto auto auto; /* Pause | Upload | Generate | Status */
      gap: 10px;
      align-items: center;
      justify-content: end;
    }
  
    /* Pause stays horizontal, wraps nicely */
    .pause-chips{
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      justify-content: flex-start;
      align-items: center;
    }
  
    /* stop any overflow/odd stretching */
    .controls-left .field,
    .controls-right > *{
      min-width: 0;
    }
  
    .status{
      white-space: nowrap;
    }
  }