:root {
  color-scheme: dark;
  --bg: #111318;
  --panel: #1b1e25;
  --panel-soft: rgba(20, 22, 28, 0.74);
  --panel-strong: rgba(11, 12, 15, 0.84);
  --text: #f7f2e8;
  --muted: #aeb5c2;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #48d6ba;
  --accent-strong: #19bfa0;
  --danger: #ff3545;
  --warn: #f4b04a;
  --button: rgba(255, 255, 255, 0.12);
  --radius: 8px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
}

body {
  min-height: 100svh;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  color: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  min-height: 100svh;
  padding: calc(18px + var(--safe-top)) 18px calc(24px + var(--safe-bottom));
  background:
    radial-gradient(circle at 20% -10%, rgba(72, 214, 186, 0.18), transparent 30%),
    linear-gradient(180deg, #171a20 0%, #0f1115 100%);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin-bottom: 20px;
}

.topbar-title {
  min-width: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
}

.subtitle {
  margin-top: 7px;
  color: var(--muted);
  font-size: 14px;
}

.icon-button,
.round-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--button);
  backdrop-filter: blur(18px);
}

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 16px;
  border-radius: var(--radius);
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.primary-button {
  background: var(--accent);
  color: #06211b;
}

.secondary-button {
  background: var(--button);
  color: var(--text);
}

.danger-button {
  background: rgba(255, 53, 69, 0.16);
  color: #ff9aa3;
}

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

.actions-row > button {
  flex: 1;
}

.script-list {
  display: grid;
  gap: 12px;
}

.script-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  text-align: left;
}

.script-open {
  min-width: 0;
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  text-align: left;
}

.script-title {
  overflow: hidden;
  font-size: 17px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.script-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.card-actions {
  display: flex;
  gap: 8px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 45svh;
  color: var(--muted);
  text-align: center;
}

.form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
}

.text-input,
.text-area {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #181b21;
  color: var(--text);
  outline: none;
}

.text-input {
  height: 48px;
  padding: 0 14px;
}

.text-area {
  min-height: min(58svh, 560px);
  padding: 14px;
  resize: vertical;
  line-height: 1.72;
}

.recorder {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #050609;
}

.camera-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.camera-preview.is-back-camera {
  transform: none;
}

.camera-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.3), transparent 22%),
    linear-gradient(0deg, rgba(0, 0, 0, 0.56), transparent 34%);
}

.record-top {
  position: absolute;
  top: calc(14px + var(--safe-top));
  left: 18px;
  right: 18px;
  display: flex;
  justify-content: space-between;
  z-index: 4;
}

.prompt-box {
  position: absolute;
  z-index: 3;
  top: calc(124px + var(--safe-top));
  left: clamp(18px, 8vw, 52px);
  right: clamp(18px, 8vw, 52px);
  height: min(62svh, 650px);
  overflow: hidden;
  border-radius: 8px;
  background: rgba(20, 20, 22, 0.54);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.prompt-scroll {
  height: 100%;
  overflow: hidden;
  padding: 28px 22px 42px;
  color: rgba(255, 255, 255, 0.88);
  font-size: var(--prompt-size, 30px);
  line-height: 1.62;
  white-space: pre-wrap;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.55);
}

.record-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 22px;
  padding: 16px 30px calc(20px + var(--safe-bottom));
}

.record-button {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: #fff;
  padding: 7px;
}

.record-button::before {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--danger);
  content: "";
}

.record-button.is-recording::before {
  width: 52%;
  height: 52%;
  margin: 24%;
  border-radius: 8px;
}

.control-left,
.control-right {
  display: flex;
  align-items: center;
}

.control-left {
  justify-content: flex-start;
}

.control-right {
  justify-content: flex-end;
}

.finish-button {
  background: rgba(255, 255, 255, 0.24);
}

.countdown {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  place-items: center;
  background: rgba(0, 0, 0, 0.18);
  color: #fff;
  font-size: clamp(86px, 28vw, 150px);
  font-weight: 800;
  text-shadow: 0 5px 36px rgba(0, 0, 0, 0.55);
}

.countdown.is-visible {
  display: grid;
}

.drawer {
  position: absolute;
  z-index: 6;
  left: 12px;
  right: 12px;
  bottom: calc(126px + var(--safe-bottom));
  display: none;
  gap: 16px;
  padding: 16px;
  border-radius: 8px;
  background: var(--panel-strong);
  backdrop-filter: blur(18px);
}

.drawer.is-open {
  display: grid;
}

.setting-row {
  display: grid;
  gap: 8px;
}

.setting-label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.status-pill {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: calc(128px + var(--safe-bottom));
  transform: translateX(-50%);
  display: none;
  max-width: calc(100vw - 36px);
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.56);
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
}

.status-pill.is-visible {
  display: block;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: end center;
  padding: 18px 18px calc(18px + var(--safe-bottom));
  background: rgba(0, 0, 0, 0.56);
}

.dialog {
  width: min(100%, 420px);
  padding: 18px;
  border-radius: 8px;
  background: #1c2028;
}

.dialog h2 {
  margin-bottom: 9px;
}

.dialog p {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.55;
}

.finish-view {
  display: grid;
  gap: 16px;
}

.playback {
  width: 100%;
  max-height: 62svh;
  border-radius: 8px;
  background: #000;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

@media (min-width: 720px) {
  .app-shell {
    padding-left: max(24px, calc((100vw - 720px) / 2));
    padding-right: max(24px, calc((100vw - 720px) / 2));
  }

  .prompt-box {
    left: 50%;
    right: auto;
    width: min(640px, calc(100vw - 96px));
    transform: translateX(-50%);
  }
}

@media (max-width: 380px) {
  h1 {
    font-size: 24px;
  }

  .record-bottom {
    gap: 14px;
    padding-left: 22px;
    padding-right: 22px;
  }

  .record-button {
    width: 78px;
    height: 78px;
  }

  .prompt-scroll {
    padding-left: 18px;
    padding-right: 18px;
  }
}
