/* ==========================================================================
   DESIGN SYSTEM: VISIONOS CRYSTAL FROSTED GLASS (通透液态磨砂玻璃)
   ========================================================================== */
:root {
  --bg-app: #141518;
  --bg-card: rgba(28, 30, 34, 0.28);
  --bg-card-hover: rgba(255, 255, 255, 0.16);
  --border-color: rgba(255, 255, 255, 0.34);
  --border-focus: rgba(255, 255, 255, 0.78);

  /* Pure VisionOS Neutral White Glass & Crisp Accent Tokens */
  --color-primary: #ffffff;
  --color-primary-hover: #f3f4f6;
  --color-secondary: #e5e7eb;
  --color-accent: #f25c2a;
  --color-success: #34d399;
  --color-warning: #fbbf24;
  --color-danger: #fb7185;

  --text-main: rgba(255, 255, 255, 0.94);
  --text-secondary: rgba(255, 255, 255, 0.72);
  --text-muted: rgba(255, 255, 255, 0.54);
  --text-contrast: #ffffff;
  --text-on-light: #121316;

  --grad-primary: rgba(255, 255, 255, 0.92);
  --grad-primary-hover: #ffffff;
  --grad-success: rgba(52, 211, 153, 0.9);
  --grad-danger: rgba(244, 63, 94, 0.88);

  --shadow-card: 0 24px 64px -16px rgba(0, 0, 0, 0.48);
  --shadow-focus: 0 0 0 3px rgba(255, 255, 255, 0.28);
  --border-radius-lg: 28px;
  --border-radius-md: 18px;
  --border-radius-sm: 12px;

  /* Authentic VisionOS Translucent Frosted Glass Tokens (No Internal Gradients) */
  --glass-bg: rgba(30, 30, 34, 0.24);
  --glass-bg-inner: rgba(16, 17, 20, 0.26);
  --glass-border: rgba(255, 255, 255, 0.42);
  --glass-border-top: rgba(255, 255, 255, 0.52);
  --glass-border-left: rgba(255, 255, 255, 0.46);
  --glass-border-inner: rgba(255, 255, 255, 0.28);
  --glass-highlight:
    inset 0 0.5px 0 rgba(255, 255, 255, 0.24),
    inset 0.5px 0 0 rgba(255, 255, 255, 0.14),
    inset 0 -1px 1px rgba(255, 255, 255, 0.12);
  --glass-blur: blur(28px) saturate(165%) brightness(1.04);
  --glass-blur-inner: blur(22px) saturate(155%);

  --transition-smooth: all 0.24s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  position: relative;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-app);
  background-image: url('/bg-studio.jpg');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 26px;
  background: rgba(24, 25, 29, 0.34);
  backdrop-filter: blur(28px) saturate(170%);
  -webkit-backdrop-filter: blur(28px) saturate(170%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.32);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.28), inset 0 -1px 0 rgba(255, 255, 255, 0.16);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.brand-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 12px;
  padding: 2px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.brand h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text-contrast);
}

.brand h1 span {
  font-weight: 400;
  color: var(--text-secondary);
  font-size: 13px;
  margin-left: 8px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-nav-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(24px) saturate(170%);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow:
    inset 0 0.5px 0 rgba(255, 255, 255, 0.24),
    inset 0 -1px 1px rgba(255, 255, 255, 0.1),
    0 6px 18px rgba(0, 0, 0, 0.22);
  color: var(--text-contrast);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-nav-pill i {
  color: rgba(255, 255, 255, 0.92);
  font-size: 13px;
}

.btn-nav-pill:hover {
  background: rgba(255, 255, 255, 0.26);
  border-color: rgba(255, 255, 255, 0.78);
  transform: translateY(-1px);
  box-shadow:
    inset 0 0.5px 0 rgba(255, 255, 255, 0.34),
    inset 0 -1px 1px rgba(255, 255, 255, 0.14),
    0 10px 24px rgba(0, 0, 0, 0.3);
}

.btn-login-header {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(24px) saturate(170%);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  padding: 7px 18px;
  border-radius: 999px;
  border: 1px solid #ffffff;
  box-shadow:
    inset 0 0.5px 0 rgba(255, 255, 255, 0.6),
    0 8px 22px rgba(0, 0, 0, 0.28);
  color: var(--text-on-light);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-login-header i {
  color: var(--text-on-light);
  font-size: 13px;
}

.btn-login-header:hover {
  background: #ffffff;
  border-color: #ffffff;
  transform: translateY(-1px);
  box-shadow:
    inset 0 0.5px 0 rgba(255, 255, 255, 0.75),
    0 12px 28px rgba(0, 0, 0, 0.36);
}

.btn-logout-header {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(244, 63, 94, 0.2);
  backdrop-filter: blur(24px) saturate(170%);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 180, 192, 0.48);
  box-shadow:
    inset 0 0.5px 0 rgba(255, 224, 230, 0.24),
    inset 0 -1px 1px rgba(255, 255, 255, 0.1),
    0 6px 18px rgba(0, 0, 0, 0.22);
  color: var(--text-contrast);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-logout-header i {
  color: #fecdd3;
  font-size: 13px;
}

.btn-logout-header:hover {
  background: rgba(244, 63, 94, 0.34);
  border-color: rgba(255, 210, 218, 0.8);
  transform: translateY(-1px);
  box-shadow:
    inset 0 0.5px 0 rgba(255, 230, 235, 0.32),
    0 10px 24px rgba(0, 0, 0, 0.3);
}

/* Buttons (VisionOS Liquid Glass Capsules) */
.btn {
  padding: 12px 24px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.44);
  backdrop-filter: blur(24px) saturate(170%);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  box-shadow:
    inset 0 0.5px 0 rgba(255, 255, 255, 0.24),
    inset 0 -1px 1px rgba(255, 255, 255, 0.1),
    0 10px 26px -6px rgba(0, 0, 0, 0.34);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  transition: var(--transition-smooth);
}

.btn-primary {
  background: rgba(255, 255, 255, 0.92);
  border-color: #ffffff;
  color: var(--text-on-light);
  box-shadow:
    inset 0 0.5px 0 rgba(255, 255, 255, 0.6),
    0 10px 28px rgba(0, 0, 0, 0.34);
}

.btn-primary:hover:not(:disabled) {
  background: #ffffff;
  border-color: #ffffff;
  transform: translateY(-2px);
  box-shadow:
    inset 0 0.5px 0 rgba(255, 255, 255, 0.75),
    0 14px 34px rgba(0, 0, 0, 0.42);
}

.btn-success {
  background: rgba(52, 211, 153, 0.88);
  border-color: rgba(209, 250, 229, 0.85);
  color: #052e1c;
  box-shadow:
    inset 0 0.5px 0 rgba(255, 255, 255, 0.32),
    0 10px 28px rgba(0, 0, 0, 0.32);
}

.btn-success:hover:not(:disabled) {
  background: rgba(52, 211, 153, 0.98);
  border-color: #ecfdf5;
  transform: translateY(-2px);
  box-shadow:
    inset 0 0.5px 0 rgba(255, 255, 255, 0.42),
    0 14px 32px rgba(0, 0, 0, 0.38);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.42);
  color: var(--text-contrast);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.26);
  border-color: rgba(255, 255, 255, 0.8);
  box-shadow:
    inset 0 0.5px 0 rgba(255, 255, 255, 0.34),
    inset 0 -1px 1px rgba(255, 255, 255, 0.14),
    0 12px 28px rgba(0, 0, 0, 0.34);
  transform: translateY(-1px);
}

.btn-danger-outline {
  background: rgba(244, 63, 94, 0.22);
  border: 1px solid rgba(255, 180, 192, 0.55);
  color: #fff1f2;
}

.btn-danger-outline:hover:not(:disabled) {
  background: rgba(244, 63, 94, 0.38);
  border-color: rgba(255, 218, 224, 0.86);
}

.btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Toast Notifications (replaces native alert) */
.toast-container {
  position: fixed;
  top: 78px;
  right: 24px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast-item {
  background: rgba(24, 25, 30, 0.58);
  backdrop-filter: blur(28px) saturate(170%);
  -webkit-backdrop-filter: blur(28px) saturate(170%);
  border: 1px solid rgba(255, 255, 255, 0.42);
  color: var(--text-contrast);
  padding: 12px 18px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.42), inset 0 0.5px 0 rgba(255, 255, 255, 0.24);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInToast 0.25s ease-out;
  pointer-events: auto;
  max-width: 360px;
}

.toast-item.error {
  border-color: rgba(251, 113, 133, 0.65);
}

.toast-item.success {
  border-color: rgba(52, 211, 153, 0.65);
}

/* Footer */
.site-footer {
  padding: 18px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  border-top: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(20, 21, 25, 0.34);
  backdrop-filter: blur(24px) saturate(165%);
  -webkit-backdrop-filter: blur(24px) saturate(165%);
  margin-top: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.site-footer a:hover {
  color: #ffffff;
}

/* ==========================================================================
   VISIONOS LIQUID FROSTED GLASS, SPECULAR BORDER RIM & 3D TILT (<=4deg)
   ========================================================================== */
.glass-surface {
  position: relative;
  isolation: isolate;
  background: var(--glass-bg) !important;
  backdrop-filter: var(--glass-blur) !important;
  -webkit-backdrop-filter: var(--glass-blur) !important;
  border: 1px solid var(--glass-border) !important;
  border-top-color: var(--glass-border-top) !important;
  border-left-color: var(--glass-border-left) !important;
  box-shadow: var(--shadow-card), var(--glass-highlight) !important;
  transform: perspective(1000px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
  transform-style: preserve-3d;
  will-change: transform;
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.35s ease, border-color 0.35s ease;
}

/* Clean inner frosted slabs resting inside main VisionOS panels */
.panel-box.glass-surface,
.audio-controls-section.glass-surface,
.recite-prompt-card.glass-surface,
.recorder-box.glass-surface,
.diff-tokens-box.glass-surface,
.info-list.glass-surface,
.qr-panel.glass-surface,
.record-row.glass-surface,
.legal-section.glass-surface {
  background: var(--glass-bg-inner) !important;
  backdrop-filter: var(--glass-blur-inner) !important;
  -webkit-backdrop-filter: var(--glass-blur-inner) !important;
  border: 1px solid var(--glass-border-inner) !important;
  border-top-color: rgba(255, 255, 255, 0.36) !important;
  border-left-color: rgba(255, 255, 255, 0.3) !important;
  box-shadow:
    0 14px 32px -10px rgba(0, 0, 0, 0.36),
    inset 0 0.5px 0 rgba(255, 255, 255, 0.16),
    inset 0 -1px 1px rgba(255, 255, 255, 0.08) !important;
}

.glass-surface.glass-active {
  transition: transform 0.12s ease-out, box-shadow 0.25s ease, border-color 0.25s ease;
  box-shadow:
    0 28px 66px -14px rgba(0, 0, 0, 0.56),
    var(--glass-highlight) !important;
}

/* Pure crisp white localized border rim glow near the cursor */
.glass-surface::after {
  content: '';
  position: absolute;
  inset: -1px;
  padding: 1.6px;
  border-radius: inherit;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(
    240px circle at var(--glass-x, 50%) var(--glass-y, 50%),
    rgba(255, 255, 255, 1) 0%,
    rgba(255, 255, 255, 0.72) 32%,
    rgba(255, 255, 255, 0.24) 60%,
    transparent 80%
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  opacity: var(--glass-opacity, 0);
  transition: opacity 0.28s ease;
}

.glass-surface > * {
  position: relative;
  z-index: 1;
}

/* Frosted glass buttons & interactive controls with pure crisp white rim highlight */
.glass-control {
  position: relative;
  isolation: isolate;
}

.glass-control::after {
  content: '';
  position: absolute;
  inset: -1px;
  padding: 1.5px;
  border-radius: inherit;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(
    130px circle at var(--glass-x, 50%) var(--glass-y, 50%),
    rgba(255, 255, 255, 1) 0%,
    rgba(255, 255, 255, 0.65) 45%,
    transparent 76%
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  opacity: var(--glass-opacity, 0);
  transition: opacity 0.22s ease;
}

.glass-control > * {
  position: relative;
  z-index: 1;
}

/* Semantic frosted glass tints on status banners & modals (uniform translucent, no gradients) */
.result-banner.passed.glass-surface {
  background: rgba(16, 185, 129, 0.2) !important;
  border-color: rgba(167, 243, 208, 0.56) !important;
}

.result-banner.failed.glass-surface {
  background: rgba(245, 158, 11, 0.2) !important;
  border-color: rgba(253, 230, 138, 0.54) !important;
}

.modal-panel.glass-surface {
  background: rgba(26, 27, 32, 0.56) !important;
  backdrop-filter: blur(36px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(36px) saturate(180%) !important;
}

.toast-item.glass-surface {
  background: rgba(26, 27, 32, 0.62) !important;
}

/* Recessed VisionOS frosted glass inputs (matches the Search bar in reference) */
.text-input {
  background: rgba(0, 0, 0, 0.24) !important;
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.22) !important;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.22), 0 1px 0 rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.text-input::placeholder {
  color: rgba(255, 255, 255, 0.55);
}

.text-input:focus {
  border-color: rgba(255, 255, 255, 0.72) !important;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.18), inset 0 1px 2px rgba(0, 0, 0, 0.2) !important;
}

@media (prefers-reduced-motion: reduce) {
  .glass-surface {
    transform: none !important;
  }
}

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

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInToast {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 768px) {
  .app-header {
    position: static;
    top: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 12px;
  }

  .header-controls {
    flex-wrap: nowrap;
    justify-content: center;
    gap: 6px;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .header-controls::-webkit-scrollbar {
    display: none;
  }

  .btn-nav-pill,
  .btn-login-header,
  .btn-logout-header {
    padding: 6px 10px;
    font-size: 12px;
    gap: 4px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .btn-nav-pill i,
  .btn-login-header i,
  .btn-logout-header i {
    font-size: 11px;
  }

  .brand h1 {
    font-size: 20px;
  }
}

@media (max-width: 400px) {
  .header-controls {
    gap: 5px;
  }

  .btn-nav-pill,
  .btn-login-header,
  .btn-logout-header {
    padding: 5px 8px;
    font-size: 11px;
    gap: 3px;
  }
}
