.tvc-export-ui,
.tvc-export-ui * { box-sizing: border-box; }
.tvc-export-ui [hidden] { display: none !important; }

.tvc-export-ui {
  --export-bg: #1c1b1a;
  --export-panel: #242321;
  --export-raised: #302e2b;
  --export-ink: #f5f2ec;
  --export-muted: #aaa69f;
  --export-line: rgba(245, 242, 236, .14);
  --export-accent: #c29b4d;
  --export-focus: #e2bd70;
  position: fixed;
  z-index: 2147483001;
  inset: 0;
  width: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--export-bg);
  color: var(--export-ink);
  color-scheme: dark;
  font-family: inherit;
  animation: tvc-export-fade .18s ease-out both;
}
dialog.tvc-export-ui:not([open]) { display: none; }
.tvc-export-ui::backdrop { background: transparent; }
.tvc-export-ui[data-theme="light"] {
  --export-bg: #f5f1e9;
  --export-panel: #fffdf8;
  --export-raised: #eee9df;
  --export-ink: #292722;
  --export-muted: #716d65;
  --export-line: rgba(41, 39, 34, .16);
  --export-accent: #9b7126;
  --export-focus: #7d5a1f;
  color-scheme: light;
}
.tvc-export-ui__header {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(80px, 1fr) auto minmax(80px, 1fr);
  align-items: center;
  min-height: 66px;
  border-bottom: 1px solid var(--export-line);
  padding: 0 28px;
  background: var(--export-bg);
}
.tvc-export-ui__title {
  margin: 0;
  font-size: 15px;
  font-weight: 730;
  letter-spacing: -.015em;
}
.tvc-export-ui__header-side { display: flex; align-items: center; gap: 8px; }
.tvc-export-ui__header-side--right { justify-content: flex-end; }
.tvc-export-ui__icon-button {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--export-muted);
  cursor: pointer;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}
.tvc-export-ui__icon-button:hover:not(:disabled) { background: var(--export-raised); color: var(--export-ink); }
.tvc-export-ui__icon-button:active:not(:disabled) { transform: scale(.95); }
.tvc-export-ui__icon-button svg { width: 19px; height: 19px; }
.tvc-export-ui__body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}
.tvc-export-ui__controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 28px 13px;
}
.tvc-export-ui__control-group { display: flex; align-items: center; gap: 9px; min-width: 0; }
.tvc-export-ui__control-label {
  color: var(--export-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.tvc-export-ui__segments {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: 100%;
  border: 1px solid var(--export-line);
  border-radius: 999px;
  padding: 3px;
  background: var(--export-panel);
}
.tvc-export-ui__segment {
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  padding: 0 14px;
  background: transparent;
  color: var(--export-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 680;
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}
.tvc-export-ui__segment:hover:not(:disabled) { color: var(--export-ink); }
.tvc-export-ui__segment[aria-pressed="true"] {
  background: var(--export-raised);
  color: var(--export-ink);
  box-shadow: inset 0 0 0 1px var(--export-line);
}
.tvc-export-ui__preview {
  position: relative;
  display: grid;
  min-height: 0;
  place-items: center;
  overflow: auto;
  padding: 8px 24px 28px;
  overscroll-behavior: contain;
}
.tvc-export-ui__canvas-frame {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  width: min(100%, calc((100dvh - 220px) * .8));
  max-height: 100%;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--export-line);
  border-radius: 2px;
  background:
    linear-gradient(45deg, var(--export-panel) 25%, transparent 25%),
    linear-gradient(-45deg, var(--export-panel) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--export-panel) 75%),
    linear-gradient(-45deg, transparent 75%, var(--export-panel) 75%);
  background-color: var(--export-bg);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .24);
}
.tvc-export-ui__canvas-frame[data-ratio="post"] { aspect-ratio: 4 / 5; }
.tvc-export-ui__canvas-frame[data-ratio="story"] { aspect-ratio: 9 / 16; width: min(100%, calc((100dvh - 220px) * .5625)); }
.tvc-export-ui__canvas-frame[data-ratio="square"] { aspect-ratio: 1 / 1; width: min(100%, calc(100dvh - 220px)); }
.tvc-export-ui__artwork {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.tvc-export-ui__loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--export-bg) 35%, transparent);
  pointer-events: none;
}
.tvc-export-ui__skeleton {
  width: 46%;
  aspect-ratio: 1;
  border-radius: 2px;
  background: linear-gradient(110deg, var(--export-panel) 30%, var(--export-raised) 45%, var(--export-panel) 60%);
  background-size: 220% 100%;
  animation: tvc-export-sheen 1.35s ease-in-out infinite;
}
.tvc-export-ui__loading-text { position: absolute; margin-top: min(58%, 330px); color: var(--export-muted); font-size: 12px; }
.tvc-export-ui__error {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  padding: 28px;
  background: var(--export-bg);
  text-align: center;
}
.tvc-export-ui__error p { max-width: 340px; margin: 0; color: var(--export-muted); font-size: 14px; line-height: 1.5; }
.tvc-export-ui__retry,
.tvc-export-ui__export {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 45px;
  border: 1px solid var(--export-line);
  border-radius: 9px;
  padding: 0 17px;
  background: var(--export-raised);
  color: var(--export-ink);
  font: inherit;
  font-size: 13px;
  font-weight: 720;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, opacity .16s ease;
}
.tvc-export-ui__retry:hover:not(:disabled) { background: var(--export-panel); }
.tvc-export-ui__retry:active:not(:disabled),
.tvc-export-ui__export:active:not(:disabled) { transform: scale(.98); }
.tvc-export-ui__footer {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  min-height: 78px;
  border-top: 1px solid var(--export-line);
  padding: 12px 28px;
  background: var(--export-bg);
}
.tvc-export-ui__pages {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-self: start;
  color: var(--export-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.tvc-export-ui__page-count { min-width: 54px; text-align: center; color: var(--export-ink); }
.tvc-export-ui__page-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--export-line);
  border-radius: 50%;
  background: var(--export-panel);
  color: var(--export-ink);
  cursor: pointer;
}
.tvc-export-ui__page-button:hover:not(:disabled) { background: var(--export-raised); }
.tvc-export-ui__page-button svg { width: 16px; height: 16px; }
.tvc-export-ui__page-button:disabled { opacity: .36; cursor: default; }
.tvc-export-ui__status {
  min-width: 0;
  color: var(--export-muted);
  font-size: 12px;
  text-align: center;
}
.tvc-export-ui__export { justify-self: end; min-width: 164px; border-color: transparent; background: var(--export-ink); color: var(--export-bg); }
.tvc-export-ui__export:hover:not(:disabled) { opacity: .88; }
.tvc-export-ui__export svg { width: 17px; height: 17px; }
.tvc-export-ui [disabled] { opacity: .5; cursor: wait !important; }
.tvc-export-ui :focus-visible { outline: 2px solid var(--export-focus); outline-offset: 3px; }
.tvc-export-ui__sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
@keyframes tvc-export-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes tvc-export-sheen { to { background-position: -220% 0; } }
@media (max-width: 700px) {
  .tvc-export-ui__header { min-height: 56px; padding: 0 12px; grid-template-columns: 1fr auto 1fr; }
  .tvc-export-ui__title { font-size: 14px; }
  .tvc-export-ui__icon-button { width: 38px; height: 38px; }
  .tvc-export-ui__controls { align-items: flex-start; flex-direction: column; gap: 10px; padding: 13px 14px 10px; }
  .tvc-export-ui__control-group { width: 100%; justify-content: space-between; }
  .tvc-export-ui__control-label { font-size: 10px; }
  .tvc-export-ui__segment { min-height: 32px; padding: 0 11px; font-size: 12px; }
  .tvc-export-ui__preview { padding: 8px 16px 16px; }
  .tvc-export-ui__canvas-frame { width: min(100%, calc((100dvh - 250px) * .8)); }
  .tvc-export-ui__canvas-frame[data-ratio="story"] { width: min(100%, calc((100dvh - 250px) * .5625)); }
  .tvc-export-ui__canvas-frame[data-ratio="square"] { width: min(100%, calc(100dvh - 250px)); }
  .tvc-export-ui__footer { grid-template-columns: auto 1fr; gap: 8px; min-height: 70px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  .tvc-export-ui__status { grid-column: 1 / -1; grid-row: 1; text-align: left; }
  .tvc-export-ui__pages { grid-column: 1; grid-row: 2; }
  .tvc-export-ui__export { grid-column: 2; grid-row: 2; min-width: 150px; }
}
@media (max-width: 380px) {
  .tvc-export-ui__control-label { display: none; }
  .tvc-export-ui__segments { width: 100%; justify-content: space-between; }
  .tvc-export-ui__segment { padding-inline: 10px; }
  .tvc-export-ui__export { min-width: 132px; }
}
@media (prefers-reduced-motion: reduce) {
  .tvc-export-ui, .tvc-export-ui *, .tvc-export-ui *::before, .tvc-export-ui *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
