:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --soft-card: #f1f5f9;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #06b6d4;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --warning: #f59e0b;
  --error: #dc2626;
  --shadow: 0 22px 60px rgba(15, 23, 42, 0.12);
  --soft-shadow: 0 12px 36px rgba(15, 23, 42, 0.08);
  --radius: 24px;
  --radius-sm: 18px;
  --nav-height: 76px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 52% -6%, rgba(37, 99, 235, 0.22), transparent 33%),
    radial-gradient(circle at 0% 22%, rgba(6, 182, 212, 0.16), transparent 30%),
    var(--bg);
  color: var(--text);
}

body {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  position: relative;
  width: 100%;
  max-width: 430px;
  min-height: 100dvh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(248, 250, 252, 0.94)),
    var(--bg);
  box-shadow: 0 0 0 1px rgba(226, 232, 240, 0.72);
  overflow: hidden;
}

.screen {
  min-height: 100dvh;
  padding: 18px 18px calc(var(--nav-height) + env(safe-area-inset-bottom) + 24px);
  animation: enter 260ms ease both;
}

.screen.no-nav {
  padding-bottom: calc(22px + env(safe-area-inset-bottom));
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

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

.topbar h1,
.topbar h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0;
}

.icon-btn,
.round-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  color: var(--text);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(226, 232, 240, 0.82);
  box-shadow: var(--soft-shadow);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.mini-logo,
.logo-mark {
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(145deg, var(--primary), var(--accent));
  box-shadow: 0 14px 38px rgba(37, 99, 235, 0.32);
}

.mini-logo {
  width: 38px;
  height: 38px;
  border-radius: 13px;
}

.logo-mark {
  width: 82px;
  height: 82px;
  margin: 10px auto 16px;
  border-radius: 28px;
  position: relative;
}

.logo-mark::after,
.mic-core::after {
  content: "";
  width: 18px;
  height: 32px;
  border-radius: 12px;
  background: currentColor;
  box-shadow: 0 34px 0 -7px currentColor;
}

.logo-mark::before,
.mic-core::before {
  content: "";
  position: absolute;
  width: 42px;
  height: 42px;
  border: 5px solid currentColor;
  border-top: 0;
  border-left-color: transparent;
  border-right-color: transparent;
  border-radius: 0 0 28px 28px;
  transform: translateY(10px);
}

.welcome-screen {
  display: flex;
  align-items: center;
}

.welcome-card,
.glass-card,
.tool-card,
.result-card,
.history-card {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(226, 232, 240, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.welcome-card {
  width: 100%;
  padding: 30px 20px 20px;
  border-radius: 32px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.welcome-card::before {
  content: "";
  position: absolute;
  inset: -90px -80px auto;
  height: 220px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.2), transparent 66%);
}

.welcome-card > * {
  position: relative;
}

.welcome-card h1 {
  margin: 0;
  font-size: clamp(32px, 9vw, 42px);
  line-height: 1;
}

.accent-text {
  color: var(--primary);
}

.subtitle {
  margin: 10px 0 16px;
  color: var(--muted);
  font-size: 15px;
}

.privacy-note,
.offline-banner {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(241, 245, 249, 0.72);
  color: var(--muted);
  padding: 14px;
  font-size: 13px;
  line-height: 1.45;
}

.welcome-list {
  margin: 20px 0;
  display: grid;
  gap: 10px;
  text-align: left;
}

.feature-row {
  min-height: 64px;
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(226, 232, 240, 0.74);
}

.feature-row strong {
  display: block;
  font-size: 13px;
}

.feature-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.feature-icon,
.tool-icon {
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: linear-gradient(145deg, #eff6ff, #ecfeff);
  color: var(--primary);
}

.feature-icon {
  width: 44px;
  height: 44px;
}

.primary-btn,
.secondary-btn,
.danger-btn {
  min-height: 52px;
  width: 100%;
  border-radius: 18px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-btn {
  color: white;
  background: linear-gradient(135deg, var(--primary), #1d4ed8 70%, var(--accent));
  box-shadow: 0 18px 34px rgba(37, 99, 235, 0.3);
}

.secondary-btn {
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
}

.danger-btn {
  color: white;
  background: var(--error);
}

.primary-btn:active,
.secondary-btn:active,
.tool-card:active,
.chip:active,
.nav-item:active,
.icon-btn:active {
  transform: scale(0.97);
}

.hero-copy {
  margin: 12px 0 18px;
}

.hero-copy h2 {
  margin: 0 0 7px;
  font-size: 22px;
  line-height: 1.1;
}

.hero-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

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

.tool-card {
  min-height: 142px;
  border-radius: 22px;
  padding: 14px;
  text-align: left;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.tool-card:focus-visible,
.chip:focus-visible,
.primary-btn:focus-visible,
.secondary-btn:focus-visible,
.nav-item:focus-visible,
.icon-btn:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.24);
  outline-offset: 2px;
}

.tool-icon {
  width: 46px;
  height: 46px;
  margin-bottom: 12px;
  font-size: 23px;
}

.tool-card h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.tool-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: 100%;
  max-width: 430px;
  transform: translateX(-50%);
  padding: 9px 16px calc(9px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: rgba(255, 255, 255, 0.88);
  border-top: 1px solid rgba(226, 232, 240, 0.86);
  backdrop-filter: blur(20px);
  z-index: 20;
}

.nav-item {
  min-height: 56px;
  border-radius: 18px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 700;
}

.nav-item.active {
  color: var(--primary);
  background: #eff6ff;
}

.record-stage {
  text-align: center;
  padding: 18px 0 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--soft-shadow);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.dot.recording {
  background: var(--error);
  box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.55);
  animation: recordingDot 1.8s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}

@keyframes recordingDot {
  0% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5);
  }
  65% {
    opacity: 0.78;
    box-shadow: 0 0 0 6px rgba(220, 38, 38, 0);
  }
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
  }
}

.mic-zone {
  position: relative;
  height: 228px;
  display: grid;
  place-items: center;
  transform: translateZ(0);
}

.ring {
  position: absolute;
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 50%;
  opacity: 0.28;
  transform: scale(0.96);
  transition: opacity 260ms ease;
  will-change: transform, opacity;
  backface-visibility: hidden;
}

.ring:nth-child(1) {
  width: 154px;
  height: 154px;
}

.ring:nth-child(2) {
  width: 196px;
  height: 196px;
  animation-delay: 320ms;
}

.ring:nth-child(3) {
  width: 228px;
  height: 228px;
  animation-delay: 640ms;
}

@keyframes pulse {
  0% {
    transform: scale(0.96);
    opacity: 0.08;
  }
  35% {
    opacity: 0.36;
  }
  100% {
    transform: scale(1.14);
    opacity: 0;
  }
}

@keyframes orbFloat {
  0% {
    transform: translateY(0) scale(1);
    box-shadow:
      0 24px 48px rgba(37, 99, 235, 0.32),
      inset 0 0 0 10px rgba(255, 255, 255, 0.16);
  }
  50% {
    transform: translateY(-2px) scale(1.022);
    box-shadow:
      0 28px 56px rgba(37, 99, 235, 0.4),
      inset 0 0 0 10px rgba(255, 255, 255, 0.18);
  }
  100% {
    transform: translateY(0) scale(1);
    box-shadow:
      0 24px 48px rgba(37, 99, 235, 0.32),
      inset 0 0 0 10px rgba(255, 255, 255, 0.16);
  }
}

.mic-orb {
  width: 126px;
  height: 126px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.7), transparent 22%),
    linear-gradient(145deg, #60a5fa, var(--primary) 68%, #1e40af);
  box-shadow:
    0 24px 48px rgba(37, 99, 235, 0.32),
    inset 0 0 0 10px rgba(255, 255, 255, 0.16);
  position: relative;
  z-index: 2;
  will-change: transform, box-shadow;
  animation: orbFloat 3.6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  backface-visibility: hidden;
  transform: translateZ(0);
}

.mic-core {
  position: relative;
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
}

.wave {
  position: absolute;
  width: 100%;
  max-width: 410px;
  height: 80px;
  color: rgba(6, 182, 212, 0.52);
  overflow: hidden;
}

.wave::before {
  content: "";
  display: block;
  width: 200%;
  height: 100%;
  background: repeating-radial-gradient(ellipse at center, transparent 0 12px, currentColor 13px 14px, transparent 15px 30px);
  opacity: 0.34;
  animation: waveMove 4.4s linear infinite;
}

@keyframes waveMove {
  to {
    transform: translateX(-50%);
  }
}

.mic-zone.is-recording .ring {
  animation: pulse 2.4s cubic-bezier(0.2, 0.7, 0.15, 1) infinite;
}

.mic-zone.is-recording .mic-orb {
  animation-duration: 2.2s;
}

.mic-zone.is-recording .wave::before {
  opacity: 0.52;
  animation-duration: 2.2s;
}

@media (hover: none) and (pointer: coarse) {
  .mic-zone {
    height: 216px;
  }

  .dot.recording {
    animation: none;
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12);
  }

  .mic-orb {
    animation: none;
    transform: translateZ(0) scale(1);
  }

  .mic-zone.is-recording .mic-orb {
    animation: none;
    box-shadow:
      0 22px 42px rgba(37, 99, 235, 0.3),
      0 0 0 12px rgba(96, 165, 250, 0.12),
      inset 0 0 0 10px rgba(255, 255, 255, 0.16);
  }

  .mic-zone.is-recording .ring {
    animation: none;
    opacity: 0.12;
  }

  .wave {
    opacity: 0.6;
  }

  .mic-zone.is-recording .wave::before {
    opacity: 0.12;
    animation: none;
  }
}

.record-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.record-actions.single {
  grid-template-columns: 1fr;
}

.glass-card,
.result-card,
.history-card {
  border-radius: var(--radius);
  padding: 16px;
}

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
  font-size: 13px;
  font-weight: 800;
}

textarea,
input[type="search"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  padding: 13px 14px;
  resize: vertical;
  min-height: 132px;
  line-height: 1.45;
}

input[type="search"] {
  min-height: 48px;
  resize: none;
}

.style-section {
  margin-top: 14px;
}

.style-section h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.chip-row {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  padding-bottom: 5px;
  scrollbar-width: none;
}

.chip-row.wrap {
  flex-wrap: wrap;
  overflow: visible;
}

.chip {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
  font-size: 13px;
  font-weight: 800;
}

.chip.selected {
  color: var(--primary);
  background: #eff6ff;
  border-color: rgba(37, 99, 235, 0.55);
}

.sticky-generate,
.sticky-actions {
  position: sticky;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 10px);
  margin-top: 14px;
  z-index: 10;
}

.result-card {
  display: grid;
  gap: 14px;
  margin-top: 8px;
}

.badge {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border-radius: 999px;
  color: #0e7490;
  background: #ecfeff;
  font-size: 12px;
  font-weight: 800;
}

.result-block {
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.result-block:first-of-type {
  border-top: 0;
}

.result-block h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
}

.result-text {
  white-space: pre-wrap;
  margin: 0;
  line-height: 1.55;
  font-size: 15px;
}

.sticky-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 9px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 20px 36px rgba(37, 99, 235, 0.32);
}

.sticky-actions button {
  min-height: 50px;
  border-radius: 15px;
  color: white;
  background: transparent;
  display: grid;
  place-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 800;
}

.inline-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.history-tools {
  display: grid;
  gap: 12px;
  margin: 12px 0;
}

.history-group {
  margin-top: 16px;
}

.history-group h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-card {
  text-align: left;
  box-shadow: var(--soft-shadow);
}

.history-card.favorite {
  border-color: rgba(245, 158, 11, 0.58);
}

.history-card h4 {
  margin: 0 0 6px;
  font-size: 15px;
}

.history-card p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.card-actions button {
  min-height: 40px;
  border-radius: 14px;
  background: var(--soft-card);
  color: var(--text);
  font-weight: 800;
  font-size: 12px;
}

.settings-panel {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.setting-row {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid var(--border);
}

.setting-row span {
  color: var(--muted);
  font-size: 12px;
}

.toggle {
  width: 54px;
  height: 32px;
  padding: 4px;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 160ms ease;
}

.toggle::before {
  content: "";
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  transition: transform 160ms ease;
}

.toggle.on {
  background: var(--primary);
}

.toggle.on::before {
  transform: translateX(22px);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  width: min(calc(100% - 32px), 398px);
  transform: translate(-50%, calc(100% + 48px));
  opacity: 0;
  pointer-events: none;
  padding: 13px 15px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.92);
  color: white;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: var(--shadow);
  z-index: 60;
  transition: transform 220ms ease, opacity 220ms ease;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

@media (max-width: 370px) {
  .screen {
    padding-left: 14px;
    padding-right: 14px;
  }

  .tool-card {
    min-height: 132px;
    padding: 12px;
  }

  .chip {
    padding: 0 11px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
