:root {
  color-scheme: dark;
  --bg: #090b16;
  --bg-soft: rgba(16, 21, 39, 0.78);
  --panel: rgba(13, 18, 34, 0.84);
  --panel-strong: rgba(17, 25, 49, 0.95);
  --text: #f6f3ea;
  --muted: #bfc4d7;
  --accent: #ffb347;
  --accent-strong: #ff7a18;
  --secondary: #88e0ff;
  --success: #7bffc4;
  --danger: #ff7f96;
  --border: rgba(255, 255, 255, 0.12);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
  --safe-bottom: max(24px, env(safe-area-inset-bottom));
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(255, 122, 24, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(136, 224, 255, 0.16), transparent 26%),
    linear-gradient(180deg, #0b1022 0%, #070910 55%, #05060a 100%);
  color: var(--text);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
  overflow: hidden;
}

body[data-runtime-mode="windows"] .reading-surface {
  touch-action: auto;
}

body[data-runtime-mode="windows"] .reading-card {
  width: min(1080px, 100%);
  min-height: min(74vh, 780px);
  padding: 36px 28px;
}

body[data-runtime-mode="mobile"] .app-shell {
  padding: 14px 10px 110px;
}

body[data-runtime-mode="mobile"] .reading-surface {
  height: calc(100dvh - 112px);
  padding: 8px 0 82px;
}

body[data-runtime-mode="mobile"] .reading-card {
  width: 100%;
  min-height: min(84vh, 920px);
  padding: 22px 16px;
}

body[data-runtime-mode="mobile"] .reading-text-wrap {
  min-height: 62vh;
}

button,
input,
textarea,
select {
  font: inherit;
}

.hidden {
  display: none !important;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  padding: 24px;
  overflow: hidden;
}

.ambient {
  position: absolute;
  width: 34vw;
  height: 34vw;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.55;
  pointer-events: none;
}

.ambient-left {
  top: -12vw;
  left: -8vw;
  background: rgba(255, 173, 84, 0.22);
}

.ambient-right {
  right: -10vw;
  bottom: 8vh;
  background: rgba(106, 203, 255, 0.18);
}

.hud-panel {
  display: flex;
  align-items: center;
  gap: 6px;
  position: fixed;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  z-index: 4;
  width: min(960px, calc(100vw - 16px));
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(7, 11, 22, 0.84);
  backdrop-filter: blur(24px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.24);
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(8, 12, 24, 0.72);
  backdrop-filter: blur(18px);
  color: var(--muted);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.22);
  font-size: 0.8rem;
  flex: 0 0 auto;
}

.chip-accent {
  color: #24150a;
  background: linear-gradient(135deg, #ffe0a6, #ffb347);
  border-color: rgba(255, 196, 105, 0.4);
  font-weight: 800;
}

.reading-surface {
  position: relative;
  z-index: 1;
  height: calc(100vh - 114px);
  display: grid;
  place-items: center;
  padding: 54px 0 72px;
  outline: none;
  touch-action: none;
  user-select: none;
}

.reading-card {
  position: relative;
  width: min(1200px, 100%);
  min-height: min(82vh, 860px);
  padding: 28px 22px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 36px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.01)),
    rgba(10, 15, 28, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 18px;
  overflow: hidden;
}

.reading-card::before {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  pointer-events: none;
}

.reading-caption {
  margin: 0;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.46);
  font-size: 0.82rem;
}

.reading-text-wrap {
  display: grid;
  place-items: center;
  min-height: 58vh;
  width: 100%;
}

.reading-text {
  margin: 0;
  max-width: 92%;
  font-size: var(--teleprompter-size, 72px);
  line-height: 1.45;
  text-align: center;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-wrap: balance;
  text-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.reading-subtitle {
  margin: 0;
  max-width: 88%;
  text-align: center;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.bottom-dock {
  position: fixed;
  left: 50%;
  bottom: var(--safe-bottom);
  transform: translateX(-50%);
  width: min(960px, calc(100vw - 16px));
  z-index: 4;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(7, 11, 22, 0.84);
  backdrop-filter: blur(24px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
}

.bottom-dock::-webkit-scrollbar {
  display: none;
}

.dock-button,
.primary-button,
.secondary-button,
.icon-button,
.mini-button,
.modal-link-button {
  border: 0;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.dock-button,
.primary-button,
.secondary-button {
  min-height: 52px;
  padding: 12px 18px;
  border-radius: 18px;
  color: var(--text);
}

.dock-button {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.04));
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.88rem;
  flex: 0 0 auto;
}

.dock-button-strong,
.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #24150a;
  font-weight: 800;
}

.secondary-button {
  background: rgba(255, 255, 255, 0.08);
}

.dock-button:hover,
.primary-button:hover,
.secondary-button:hover,
.icon-button:hover,
.mini-button:hover,
.modal-link-button:hover {
  transform: translateY(-2px);
}

.modal-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.56);
  backdrop-filter: blur(12px);
}

.modal-card {
  position: relative;
  width: min(720px, calc(100vw - 24px));
  max-height: calc(100vh - 48px);
  margin: 24px auto;
  padding: 22px;
  border-radius: 28px;
  border: 1px solid var(--border);
  background: rgba(11, 16, 28, 0.96);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-card-wide {
  width: min(980px, calc(100vw - 24px));
}

.modal-card-scroll {
  overflow: auto;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-head h2,
.settings-section h3 {
  margin: 0;
}

.icon-button,
.mini-button {
  min-width: 44px;
  min-height: 44px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.field {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.field span {
  color: var(--muted);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 54px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.field textarea {
  min-height: 220px;
  resize: vertical;
}

.field-group {
  margin-top: 14px;
}

.ai-mode-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.mode-card {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

.mode-card input {
  margin: 0;
}

.mode-card span {
  font-weight: 700;
}

.mode-card small {
  color: var(--muted);
  line-height: 1.6;
}

.settings-section {
  margin-bottom: 28px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.03);
}

.row-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.slider-row {
  display: grid;
  grid-template-columns: 76px 44px minmax(0, 1fr) 44px 54px;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.slider-row input[type="range"] {
  accent-color: var(--accent);
}

.modal-actions,
.prompt-toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.modal-actions {
  justify-content: flex-end;
}

.modal-actions-spread {
  justify-content: space-between;
}

.text-block {
  color: var(--muted);
  line-height: 1.8;
  white-space: pre-wrap;
}

.help-lines {
  display: grid;
  gap: 8px;
}

.help-line {
  margin: 0;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  line-height: 1.8;
  outline: none;
}

.help-line:focus {
  border-color: rgba(255, 179, 71, 0.5);
  box-shadow: 0 0 0 1px rgba(255, 179, 71, 0.45);
}

.prompt-list {
  display: grid;
  gap: 14px;
}

.prompt-item {
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.prompt-item h4 {
  margin: 0 0 10px;
}

.prompt-item p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.7;
  white-space: pre-wrap;
}

.prompt-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.toast,
.status-banner {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(12, 17, 32, 0.92);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.25);
}

.toast {
  top: 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(8px);
}

.status-banner {
  bottom: calc(var(--safe-bottom) + 182px);
}

@media (max-width: 900px) {
  .app-shell {
    padding: 16px;
  }

  .reading-surface {
    height: calc(100vh - 120px);
    padding-bottom: 92px;
  }

  .reading-card {
    min-height: 78vh;
    padding: 20px 14px;
  }

  .reading-text {
    max-width: 100%;
  }

  .bottom-dock {
    width: calc(100vw - 10px);
    bottom: 8px;
    justify-content: flex-start;
  }

  .row-grid {
    grid-template-columns: 1fr;
  }

  .ai-mode-group {
    grid-template-columns: 1fr;
  }

  .slider-row {
    grid-template-columns: 64px 40px minmax(0, 1fr) 40px 48px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 10px 8px;
  }

  .hud-panel {
    top: 8px;
    width: calc(100vw - 10px);
    padding: 7px 8px;
  }

  .chip {
    min-height: 26px;
    padding: 4px 8px;
    font-size: 0.74rem;
  }

  .reading-subtitle {
    max-width: 100%;
    font-size: 0.92rem;
  }

  .reading-text-wrap {
    min-height: 64vh;
  }

  .bottom-dock {
    padding: 8px 10px;
    gap: 6px;
  }

  .dock-button {
    min-height: 36px;
    padding: 7px 10px;
    font-size: 0.8rem;
  }

  .modal-card {
    margin: 12px auto;
    padding: 16px;
    max-height: calc(100vh - 24px);
  }
}
