:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --accent-en: #10b981;
  --accent-ru: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC',
    'Microsoft YaHei', sans-serif;
  background: radial-gradient(circle at top, #1e293b 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.page {
  min-height: 100vh;
  padding: 24px;
}

.center-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.brand {
  text-align: center;
  margin-bottom: 28px;
}

.brand-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
}

.brand h1 {
  margin: 0 0 8px;
  font-size: 1.6rem;
}

.brand p,
.panel-desc,
.demo-hint p {
  color: var(--muted);
  margin: 0;
}

.login-form,
.stack-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.92rem;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.92rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394a3b8' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(59, 130, 246, 0.45);
  border-color: var(--primary);
}

button {
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  cursor: pointer;
  font-weight: 600;
}

button:hover:not(:disabled) {
  background: var(--primary-hover);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

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

.ghost-btn:hover:not(:disabled) {
  background: var(--surface-2);
}

.ghost-btn.listening {
  border-color: var(--danger);
  color: #fecaca;
}

.error-banner {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.15);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.error-banner.floating {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
}

.demo-hint {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.demo-hint code {
  display: block;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  padding: 4px;
  border-radius: 10px;
  background: var(--surface-2);
}

.auth-tabs button {
  flex: 1;
  padding: 10px 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}

.auth-tabs button.active {
  background: var(--primary);
  color: white;
}

.auth-tabs button:hover:not(.active) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.top-bar h1 {
  margin: 8px 0 4px;
}

.back-link {
  color: var(--muted);
  font-size: 0.9rem;
}

.room-grid,
.interpret-layout {
  display: grid;
  gap: 20px;
}

.room-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.interpret-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  box-sizing: border-box;
  overflow: hidden;
}

.interpret-page .top-bar {
  flex-shrink: 0;
  margin-bottom: 12px;
}

.interpret-body,
.interpret-layout {
  flex: 1;
  min-height: 0;
}

.interpret-page .interpret-layout {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  align-items: stretch;
  height: 100%;
  gap: 20px;
}

/* 桌面：左记录、右输入 */
.interpret-page .history-panel {
  grid-column: 1;
  grid-row: 1;
}

.interpret-page .input-panel {
  grid-column: 2;
  grid-row: 1;
}

.history-panel,
.input-panel {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.history-panel {
  min-height: unset;
}

.history-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  scrollbar-width: thin;
  scrollbar-color: #64748b var(--surface-2);
}

.history-list::-webkit-scrollbar {
  width: 8px;
}

.history-list::-webkit-scrollbar-track {
  background: rgba(15, 20, 25, 0.35);
  border-radius: 8px;
}

.history-list::-webkit-scrollbar-thumb {
  background: #64748b;
  border-radius: 8px;
  border: 2px solid var(--surface-2);
}

.history-list::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.input-panel .stack-form {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: #64748b var(--surface-2);
}

.input-panel .stack-form > label:has(textarea) {
  flex: 1;
  min-height: 0;
}

.input-panel .stack-form::-webkit-scrollbar {
  width: 8px;
}

.input-panel .stack-form::-webkit-scrollbar-track {
  background: rgba(15, 20, 25, 0.35);
  border-radius: 8px;
}

.input-panel .stack-form::-webkit-scrollbar-thumb {
  background: #64748b;
  border-radius: 8px;
}

.input-panel textarea {
  flex: 1;
  min-height: 140px;
  height: auto;
  max-height: none;
  resize: none;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.panel h2 {
  margin: 0 0 8px;
}

.pair-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pair-select {
  width: 100%;
}

.room-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.room-id,
.pair-badge,
.status-dot,
.module-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
}

.room-id {
  background: var(--surface-2);
}

.room-id-with-participants {
  gap: 8px;
}

.room-participants-meta {
  color: var(--muted);
}

.participants-count-btn {
  border: none;
  background: none;
  padding: 0 2px;
  color: var(--primary);
  font: inherit;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.participants-count-btn:disabled {
  color: var(--muted);
  cursor: default;
  text-decoration: none;
}

.participants-dialog {
  width: min(420px, 100%);
}

.participants-list {
  padding: 12px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 50vh;
  overflow: auto;
}

.participant-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
}

.participant-name {
  font-weight: 600;
}

.participant-tag {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

.pair-badge.pair-zh-en {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}

.pair-badge.pair-zh-ru {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
}

.pair-badge.pair-zh-ja {
  background: rgba(236, 72, 153, 0.15);
  color: #f9a8d4;
}

.pair-badge.pair-zh-ko {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

.status-dot.online {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}

.status-dot.offline {
  background: rgba(148, 163, 184, 0.15);
  color: var(--muted);
}

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

.history-item {
  padding: 14px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.history-item header {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.85rem;
}

.history-item .source {
  margin: 0 0 8px;
}

.history-item .translated {
  margin: 0;
  color: #bfdbfe;
  font-size: 1.05rem;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.history-item .translated-text {
  flex: 1;
  min-width: 0;
}

.speak-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-top: -2px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.speak-btn:hover {
  background: rgba(59, 130, 246, 0.22);
  color: #bfdbfe;
}

.speak-btn.playing {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
}

.module-tag {
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
}

.direction-toggle {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0;
}

.direction-toggle button {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.direction-toggle button.active {
  background: rgba(59, 130, 246, 0.18);
  border-color: var(--primary);
  color: #bfdbfe;
}

.action-row {
  display: flex;
  gap: 10px;
}

.action-row button {
  flex: 1;
}

.interpret-action-dock {
  flex-shrink: 0;
  margin-top: 0;
  padding: 12px 0 0;
  border-top: 2px solid rgba(59, 130, 246, 0.55);
  background: linear-gradient(180deg, rgba(26, 35, 50, 0.98), rgba(15, 20, 25, 1));
}

.connect-hint {
  margin: 0 0 8px;
  text-align: center;
  color: #fcd34d;
  font-size: 0.85rem;
}

.huawei-edge-banner {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: rgba(255, 248, 230, 0.12);
  border: 1px solid rgba(240, 215, 140, 0.45);
  font-size: 0.85rem;
  line-height: 1.45;
  color: #fcd34d;
}

.huawei-edge-banner a {
  align-self: flex-start;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  background: #0078d4;
  color: #fff;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
}

.interpret-toast {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(88px + env(safe-area-inset-bottom));
  z-index: 400;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.88rem;
  line-height: 1.45;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.interpret-toast--error {
  background: rgba(127, 29, 29, 0.95);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.45);
}

.interpret-toast--info {
  background: rgba(30, 58, 95, 0.95);
  color: #bfdbfe;
  border: 1px solid rgba(59, 130, 246, 0.45);
}

.input-panel-compact .stack-form-compact {
  flex: 0 0 auto;
  gap: 8px;
}

.input-panel-compact .input-label-compact {
  flex: 0 0 auto;
  font-size: 0.82rem;
  gap: 6px;
}

.input-panel-compact textarea {
  flex: none;
  box-sizing: border-box;
  min-height: calc(1.35em * 3 + 12px);
  height: calc(1.35em * 3 + 12px);
  max-height: calc(1.35em * 3 + 12px);
  padding: 6px 10px;
  line-height: 1.35;
  font-size: 0.88rem;
  resize: none;
}

.interim-region {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 10px;
}

.interim-box {
  flex: 1;
  min-height: 0;
  margin-bottom: 0;
  padding: 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.interim-box.is-empty {
  border-style: dashed;
}

.interim-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 6px;
  flex-shrink: 0;
}

.interim-box p {
  flex: 1;
  min-height: 0;
  margin: 0;
  line-height: 1.55;
  color: #fde68a;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.interim-box.is-empty p {
  color: var(--muted);
  font-size: 0.88rem;
}

.panel-desc-compact {
  font-size: 0.82rem;
  line-height: 1.45;
}

.speech-input-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-icon {
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
}

.speech-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: 10px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #6ee7b7;
  font-size: 0.9rem;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #34d399;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.detect-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  background: rgba(245, 158, 11, 0.12);
  color: #fcd34d;
}

.minutes-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.minutes-dialog {
  width: min(760px, 100%);
  max-height: 85vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.minutes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.minutes-header h2 {
  margin: 0;
}

.minutes-meta {
  padding: 12px 20px 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.minutes-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  line-height: 1.7;
  color: var(--text);
}

.minutes-content h2,
.minutes-content h3,
.minutes-content h4 {
  margin: 16px 0 8px;
}

.minutes-content li {
  margin: 4px 0 4px 20px;
}

.minutes-actions {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.minutes-actions button {
  flex: 1;
}

.lang-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.lang-switcher--fixed {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  box-shadow: var(--shadow);
}

.lang-btn {
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  border: none;
}

.lang-btn:hover {
  color: var(--text);
  background: var(--surface-2);
}

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

.lang-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 6px 28px 6px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394a3b8' d='M1 1l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 8px center;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}

.lang-select-mobile,
.gen-minutes-mobile {
  display: none;
}

.top-bar-primary {
  min-width: 0;
  flex: 1;
}

.top-bar-leading {
  display: block;
}

.top-bar-interpret .top-bar-actions-desktop {
  flex-shrink: 0;
}

.mobile-input-slot {
  display: none;
}

@media (max-width: 900px) {
  .interpret-layout {
    display: grid;
    grid-template-columns: minmax(0, 0.74fr) minmax(0, 0.26fr);
    gap: 8px;
    overflow: hidden;
    align-items: stretch;
  }

  /* 手机：左侧传译记录 + 文本输入，右侧语音控制 */
  .history-panel {
    grid-column: 1;
    grid-row: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 8px 10px;
  }

  .input-panel-compact {
    grid-column: 2;
    grid-row: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 8px 10px;
  }

  .mobile-input-slot {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }

  .mobile-input-slot .stack-form-compact {
    flex: 0 0 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .mobile-input-slot .input-label-compact {
    flex: 0 0 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    font-size: 0.72rem;
  }

  .mobile-input-slot textarea {
    flex: none;
    box-sizing: border-box;
    min-height: calc(1.35em * 3 + 12px) !important;
    height: calc(1.35em * 3 + 12px) !important;
    max-height: calc(1.35em * 3 + 12px) !important;
    padding: 8px 10px;
    resize: none;
    font-size: 16px;
    line-height: 1.35;
    -webkit-user-select: text;
    user-select: text;
    touch-action: manipulation;
  }

  .input-panel-compact > h2,
  .input-panel-compact .panel-desc {
    display: none;
  }

  .direction-toggle-mobile {
    grid-template-columns: 1fr;
    gap: 5px;
    margin: 0 0 8px;
  }

  .direction-toggle-mobile button {
    padding: 7px 6px;
    font-size: 0.72rem;
    line-height: 1.2;
    min-height: 34px;
  }

  .input-panel-compact .stack-form-compact {
    flex: 0 0 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .input-panel-compact .input-label-compact {
    flex: 0 0 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .input-panel-compact textarea {
    flex: none;
    box-sizing: border-box;
    min-height: calc(1.35em * 2 + 10px) !important;
    height: calc(1.35em * 2 + 10px) !important;
    max-height: calc(1.35em * 2 + 10px) !important;
    padding: 5px 8px;
    resize: none;
  }

  .interim-region {
    min-height: 0;
  }

  .history-panel h2 {
    margin: 0 0 6px;
    font-size: 0.88rem;
  }

  .history-list {
    flex: 1;
    min-height: 0;
  }

  .history-panel .mobile-input-slot {
    position: relative;
    z-index: 2;
  }

  .top-bar {
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
  }

  .top-bar-interpret {
    flex-direction: column;
    gap: 0;
  }

  .top-bar-leading {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    margin-bottom: 4px;
    min-width: 0;
  }

  .top-bar-leading .back-link {
    flex-shrink: 0;
    font-size: 0.82rem;
    white-space: nowrap;
  }

  .lang-select-mobile {
    display: block;
    min-width: 72px;
    max-width: 88px;
    min-height: 34px;
    padding: 4px 24px 4px 8px;
    font-size: 0.78rem;
  }

  .gen-minutes-mobile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 0;
    min-height: 34px !important;
    padding: 4px 8px !important;
    font-size: 0.72rem !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .top-bar-actions-desktop {
    display: none !important;
  }

  .top-bar-primary h1 {
    margin: 0 0 2px;
    font-size: 0.95rem;
    line-height: 1.2;
  }

  .top-bar-actions {
    width: auto;
    justify-content: flex-end;
  }
}

/* Admin panel */
.admin-page {
  max-width: 1280px;
  margin: 0 auto;
}

.admin-top-bar {
  margin-bottom: 20px;
}

.admin-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 20px;
  align-items: start;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}

.admin-nav-btn {
  text-align: left;
  padding: 10px 14px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.admin-nav-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.admin-nav-btn.active {
  background: var(--primary);
  color: white;
}

.admin-main {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  min-height: 480px;
}

.admin-main h2 {
  margin: 0 0 20px;
  font-size: 1.2rem;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.admin-stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
}

.admin-stat-label {
  color: var(--muted);
  font-size: 0.88rem;
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.admin-toolbar input,
.admin-toolbar select {
  flex: 1;
  min-width: 140px;
  max-width: 280px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
}

.admin-table tbody tr:hover {
  background: var(--surface-2);
}

.admin-actions {
  white-space: nowrap;
}

.admin-text-cell {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 0.88rem;
}

.link-btn.danger {
  color: var(--danger);
}

.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
}

.role-admin {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

.role-user {
  background: rgba(148, 163, 184, 0.15);
  color: var(--muted);
}

.admin-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  max-width: 420px;
  width: calc(100% - 32px);
}

.admin-dialog-wide {
  max-width: 720px;
}

.admin-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.admin-dialog form,
.admin-minutes-view {
  padding: 24px;
}

.admin-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.admin-dialog select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.minutes-pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  max-height: 400px;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 0.88rem;
  line-height: 1.6;
}

.admin-loading,
.admin-error {
  color: var(--muted);
}

.admin-error {
  color: var(--danger);
}

.admin-toast.success-toast {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--accent-en);
  color: #6ee7b7;
}

@media (max-width: 768px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .admin-table {
    display: block;
    overflow-x: auto;
  }
}

/* Mobile app & download page */
.mobile-download-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  padding: 14px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.18), rgba(37, 99, 235, 0.28));
  border: 1px solid rgba(59, 130, 246, 0.45);
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.15);
}

.mobile-download-banner:active {
  transform: scale(0.98);
}

.mobile-download-banner__icon {
  flex-shrink: 0;
  font-size: 1.75rem;
  line-height: 1;
}

.mobile-download-banner__content {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.mobile-download-banner__content strong {
  display: block;
  font-size: 1rem;
  color: #93c5fd;
  margin-bottom: 2px;
}

.mobile-download-banner__content small {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

.mobile-download-banner__arrow {
  flex-shrink: 0;
  font-size: 1.25rem;
  color: var(--primary);
  font-weight: 700;
}

.mobile-download-link {
  margin: 20px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.92rem;
}

.mobile-download-link a {
  color: var(--primary);
}

.download-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

.download-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px 24px;
  box-shadow: var(--shadow);
  text-align: center;
}

.download-card .brand-icon {
  margin: 0 auto 16px;
}

.download-card h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}

.download-qr-wrap {
  margin: 24px auto;
  padding: 16px;
  background: white;
  border-radius: 16px;
  display: inline-block;
  line-height: 0;
}

.download-hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 20px;
}

.download-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 28px;
}

.download-primary-btn,
.download-secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 20px;
  border-radius: 12px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
}

.download-primary-btn {
  background: var(--primary);
  color: white;
}

#install-app-btn.download-primary-btn {
  font-size: 1.05rem;
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.35);
  animation: install-pulse 2.5s ease-in-out infinite;
}

@keyframes install-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(59, 130, 246, 0.35); }
  50% { box-shadow: 0 4px 28px rgba(59, 130, 246, 0.55); }
}

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

.download-steps {
  text-align: left;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.download-steps h2 {
  margin: 0 0 16px;
  font-size: 1rem;
}

.download-step {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.download-step strong {
  display: block;
  margin-bottom: 4px;
}

.download-step p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.step-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.download-url {
  margin: 20px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  word-break: break-all;
}

.in-app-banner {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fcd34d;
  font-size: 0.88rem;
  line-height: 1.5;
  text-align: left;
}

.install-guide-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 2000;
}

.install-guide-dialog {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px 20px 16px 16px;
  padding: 24px 20px;
  box-shadow: var(--shadow);
}

.install-guide-dialog h3 {
  margin: 0 0 16px;
  font-size: 1.1rem;
}

.install-guide-steps p {
  margin: 0 0 12px;
  line-height: 1.6;
  color: var(--text);
  font-size: 0.95rem;
}

.install-guide-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.install-guide-actions button {
  flex: 1;
  min-height: 44px;
}

.install-guide-actions .ghost-btn {
  border: 1px solid var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.admin-mobile-qr {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.admin-mobile-qr h3 {
  margin: 0 0 8px;
}

.admin-mobile-qr img {
  margin: 16px 0;
  padding: 12px;
  background: white;
  border-radius: 12px;
}

@media (max-width: 640px) {
  .page {
    padding: 16px;
    padding-top: calc(16px + env(safe-area-inset-top));
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .login-card {
    padding: 24px 20px;
    border-radius: 16px;
  }

  .room-grid {
    grid-template-columns: 1fr;
  }

  .interpret-page {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 8px 10px 0;
    padding-top: calc(8px + env(safe-area-inset-top));
    overflow: hidden;
  }

  .interpret-page .top-bar {
    margin-bottom: 4px;
  }

  .interpret-page .top-bar h1 {
    font-size: 0.92rem;
    margin: 0 0 2px;
  }

  .top-bar-leading {
    gap: 6px;
    margin-bottom: 3px;
  }

  .top-bar-leading .back-link {
    font-size: 0.78rem;
  }

  .lang-select-mobile {
    min-width: 68px;
    max-width: 80px;
    min-height: 32px;
    font-size: 0.74rem;
  }

  .gen-minutes-mobile {
    min-height: 32px !important;
    font-size: 0.68rem !important;
    padding: 4px 6px !important;
  }

  .top-bar-actions .ghost-btn {
    padding: 8px 10px;
    font-size: 0.78rem;
  }

  .room-meta {
    gap: 4px;
  }

  .room-id,
  .pair-badge,
  .status-dot {
    font-size: 0.7rem;
    padding: 2px 7px;
  }

  .interpret-layout {
    grid-template-columns: minmax(0, 0.78fr) minmax(0, 0.22fr);
    gap: 6px;
  }

  .history-panel {
    padding: 8px;
  }

  .mobile-input-slot {
    margin-top: 6px;
    padding-top: 6px;
    flex-shrink: 0;
  }

  .mobile-input-slot textarea {
    min-height: calc(1.35em * 3 + 12px) !important;
    height: calc(1.35em * 3 + 12px) !important;
    max-height: calc(1.35em * 3 + 12px) !important;
    font-size: 16px;
    padding: 8px 10px;
  }

  .mobile-input-slot .input-label-compact {
    font-size: 0.72rem;
  }

  .history-panel h2 {
    font-size: 0.82rem;
  }

  .history-list {
    margin-top: 4px;
    padding: 6px;
  }

  .history-item {
    padding: 10px;
  }

  .history-item header {
    font-size: 0.72rem;
  }

  .history-item .translated {
    font-size: 0.92rem;
  }

  .input-panel-compact {
    padding: 8px;
  }

  .input-panel-compact textarea {
    min-height: 28px !important;
    height: 28px !important;
    max-height: 28px !important;
    font-size: 0.85rem;
    padding: 4px 8px;
  }

  .input-label-compact {
    font-size: 0.72rem;
  }

  .direction-toggle-mobile button {
    font-size: 0.66rem;
    min-height: 32px;
  }

  .speech-status,
  .interim-box {
    font-size: 0.72rem;
  }

  .interpret-action-dock {
    position: relative;
    z-index: 300;
    margin: 0 -10px;
    padding: 8px 10px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    box-shadow: 0 -12px 28px rgba(0, 0, 0, 0.55);
  }

  .interpret-action-dock .action-row {
    flex-direction: row;
    gap: 8px;
  }

  .interpret-action-dock button {
    min-height: 48px;
    font-size: 0.92rem;
    font-weight: 700;
    padding: 10px 8px;
  }

  .interpret-action-dock #send-btn {
    background: linear-gradient(180deg, #3b82f6, #2563eb);
  }

  .interpret-action-dock #speech-btn {
    border-color: rgba(16, 185, 129, 0.65);
    color: #6ee7b7;
  }

  .direction-toggle,
  .direction-toggle-compact {
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    margin: 0 0 6px;
  }

  .direction-toggle-mobile {
    grid-template-columns: 1fr !important;
  }

  .action-row {
    flex-direction: row;
  }

  .interpret-toast {
    left: 10px;
    right: 10px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    font-size: 0.82rem;
  }

  button,
  .ghost-btn,
  input {
    min-height: 44px;
  }

  textarea {
    min-height: unset;
  }

  .top-bar h1 {
    font-size: 1.25rem;
  }

  .lang-switcher--fixed {
    top: calc(12px + env(safe-area-inset-top));
    right: 12px;
  }

  .error-banner.floating {
    bottom: calc(16px + env(safe-area-inset-bottom));
    left: 16px;
    right: 16px;
    transform: none;
    width: auto;
  }

  .minutes-modal {
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}
