:root {
  --ink: #12263a;
  --muted: #5a6f82;
  --line: rgba(18, 38, 58, 0.12);
  --accent: #1b6b8a;
  --accent-deep: #0f4d66;
  --panel: rgba(255, 255, 255, 0.78);
  --font-brand: "Literata", "Noto Serif SC", serif;
  --font-body: "Manrope", "Noto Sans SC", sans-serif;
  --font-ug: "Noto Naskh Arabic", "Manrope", serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

html > #idraky-page-nav-float:not([data-nav-inline="1"]):not(.idraky-topbar-nav),
body > #idraky-page-nav-float:not([data-nav-inline="1"]):not(.idraky-topbar-nav) {
  position: fixed !important;
  top: max(0.65rem, env(safe-area-inset-top, 0px)) !important;
  left: max(0.65rem, env(safe-area-inset-left, 0px)) !important;
  right: auto !important;
  bottom: auto !important;
  z-index: 2147483000 !important;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: #eef3f6;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 70% 50% at 10% 0%, #c5e4ef 0%, transparent 55%),
    radial-gradient(ellipse 50% 40% at 100% 15%, #d5e3f0 0%, transparent 50%),
    radial-gradient(ellipse 45% 35% at 60% 100%, #e7efe6 0%, transparent 55%),
    linear-gradient(180deg, #e8eef3 0%, #f2f5f7 55%, #e9eef2 100%);
}

.shell {
  width: min(640px, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 1.25rem 0 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: rise 0.5s ease-out;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.brand-block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
}

.auth-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(18, 38, 58, 0.35);
  backdrop-filter: blur(4px);
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(400px, 100%);
  padding: 1.2rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  animation: rise 0.25s ease-out;
}

.modal-card h2 {
  margin: 0;
  font-family: var(--font-brand);
  font-size: 1.25rem;
}

.modal-desc {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.modal-card input {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 1.05rem;
  color: #f7fbfd;
  background: linear-gradient(145deg, var(--accent) 0%, var(--accent-deep) 100%);
  box-shadow: 0 8px 20px rgba(15, 77, 102, 0.22);
}

.brand-text h1 {
  margin: 0;
  font-family: var(--font-brand);
  font-size: clamp(1.55rem, 4vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.brand-text p {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.status {
  flex-shrink: 0;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  color: var(--muted);
}

.status[data-state="ok"] {
  color: #1a6b4a;
  border-color: rgba(26, 107, 74, 0.25);
  background: rgba(220, 245, 232, 0.85);
}

.status[data-state="error"] {
  color: #9b3a32;
  border-color: rgba(155, 58, 50, 0.25);
  background: rgba(247, 228, 225, 0.9);
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  padding: 0.35rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
}

.mode-tab {
  border: none;
  border-radius: 12px;
  padding: 0.55rem 0.35rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.mode-tab:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.65);
}

.mode-tab.active {
  color: #f7fbfd;
  background: linear-gradient(145deg, var(--accent) 0%, var(--accent-deep) 100%);
  box-shadow: 0 6px 14px rgba(15, 77, 102, 0.18);
}

.panel[hidden] {
  display: none;
}

.quota {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.file-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1.55rem 1.1rem;
  border-radius: 18px;
  border: 1.5px dashed rgba(27, 107, 138, 0.32);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(241, 248, 251, 0.75));
  cursor: pointer;
  text-align: center;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.file-drop:hover,
.file-drop.dragover {
  border-color: var(--accent);
  background: rgba(228, 241, 246, 0.92);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(15, 77, 102, 0.08);
}

.file-drop.has-file {
  border-style: solid;
  border-color: rgba(27, 107, 138, 0.28);
}

.file-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background:
    linear-gradient(145deg, rgba(27, 107, 138, 0.16), rgba(15, 77, 102, 0.08))
    center / 18px 18px no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231b6b8a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5'/%3E%3C/svg%3E");
}

.file-title {
  font-weight: 700;
  color: var(--ink);
}

.file-sub,
.file-name {
  font-size: 0.84rem;
  color: var(--muted);
}

.file-name {
  margin-top: 0.2rem;
  font-weight: 600;
  color: var(--accent-deep);
  word-break: break-all;
  max-width: 100%;
}

.info-card {
  padding: 0.9rem;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  animation: rise 0.35s ease-out;
}

.info-card[hidden] {
  display: none;
}

.stats-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.stats-bar[hidden] {
  display: none;
}

.stats-toggle {
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
}

.stats-bar-summary {
  font-size: 0.82rem;
  color: var(--muted);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.info-grid + .info-grid {
  margin-top: 0.55rem;
}

.info-grid-est .info-val {
  font-size: 1.02rem;
}

.info-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.7rem 0.35rem;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(232, 242, 247, 0.65));
  border: 1px solid rgba(27, 107, 138, 0.08);
}

.info-val {
  font-family: var(--font-brand);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-deep);
  line-height: 1.1;
}

.info-key {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.lang-levels {
  margin: 0.75rem 0 0;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
}

.lang-levels[hidden] {
  display: none;
}

.lang-levels-title {
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--ink);
  margin-bottom: 0.45rem;
}

.lang-levels-rows {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.lang-row {
  display: grid;
  grid-template-columns: 4.2rem 1fr;
  gap: 0.55rem;
  align-items: start;
  font-size: 0.82rem;
  line-height: 1.45;
}

.lang-level-name {
  color: var(--muted);
  flex-shrink: 0;
}

.lang-level-val {
  color: var(--ink);
  word-break: break-word;
}

.lang-levels-note {
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.lang-levels-note[hidden] {
  display: none;
}

.chapter-preview {
  margin: 0.7rem 0 0;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--muted);
  white-space: pre-wrap;
  max-height: 140px;
  overflow: auto;
}

.chapter-preview[hidden] {
  display: none;
}

.progress-panel {
  padding: 0.85rem 0.95rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  animation: rise 0.3s ease-out;
}

.progress-panel[hidden] {
  display: none;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
  font-size: 0.86rem;
  font-weight: 600;
}

#progressLabel {
  color: var(--ink);
}

#progressPct {
  color: var(--accent-deep);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(18, 38, 58, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2a8aad, var(--accent-deep));
  box-shadow: 0 0 12px rgba(27, 107, 138, 0.35);
  transition: width 0.25s ease;
  position: relative;
}

.progress-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    transparent 30%,
    rgba(255, 255, 255, 0.35) 50%,
    transparent 70%
  );
  background-size: 200% 100%;
  animation: sheen 1.2s linear infinite;
}

@keyframes sheen {
  from {
    background-position: 120% 0;
  }
  to {
    background-position: -120% 0;
  }
}

.controls {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 0.65rem;
}

.field,
.text-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field span,
.text-field > span:first-child {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.field select,
.text-field textarea {
  width: 100%;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  color: var(--ink);
  font: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field select {
  padding: 0.7rem 2rem 0.7rem 0.85rem;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235a6f82' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  cursor: pointer;
}

.text-field textarea {
  min-height: 200px;
  padding: 0.9rem 1rem;
  resize: vertical;
  line-height: 1.55;
}

.field select:focus,
.text-field textarea:focus {
  outline: none;
  border-color: rgba(27, 107, 138, 0.45);
  box-shadow: 0 0 0 3px rgba(27, 107, 138, 0.12);
}

.text-field textarea[dir="rtl"] {
  font-family: var(--font-ug);
  font-size: 1.1rem;
}

.count {
  align-self: flex-end;
  font-size: 0.75rem;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.primary,
.ghost,
.download {
  border: none;
  border-radius: 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.primary {
  flex: 1;
  min-width: 140px;
  padding: 0.85rem 1.2rem;
  color: #f7fbfd;
  background: linear-gradient(145deg, var(--accent) 0%, var(--accent-deep) 100%);
  box-shadow: 0 10px 22px rgba(15, 77, 102, 0.2);
}

.primary:hover:not(:disabled) {
  transform: translateY(-1px);
}

.primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.ghost {
  padding: 0.85rem 1.1rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
}

.ghost:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.85);
}

.player-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  animation: rise 0.35s ease-out;
}

.player-panel[hidden] {
  display: none;
}

.player-panel audio {
  width: 100%;
}

.download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  padding: 0.65rem 1rem;
  text-decoration: none;
  color: var(--accent-deep);
  background: rgba(27, 107, 138, 0.08);
  border: 1px solid rgba(27, 107, 138, 0.18);
}

.download:hover {
  background: rgba(27, 107, 138, 0.14);
}

.note {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.88rem;
  color: var(--muted);
}

.note.error {
  color: #9b3a32;
}

.foot {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: rgba(90, 111, 130, 0.75);
}

@media (max-width: 520px) {
  .controls {
    grid-template-columns: 1fr;
  }

  .mode-tabs {
    grid-template-columns: repeat(2, 1fr);
  }

  .info-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .info-val {
    font-size: 1.02rem;
  }

  .brand-block {
    align-items: flex-start;
  }

  .text-field textarea {
    min-height: 180px;
  }
}

/* ===== 角色 ===== */
.controls {
  grid-template-columns: 1.4fr 1fr;
}
.field-role {
  grid-column: 1 / -1;
}
@media (min-width: 900px) {
  .controls {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .field-role {
    grid-column: auto;
  }
}

/* ===== 声音克隆面板 ===== */
.clone-panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.85rem 1rem;
  background: var(--panel);
}
.clone-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.clone-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink);
}
.clone-sub {
  font-size: 0.78rem;
  color: var(--muted);
}
.clone-toggle {
  margin-left: auto;
}
.clone-body {
  margin-top: 0.75rem;
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}
.clone-tip {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0 0 0.6rem;
}
.clone-rec-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.clone-status {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0.55rem 0 0;
  min-height: 1em;
}
.clone-status.error {
  color: #c0392b;
}
.clone-create {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.clone-create input[type="text"] {
  flex: 1 1 160px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  padding: 0.5rem 0.7rem;
  font-size: 0.86rem;
}
.clone-create select {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  padding: 0.5rem 0.6rem;
  font-size: 0.86rem;
}
.clone-list {
  margin-top: 0.8rem;
  border-top: 1px dashed var(--line);
  padding-top: 0.6rem;
}
.clone-list-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 0.5rem;
}
.clone-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
}
.clone-item-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.clone-item-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
}
.clone-item-meta {
  font-size: 0.76rem;
  color: var(--muted);
}
.clone-del {
  font-size: 0.78rem;
}
