/* ============================================
   CSS Custom Properties & Reset
   ============================================ */
:root {
  --color-primary: #4F46E5;
  --color-primary-light: #E0E7FF;
  --color-primary-dark: #4338CA;
  --color-bg: #F9FAFB;
  --color-card: #FFFFFF;
  --color-text: #111827;
  --color-text-secondary: #6B7280;
  --color-text-light: #9CA3AF;
  --color-border: #E5E7EB;
  --color-success: #10B981;
  --color-error: #EF4444;
  --color-warning: #F59E0B;
  --color-info: #3B82F6;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 25px -3px rgba(0,0,0,0.1);
  --font-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  --navbar-height: 52px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
  font-size: calc(100vw / 375 * 16);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-base);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

input, textarea, button {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
}

input:focus, textarea:focus {
  outline: none;
}

/* ============================================
   Layout
   ============================================ */
.page {
  display: none;
  max-width: 480px;
  margin: 0 auto;
  min-height: calc(100vh - var(--navbar-height));
  min-height: calc(100dvh - var(--navbar-height));
  padding: 20px 16px calc(20px + var(--safe-bottom));
  padding-top: calc(var(--navbar-height) + 20px);
}

.page.active {
  display: block;
}

.page.no-navbar {
  padding-top: 20px;
}

/* ============================================
   Navbar
   ============================================ */
.navbar {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--navbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  z-index: 1000;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.nav-back {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text);
  border-radius: 50%;
  transition: background 0.2s;
}

.nav-back:active {
  background: var(--color-border);
}

.navbar.hidden {
  display: none;
}

.nav-back.hidden {
  visibility: hidden;
  pointer-events: none;
}

.nav-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--color-text);
  flex: 1;
  text-align: center;
}

.nav-right {
  width: 44px;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.2s;
  min-height: 48px;
  user-select: none;
  -webkit-user-select: none;
}

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

.btn-lg {
  width: 100%;
  padding: 14px 24px;
  font-size: 1.0625rem;
  border-radius: var(--radius-lg);
}

.btn-primary {
  background: var(--color-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.btn-primary:active {
  background: var(--color-primary-dark);
}

.btn-primary:disabled {
  background: var(--color-text-light);
  box-shadow: none;
  opacity: 0.6;
  transform: none;
}

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

.btn-secondary:active {
  background: var(--color-bg);
}

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
  padding: 12px 20px;
  border-radius: var(--radius-md);
}

.btn-outline:active {
  background: var(--color-primary-light);
}

/* ============================================
   Form Elements
   ============================================ */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  font-size: 1rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-card);
  color: var(--color-text);
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-input.error {
  border-color: var(--color-error);
}

.form-input.error:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-input:disabled {
  background: var(--color-bg);
  opacity: 0.6;
}

.form-textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-card);
  color: var(--color-text);
  resize: none;
  min-height: 120px;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

.form-textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-textarea.error {
  border-color: var(--color-error);
}

.form-error {
  font-size: 0.8125rem;
  color: var(--color-error);
  margin-top: 4px;
}

.char-count {
  text-align: right;
  font-size: 0.8125rem;
  color: var(--color-text-light);
  margin-top: 4px;
}

.char-count.warning {
  color: var(--color-warning);
}

.char-count.over {
  color: var(--color-error);
}

/* ============================================
   Tab Bar
   ============================================ */
.tab-bar {
  display: flex;
  gap: 0;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 20px;
}

.tab-btn {
  flex: 1;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  border-radius: 6px;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--color-card);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.tab-btn:active {
  opacity: 0.7;
}

.send-panel {
  display: none;
}

.send-panel.active {
  display: block;
}

/* ============================================
   Home Page
   ============================================ */
.page-home {
  background: linear-gradient(160deg, #EEF2FF 0%, #F9FAFB 50%, #ECFDF5 100%);
  min-height: calc(100vh - var(--navbar-height));
  min-height: calc(100dvh - var(--navbar-height));
  padding: 0 16px;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.page-home.active {
  display: flex;
}

.home-content {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 40px 0;
}

.home-brand {
  text-align: center;
}

.home-icon {
  font-size: 4rem;
  margin-bottom: 12px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.home-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 8px;
}

.home-subtitle {
  font-size: 1rem;
  color: var(--color-text-secondary);
}

.home-banner {
  width: 100%;
  padding: 12px 16px;
  background: var(--color-primary-light);
  border-radius: var(--radius-md);
  text-align: center;
  font-size: 0.9375rem;
  color: var(--color-primary);
  font-weight: 500;
}

.home-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.home-offline {
  width: 100%;
  padding: 10px 16px;
  background: #FEF3C7;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 0.875rem;
  color: #92400E;
}

.home-footer {
  font-size: 0.8125rem;
  color: var(--color-text-light);
  margin-top: 20px;
}

.hidden {
  display: none !important;
}

.page-send {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  background: var(--color-bg);
  padding: 0;
}

.page-send.active {
  display: flex;
  padding-top: 0;
}

.page-send.has-navbar {
  padding-top: calc(var(--navbar-height) + 12px);
}

/* ============================================
   Send Page
   ============================================ */
.send-content {
  max-width: 400px;
  margin: 0 auto;
}

/* ============================================
   Content Templates
   ============================================ */
.templates-section {
  margin-top: 8px;
}

.templates-label {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  margin: 0 0 8px;
}

.templates-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.template-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  font-size: 0.8125rem;
  border: 1.5px solid var(--color-border);
  border-radius: 20px;
  background: var(--color-card);
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.template-chip:active {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.send-form-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 16px 20px;
}

.send-form-wrapper .btn-lg {
  margin-top: auto;
}

.send-success {
  margin-top: 0;
}

.voice-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px 0;
}

.voice-record-btn {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--color-card);
  border: 3px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  position: relative;
}

.voice-record-btn:active {
  transform: scale(0.95);
}

.voice-record-btn.recording {
  border-color: var(--color-error);
  animation: pulse-record 1.5s ease-in-out infinite;
}

@keyframes pulse-record {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 20px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.voice-record-btn.completed {
  border-color: var(--color-success);
}

.voice-record-btn.denied {
  border-color: var(--color-error);
  opacity: 0.5;
}

.voice-icon {
  font-size: 2.5rem;
  transition: transform 0.3s;
}

.voice-record-btn.recording .voice-icon {
  transform: scale(1.2);
}

.voice-status {
  font-size: 0.9375rem;
  color: var(--color-text-secondary);
}

.voice-timer {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-error);
  font-variant-numeric: tabular-nums;
}

.voice-wave {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 32px;
}

.voice-wave span {
  width: 4px;
  background: var(--color-primary);
  border-radius: 2px;
  animation: wave-bounce 0.6s ease-in-out infinite alternate;
}

.voice-wave span:nth-child(1) { animation-delay: 0s; height: 12px; }
.voice-wave span:nth-child(2) { animation-delay: 0.1s; height: 20px; }
.voice-wave span:nth-child(3) { animation-delay: 0.2s; height: 28px; }
.voice-wave span:nth-child(4) { animation-delay: 0.3s; height: 20px; }
.voice-wave span:nth-child(5) { animation-delay: 0.4s; height: 12px; }

@keyframes wave-bounce {
  0% { transform: scaleY(0.5); }
  100% { transform: scaleY(1); }
}

.voice-preview {
  display: flex;
  align-items: center;
  gap: 12px;
}

.voice-play-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  font-size: 1.125rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.voice-play-btn:active {
  background: var(--color-primary-dark);
}

.voice-play-btn.playing {
  background: var(--color-warning);
}

.voice-play-time {
  font-size: 0.9375rem;
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

.voice-rerecord {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  text-decoration: underline;
  padding: 4px 8px;
}

.send-success {
  margin-top: 24px;
  padding: 32px 24px;
  background: #ECFDF5;
  border-radius: var(--radius-lg);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.send-success-icon {
  font-size: 3rem;
}

.send-success-tip {
  font-size: 1rem;
  color: #065F46;
  font-weight: 500;
  line-height: 1.5;
}

/* ============================================
   Receive (Query) Page
   ============================================ */
.page-receive {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  background-image: url('https://pic.keimsoft.com/view_back.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  padding: 0;
  position: relative;
}

.page-receive::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 0;
}

.page-receive.active {
  display: flex;
}

.receive-content {
  max-width: 400px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 20px;
  padding: 20px 16px;
  flex: 1;
  position: relative;
  z-index: 1;
}

.receive-header {
  text-align: center;
  padding: 32px 0 20px;
}

.receive-icon {
  font-size: 3.5rem;
  margin-bottom: 12px;
  animation: float 3s ease-in-out infinite;
  display: inline-block;
}

.receive-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #FFFFFF;
}

.receive-content .form-label {
  color: rgba(255, 255, 255, 0.8);
}

.receive-content .form-input {
  background: rgba(255, 255, 255, 0.9);
}

.receive-content .form-group {
  width: 100%;
}

.receive-content .btn-lg {
  width: 100%;
}

.receive-result {
  padding: 16px;
  border-radius: var(--radius-md);
  text-align: center;
  font-size: 0.9375rem;
}

.receive-result.success {
  background: rgba(16, 185, 129, 0.2);
  color: #6EE7B7;
}

.receive-result.empty {
  background: rgba(79, 70, 229, 0.2);
  color: #C7D2FE;
}

.receive-result.error {
  background: rgba(239, 68, 68, 0.2);
  color: #FCA5A5;
}

/* ============================================
   Messages (List) Page
   ============================================ */
.messages-content {
  max-width: 400px;
  margin: 0 auto;
}

.msg-header {
  margin-bottom: 16px;
}

.msg-count {
  font-size: 0.9375rem;
  color: var(--color-text-secondary);
}

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

.msg-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--color-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.2s;
  min-height: 64px;
}

.msg-card:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-md);
}

.msg-card-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: var(--color-primary-light);
  border-radius: 50%;
  flex-shrink: 0;
}

.msg-card-text {
  flex: 1;
  min-width: 0;
}

.msg-card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
}

.msg-card-preview {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-card-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.msg-card-time {
  font-size: 0.75rem;
  color: var(--color-text-light);
}

.msg-card-play {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.msg-card-play:active {
  background: var(--color-primary-dark);
}

.msg-card-play.playing {
  background: var(--color-warning);
}

/* ============================================
   Skeleton Loading
   ============================================ */
.skeleton-card {
  padding: 16px;
  background: var(--color-card);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
}

.skeleton-line {
  height: 14px;
  background: linear-gradient(90deg, var(--color-border) 25%, #F3F4F6 50%, var(--color-border) 75%);
  background-size: 200% 100%;
  border-radius: 4px;
  margin-bottom: 8px;
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-line:last-child {
  margin-bottom: 0;
}

.skeleton-line.w30 { width: 30%; }
.skeleton-line.w35 { width: 35%; }
.skeleton-line.w40 { width: 40%; }
.skeleton-line.w50 { width: 50%; }
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w70 { width: 70%; }

.envelope-skeleton {
  height: 300px;
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg, var(--color-border) 25%, #F3F4F6 50%, var(--color-border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================
   State displays (empty, error)
   ============================================ */
.msg-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 60px 24px;
  text-align: center;
}

.state-icon {
  font-size: 3.5rem;
  margin-bottom: 4px;
}

.state-text {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text);
}

.state-desc {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

/* ============================================
   Detail Page - Envelope
   ============================================ */
.detail-content {
  max-width: 400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 180px);
  padding-bottom: 40px;
}

/* Envelope container */
.envelope {
  width: 300px;
  height: 200px;
  position: relative;
  cursor: pointer;
  margin-top: 20px;
}

/* Envelope body (pink rectangle) */
.envelope-body {
  width: 100%;
  height: 100%;
  background: #f8e8ee;
  border-radius: 4px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.1);
  position: absolute;
  z-index: 2;
}

/* Triangular lid */
.envelope-lid {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  background: #f4d5e3;
  clip-path: polygon(0 0, 50% 50%, 100% 0);
  transform-origin: center top;
  transition: transform 0.8s ease;
  z-index: 3;
  backface-visibility: hidden;
}

/* Open state */
.envelope.open .envelope-lid {
  transform: rotateX(180deg);
}

/* Seal on envelope body */
.envelope .envelope-seal {
  position: absolute;
  top: 55%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 4rem;
  z-index: 4;
  pointer-events: none;
}

/* Open button on envelope body */
.envelope .envelope-open-btn {
  position: absolute;
  top: 78%;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 28px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #b57295;
  background: rgba(255,255,255,0.7);
  border-radius: 20px;
  transition: all 0.2s;
  z-index: 4;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.envelope .envelope-open-btn:active {
  background: rgba(255,255,255,0.9);
}

/* ============================================
   Detail Page - Letter Overlay (fixed)
   ============================================ */
.letter-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.letter-paper {
  width: 90%;
  max-width: 460px;
  height: 70vh;
  max-height: 480px;
  padding: 35px 30px;
  background: #fffcf2;
  /* Grid paper: dots + horizontal lines */
  background-image:
    radial-gradient(#e9e3d3 0.5px, transparent 0.5px),
    repeating-linear-gradient(transparent 0px, transparent 30px, #c9d6e2 30px, #c9d6e2 31px);
  background-size: 8px 8px, 100% 31px;
  /* Layered shadows for paper depth + curled corners */
  box-shadow:
    0 1px 2px rgba(0,0,0,0.05),
    0 8px 20px rgba(0,0,0,0.12),
    0 15px 40px rgba(0,0,0,0.18),
    inset 0 0 60px rgba(210,195,165,0.15),
    inset 0 0 120px rgba(224,208,182,0.08);
  border-radius: 6px;
  border-top-right-radius: 12px;
  border-bottom-left-radius: 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* Scrollbar styling */
  scrollbar-width: thin;
  scrollbar-color: #d8c9b4 transparent;
  /* Hidden by default */
  opacity: 0;
  transform: scale(0) rotate(1deg);
  transition: all 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.letter-paper::-webkit-scrollbar {
  width: 6px;
}
.letter-paper::-webkit-scrollbar-thumb {
  background: #d8c9b4;
  border-radius: 3px;
}
.letter-paper::-webkit-scrollbar-track {
  background: transparent;
}

.letter-paper.show {
  opacity: 1;
  transform: scale(1) rotate(-0.5deg);
}

.letter-text {
  font-size: 16px;
  line-height: 31px;
  color: #2c2c2c;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "KaiTi", "STKaiti", serif;
  letter-spacing: 0.5px;
}

.letter-time {
  font-size: 13px;
  color: #999;
  line-height: 31px;
  font-family: "KaiTi", "STKaiti", serif;
}

/* ============================================
   Detail Page - Voice Player
   ============================================ */

.letter-content {
  text-align: left;
  width: 100%;
}

.detail-text-content {
  font-size: 1.125rem;
  line-height: 1.8;
  color: var(--color-text);
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 24px;
}

.detail-text-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8125rem;
  color: var(--color-text-light);
}

/* ============================================
   Detail Page - Voice Player
   ============================================ */
.detail-voice {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.voice-player-header {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 24px;
}

.voice-player {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.voice-player-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
  transition: all 0.2s;
}

.voice-player-btn:active {
  transform: scale(0.95);
}

.voice-player-btn.playing {
  background: var(--color-warning);
}

.voice-player-btn:disabled {
  background: var(--color-text-light);
  box-shadow: none;
}

.voice-player-wave {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 40px;
}

.voice-player-wave span {
  width: 4px;
  background: var(--color-primary);
  border-radius: 2px;
  transition: height 0.1s;
  height: 8px;
}

.voice-player-wave.playing span {
  animation: wave-play 0.4s ease-in-out infinite alternate;
}

.voice-player-wave.playing span:nth-child(1) { animation-delay: 0s; }
.voice-player-wave.playing span:nth-child(2) { animation-delay: 0.04s; }
.voice-player-wave.playing span:nth-child(3) { animation-delay: 0.08s; }
.voice-player-wave.playing span:nth-child(4) { animation-delay: 0.12s; }
.voice-player-wave.playing span:nth-child(5) { animation-delay: 0.16s; }
.voice-player-wave.playing span:nth-child(6) { animation-delay: 0.2s; }
.voice-player-wave.playing span:nth-child(7) { animation-delay: 0.24s; }
.voice-player-wave.playing span:nth-child(8) { animation-delay: 0.28s; }
.voice-player-wave.playing span:nth-child(9) { animation-delay: 0.32s; }
.voice-player-wave.playing span:nth-child(10) { animation-delay: 0.36s; }

@keyframes wave-play {
  0% { height: 8px; }
  100% { height: 32px; }
}

.voice-player-time {
  font-size: 1.125rem;
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

.voice-player-progress {
  width: 100%;
}

.voice-player-range {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--color-border);
  border-radius: 3px;
  outline: none;
}

.voice-player-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3);
}

.voice-player-range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-primary);
  border: none;
  cursor: pointer;
}

.voice-player-error {
  text-align: center;
  padding: 20px;
  color: var(--color-error);
}

.detail-voice-time {
  text-align: center;
  font-size: 0.875rem;
  color: var(--color-text-light);
  margin-top: 16px;
}

/* ============================================
   Toast
   ============================================ */
.toast-container {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 440px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in 0.3s ease-out;
}

.toast.removing {
  animation: toast-out 0.3s ease-in forwards;
}

.toast-success {
  background: #ECFDF5;
  color: #065F46;
  border-left: 4px solid var(--color-success);
}

.toast-error {
  background: #FEF2F2;
  color: #991B1B;
  border-left: 4px solid var(--color-error);
}

.toast-warning {
  background: #FFFBEB;
  color: #92400E;
  border-left: 4px solid var(--color-warning);
}

.toast-info {
  background: #EFF6FF;
  color: #1E40AF;
  border-left: 4px solid var(--color-info);
}

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

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

/* ============================================
   Loading Spinner
   ============================================ */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-dark {
  border-color: rgba(0,0,0,0.1);
  border-top-color: var(--color-primary);
}

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

/* ============================================
   Utility
   ============================================ */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 60px 24px;
}

/* ============================================
   Responsive Adjustments
   ============================================ */
@media (max-width: 374px) {
  html {
    font-size: 14px;
  }
  .home-icon {
    font-size: 3rem;
  }
  .home-title {
    font-size: 1.625rem;
  }
}

@media (min-width: 414px) {
  html {
    font-size: 17px;
  }
}

/* ============================================
   Keyboard Avoidance
   ============================================ */
@media (max-height: 600px) {
  .send-content {
    padding-bottom: 120px;
  }
  .voice-record-btn {
    width: 90px;
    height: 90px;
  }
  .voice-icon {
    font-size: 2rem;
  }
}

/* Fix for iOS input zoom */
@media screen and (max-width: 480px) {
  input, textarea, select {
    font-size: 16px !important;
  }
}

/* ============================================
   Send Page — Landing Step
   ============================================ */
.send-landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 40px 32px;
  text-align: center;
  background-image: url('https://pic.keimsoft.com/send_back.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
}

.send-landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 40px 32px;
  text-align: center;
  background-image: url('https://pic.keimsoft.com/send_back.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
}

.send-landing::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 0;
}

.send-landing-icon {
  font-size: 64px;
  margin-bottom: 20px;
  animation: float 3s ease-in-out infinite;
  position: relative;
  z-index: 1;
}

.send-landing-title {
  font-size: 24px;
  font-weight: 700;
  color: #FFFFFF;
  margin: 0 0 8px;
  position: relative;
  z-index: 1;
}

.send-landing-desc {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
  margin: 0 0 40px;
  line-height: 1.5;
  position: relative;
  z-index: 1;
}

.btn-xl {
  padding: 16px 48px;
  font-size: 18px;
  border-radius: 14px;
  min-width: 220px;
  position: relative;
  z-index: 1;
}

/* ============================================
   Admin / Management Page
   ============================================ */
.page-admin {
  padding-bottom: 80px;
}

/* Admin Login Screen */
.admin-login {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 180px);
  padding: 40px 32px;
  text-align: center;
}

.admin-login-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

.admin-login-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 8px;
}

.admin-login-desc {
  font-size: 0.9375rem;
  color: var(--color-text-secondary);
  margin-bottom: 32px;
}

.admin-login-form {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.admin-login-form .form-input {
  text-align: center;
  font-size: 1.125rem;
  letter-spacing: 4px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 16px;
}

.admin-stat-card {
  background: var(--color-card);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.admin-stat-num {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.3;
}

.admin-stat-label {
  display: block;
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.admin-filters {
  display: flex;
  gap: 8px;
  padding: 0 16px 12px;
}

.admin-select, .admin-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--color-card);
  color: var(--color-text);
  outline: none;
  appearance: auto;
  min-width: 0;
}

.admin-select:focus, .admin-input:focus {
  border-color: var(--color-primary);
}

.admin-table-wrap {
  padding: 0 16px;
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: var(--color-card);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.admin-table th {
  background: var(--color-bg);
  color: var(--color-text-secondary);
  font-weight: 600;
  text-align: left;
  padding: 10px 8px;
  white-space: nowrap;
  border-bottom: 1px solid var(--color-border);
}

.admin-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-cell-preview {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text-secondary);
}

.admin-cell-time {
  white-space: nowrap;
  font-size: 11px;
  color: var(--color-text-secondary);
}

.admin-empty {
  text-align: center;
  padding: 32px 8px !important;
  color: var(--color-text-secondary);
}

/* Admin Stats Header (title + logout) */
.admin-stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  margin-bottom: 12px;
}

.admin-stats-header span {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.admin-logout-btn {
  font-size: 0.75rem;
  padding: 4px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: transparent;
  color: var(--color-text-light);
  cursor: pointer;
  transition: all 0.2s;
}

.admin-logout-btn:hover {
  border-color: var(--color-error);
  color: var(--color-error);
}

/* Admin Pagination */
.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px 16px 32px;
}

.admin-page-btn {
  padding: 6px 16px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-card);
  color: var(--color-primary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.admin-page-btn:hover:not(:disabled) {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.admin-page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.admin-page-info {
  font-size: 13px;
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-text {
  background: #e0e7ff;
  color: #3730a3;
}

.badge-voice {
  background: #fce7f3;
  color: #9d174d;
}

.badge-claimed {
  background: #d1fae5;
  color: #065f46;
}

.badge-unclaimed {
  background: #fef3c7;
  color: #92400e;
}

/* Home admin link */
.home-admin-link {
  display: inline-block;
  font-size: 11px;
  color: var(--color-text-secondary);
  cursor: pointer;
  margin-left: 12px;
  text-decoration: none;
}

.home-admin-link:hover {
  color: var(--color-primary);
}