/* Modern Typeless Design System - iOS Light Mode */

:root {
  --app-bg: #F3F4F6; /* Soft off-white desktop backdrop */
  --screen-bg: #FAFAFC; /* Native iOS off-white app backdrop */
  --card-bg: #FFFFFF; /* Pure white elements */
  --card-border: #F1F5F9;
  
  --primary-blue: #1E56FC; /* Official Typeless Royal Blue */
  --primary-blue-hover: #1044D9;
  --primary-blue-glow: rgba(30, 86, 252, 0.15);
  
  --record-active: #EF4444; /* High fidelity recording red */
  --record-glow: rgba(239, 68, 68, 0.2);
  
  --text-dark: #0F172A; /* Slate 900 for premium typography */
  --text-slate: #334155; /* Slate 700 */
  --text-muted: #64748B; /* Slate 500 */
  --text-light: #94A3B8; /* Slate 400 */
  
  --transition-ios: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  --font-sans: 'Outfit', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--app-bg);
  font-family: var(--font-sans);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
}

/* Desktop App Container Backdrop */
.viewport-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

/* Smartphone Mockup Frame on Desktop */
.phone-frame {
  width: 420px;
  height: 890px;
  background-color: var(--screen-bg);
  border-radius: 44px;
  border: 12px solid #0F172A; /* Matte graphite metal physical bezel */
  box-shadow: 0 25px 60px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(15, 23, 42, 0.05);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Native full-screen on mobile devices */
@media (max-width: 500px), (max-width: 768px) {
  body {
    background-color: var(--screen-bg);
  }
  .viewport-wrapper {
    padding: 0;
    width: 100%;
    min-height: 100dvh;
  }
  .phone-frame {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }
}

/* Safe Area Top Spacer (Separates safe area from sticky header compositing layer) */
.safe-area-top {
  height: env(safe-area-inset-top, 0px);
  background: #FAFAFC;
  flex-shrink: 0;
  width: 100%;
}

/* App Header styling */
.app-header {
  min-height: 56px;
  height: 56px;
  padding: 0 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #FAFAFC !important;
  background-color: #FAFAFC !important;
  border-bottom: 1px solid rgba(15, 23, 42, 0.03);
  position: sticky;
  top: 0;
  z-index: 100;
  box-sizing: border-box;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  filter: none !important;
}

.header-logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.typeless-logo {
  color: var(--text-dark);
}

.logo-text {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text-dark);
}

/* Premium iOS Toggle Switch */
.ios-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 31px;
}

.ios-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #E2E8F0;
  transition: var(--transition-ios);
  border-radius: 34px;
  display: flex;
  align-items: center;
  padding: 0 6px;
}

.slider::before {
  content: "";
  position: absolute;
  height: 25px;
  width: 25px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: var(--transition-ios);
  border-radius: 50%;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
  z-index: 2;
}

.checkmark-icon {
  position: absolute;
  right: 8px;
  color: white;
  opacity: 0;
  transition: var(--transition-ios);
  z-index: 1;
}

input:checked + .slider {
  background-color: var(--primary-blue);
}

input:checked + .slider::before {
  transform: translateX(21px);
}

input:checked + .slider .checkmark-icon {
  opacity: 1;
  left: 10px;
}

/* Scrollable Container Content */
.app-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 24px; /* Sits cleanly above the fixed action dock sibling */
  -webkit-overflow-scrolling: touch;
}

/* Hide scrollbar */
.app-body::-webkit-scrollbar {
  display: none;
}

/* Tab Switching visibility logic */
.tab-content {
  display: none !important;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

.tab-content.active {
  display: flex !important;
  animation: tab-fade 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#tab-home.active {
  flex: 1;
  min-height: 0;
}

@keyframes tab-fade {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cards System */
.card {
  background-color: var(--card-bg);
  border-radius: 24px;
  padding: 20px;
  border: 1px solid var(--card-border);
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.02);
  transition: var(--transition-ios);
  position: relative;
  overflow: hidden;
}

.card:hover {
  box-shadow: 0 6px 30px rgba(15, 23, 42, 0.04);
}

/* 2x2 Stats Dashboard Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
}

.stat-card {
  background-color: var(--card-bg);
  border-radius: 24px;
  padding: 16px;
  border: 1px solid var(--card-border);
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.02);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 104px;
}

.stat-icon-wrapper {
  margin-bottom: 6px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-dark);
  margin-bottom: 2px;
}

.stat-value .unit {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-slate);
  margin-left: 2px;
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-light);
}

/* Responsive Recorder Parents */
#mobile-recorder-parent {
  display: block;
  width: 100%;
}

#desktop-recorder-parent {
  display: none !important;
}

/* Mobile-First layout: Style of recorder-card inside mobile parent container */
#mobile-recorder-parent .recorder-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  background-color: #FFFFFF;
  border: 1.5px solid rgba(15, 23, 42, 0.05);
  border-radius: 20px;
  padding: 0 16px; /* Letting flexbox center-align items vertically inside the 72px height */
  margin-bottom: 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
  height: 72px;
  width: 100%;
  box-sizing: border-box;
  gap: 12px;
}

#mobile-recorder-parent .record-button-container {
  width: 52px; /* Set to match button dimensions exactly to prevent any overflow or alignment shifts */
  height: 52px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1; /* Centered container takes up remaining space symmetrically */
}

#mobile-recorder-parent .record-btn {
  width: 52px;
  height: 52px;
  box-shadow: 0 6px 16px rgba(30, 86, 252, 0.18);
  margin: 0;
}

#mobile-recorder-parent .btn-icon {
  width: 21px; /* Adjusted icon size 30% larger (from 16px to 21px) */
  height: 21px;
}

#mobile-recorder-parent .timer-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dark);
  text-align: left;
  width: 100px; /* Perfectly symmetrical column widths */
  flex-shrink: 0;
  margin: 0;
  line-height: 1; /* Prevent text line-height baseline pushing */
  display: block;
}

#mobile-recorder-parent .voice-wave-canvas {
  width: 100px;
  height: 30px;
  display: block;
  flex-shrink: 0;
  margin: 0; /* Eradicate the inherited margin-top: 8px to guarantee pixel-perfect vertical centering */
}

#mobile-recorder-parent .voice-wave-canvas.hidden {
  display: none;
}

#mobile-recorder-parent .ai-progress-container {
  width: 100px; /* Matches symmetrical 100px column width */
  height: 6px;
  display: block;
  flex-shrink: 0;
  margin: 0; /* Clean centering in flexbox row */
  background-color: #E2E8F0;
  border-radius: 99px;
  overflow: hidden;
}

#mobile-recorder-parent .ai-progress-container.hidden {
  display: none;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: #F8FAFC;
  padding: 4px 12px;
  border-radius: 99px;
  border: 1px solid #F1F5F9;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--primary-blue);
  box-shadow: 0 0 8px var(--primary-blue-glow);
}

.status-text {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-slate);
  letter-spacing: 0.01em;
}

/* Central Record Circle Trigger */
.record-button-container {
  position: relative;
  width: 86px;
  height: 86px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px 0;
}

.record-btn {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: none;
  padding: 0; /* Reset default browser button padding to guarantee mathematical centering */
  background: var(--primary-blue);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 3;
  box-shadow: 0 8px 24px rgba(30, 86, 252, 0.3);
  transition: var(--transition-ios);
}

.record-btn:active {
  transform: scale(0.95);
  box-shadow: 0 4px 15px rgba(30, 86, 252, 0.2);
}

/* Record Button Loading State */
.record-btn.state-loading,
.recorder-card.state-loading .record-btn {
  background-color: var(--record-active) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35) !important;
  cursor: wait !important;
}

.record-btn.state-loading .pulse-ring,
.record-btn.state-loading .pulse-ring-outer {
  display: none !important;
}

.btn-icon {
  width: 26px;
  height: 26px;
  transition: none !important;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.spinner {
  animation: spin 0.8s linear infinite !important;
}

.btn-icon.hidden,
.btn-icon.hidden * {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  width: 0 !important;
  height: 0 !important;
  transition: none !important;
  transform: none !important;
}

/* Capsule Recording State Pulse Wave Animations */
.capsule-pulse-ring, .capsule-pulse-ring-outer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 30px;
  border: 1.5px solid rgba(239, 68, 68, 0.5); /* Softened transparent red border */
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

#webapp-record-capsule.state-recording .capsule-pulse-ring,
#popup-record-capsule.state-recording .capsule-pulse-ring {
  animation: capsule-pulse-ring-anim 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

#webapp-record-capsule.state-recording .capsule-pulse-ring-outer,
#popup-record-capsule.state-recording .capsule-pulse-ring-outer {
  animation: capsule-pulse-ring-anim 2s cubic-bezier(0.215, 0.61, 0.355, 1) 0.6s infinite;
}

@keyframes capsule-pulse-ring-anim {
  0% {
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    opacity: 0; /* Fully hidden inside the button at start */
  }
  30% {
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    opacity: 0.8; /* Emerge smoothly just outside the edge */
  }
  100% {
    top: -12px;
    left: -12px;
    right: -12px;
    bottom: -12px;
    opacity: 0;
  }
}

.button-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

/* Animated Ring Ripple effects */
.pulse-ring, .pulse-ring-outer {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--primary-blue);
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  transition: var(--transition-ios);
}

.pulse-ring {
  animation: none;
}

.pulse-ring-outer {
  animation: none;
}

/* Recording State Classes */
.recorder-card.state-recording .status-dot {
  background-color: var(--record-active);
  animation: blink-dot 1s ease-in-out infinite;
  box-shadow: 0 0 8px var(--record-glow);
}

.recorder-card.state-recording .record-btn {
  background: var(--record-active);
  box-shadow: 0 10px 30px rgba(239, 68, 68, 0.35);
}

.recorder-card.state-recording .pulse-ring {
  border-color: var(--record-active);
  animation: pulse-ring-anim 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

.recorder-card.state-recording .pulse-ring-outer {
  border-color: var(--record-active);
  animation: pulse-ring-anim 2s cubic-bezier(0.215, 0.61, 0.355, 1) 0.6s infinite;
}

@keyframes pulse-ring-anim {
  0% { transform: scale(0.85); opacity: 0.8; }
  100% { transform: scale(1.4); opacity: 0; }
}

@keyframes blink-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.timer-display, .timer-text {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-dark);
}

.hint-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
  text-align: center;
}

/* Editor Workspace and Input styling */
.editor-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dark);
}

.btn-action-icon {
  background-color: #F8FAFC;
  border: 1px solid #F1F5F9;
  color: var(--primary-blue);
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-ios);
}

.btn-action-icon:hover {
  background-color: #F1F5F9;
}

.editor-container {
  width: 100%;
  position: relative;
}

textarea {
  width: 100%;
  border: none;
  resize: none;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.6;
  color: var(--text-slate);
  background: transparent;
  outline: none;
}

textarea::placeholder {
  color: var(--text-light);
}

/* iOS Standard Buttons */
.btn-primary-blue {
  background-color: var(--primary-blue);
  color: white;
  border: none;
  width: 100%;
  height: 48px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 6px 20px var(--primary-blue-glow);
  transition: var(--transition-ios);
}

.btn-primary-blue:hover:not(:disabled) {
  background-color: var(--primary-blue-hover);
}

.btn-primary-blue:disabled {
  background-color: #F1F5F9;
  color: var(--text-light);
  box-shadow: none;
  cursor: not-allowed;
}

/* Limit & Upgrade Card */
.limit-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.limit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.limit-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dark);
}

.limit-count {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-slate);
  display: flex;
  align-items: center;
  gap: 4px;
}

.info-icon {
  color: var(--text-light);
}

.progress-bar-wrapper {
  height: 8px;
  background-color: #F1F5F9;
  border-radius: 99px;
  overflow: hidden;
  width: 100%;
}

.progress-bar {
  height: 100%;
  background-color: var(--text-slate); /* Sleek slate grey bar as in screenshot */
  border-radius: 99px;
  transition: width 0.5s ease;
}

.limit-desc {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
  line-height: 1.5;
}

.btn-primary-blue-block {
  background-color: var(--primary-blue);
  color: white;
  border: none;
  width: 100%;
  height: 48px;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 15px var(--primary-blue-glow);
  transition: var(--transition-ios);
}

.btn-primary-blue-block:hover {
  background-color: var(--primary-blue-hover);
}

/* Promo Card layout */
.promo-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #F8FAFC;
  position: relative;
}

.promo-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2;
}

.promo-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dark);
}

.btn-light-gray {
  background-color: var(--card-bg);
  color: var(--text-slate);
  border: 1px solid var(--card-border);
  padding: 8px 16px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  width: fit-content;
  transition: var(--transition-ios);
}

.btn-light-gray:hover {
  background-color: #F1F5F9;
}

.promo-watermark {
  position: absolute;
  right: 15px;
  bottom: -4px;
  display: flex;
  gap: 10px;
  pointer-events: none;
  z-index: 1;
}

/* Tab Header Card */
.tab-header-card {
  background-color: transparent;
  box-shadow: none;
  border: none;
  padding: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-sync:hover {
  background-color: rgba(30, 86, 252, 0.08) !important;
  border-color: rgba(30, 86, 252, 0.4) !important;
}

@keyframes spin-sync {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.spinning-sync {
  animation: spin-sync 1.2s linear infinite;
}

.section-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text-dark);
}

.section-desc {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
  line-height: 1.5;
}

/* History Content layout */
.history-list-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 14px;
  color: var(--text-light);
  text-align: center;
}

.history-empty p {
  font-size: 14px;
  font-weight: 500;
}

.history-item {
  background-color: var(--card-bg);
  border-radius: 20px;
  padding: 16px;
  border: 1px solid var(--card-border);
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.01);
  cursor: pointer;
  transition: var(--transition-ios);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(15, 23, 42, 0.03);
  border-color: #E2E8F0;
}

.history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-time {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
}

.history-item-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background-color: rgba(30, 86, 252, 0.08);
  color: var(--primary-blue);
}

.history-item-badge.draft {
  background-color: #F1F5F9;
  color: var(--text-muted);
}

.history-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-slate);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-comparison {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background-color: #F8FAFC;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 11px;
  color: var(--text-muted);
  border: 1px dashed #E2E8F0;
}

.history-comparison-title {
  font-weight: 700;
  color: var(--text-slate);
}

/* Dictionary Rules layout */
.dictionary-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.dict-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dict-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-dark);
}

.dict-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dict-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 10px;
  gap: 12px;
  color: var(--text-light);
  text-align: center;
}

.dict-empty p {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
}

.dict-rule-item {
  background-color: #F8FAFC;
  border: 1px solid #F1F5F9;
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dict-rule-words {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  flex: 1;
  width: 100%;
}

.dict-word-box {
  background-color: white;
  border: 1px solid #E2E8F0;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-slate);
  word-break: break-word; /* Prevents overflow of any long hand-corrected sentences */
  line-height: 1.4;
  width: 100%;
  box-sizing: border-box;
}

.dict-word-box.corrected {
  border-color: rgba(30, 86, 252, 0.2);
  color: var(--primary-blue);
  background-color: rgba(30, 86, 252, 0.02);
  word-break: break-word;
  line-height: 1.4;
  width: 100%;
  box-sizing: border-box;
}

.dict-arrow {
  color: #94A3B8;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
}

.dict-badge {
  font-size: 10px;
  font-weight: 700;
  color: #10B981;
  background-color: rgba(16, 185, 129, 0.1);
  padding: 3px 8px;
  border-radius: 6px;
}

/* AI Distilled Lexicon Cards */
.dict-distilled-card {
  background-color: #FFFFFF;
  border: 1.2px solid #E2E8F0;
  border-radius: 14px;
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.dict-distilled-card:hover {
  border-color: rgba(121, 40, 202, 0.3);
  box-shadow: 0 4px 12px rgba(121, 40, 202, 0.06);
}

.dict-distilled-card.expanded {
  border-color: rgba(121, 40, 202, 0.4);
  background-color: #FAF8FF;
}

.dict-distilled-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.dict-distilled-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}

.dict-distilled-pair {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

.dict-distilled-from {
  color: #64748B;
  background-color: #F1F5F9;
  padding: 3px 8px;
  border-radius: 6px;
}

.dict-distilled-to {
  color: #7928CA;
  background-color: rgba(121, 40, 202, 0.08);
  padding: 3px 8px;
  border-radius: 6px;
}

.category-badge {
  font-size: 11px;
  font-weight: 600;
  color: #0284C7;
  background-color: #E0F2FE;
  padding: 3px 8px;
  border-radius: 99px;
  white-space: nowrap;
}

.dict-expand-arrow {
  color: #94A3B8;
  font-size: 12px;
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.dict-distilled-card.expanded .dict-expand-arrow {
  transform: rotate(180deg);
  color: #7928CA;
}

.dict-distilled-body {
  display: none;
  padding: 0 16px 14px 16px;
  border-top: 1px dashed #E2E8F0;
  margin-top: 2px;
  padding-top: 12px;
  flex-direction: column;
  gap: 10px;
}

.dict-distilled-card.expanded .dict-distilled-body {
  display: flex;
}

.distilled-detail-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  line-height: 1.5;
}

.distilled-detail-label {
  font-weight: 700;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 4px;
}

.distilled-example-box {
  background-color: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: #334155;
}

.distilled-example-box strong {
  color: #7928CA;
}

.distilled-condition-box {
  background-color: #FFFBEB;
  border: 1px solid #FEF3C7;
  color: #B45309;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12.5px;
}

.distilled-actions-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.btn-distill-delete {
  background: transparent;
  border: 1px solid #FCA5A5;
  color: #DC2626;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-distill-delete:hover {
  background-color: #FEF2F2;
}

.btn-distill-action.loading svg {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Account styling */
.account-details-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.account-user-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.user-avatar-wrapper {
  display: flex;
  align-items: center;
  gap: 16px;
}

.avatar-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background-color: rgba(30, 86, 252, 0.1);
  color: var(--primary-blue);
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dark);
}

.user-email {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-light);
}

.user-status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.15);
  color: #059669;
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  width: fit-content;
}

.pulse-dot-green {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #10B981;
  animation: blink-dot 1s ease-in-out infinite;
}

.account-info-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.info-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-dark);
  border-bottom: 1px solid #F1F5F9;
  padding-bottom: 8px;
  margin-bottom: 4px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid #FAFBFD;
  font-size: 13px;
}

.info-row.border-none {
  border-bottom: none;
  padding-bottom: 0;
}

.info-label {
  font-weight: 500;
  color: var(--text-light);
}

.info-value {
  font-weight: 600;
  color: var(--text-slate);
}

.info-value.text-blue {
  color: var(--primary-blue);
}

.info-value.text-mono {
  font-family: monospace;
  font-size: 12px;
}

/* Advanced Collapsible Details Area */
.details-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  gap: 0;
}

.details-toggle-btn {
  background: transparent;
  border: none;
  width: 100%;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-slate);
  transition: var(--transition-ios);
}

.details-toggle-btn:hover {
  background-color: #F8FAFC;
}

.chevron-icon {
  color: var(--text-light);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.details-card.collapsed .chevron-icon {
  transform: rotate(-90deg);
}

.details-content {
  overflow: hidden;
  max-height: 800px;
  transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  border-top: 1px solid var(--card-border);
}

.details-card.collapsed .details-content {
  max-height: 0;
}

.comparison-grid {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.comparison-pane {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.comparison-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-light);
  text-transform: uppercase;
}

.text-pane {
  background-color: #F8FAFC;
  border: 1px solid #F1F5F9;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-slate);
  line-height: 1.5;
}

.sidebar-header {
  display: none;
}

/* Premium Navigation Tab Bar */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
  background-color: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(15, 23, 42, 0.05);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 10px;
  padding-bottom: 12px; /* iOS home bar safe area padding */
  z-index: 100;
}

.nav-tab {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-light);
  cursor: pointer;
  width: 70px;
  height: 100%;
  transition: var(--transition-ios);
}

.nav-tab svg {
  transition: var(--transition-ios);
}

.nav-tab span {
  font-size: 10px;
  font-weight: 700;
}

.nav-tab:hover {
  color: var(--text-slate);
}

.nav-tab.active {
  color: var(--primary-blue);
}

.nav-tab.active svg {
  transform: translateY(-2px);
}

/* Toast Notifications Container (Moved to Top to prevent blocking active bottom buttons) */
.toast-container {
  position: fixed;
  top: max(calc(env(safe-area-inset-top, 0px) + 12px), 24px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 10000;
  max-width: 380px;
  width: calc(100% - 48px);
}

.toast {
  background-color: white;
  color: var(--text-dark);
  border-radius: 16px;
  padding: 12px 18px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  border: 1px solid #F1F5F9;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 600;
  animation: slide-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.toast-success {
  border-left: 4px solid #10B981;
}

.toast-success .toast-icon {
  color: #10B981;
}

.toast-error {
  border-left: 4px solid #EF4444;
}

.toast-error .toast-icon {
  color: #EF4444;
}

.toast-info {
  border-left: 4px solid var(--primary-blue);
}

.toast-info .toast-icon {
  color: var(--primary-blue);
}

@keyframes slide-in {
  from { transform: translateY(-30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes logo-sway {
  from { transform: rotate(-5deg); }
  to { transform: rotate(5deg); }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Custom Copy & Translate Action Buttons (Pill Replica) */
.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.editor-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-dark);
}

.btn-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background-color: #FFFFFF;
  border: 1px solid #E2E8F0; /* Soft light-grey border */
  border-radius: 99px; /* Pill shape matching reference */
  padding: 6px 16px;
  height: 36px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-blue); /* Royal Blue text */
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.02); /* Soft shadow */
  transition: var(--transition-ios);
}

.btn-copy:hover {
  background-color: #F8FAFC;
  border-color: #CBD5E1;
  transform: translateY(-1px);
}

.btn-copy:active {
  transform: scale(0.97);
}

.btn-copy:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-copy svg {
  color: var(--primary-blue); /* Royal Blue icon */
  flex-shrink: 0;
}

/* Dynamic AI Processing Progress Bar style */
.ai-progress-container {
  width: 120px;
  height: 6px;
  background-color: #E2E8F0;
  border-radius: 99px;
  overflow: hidden;
  margin-top: 6px;
  position: relative;
  transition: opacity 0.3s ease;
}

.ai-progress-container.hidden {
  display: none !important;
  opacity: 0;
}

.ai-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary-blue), #4F46E5, var(--primary-blue));
  background-size: 200% auto;
  border-radius: 99px;
  box-shadow: 0 0 6px var(--primary-blue-glow);
  transition: width 0.3s cubic-bezier(0.1, 0.8, 0.2, 1);
  animation: shine-progress 1.5s linear infinite;
}

@keyframes shine-progress {
  from { background-position: 0% center; }
  to { background-position: 200% center; }
}

/* ==========================================================================
   DESKTOP APP & RESPONSIVE GRID TRANSFORMATION
   ========================================================================== */
@media (min-width: 900px) {
  /* Back canvas desktop body */
  body {
    background-color: #F1F5F9;
    background-image: radial-gradient(at 0% 0%, rgba(226, 232, 240, 0.5) 0px, transparent 50%),
                      radial-gradient(at 50% 0%, rgba(241, 245, 249, 0.3) 0px, transparent 50%);
  }

  /* Spacious viewport container */
  .viewport-wrapper {
    padding: 40px;
    height: 100vh;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  /* Overwrite mobile physical device mockup into float desktop window frame */
  .phone-frame {
    width: 100%;
    max-width: 1200px;
    height: 800px;
    background-color: var(--screen-bg);
    border-radius: 28px;
    border: 1px solid #E2E8F0;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08), 0 0 0 1px rgba(15, 23, 42, 0.02);
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-rows: 72px 1fr auto; /* Desktop Grid: Header, Scrollable Body, Fixed Action capsule */
    overflow: hidden;
  }

  /* Desktop Left Sidebar Navigation Bar (Transformed from Bottom Nav Bar) */
  .bottom-nav {
    grid-column: 1 / 2;
    grid-row: 1 / span 3; /* Spans across all 3 grid rows on desktop sidebar */
    position: static;
    width: 100%;
    height: 100%;
    background-color: #FFFFFF;
    border-right: 1px solid #E2E8F0;
    border-top: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    padding: 28px 20px;
    padding-bottom: 28px;
    gap: 8px;
    z-index: 50;
    backdrop-filter: none;
  }

  /* Sidebar header logo section (Hidden on mobile, block on desktop) */
  .sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
    padding-left: 8px;
    color: var(--text-dark);
  }

  .sidebar-header .typeless-logo {
    /* Static icon per user preference */
  }

  .sidebar-header .logo-text {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.04em;
  }

  /* Transformed Vertical Menu Navigation Tabs */
  .nav-tab {
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 14px;
    width: 100%;
    height: 48px;
    padding: 0 16px;
    border-radius: 12px;
    color: var(--text-light);
    transition: var(--transition-ios);
  }

  .nav-tab:hover {
    background-color: #F8FAFC;
    color: var(--text-slate);
  }

  .nav-tab.active {
    background-color: #EEF2F6;
    color: var(--primary-blue);
  }

  .nav-tab span {
    font-size: 13px;
    font-weight: 600;
  }

  .nav-tab svg {
    width: 20px;
    height: 20px;
  }

  .nav-tab.active svg {
    transform: none; /* remove mobile vertical translate nudge */
  }

  .safe-area-top {
    display: none;
  }

  /* Desktop Top Header Bar */
  .app-header {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    background-color: var(--screen-bg);
    border-bottom: 1px solid rgba(15, 23, 42, 0.04);
    height: 100% !important;
    min-height: 0;
    padding: 0 36px;
    position: static;
    display: flex;
    justify-content: flex-end; /* Right-align the header action cluster */
  }

  /* Responsive parent toggle inside desktop view */
  #mobile-recorder-parent {
    display: block !important;
    grid-column: 2 / 3;
    grid-row: 3 / 4;
    width: 100% !important;
    max-width: 800px;
    margin: 0 auto !important;
    padding: 0 36px 20px 36px !important;
    box-sizing: border-box;
    background-color: var(--screen-bg) !important;
    z-index: 100;
  }

  #desktop-recorder-parent {
    display: none !important;
  }

  /* Desktop layout: Style of recorder-card inside desktop parent container */
  #desktop-recorder-parent .recorder-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    background-color: #F8FAFC;
    border: 1px solid #F1F5F9;
    padding: 4px 12px;
    border-radius: 99px;
    gap: 10px;
  }

  #desktop-recorder-parent .record-button-container {
    width: 38px;
    height: 38px;
    margin: 0;
  }

  #desktop-recorder-parent .record-btn {
    width: 32px;
    height: 32px;
    box-shadow: 0 4px 12px rgba(30, 86, 252, 0.15);
  }

  #desktop-recorder-parent .btn-icon {
    width: 14px;
    height: 14px;
  }

  #desktop-recorder-parent .timer-text {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-dark);
  }

  #desktop-recorder-parent .ai-progress-container {
    width: 60px;
    height: 4px;
    margin-top: 0;
  }

  /* Flex cluster inside the header action */
  .header-action {
    display: flex;
    align-items: center;
    gap: 16px;
  }

  /* Hide mobile-specific logo area on desktop */
  .app-header .header-logo-area {
    display: none;
  }

  /* Scrollable Workspace Container area */
  .app-body {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
    height: 100%;
    overflow-y: auto;
    padding: 36px 40px;
    padding-bottom: 36px; /* No need to reserve space for bottom nav on desktop */
  }

  .tab-content {
    padding-bottom: 24px; /* standard padding for desktop scroll margins */
  }

  /* Home Tab Maximized Single Column Vertical Layout */
  #tab-home {
    display: flex;
    flex-direction: column;
    gap: 24px;
    align-items: stretch;
  }

  /* Main Large Text Editor Card (Fully Maximized) */
  #tab-home .editor-card {
    width: 100%;
    min-height: 480px;
    display: flex;
    flex-direction: column;
    background-color: #FFFFFF;
  }

  #output-textarea {
    flex: 1 !important;
    min-height: 280px !important;
  }

  /* Advanced Collapsible Comparison Details (Span full width) */
  #tab-home .details-card {
    width: 100%;
  }

  /* Stats Grid spans 4 elements horizontally on desktop dashboard */
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }

  .stat-card {
    min-height: 110px;
    padding: 20px;
  }

  /* Increase textarea editor min-height for desktop */
  .editor-textarea {
    min-height: 320px !important;
  }
}

/* ==========================================================================
   Premium Suite Upgrades Styling (Live Waveforms, Profiles, Diff, Search)
   ========================================================================== */

/* 1. Voice Waveform Canvas */
.voice-wave-canvas {
  background-color: transparent;
  border-radius: 8px;
}
.voice-wave-canvas.hidden {
  display: none !important;
}

/* Perfect Exclusive Mutual State Selector: If progress bar is visible, unconditionally hide the voice wave canvas */
#ai-progress-wrapper:not(.hidden) ~ #voice-wave-canvas {
  display: none !important;
}

#ai-progress-wrapper {
  display: none !important;
}

#mobile-recorder-parent .voice-wave-canvas {
  width: 180px;
  height: 40px;
  margin-top: 8px;
}

#desktop-recorder-parent .voice-wave-canvas {
  width: 70px;
  height: 20px;
  margin-left: 2px;
}

/* 2. Silence / Low Volume Warning */
.silence-warning {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: #FEF2F2;
  color: #EF4444;
  border: 1px solid #FEE2E2;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 6px;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.08);
  animation: soft-pulse 2s infinite ease-in-out;
}
.silence-warning svg {
  flex-shrink: 0;
}
.silence-warning.hidden {
  display: none !important;
}

@keyframes soft-pulse {
  0% { opacity: 0.7; transform: scale(0.98); }
  50% { opacity: 1; transform: scale(1); }
  100% { opacity: 0.7; transform: scale(0.98); }
}

/* 3. Style Profile Switcher Capsules */
.style-profile-selector {
  display: flex;
  gap: 4px;
  background-color: #F1F5F9;
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
}
.style-profile-selector::-webkit-scrollbar {
  display: none; /* Safari & Chrome */
}

.profile-btn {
  flex: 1;
  min-width: fit-content;
  border: none;
  background: transparent;
  color: #64748B;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}
.profile-btn:hover {
  color: #334155;
  background-color: rgba(255, 255, 255, 0.4);
}
.profile-btn.active {
  color: #1E56FC;
  background-color: #FFFFFF;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
}

/* 4. Interactive Diff Highlights */
.diff-delete {
  background-color: #FEE2E2;
  color: #EF4444;
  text-decoration: line-through;
  padding: 0 2px;
  border-radius: 3px;
  margin: 0 1px;
}
.diff-insert {
  background-color: #D1FAE5;
  color: #059669;
  font-weight: 600;
  padding: 0 2px;
  border-radius: 3px;
  margin: 0 1px;
}

/* 5. Smart History Search Bar */
.search-box-container {
  margin-bottom: 14px;
  width: 100%;
}
.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background-color: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  padding: 0 12px;
  height: 40px;
  transition: all 0.2s ease;
}
.search-input-wrapper:focus-within {
  border-color: #1E56FC;
  box-shadow: 0 0 0 3px rgba(30, 86, 252, 0.1);
}
.search-icon {
  color: #94A3B8;
  margin-right: 8px;
  flex-shrink: 0;
}
#history-search-input {
  border: none;
  background: transparent;
  width: 100%;
  height: 100%;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dark);
  outline: none;
}
#history-search-input::placeholder {
  color: #94A3B8;
}
.clear-search-btn {
  border: none;
  background: #F1F5F9;
  color: #64748B;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.clear-search-btn:hover {
  background-color: #E2E8F0;
  color: #0F172A;
}
.clear-search-btn.hidden {
  display: none !important;
}
/* Premium Apple-like Reset Statistics Button */
.btn-reset {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background-color: transparent;
  color: #EF4444; /* iOS alert red */
  border: 1px solid rgba(239, 68, 68, 0.2);
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-ios);
}

.btn-reset:hover {
  background-color: rgba(239, 68, 68, 0.05);
  border-color: #EF4444;
}

.btn-reset:active {
  transform: scale(0.97);
}

.btn-reset svg {
  transition: transform 0.4s ease;
}

.btn-reset:hover svg {
  transform: rotate(-180deg);
}

/* Individual Rule Delete Button */
.btn-rule-delete {
  border: none;
  background: transparent;
  color: #94A3B8;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
}

.btn-rule-delete:hover {
  background-color: rgba(239, 68, 68, 0.08);
  color: #EF4444;
}

.btn-rule-delete:active {
  transform: scale(0.9);
}

/* ==========================================================================
   🔑 Premium Light-Themed Password Login Styles (iOS/Apple Aesthetic)
   ========================================================================== */
.login-overlay-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(241, 245, 249, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  box-sizing: border-box;
  animation: fadeInOverlay 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInOverlay {
  from { opacity: 0; }
  to { opacity: 1; }
}

.login-card {
  width: 100%;
  max-width: 380px;
  background-color: #ffffff;
  border-radius: 32px;
  padding: 40px 32px;
  box-shadow: 
    0 10px 40px -10px rgba(15, 23, 42, 0.08),
    0 0 1px 1px rgba(15, 23, 42, 0.03);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-sizing: border-box;
  transform: scale(0.98) translateY(10px);
  animation: scaleInCard 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes scaleInCard {
  to {
    transform: scale(1) translateY(0);
  }
}

.login-logo-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
}

.animated-logo {
  animation: wavePulse 2.5s ease-in-out infinite alternate;
}

@keyframes wavePulse {
  0% { transform: scale(0.96); opacity: 0.9; }
  100% { transform: scale(1.04); opacity: 1; }
}

.login-title {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Outfit", "Segoe UI", sans-serif;
  font-size: 28px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.5px;
  margin: 0 0 4px 0;
}

.login-subtitle {
  font-size: 14px;
  font-weight: 500;
  color: #64748b;
  margin: 0;
}

.login-divider {
  width: 40px;
  height: 3px;
  background-color: #e2e8f0;
  border-radius: 2px;
  margin-bottom: 20px;
}

.login-instruction {
  font-size: 14px;
  font-weight: 600;
  color: #475569;
  margin: 0 0 20px 0;
}

.login-footer {
  font-size: 12px;
  font-weight: 500;
  color: #94a3b8;
  margin-top: 10px;
}

/* -------------------------------------------------------------
   ADVANCED MOBILE OVERRIDES (Placing at the bottom ensures 
   highest CSS cascade override priority for absolute pixel perfection)
   ------------------------------------------------------------- */
@media (max-width: 900px) {
  html, body {
    height: 100% !important;
    height: 100dvh !important;
    min-height: 0 !important;
    align-items: stretch !important;
    overflow: hidden !important;
    overscroll-behavior: none !important;
    position: fixed !important;
    width: 100% !important;
    top: 0 !important;
    left: 0 !important;
    background-color: var(--screen-bg) !important;
  }
  .viewport-wrapper {
    height: 100% !important;
    height: 100dvh !important;
    overflow: hidden !important;
    padding: 0 !important;
    width: 100% !important;
  }
  .phone-frame {
    height: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
    width: 100% !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: column !important;
  }
  .safe-area-top {
    height: 0 !important;
    background-color: var(--screen-bg) !important;
    flex-shrink: 0 !important;
  }
  .app-header {
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 16px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    background-color: var(--screen-bg) !important;
    background: var(--screen-bg) !important;
    border-bottom: none !important;
    flex-shrink: 0 !important;
    position: relative !important;
    z-index: 100 !important;
  }
  .app-body {
    padding: 6px 16px 4px 16px !important;
    gap: 6px !important;
    min-height: 0 !important;
    flex: 1 !important;
    overflow-y: auto !important;
    overscroll-behavior-y: contain !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .tab-content {
    display: none !important;
    gap: 6px !important;
    padding-bottom: 0px !important;
  }
  .tab-content.active {
    display: flex !important;
  }

  /* Style Profile Selector grid */
  .style-profile-selector {
    gap: 6px !important;
    margin-bottom: 0px !important;
    flex-shrink: 0 !important;
  }
  .profile-btn {
    padding: 7px 6px !important;
    font-size: 12px !important;
    border-radius: 12px !important;
  }

  /* Home Tab and full vertical expansion of text editor card */
  #tab-home.active {
    flex: 1 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    padding-bottom: 0 !important;
    gap: 6px !important;
  }

  #webapp-editor-card {
    flex: 1 !important;
    min-height: 0 !important;
    padding: 12px 14px !important;
    border-radius: 20px !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
  }

  #output-textarea {
    flex: 1 !important;
    min-height: 0 !important;
    height: 100% !important;
    font-size: 15px !important;
    line-height: 1.55 !important;
    overflow-y: auto !important;
  }

  /* Details Card (顯示進階對照分析) */
  #details-card {
    margin: 0 !important;
    border-radius: 16px !important;
    flex-shrink: 0 !important;
  }
  #details-card .card-header {
    padding: 9px 14px !important;
  }

  /* Mobile floating recorder dock */
  #mobile-recorder-parent {
    position: relative !important;
    bottom: auto !important;
    padding: 0 16px !important;
    margin-bottom: 6px !important;
    flex-shrink: 0 !important;
  }

  #shared-recorder {
    padding: 7px 12px !important;
    border-radius: 20px !important;
  }
  #shared-recorder .action-btn {
    height: 44px !important;
    border-radius: 14px !important;
  }
  #shared-recorder .action-btn svg {
    width: 18px !important;
    height: 18px !important;
  }
  #shared-recorder .action-btn span {
    font-size: 10px !important;
    font-weight: 700 !important;
  }
  #record-btn {
    width: 48px !important;
    height: 48px !important;
  }

  /* Bottom Navigation - unified 16px horizontal margin & shifted downwards towards home indicator */
  .bottom-nav {
    position: relative !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    height: auto !important;
    min-height: 62px !important;
    padding-top: 6px !important;
    padding-bottom: max(calc(env(safe-area-inset-bottom, 0px) - 12px), 22px) !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
    background-color: rgba(255, 255, 255, 0.98) !important;
    border-top: 1px solid rgba(15, 23, 42, 0.05) !important;
    z-index: 100 !important;
    flex-shrink: 0 !important;
  }
  .nav-tab {
    height: auto !important;
    gap: 3px !important;
    padding: 0 !important;
  }
  .nav-tab svg {
    width: 21px !important;
    height: 21px !important;
  }
  .nav-tab span {
    font-size: 10px !important;
    font-weight: 700 !important;
    line-height: 1.1 !important;
  }

  /* Compact space-saving editor header */
  .editor-header {
    gap: 4px !important;
    margin-bottom: 8px !important;
  }
  .editor-title {
    font-size: 15px !important;
    font-weight: 700 !important;
  }
  .btn-copy {
    padding: 4px 10px !important;
    font-size: 11.5px !important;
    height: 32px !important;
    gap: 4px !important;
  }
  .btn-copy svg {
    width: 14px !important;
    height: 14px !important;
  }
  
  /* Divider and styling for output footer */
  .editor-footer {
    border-top: 1.5px solid rgba(15, 23, 42, 0.04) !important;
    padding-top: 12px !important;
    margin-top: 4px !important;
  }

  /* Prevent iOS keyboard/accessory bar overlapping the login card and submit button */
  .login-overlay-container {
    align-items: flex-start !important;
    padding-top: 6vh !important;
  }
  .login-card {
    border-radius: 24px !important;
    padding: 32px 24px !important;
    margin: 0 16px !important;
    width: calc(100% - 32px) !important;
  }
}

/* ==========================================================================
   Mockup-Aligned Bottom Action Dock & Settings Drawer Styling
   ========================================================================== */

/* Stylings for the bottom control panel buttons inside #shared-recorder */
.action-btn {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 12px;
}

.action-btn:hover {
  color: var(--primary-blue);
  background-color: rgba(15, 23, 42, 0.03);
}

.action-btn:active {
  transform: scale(0.95);
  background-color: rgba(15, 23, 42, 0.06);
}

/* Ensure disabled buttons like the save/optimize state look clean and inactive */
.action-btn:disabled {
  opacity: 1 !important;
  color: var(--text-muted) !important;
  -webkit-text-fill-color: var(--text-muted) !important;
  cursor: not-allowed;
  background-color: transparent !important;
}

/* Settings Drawer active class triggered programmatically */
#settings-drawer.active {
  bottom: 0 !important;
}

#btn-settings-close:hover {
  background: rgba(15, 23, 42, 0.1) !important;
  color: var(--text-dark) !important;
}

#btn-settings-sync:hover {
  background-color: #1d4ed8 !important; /* Slightly darker slate-blue for premium hover feedback */
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3) !important;
}

#btn-settings-sync:active {
  transform: scale(0.98);
}

@keyframes copy-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

/* iOS-style Switch Toggle for settings */
.switch-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: .25s ease;
  border-radius: 24px;
}
.switch-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .25s ease;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.switch-toggle input:checked + .switch-slider {
  background-color: #2563eb;
}
.switch-toggle input:checked + .switch-slider:before {
  transform: translateX(20px);
}

/* Prevent iOS Safari automatic zoom on text box / input focus */
input,
textarea,
select,
#output-textarea,
#history-search-input,
#ai-model-select,
#stt-engine-select {
  font-size: 16px !important;
  -webkit-text-size-adjust: 100%;
}

@media screen and (max-width: 768px) {
  #output-textarea {
    font-size: 16px !important;
    line-height: 1.6 !important;
  }
}

/* Gemini 3.5 Transcribe Mode Managed Styles */
.managed-by-gemini-35 {
  transition: opacity 0.25s ease, filter 0.25s ease;
  position: relative;
}

.managed-by-gemini-35.is-managed-disabled {
  opacity: 0.42 !important;
  pointer-events: none !important;
  filter: grayscale(0.25);
  user-select: none;
}

.managed-by-gemini-35.is-managed-disabled input,
.managed-by-gemini-35.is-managed-disabled select,
.managed-by-gemini-35.is-managed-disabled .switch-toggle {
  cursor: not-allowed !important;
  pointer-events: none !important;
}

.managed-by-gemini-35.is-managed-disabled label span {
  color: #94a3b8 !important;
}




