.tts-dialog {
  box-sizing: border-box;
  width: min(720px, calc(100% - 24px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 24px;
  border: 1px solid #c8c1b8;
  border-radius: 8px;
  background: #faf9f6;
  color: #302f2c;
  box-shadow: 0 20px 80px #0005;
  font-family: inherit;
  overflow: auto;
}
.tts-dialog::backdrop {
  background: #17201c99;
}
.voice-portrait.openai-portrait { display: grid; place-items: center; background: #d7e9e5; color: #24665b; font-size: 42px; font-weight: bold; }
.tts-dialog h2 {
  font-size: 20px;
  line-height: 1.4;
  margin: 0;
  overflow-wrap: anywhere;
}
.tts-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.tts-dialog button {
  cursor: pointer;
  font-family: inherit;
  padding: 8px 14px;
  border: 1px solid #a6b6ae;
  border-radius: 5px;
  background: #fff;
  color: #244f3a;
  font-size: 14px;
}
.tts-dialog button:disabled {
  opacity: 0.55;
  cursor: wait;
}
.tts-dialog .tts-close {
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}
.tts-dialog label {
  display: block;
  font-size: 14px;
  line-height: 1.5;
}
.tts-dialog textarea,
.tts-dialog input,
.tts-dialog select {
  box-sizing: border-box;
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px;
  background: #fff;
  color: #282c29;
  border: 1px solid #b7bdb7;
  border-radius: 5px;
  font: inherit;
  font-size: 16px;
}
.tts-dialog textarea {
  height: 230px;
  min-height: 120px;
  resize: vertical;
  line-height: 1.6;
}
.tts-options {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 18px;
}
.tts-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}
.tts-dialog .tts-submit {
  background: #285a43;
  color: white;
}
.voice-desktop {
  --desk-light: #555256;
  --desk-dark: #38363a;
  --desk-line: #242428;
  width: min(590px, calc(100% - 24px));
  height: min(760px, calc(100dvh - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 1px solid #242428;
  border-radius: 8px;
  background: var(--desk-dark);
  color: #f4f5f3;
  box-shadow: 0 24px 80px #0007;
  overflow: hidden;
}
.voice-desktop[open] {
  display: flex;
  flex-direction: column;
}
.voice-desktop[data-step="style"] {
  --desk-light: #405554;
  --desk-dark: #293b3a;
  --desk-line: #182d2b;
}
.desktop-toolbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(6px + env(safe-area-inset-top)) 12px 6px;
  background: linear-gradient(var(--desk-light), var(--desk-dark));
  border-bottom: 1px solid var(--desk-line);
  box-shadow: inset 0 1px #fff2;
}
.voice-desktop #ttsBack {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 4px;
  padding: 10px;
  background: transparent;
  box-shadow: none;
}
#ttsBack img {
  display: block;
  max-width: 24px;
  max-height: 24px;
  width: auto;
  height: auto;
}
#ttsStatus {
  font-size: 13px;
  color: #e1e8e6;
}
.voice-desktop #ttsBack:hover {
  background: #ffffff12;
}
.voice-desktop #ttsBack:focus-visible {
  outline: 2px solid #e3d98e;
  outline-offset: -2px;
}
.voice-desktop #ttsForm {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 26px);
}
.voice-desktop .tts-head {
  flex: none;
  align-items: center;
  padding: 14px 18px;
  margin: 0;
  background: linear-gradient(#fff, #e1e5e6);
  border-bottom: 1px solid #a9b1b5;
  box-shadow: 0 1px 0 #fff inset;
}
.voice-desktop .tts-head h2 {
  font-size: 18px;
  color: #3a454e;
  text-shadow: 0 1px white;
}
.voice-desktop .tts-close {
  background: linear-gradient(#fff, #e0e5e8);
  border-color: #bcc4c9;
  color: #596873;
  box-shadow:
    0 1px 2px #18394b26,
    inset 0 1px white;
}
.voice-tabs {
  flex: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 10px 18px;
  gap: 0;
  background: #e5e9eb;
  border-bottom: 1px solid #2d719f;
}
.voice-desktop .voice-tabs button {
  padding: 9px;
  border-radius: 0;
  border: 1px solid #a5afb7;
  color: #65717b;
  background: linear-gradient(#fdfefe, #dce2e7);
  box-shadow: inset 0 1px #fff;
  font-size: 14px;
}
.voice-desktop .voice-tabs button:first-child {
  border-radius: 5px 0 0 5px;
}
.voice-desktop .voice-tabs button:last-child {
  border-radius: 0 5px 5px 0;
  border-left: 0;
}
.voice-desktop .voice-tabs button[aria-selected="true"] {
  color: #fff;
  background: linear-gradient(#417baa, #32638c);
  text-shadow: 0 1px 1px #163452;
  box-shadow: inset 0 2px 4px #10324d66;
}
.voice-desktop .desktop-panel {
  flex: 1 1 0;
  height: auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #b4bdbb55 transparent;
  padding-bottom: env(safe-area-inset-bottom);
  background:
    repeating-linear-gradient(90deg, #fff0 0 3px, #ffffff02 3px 4px),
    repeating-linear-gradient(0deg, #0000 0 3px, #00000004 3px 4px),
    linear-gradient(125deg, var(--desk-light), var(--desk-dark));
}
.desktop-panel[hidden] {
  display: none;
}
.voice-search {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  box-sizing: border-box;
  padding: 9px 14px;
  color: #fff;
  border-bottom: 1px solid #286b9780;
  box-shadow: inset 0 -1px #ffffff26;
  font-size: 12px;
}
.voice-search > span {
  white-space: nowrap;
}
.voice-desktop .voice-search input {
  margin: 0;
  font-size: 14px;
  padding: 7px 10px;
  height: 34px;
  border-color: #2c6b96;
  background: #f3f9ff;
  box-shadow:
    inset 0 1px 3px #1247754a,
    0 1px #ffffff50;
}
.style-heading {
  justify-content: space-between;
  font-size: 14px;
}
.desktop-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 150px;
  min-height: 100%;
  align-content: start;
  background: linear-gradient(
    90deg,
    transparent calc(33.333% - 1px),
    var(--desk-line) 33.333%,
    #ffffff0d calc(33.333% + 1px),
    transparent calc(33.333% + 2px),
    transparent calc(66.666% - 1px),
    var(--desk-line) 66.666%,
    #ffffff0d calc(66.666% + 1px),
    transparent calc(66.666% + 2px)
  );
}
.voice-desktop .desktop-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 12px 4px;
  box-sizing: border-box;
  min-width: 0;
  cursor: pointer;
  border: 0;
  border-radius: 0;
  border-right: 1px solid var(--desk-line);
  border-bottom: 1px solid var(--desk-line);
  background: transparent;
  box-shadow: inset 1px 1px #ffffff0b;
  color: #f3f5f5;
  text-shadow: 0 1px 2px #0009;
  transition:
    background 0.12s,
    box-shadow 0.12s;
}
.voice-desktop .desktop-tile:nth-child(3n) {
  border-right: 0;
}
.voice-desktop .desktop-tile:hover {
  background: #ffffff08;
}
.voice-desktop .desktop-tile[aria-pressed="true"],
.voice-desktop .desktop-tile:active {
  background: #00000028;
  box-shadow:
    inset 3px 4px 12px #0008,
    inset -1px -1px 0 #ffffff2b;
}
.desktop-tile[aria-pressed="true"] .voice-emblem {
  transform: translateY(3px) scale(0.94);
  box-shadow:
    0 1px 1px #0008,
    inset 0 2px 2px #fff7,
    inset 0 -3px 5px #0004;
}
.desktop-tile[aria-pressed="true"] strong {
  color: #ffe6a4;
  transform: translateY(2px);
}
.voice-desktop .desktop-tile:focus-visible {
  outline: 2px solid #e6d499;
  outline-offset: -5px;
}
.voice-desktop .desktop-tile:disabled {
  cursor: wait;
  opacity: 0.75;
}
.desktop-tile:nth-child(3n) {
  border-right: 0;
}
.desktop-tile:hover {
  background: #ffffff12;
}
.desktop-tile:has(input:checked) {
  background: #123d6a28;
  box-shadow:
    inset 0 0 0 2px #e7f7ffcc,
    inset 0 2px 14px #15375144;
}
.desktop-tile:has(input:focus-visible) {
  outline: 3px solid #fff4ae;
  outline-offset: -4px;
}
.voice-desktop .desktop-tile input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: 0;
  inset: 50% auto auto 50%;
}
.desktop-tile strong {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: center;
  letter-spacing: 0;
}
.tile-detail {
  font-size: 11px;
  line-height: 1.2;
  color: #eff9ff;
}
.voice-emblem {
  --emblem-light: #d5efc4;
  --emblem-dark: #318d64;
  --emblem-edge: #26764e;
  position: relative;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--emblem-edge);
  background: linear-gradient(150deg, #ffffffc9, var(--emblem-light) 28%, var(--emblem-dark) 83%);
  box-shadow:
    0 4px 5px #173e6c66,
    inset 0 2px 1px #ffffffeb,
    inset 0 -3px 3px #12382240;
}
.voice-emblem::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 1px solid #ffffff52;
}
.voice-emblem img {
  width: 29px;
  height: 29px;
  filter: brightness(0) invert(1) drop-shadow(0 1px 1px #24455288);
}
.voice-emblem.red {
  --emblem-light: #ffbaa8;
  --emblem-dark: #c9474a;
  --emblem-edge: #a8474a;
}
.voice-emblem.gold {
  --emblem-light: #fff1b3;
  --emblem-dark: #dfa931;
  --emblem-edge: #a17b2e;
}
.voice-emblem.blue {
  --emblem-light: #abe3ff;
  --emblem-dark: #306caf;
  --emblem-edge: #235681;
}
.voice-emblem.lilac {
  --emblem-light: #edcdea;
  --emblem-dark: #9577b1;
  --emblem-edge: #725984;
}
.voice-emblem.silver {
  --emblem-light: #fff;
  --emblem-dark: #91a3af;
  --emblem-edge: #6b8397;
}
.tile-check {
  position: absolute;
  top: 8px;
  right: 8px;
  display: none;
  width: 19px;
  height: 19px;
  line-height: 19px;
  text-align: center;
  border-radius: 50%;
  color: #fff;
  background: #337d44;
  box-shadow:
    0 1px 3px #1b426c80,
    inset 0 1px #bceca4;
  text-shadow: none;
  font-size: 12px;
}
.desktop-tile:has(input:checked) .tile-check {
  display: block;
}
.voice-pages {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  height: 42px;
  color: #f5fbff;
  font-size: 12px;
  text-shadow: 0 1px #276a97;
}
.voice-desktop .voice-pages button {
  padding: 0;
  width: 32px;
  height: 30px;
  font-size: 24px;
  line-height: 24px;
  background: #19578240;
  color: white;
  border: 1px solid #1e5f8c7a;
  box-shadow: inset 0 1px #fff3;
}
.voice-desktop .voice-pages button:disabled {
  opacity: 0.35;
  cursor: default;
}
.desktop-empty {
  grid-column: 1 / -1;
  color: #fff;
  text-align: center;
  font-size: 14px;
  padding: 32px 12px;
}
.desktop-bottom {
  flex: none;
  padding: 12px 18px 16px;
  border-top: 1px solid #adb9c0;
  background: linear-gradient(#f9fbfc, #e1e7e9);
  box-shadow: inset 0 1px white;
}
.voice-desktop .tts-error {
  flex: none;
  margin: 0;
  padding: 12px 16px;
  font-size: 13px;
  color: #ffd6bd;
  background: #392e2e;
  max-height: 110px;
  overflow: auto;
}
.voice-desktop .tts-error:empty {
  display: none;
}
.voice-selection {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
  color: #435561;
  font-size: 13px;
  line-height: 1.5;
}
#selectedVoice {
  font-weight: 700;
}
.voice-desktop .tts-footer {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 2fr;
}
.voice-desktop .tts-footer button {
  border-color: #a8b2b9;
  color: #52616d;
  background: linear-gradient(#fff, #dce2e6);
  box-shadow:
    inset 0 1px white,
    0 1px 2px #23435c22;
}
.voice-desktop .tts-footer .tts-submit {
  color: #fff;
  border-color: #25674f;
  background: linear-gradient(#549c75, #347d59);
  box-shadow:
    inset 0 1px #c3ebc180,
    0 1px 2px #23435c33;
  text-shadow: 0 1px #285b44;
}
@media (max-width: 600px) {
  .voice-desktop.tts-dialog {
    position: fixed;
    inset: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
  }
  .voice-desktop .desktop-grid {
    grid-auto-rows: 150px;
  }
  .voice-desktop .desktop-tile strong {
    font-size: 12px;
  }
  .voice-desktop .voice-emblem {
    width: 54px;
    height: 54px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .desktop-tile {
    transition: none;
  }
}
/* Portrait selection is the first step; style selection keeps its own desktop. */
.voice-desktop[data-step="voice"] {
  --desk-light: #469af9;
  --desk-dark: #469af9;
  --desk-line: #1e2730;
  width: min(780px, calc(100% - 24px), calc((100dvh - 80px) * 1.2));
  height: auto;
  border-color: #0087dc;
}
.voice-desktop[data-step="voice"] .desktop-toolbar {
  background: #469af9;
  box-shadow: none;
}
.voice-desktop[data-step="voice"] .desktop-panel {
  flex: none;
  background: transparent;
  overflow: hidden;
}
#voiceGrid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(5, auto);
  grid-auto-rows: auto;
  min-height: 0;
  background: none;
}
.voice-desktop #voiceGrid .desktop-tile {
  gap: 0;
  padding: 0;
  background: transparent;
  border-right: 1px solid var(--desk-line);
  box-shadow: none;
  text-shadow: none;
}
.voice-desktop #voiceGrid .desktop-tile:nth-child(6n) {
  border-right: 0;
}
.voice-portrait {
  position: relative;
  display: block;
  flex: none;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  pointer-events: none;
}
.voice-portrait img {
  position: absolute;
  display: block;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
}
.voice-desktop #voiceGrid strong {
  font-size: clamp(11px, 1.1vw, 15px);
  line-height: 1.15;
  font-weight: 500;
  color: white;
  transform: none;
}
.voice-desktop #voiceGrid .tile-detail {
  font-size: clamp(11px, 1vw, 14px);
  line-height: 1.15;
  color: white;
}
.voice-desktop #voiceGrid .desktop-tile:hover {
  box-shadow: inset 0 0 0 2px #ffffff80;
}
.voice-desktop #voiceGrid .desktop-tile[aria-pressed="true"],
.voice-desktop #voiceGrid .desktop-tile:active {
  background: #008de7;
  box-shadow:
    inset 0 0 0 3px #fff1af,
    inset 0 4px 14px #00549d66;
}
.voice-desktop #voiceGrid .desktop-tile[aria-pressed="true"]::after {
  content: "✓";
  position: absolute;
  inset: 9px 9px auto auto;
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: #fff1af;
  color: #08639b;
  font: 700 15px/1 sans-serif;
  opacity: 1;
  transform: none;
}
.voice-desktop #voiceGrid .desktop-tile:focus-visible {
  outline: 3px solid white;
  outline-offset: -5px;
}
@media (max-width: 600px) {
  .voice-desktop.tts-dialog[data-step="voice"] {
    width: 100vw;
    height: 100dvh;
  }
  .voice-desktop[data-step="voice"] #voicePanel {
    flex: 1 1 0;
    display: grid;
    align-items: center;
    overflow: hidden;
  }
  #voiceGrid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: repeat(6, auto);
    width: min(100%, calc((100dvh - 60px) * 0.8333));
    margin: auto;
  }
  .voice-desktop #voiceGrid .desktop-tile:nth-child(6n) {
    border-right: 1px solid var(--desk-line);
  }
  .voice-desktop #voiceGrid .desktop-tile:nth-child(5n) {
    border-right: 0;
  }
}
/* Two-step voice picker: editable labels and artwork are separate layers. */
.voice-desktop.tts-dialog {
  width: min(1120px, calc(100% - 24px));
  height: min(850px, calc(100dvh - 24px));
  background: #fff;
  border-color: #b8d7fa;
  color: #19345a;
}
.voice-desktop[data-step="voice"] {
  --desk-line: #d2e3fa;
}
.voice-desktop .desktop-toolbar,
.voice-desktop[data-step="voice"] .desktop-toolbar {
  position: relative;
  justify-content: space-between;
  background: #2688ed;
  border-bottom: 0;
  color: #fff;
}
.tts-steps {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
}
.tts-steps span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #ffffff78;
  color: #176ac4;
  font-weight: 700;
}
.tts-steps span.current { background: #fff; }
.tts-steps i { width: 40px; border-top: 2px solid #ffffffa8; }
.tts-choice-heading { flex: none; text-align: center; padding: 12px 8px 8px; }
.tts-choice-heading h2 { margin: 0; font-size: 25px; color: #173d71; }
.tts-choice-heading p { margin: 4px 0 0; color: #617b9d; font-size: 13px; }
.voice-desktop .desktop-panel,
.voice-desktop[data-step="voice"] .desktop-panel {
  flex: 1 1 0;
  min-height: 0;
  padding: 8px 16px;
  overflow: hidden;
  background: #fff;
}
.voice-desktop .desktop-panel[hidden] { display: none; }
.voice-desktop #voiceGrid {
  height: 100%;
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: 7px;
}
.voice-desktop #voiceGrid .desktop-tile,
.voice-desktop #styleGrid .desktop-tile {
  border: 1px solid #cbdff9;
  border-radius: 10px;
  background: #f9fcff;
  color: #183c70;
  text-shadow: none;
  box-shadow: none;
}
.voice-desktop #voiceGrid .desktop-tile {
  flex-direction: row;
  gap: 4px;
  justify-content: center;
  padding: 3px 5px;
}
.voice-desktop #voiceGrid .desktop-tile:nth-child(6n) { border-right: 1px solid #cbdff9; }
.voice-portrait {
  width: min(48%, 88px);
  aspect-ratio: 1;
}
.choice-copy { display: flex; flex-direction: column; min-width: 0; gap: 3px; }
.voice-desktop #voiceGrid strong,
.voice-desktop #styleGrid strong {
  color: #183c70;
  font-size: clamp(11px, 1.15vw, 15px);
  font-weight: 700;
  text-align: left;
  overflow-wrap: anywhere;
}
.voice-desktop #voiceGrid strong {
  max-width: 100%;
  white-space: nowrap;
  overflow-wrap: normal;
  overflow: hidden;
}
.voice-desktop #voiceGrid .tile-detail,
.voice-desktop #styleGrid .tile-detail {
  color: #6680a7;
  font-size: clamp(10px, 1vw, 13px);
  line-height: 1.25;
}
.voice-desktop #voiceGrid .desktop-tile[aria-pressed="true"],
.voice-desktop #styleGrid .desktop-tile[aria-pressed="true"] {
  background: #eef6ff;
  border-color: #197ff2;
  box-shadow: inset 0 0 0 2px #197ff2;
}
.voice-desktop #voiceGrid .desktop-tile[aria-pressed="true"]::after { content: none; }
.voice-usage {
  position: absolute;
  top: 8px;
  right: 8px;
  display: none;
  place-items: center;
  min-width: 26px;
  height: 26px;
  box-sizing: border-box;
  padding: 0 4px;
  border-radius: 999px;
  background: #3678e5;
  color: #fff;
  font: 700 16px/1 sans-serif;
  box-shadow: 0 1px 3px #183c7050;
}
.voice-usage[data-visible="true"] { display: grid; }
.voice-usage[data-repeat="true"] {
  background: #e53945;
  font-size: 13px;
  padding-top: 2px;
}
#styleGrid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 12px;
  height: 100%;
  min-height: 0;
  background: none;
}
.voice-desktop #styleGrid .desktop-tile {
  grid-column: span 2;
  gap: 6px;
  padding: 10px;
}
.voice-desktop #styleGrid .desktop-tile:nth-child(4),
.voice-desktop #styleGrid .desktop-tile:nth-child(5) { grid-column: span 3; }
.voice-desktop #styleGrid .choice-copy { align-items: center; text-align: center; }
.voice-desktop #styleGrid strong { font-size: clamp(16px, 1.6vw, 22px); text-align: center; }
.voice-desktop #styleGrid .tile-detail { font-size: clamp(11px, 1.1vw, 14px); }
.style-art {
  position: relative;
  display: block;
  flex: none;
  width: min(70%, 210px);
  aspect-ratio: 1.25;
  overflow: hidden;
}
.style-art img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.tts-choice-footer {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 16px 12px;
  padding: 8px 12px;
  border-radius: 10px;
  background: #eaf4ff;
  color: #20528e;
  font-size: 14px;
  font-weight: 700;
}
#ttsChoiceSummary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.tts-summary-avatar {
  width: 32px;
  height: 32px;
  flex: none;
  object-fit: contain;
}
.voice-desktop #ttsChoiceAction {
  flex: none;
  min-width: 140px;
  padding: 9px 18px;
  border: 0;
  border-radius: 8px;
  background: #0878ea;
  color: white;
  font-weight: 700;
}
@media (max-width: 600px) {
  .voice-desktop.tts-dialog,
  .voice-desktop.tts-dialog[data-step="voice"] {
    width: 100vw;
    height: 100dvh;
  }
  .tts-choice-heading { padding: 7px 6px 5px; }
  .tts-choice-heading h2 { font-size: 18px; }
  .tts-choice-heading p { font-size: 11px; }
  .voice-desktop .desktop-panel,
  .voice-desktop[data-step="voice"] #voicePanel {
    display: block;
    flex: 1 1 0;
    padding: 4px;
    overflow: hidden;
  }
  .voice-desktop .desktop-panel[hidden] { display: none; }
  .voice-desktop #voiceGrid {
    width: 100%;
    height: 100%;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: repeat(6, minmax(0, 1fr));
    gap: 3px;
    margin: 0;
  }
  .voice-desktop #voiceGrid .desktop-tile {
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    padding: 2px 1px;
    border-right: 1px solid #cbdff9;
  }
  .voice-portrait { width: auto; max-width: 100%; height: min(50%, 54px); }
  .voice-desktop #voiceGrid .choice-copy { align-items: center; width: 100%; gap: 0; }
  .voice-desktop #voiceGrid strong { font-size: clamp(8px, 2.3vw, 11px); text-align: center; }
  .voice-desktop #voiceGrid .tile-detail { font-size: clamp(8px, 2.2vw, 10px); }
  .voice-usage { top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 2px; font-size: 10px; }
  .voice-usage[data-repeat="true"] { font-size: 9px; padding-top: 1px; }
  #styleGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .voice-desktop #styleGrid .desktop-tile,
  .voice-desktop #styleGrid .desktop-tile:nth-child(4),
  .voice-desktop #styleGrid .desktop-tile:nth-child(5) { grid-column: auto; padding: 3px; }
  .voice-desktop #styleGrid .desktop-tile:nth-child(5) { grid-column: 1 / -1; }
  .style-art { width: min(55%, 110px); }
  .voice-desktop #styleGrid strong { font-size: 14px; }
  .voice-desktop #styleGrid .tile-detail { font-size: 10px; }
  .tts-choice-footer { margin: 0 4px 4px; padding: 6px; font-size: 11px; }
  .tts-summary-avatar { width: 26px; height: 26px; }
  .voice-desktop #ttsChoiceAction { min-width: 100px; padding: 8px 10px; font-size: 12px; }
}
.tts-error {
  color: #a43131;
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.tts-article-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 17px;
  line-height: 1.9;
}
.tts-jobs {
  margin-top: 12px;
}
#progress.has-tts > .empty {
  display: none;
}
.video-copy h3 a {
  color: inherit;
  text-decoration: none;
}
.video-actions a {
  font-size: 12px;
}
.tts-job {
  gap: 11px;
  padding: 16px 18px;
  border: 1px solid #d5c3c3;
  border-radius: 9px;
  background: linear-gradient(145deg, #fffafa, #f0e8e8);
  box-shadow: inset 0 1px 0 #fff, inset 0 -1px 0 rgba(103, 68, 68, 0.09), 0 3px 8px rgba(79, 47, 47, 0.09);
  color: var(--ink, #2a2222);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.tts-job[data-status="failed"] {
  border-color: #d9b9b5;
  background: linear-gradient(145deg, #fff9f8, #f4e9e7);
}
.tts-job[data-status="interrupted"] {
  border-color: #d8c59e;
  background: linear-gradient(145deg, #fffaf1, #f3ead8);
}
.tts-job-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}
.tts-job-title {
  min-width: 0;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.45;
}
.tts-job-badge {
  flex: none;
  padding: 3px 9px;
  border: 1px solid #d6b4b1;
  border-radius: 99px;
  color: #873f3b;
  background: linear-gradient(#fffafa, #f0dfdd);
  box-shadow: inset 0 1px 0 #fff, 0 1px 2px rgba(94, 52, 52, 0.1);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.tts-job-badge::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: #b65353;
  box-shadow: 0 0 0 2px rgba(182, 83, 83, 0.13);
}
.tts-job[data-status="queued"] .tts-job-badge,
.tts-job[data-status="extracting"] .tts-job-badge,
.tts-job[data-status="polishing"] .tts-job-badge,
.tts-job[data-status="synthesizing"] .tts-job-badge {
  border-color: #cfb97d;
  color: #805d14;
  background: linear-gradient(#fffaf0, #f2e5c8);
}
.tts-job[data-status="queued"] .tts-job-badge::before,
.tts-job[data-status="extracting"] .tts-job-badge::before,
.tts-job[data-status="polishing"] .tts-job-badge::before,
.tts-job[data-status="synthesizing"] .tts-job-badge::before {
  background: #e0a21b;
  box-shadow: 0 0 0 2px rgba(224, 162, 27, 0.18);
}
.tts-job-meta {
  color: var(--muted, #796d6d);
  font-size: 12px;
  font-weight: 650;
}
.tts-job-progress {
  display: grid;
  gap: 8px;
  min-width: 0;
}
.tts-job .tts-progress-row {
  gap: 7px;
  padding: 10px 12px;
  border-radius: 7px;
}
.tts-job .tts-progress-row .progress-head {
  font-size: 12px;
}
.tts-job .tts-progress-row .task-label {
  padding-left: 4px;
}
.tts-job .tts-progress-row .meta {
  font-size: 10px;
  line-height: 1.4;
}
.tts-job .tts-progress-row.overall .bar {
  height: 15px;
}
.tts-job .tts-progress-row.processing .bar {
  height: 11px;
}
.tts-job .tts-progress-row.processing .bar i {
  background: linear-gradient(90deg, #c98416, #f3bd4a);
}
.tts-job-error {
  padding: 9px 11px;
  border: 1px solid #e4cbc7;
  border-radius: 6px;
  color: #963d37;
  background: #fff7f5;
  box-shadow: inset 0 1px 3px rgba(111, 58, 50, 0.07);
  font-size: 12px;
  line-height: 1.5;
}
.tts-job-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.tts-job-action,
.tts-job-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 7px 13px;
  border: 1px solid #a9c9b4;
  border-radius: 7px;
  color: #286e49;
  background: linear-gradient(#fff, #e3f0e7);
  box-shadow: inset 0 1px 0 #fff, 0 2px 0 #a1c4ad, 0 3px 5px rgba(35, 70, 48, 0.1);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.tts-job-link {
  border-color: #cfb9b9;
  color: #753b3b;
  background: linear-gradient(#fffafa, #efe3e3);
  box-shadow: inset 0 1px 0 #fff, 0 2px 0 #d4baba, 0 3px 5px rgba(75, 43, 43, 0.1);
}
.tts-job-action.tts-job-remove {
  color: #943d38;
  border-color: #d3aaa7;
  background: linear-gradient(#fffafa, #f0dfdd);
  box-shadow: inset 0 1px 0 #fff, 0 2px 0 #c7a19e, 0 3px 5px #703c381a;
}
.tts-job-action:hover:not(:disabled),
.tts-job-link:hover {
  filter: brightness(1.03);
  transform: translateY(-1px);
}
.tts-job-action:active:not(:disabled),
.tts-job-link:active {
  transform: translateY(1px);
  box-shadow: inset 0 2px 4px rgba(55, 80, 61, 0.17);
}
.tts-job-action:focus-visible,
.tts-job-link:focus-visible {
  outline: 3px solid rgba(169, 75, 75, 0.27);
  outline-offset: 2px;
}
@media (max-width: 520px) {
  .tts-job { padding: 14px; }
  .tts-job-head { align-items: flex-start; }
  .tts-job-title { font-size: 13px; }
}
.article-action img {
  width: 20px;
  height: 20px;
}
.reading-open {
  overflow: hidden;
}
#readingView {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #f8faf9;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}
#readingView[hidden] {
  display: none;
}
#readingFrame {
  border: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
}
.mini-player {
  padding: 12px max(16px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: minmax(100px, 1fr) 42px 48px minmax(80px, 2fr) 48px 86px;
  gap: 12px;
  align-items: center;
  background: #edf3ef;
  border-top: 1px solid #b5c6bd;
  color: #233c2f;
}
.mini-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}
.mini-player button {
  width: 42px;
  height: 42px;
  padding: 9px;
  border: 1px solid #a7bbae;
  border-radius: 5px;
  background: white;
}
.mini-player button img {
  width: 100%;
  height: 100%;
}
.mini-player input {
  width: 100%;
  min-width: 0;
  accent-color: #285a43;
}
.mini-player span {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.mini-player .mini-rate-button {
  width: 86px;
  height: 38px;
  padding: 0 8px;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 3px rgba(35, 60, 47, 0.08);
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}
.mini-player .mini-rate-button[data-rate="1"] {
  border-color: #a7bbae;
  background: #fff;
  color: #233c2f;
}
.mini-player .mini-rate-button[data-rate="1.5"] {
  border-color: #9fc8b2;
  background: #dcefe2;
  color: #20543a;
}
.mini-player .mini-rate-button[data-rate="2"] {
  border-color: #285a43;
  background: #285a43;
  color: #fff;
}
.mini-player .mini-rate-button:hover {
  filter: brightness(0.96);
}
.mini-player .mini-rate-button:focus-visible {
  outline: 2px solid #285a43;
  outline-offset: 2px;
}
.mini-player .mini-rate-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
@media (max-width: 600px) {
  .mini-player {
    grid-template-columns: 38px 40px minmax(30px, 1fr) 40px 72px;
    gap: 8px;
    padding-top: 8px;
  }
  .mini-title {
    grid-column: 1 / -1;
  }
  .mini-player button {
    width: 38px;
    height: 38px;
  }
}
@media (max-width: 520px) {
  .tts-dialog {
    padding: 16px;
  }
  .tts-options {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
  .tts-dialog textarea {
    height: 180px;
  }
}

.tts-dialog.ai-settings {
  width: min(540px, calc(100% - 28px));
  padding: 0;
  color: var(--ink);
  border: 1px solid #c4adad;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--surface), var(--paper));
  box-shadow: inset 0 1px 0 #fff, 0 4px 0 #b6a0a0, 0 24px 64px #38222255;
}
.ai-settings::backdrop { background: #35282880; backdrop-filter: blur(3px); }
.ai-settings-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 24px 26px 20px; border-bottom: 1px solid var(--line); background: linear-gradient(#fff9, #e9dede66); box-shadow: 0 1px 0 #fff; }
.ai-settings .ai-settings-heading h2 { font-size: 23px; font-weight: 800; text-shadow: 0 1px #fff; }
.ai-settings-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.ai-settings-body { padding: 22px 26px 14px; }
.ai-provider-row { min-width: 0; margin: 0 0 22px; padding: 0; border: 0; }
.ai-provider-row legend { display: flex; align-items: center; gap: 9px; margin-bottom: 11px; padding: 0; font-size: 14px; font-weight: 800; text-shadow: 0 1px #fff; }
.ai-step-number { display: grid; place-items: center; width: 23px; height: 23px; border: 1px solid #cdbbbb; border-radius: 50%; background: linear-gradient(#e3d6d6, #f5eeee); color: #855252; box-shadow: inset 0 1px 3px #74404026, 0 1px 0 #fff; font: 700 12px/1 sans-serif; }
.ai-provider-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.ai-settings button { border: 1px solid #c6adad; border-radius: 7px; color: #754141; background: linear-gradient(#fffcfc, #e9dede); box-shadow: inset 0 1px 0 #fff, 0 3px 0 #baa2a2, 0 5px 9px #5030301a; text-shadow: 0 1px #fff; font-weight: 800; transition: box-shadow .12s, background .12s, transform .12s; }
.ai-settings button:hover { background: linear-gradient(#fff, #f1e6e6); }
.ai-settings button:focus-visible { outline: 2px solid var(--green); outline-offset: 4px; }
.ai-settings button:active { transform: translateY(2px); box-shadow: inset 0 2px 4px #68444426, 0 1px 0 #baa2a2; }
.ai-settings .ai-settings-close { flex: none; width: 34px; height: 34px; padding: 0; font-size: 22px; line-height: 1; }
.ai-settings .ai-provider-button { display: flex; align-items: center; gap: 11px; min-width: 0; min-height: 84px; padding: 14px; text-align: left; }
.ai-provider-icon { display: grid; flex: 0 0 43px; place-items: center; height: 43px; border: 1px solid #dfd0d0; border-radius: 11px; background: linear-gradient(145deg, #fff, #f1eaea); box-shadow: inset 0 1px 0 #fff, 0 2px 3px #54333315; }
.ai-provider-icon img { display: block; width: 30px; height: 30px; }
.ai-provider-copy { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.ai-provider-copy strong { color: var(--ink); font-size: 16px; line-height: 1.3; }
.ai-provider-copy small { color: var(--muted); font-size: 11px; font-weight: 500; }
.ai-provider-check { display: grid; flex: 0 0 17px; place-items: center; height: 17px; margin-left: auto; border: 1px solid #cbbaba; border-radius: 50%; background: #e4d8d8; box-shadow: inset 0 1px 2px #60404024, 0 1px #fff; color: transparent; font: 700 11px/1 sans-serif; text-shadow: none; }
.ai-settings .ai-provider-button[aria-pressed="true"] { transform: translateY(2px); border-color: #b88989; background: linear-gradient(#e5d2d2, #efdfdf); box-shadow: inset 0 2px 5px #703d3d30, inset 0 0 0 1px #b67f7f20, 0 1px 0 #fff; }
.ai-provider-button[aria-pressed="true"] .ai-provider-check { color: #fff; border-color: #8b4141; background: linear-gradient(#c17272, #9a4848); box-shadow: inset 0 1px 0 #fff5, 0 1px 2px #743e3e30; }
.ai-settings-note { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.ai-settings-actions { display: flex; justify-content: flex-end; gap: 12px; padding: 17px 26px 21px; border-top: 1px solid var(--line); background: #e7dbdb55; box-shadow: inset 0 1px 0 #fff; }
.ai-settings-actions button { min-width: 78px; padding: 9px 18px; }
.ai-settings #saveAISettings { border-color: #8b4141; color: #fff8f8; background: linear-gradient(#bd6565, var(--green)); box-shadow: inset 0 1px 0 #ffffff55, 0 3px 0 #793535, 0 5px 9px #743e3e22; text-shadow: 0 1px 1px #652d2d; }
.ai-settings #saveAISettings:hover { background: linear-gradient(#c87373, #af5252); }
.ai-settings #saveAISettings:active { box-shadow: inset 0 2px 4px #743e3e55, 0 1px 0 #793535; }
#aiSettingsError { margin: 8px 0 0; color: var(--danger); font-size: 12px; }
#aiSettingsError:empty { display: none; }
@media (max-width: 440px) {
  .ai-settings-heading { padding: 20px 18px 16px; }
  .ai-settings-body { padding: 18px 18px 14px; }
  .ai-provider-options { gap: 10px; }
  .ai-settings .ai-provider-button { position: relative; flex-direction: column; justify-content: center; gap: 7px; padding: 13px 8px; text-align: center; }
  .ai-provider-icon { flex-basis: auto; width: 40px; height: 40px; }
  .ai-provider-check { position: absolute; top: 10px; right: 10px; width: 17px; }
  .ai-provider-copy strong { font-size: 15px; }
  .ai-settings-actions { padding: 15px 18px 19px; }
}
@media (prefers-reduced-motion: reduce) { .ai-settings button { transition: none; } }

/* Portrait cards: text remains selectable DOM content, independent of artwork. */
.voice-desktop.openai-characters #voicePanel { overflow: auto; }
.voice-desktop.openai-characters #voiceGrid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(170px, 1fr));
  grid-auto-rows: minmax(170px, 1fr);
  gap: 12px;
}
.voice-desktop.openai-characters #voiceGrid .character-tile {
  position: relative; isolation: isolate; overflow: hidden;
  justify-content: flex-start; align-items: center; padding: 18px;
  background: #f8fbff; border-radius: 14px;
}
.character-art { position: absolute; inset: 0; z-index: -2; }
.character-art img { position: absolute; right: 0; top: 0; width: 78%; height: 100%; object-fit: cover; object-position: center 20%; }
.character-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, #f8fbff 0%, #f8fbfff5 20%, #f8fbff80 39%, transparent 58%); }
.voice-desktop.openai-characters #voiceGrid .choice-copy { align-items: flex-start; width: 44%; gap: 7px; z-index: 1; text-align: left; }
.voice-desktop.openai-characters #voiceGrid strong { font-size: clamp(18px, 1.9vw, 27px); text-align: left; transform: none; }
.character-profile { font-size: clamp(12px, 1.1vw, 16px); color: #627ca3; white-space: nowrap; }
.voice-desktop.openai-characters #voiceGrid .tile-detail { font-size: clamp(14px, 1.4vw, 20px); color: #526c94; font-weight: 700; }
.voice-desktop.openai-characters #voiceGrid .character-tile[aria-pressed='true'] { border-color: #197ff2; box-shadow: inset 0 0 0 2px #197ff2, inset 0 3px 12px #183c7022; }
@media (max-width: 1000px) and (min-width: 601px) {
  .voice-desktop.openai-characters #voiceGrid { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(4, minmax(155px, 1fr)); }
}
@media (max-width: 600px) {
  .voice-desktop.openai-characters #voiceGrid { height: auto; min-height: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(6, 140px); gap: 7px; }
  .voice-desktop.openai-characters #voiceGrid .character-tile { flex-direction: row; padding: 11px; }
  .voice-desktop.openai-characters #voiceGrid .choice-copy { width: 49%; gap: 5px; }
  .voice-desktop.openai-characters #voiceGrid strong { font-size: 18px; }
  .voice-desktop.openai-characters #voiceGrid .tile-detail { font-size: 14px; }
  .character-profile { font-size: 11px; }
}
