* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; padding-top: 80px; -webkit-overflow-scrolling: touch; }

.navbar { position: fixed; top: 0; left: 0; right: 0; background: rgba(255,255,255,0.95); backdrop-filter: blur(10px); border-bottom: 1px solid rgba(255,255,255,0.2); padding: 0 20px; height: 80px; display: flex; align-items: center; justify-content: space-between; z-index: 1000; }
.navbar-brand { font-size: 24px; font-weight: 700; color: #333; text-decoration: none; }
.navbar-auth, .user-info-nav { display: flex; align-items: center; gap: 12px; }
.nav-btn { padding: 8px 12px; font-size: 14px; border-radius: 8px; background: #f0f2f5; color: #333; }
.user-name { font-weight: 600; color: #333; }
.language-selector { display: flex; align-items: center; }
.language-select { padding: 6px 10px; font-size: 14px; border: 1px solid #ddd; border-radius: 8px; background: #fff; color: #333; cursor: pointer; }
.language-select:hover { border-color: #667eea; }

.container { background: #fff; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); padding: 32px; max-width: 1100px; width: 100%; margin: 0 auto 32px; }

@media (max-width: 768px) {
  .container { padding: 20px; margin: 16px; border-radius: 12px; }
  .navbar { padding: 0 12px; }
  .navbar-brand { font-size: 20px; }
  .mic-button { width: 80px; height: 80px; font-size: 14px; }
  .transcript-box textarea, .translation-box textarea { font-size: 16px; min-height: 120px; }
}

h1 { color: #333; margin-bottom: 10px; font-size: 28px; }
.subtitle { color: #27ae60; margin-bottom: 16px; font-size: 14px; font-weight: 600; }
.status { color: #666; margin-bottom: 24px; font-size: 14px; }
.status.recording { color: #e74c3c; font-weight: 600; }

button { padding: 12px 20px; font-size: 16px; border: none; border-radius: 10px; cursor: pointer; transition: all 0.3s ease; font-weight: 600; background: #667eea; color: #fff; -webkit-tap-highlight-color: transparent; touch-action: manipulation; pointer-events: auto !important; z-index: 10000 !important; position: relative !important; }
#loginBtn, #registerBtn { pointer-events: auto !important; z-index: 10000 !important; position: relative !important; -webkit-tap-highlight-color: rgba(0,0,0,0.3) !important; }
button:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.2); background: #5a6fe0; }
button:active { transform: scale(0.98); }
button:disabled { background: #bdc3c7; cursor: not-allowed; transform: none; box-shadow: none; opacity: 0.6; }

input, select, textarea { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 8px; font-size: 16px; background: #fff; color: #2c3e50; }
select { cursor: pointer; }
label { display: block; margin-bottom: 6px; color: #555; font-weight: 600; font-size: 14px; }
form { background: #f8f9fa; padding: 20px; border-radius: 8px; }

.controls { display: flex; gap: 12px; margin-bottom: 24px; }
.translate { margin-top: 16px; display: grid; gap: 10px; }
.translate-row { display: flex; gap: 10px; }

.transcript-container { background: #f8f9fa; border-radius: 10px; padding: 16px; min-height: 180px; max-height: 380px; overflow-y: auto; }
.transcript-label { color: #666; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; font-weight: 600; }
.transcript-text { color: #333; font-size: 18px; line-height: 1.6; white-space: pre-wrap; }

.info { background: #e8f5e9; border-left: 4px solid #27ae60; padding: 12px; margin-top: 16px; border-radius: 6px; font-size: 14px; color: #2c3e50; }

#translation { background: #f8f9fa; border-radius: 10px; padding: 16px; min-height: 80px; white-space: pre-wrap; color: #2c3e50; font-size: 16px; }

.coverage { margin-top: 16px; display: grid; gap: 10px; }
.coverage-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat-box { background: #e8f5e9; border-left: 4px solid #27ae60; padding: 12px; border-radius: 5px; flex: 1; min-width: 150px; text-align: center; }
.stat-value { font-size: 22px; font-weight: 700; color: #27ae60; }
.stat-label { font-size: 12px; color: #666; text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; }

#unknownWords { background: #fff3cd; border-left: 4px solid #ffc107; padding: 12px; border-radius: 5px; max-height: 120px; overflow-y: auto; font-size: 14px; color: #333; }
#knownWords { background: #e8f5e9; border-left: 4px solid #27ae60; padding: 12px; border-radius: 5px; max-height: 120px; overflow-y: auto; font-size: 14px; color: #333; }

.auth-tabs { display: flex; margin-bottom: 16px; }
.auth-tab { flex: 1; padding: 10px; border: none; background: #f0f2f5; cursor: pointer; border-radius: 5px 5px 0 0; }
.auth-form.hidden { display: none; }

.auth-status { margin-top: 16px; padding: 14px 16px; border-radius: 8px; text-align: center; font-size: 16px; font-weight: 500; min-height: 44px; min-width: 200px; display: block !important; visibility: visible !important; opacity: 1 !important; word-wrap: break-word; z-index: 1000; position: relative; }
.auth-status.success { background: #d4edda; color: #155724; border: 2px solid #c3e6cb; }
.auth-status.error { background: #f8d7da; color: #721c24; border: 2px solid #f5c6cb; font-weight: 600; }
.auth-status:empty { display: block !important; }

.user-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; padding: 10px; background: #e8f5e9; border-radius: 5px; }

.simple-app { display: flex; flex-direction: column; align-items: center; gap: 24px; padding: 16px 0; }
.transcript-box, .translation-box { width: 100%; max-width: 800px; }
.transcript-box .chat-box { width: 100%; min-height: 140px; max-height: 700px; padding: 16px; border: 2px solid #e0e0e0; border-radius: 12px; font-size: 18px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; transition: border-color 0.3s ease; background: #fafafa; overflow-y: auto; }
.transcript-box .chat-box { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.transcript-box .chat-box:focus, .translation-box textarea:focus { outline: none; border-color: #667eea; background: #fff; }
.msg { display: flex; width: 100%; }
.msg.left { justify-content: flex-start; }
.msg.right { justify-content: flex-end; }
.bubble { max-width: 75%; padding: 10px 14px; border-radius: 14px; background: #ffffff; border: 1px solid #e0e0e0; color: #2c3e50; }
.msg.left .bubble { background: #e8f0ff; border-color: #c7d2fe; }
.msg.right .bubble { background: #e8f5e9; border-color: #c9e7cd; }
.msg.draft .bubble { opacity: 0.7; }
.bubble.trans { background: #fff; border-style: dashed; font-size: 16px; color: #555; }

.vocab-page { display: flex; flex-direction: column; gap: 12px; }
.vocab-chart { background: #f8f9fa; border: 1px solid #eee; border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.vocab-chart-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.vocab-chart-title { font-size: 18px; font-weight: 700; color: #2c3e50; }
.vocab-chart-subtitle { font-size: 14px; color: #666; }
.vocab-chart-total { display: flex; align-items: baseline; gap: 6px; font-size: 28px; font-weight: 700; color: #667eea; }
.vocab-chart-total-label { font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: #888; }
.vocab-chart-canvas { width: 100%; height: 200px; }
.vocab-chart-footer { display: flex; justify-content: space-between; font-size: 12px; color: #999; }
.chart-date { font-variant-numeric: tabular-nums; }
.chart-svg { width: 100%; height: 100%; }
.chart-line { fill: none; stroke: #667eea; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chart-fill { fill: rgba(102, 126, 234, 0.2); }
.vocab-chart-empty { text-align: center; padding: 20px; border: 1px dashed #d0d7ff; border-radius: 10px; font-size: 14px; color: #666; }
.vocab-header { display: grid; grid-template-columns: 1fr 120px 120px 1fr; gap: 12px; align-items: center; }
.vocab-header .v-sort { padding: 8px 10px; background: #eef2ff; border: 1px solid #c7d2fe; border-radius: 8px; cursor: pointer; }
.vocab-list { display: grid; grid-template-columns: 1fr; gap: 8px; max-height: 420px; overflow-y: auto; padding-right: 4px; }
.vocab-row { display: grid; grid-template-columns: 1fr 120px 120px 1fr; gap: 12px; background: #f8f9fa; padding: 10px 12px; border-radius: 8px; border: 1px solid #eee; }
.v-base { font-weight: 700; color: #2c3e50; }
.v-ret { text-align: right; font-weight: 600; color: #546de5; }
.v-freq { color: #333; text-align: right; }
.v-last { color: #666; font-size: 14px; }
.v-tr { color: #333; }

.mic-control { display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; }
.mic-button { width: 100px; height: 100px; border-radius: 50%; border: none; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.3s ease; box-shadow: 0 4px 15px rgba(102,126,234,0.4); font-size: 16px; font-weight: 600; }
.mic-button:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(102,126,234,0.6); }
.mic-button:active { transform: scale(0.96); }
.mic-button.recording { background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%); box-shadow: 0 4px 15px rgba(231,76,60,0.4); }
.status-text { color: #666; font-size: 14px; margin-top: 8px; }
.status-text.recording { color: #e74c3c; font-weight: 600; }

.voice-toggle-container { display: flex; justify-content: center; align-items: center; margin-top: 8px; }
.voice-toggle-label { display: flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; }
.voice-toggle-input { display: none; }
.voice-toggle-slider { position: relative; width: 50px; height: 26px; background: #ccc; border-radius: 26px; transition: background 0.3s ease; }
.voice-toggle-slider::before { content: ''; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform 0.3s ease; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.voice-toggle-input:checked + .voice-toggle-slider { background: #667eea; }
.voice-toggle-input:checked + .voice-toggle-slider::before { transform: translateX(24px); }
.voice-toggle-text { font-size: 14px; color: #333; font-weight: 500; }

.learn-page { display: flex; flex-direction: column; gap: 20px; align-items: center; }
.learn-container { width: 100%; max-width: 500px; }
.learn-stats { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; }
.learn-stats #learnProgress { font-size: 18px; font-weight: 600; color: #667eea; }

.card-stack { position: relative; height: 400px; display: flex; align-items: center; justify-content: center; -webkit-overflow-scrolling: touch; }
.vocab-card { width: 100%; max-width: 350px; height: 400px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 20px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); position: relative; cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: pan-x pan-y; -webkit-tap-highlight-color: transparent; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 30px; }
.card-base { font-size: 48px; font-weight: 700; color: #fff; text-align: center; margin-bottom: 40px; }
.card-translation { font-size: 32px; font-weight: 600; color: #fff; text-align: center; line-height: 1.4; border-top: 2px solid rgba(255,255,255,0.3); padding-top: 40px; width: 100%; }
.hidden { display: none; }

.swipe-indicators { position: absolute; top: 20px; left: 0; right: 0; display: flex; justify-content: space-between; pointer-events: none; z-index: 10; }
.swipe-left-indicator, .swipe-right-indicator { padding: 8px 16px; border-radius: 20px; font-size: 14px; font-weight: 600; opacity: 0; transition: opacity 0.3s; }
.swipe-left-indicator { background: rgba(231, 76, 60, 0.9); color: #fff; }
.swipe-right-indicator { background: rgba(39, 174, 96, 0.9); color: #fff; }

.restart-btn { padding: 10px 20px; font-size: 14px; background: #95a5a6; }
.restart-btn:hover { background: #7f8c8d; }

@media (max-width: 768px) {
  .vocab-card { max-width: 300px; height: 350px; }
  .card-base { font-size: 36px; }
  .card-translation { font-size: 24px; }
}

.document-translate-page { display: flex; flex-direction: column; gap: 24px; }
.doc-pane { background: #f8f9fa; border-radius: 16px; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.doc-pane-header { display: flex; flex-direction: column; gap: 12px; }
.doc-select { width: 220px; align-self: flex-end; }
.doc-input { min-height: 220px; font-size: 16px; line-height: 1.5; resize: vertical; }
.doc-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.doc-action-primary { flex: 1; min-width: 160px; }
.doc-action-secondary { flex: 1; min-width: 140px; background: #f0f2f5; color: #333; }
.doc-action-secondary:hover { background: #e0e3eb; }
.doc-status { font-size: 14px; color: #555; font-weight: 500; }
.doc-section-title { font-size: 18px; font-weight: 600; color: #2c3e50; }
.doc-translation-box { min-height: 180px; background: #fff; border: 1px solid #e0e0e0; border-radius: 12px; padding: 16px; font-size: 16px; line-height: 1.6; white-space: pre-wrap; color: #2c3e50; }
.doc-cards-header { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.doc-card-count { font-size: 20px; font-weight: 700; color: #667eea; }
.doc-cards-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.doc-card { background: #ffffff; border: 1px solid #e0e0e0; border-radius: 12px; padding: 12px; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.doc-card-word { font-weight: 600; color: #2c3e50; flex: 1; }
.doc-empty { padding: 20px; border: 1px dashed #c5cae9; border-radius: 12px; text-align: center; color: #666; background: #fff; }

@media (max-width: 768px) {
  .doc-pane { padding: 16px; }
  .doc-select { width: 100%; }
  .doc-actions { flex-direction: column; }
  .doc-action-primary, .doc-action-secondary { width: 100%; }
}
