/* CHSHNY Translator Web/PWA v0.1.0 */
:root {
  --blue: #0b5fff;
  --teal: #00897b;
  --red: #d32f2f;
  --bg: #f5f7fa;
  --card-user: #f3f7ff;
  --card-cust: #f2fbf7;
  --text: #16202c;
  --muted: #6b7683;
  --scale: 1;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--blue);
  color: #fff;
  flex-wrap: wrap;
}
.brand { display: flex; flex-direction: column; margin-right: auto; }
.title { font-weight: 700; font-size: 16px; }
.status { font-size: 12px; opacity: .95; }
.status.on::before { content: "🟢 "; }
.status.slow::before { content: "🟡 "; }
.status.off::before { content: "🔴 "; }

.langs { display: flex; gap: 6px; }
.lang {
  border: 1px solid rgba(255,255,255,.6);
  background: transparent;
  color: #fff;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 14px;
}
.lang.active { background: #fff; color: var(--blue); font-weight: 700; }
.icon-btn {
  border: none; background: rgba(255,255,255,.15); color: #fff;
  width: 36px; height: 36px; border-radius: 10px; font-size: 18px;
}

.error-bar {
  display: flex; align-items: center; gap: 8px;
  background: #ffebee; color: #b71c1c; padding: 8px 12px; font-size: 14px;
}
.error-bar span { flex: 1; }
.hidden { display: none !important; }

.chat { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.chat .empty { color: var(--muted); text-align: center; margin-top: 40px; line-height: 1.8; }

.card {
  background: #fff; border-radius: 14px; padding: 12px;
  box-shadow: 0 1px 4px rgba(16, 32, 60, .08);
  border-left: 5px solid var(--blue);
}
.card.customer { border-left-color: var(--teal); background: var(--card-cust); }
.card.user { background: var(--card-user); }
.card .meta { display: flex; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.card .who { font-weight: 700; }
.card.user .who { color: var(--blue); }
.card.customer .who { color: var(--teal); }
.card .time { margin-left: auto; }
.src, .dst { font-size: calc(16px * var(--scale)); line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.dst { font-size: calc(21px * var(--scale)); font-weight: 600; margin-top: 8px; padding-top: 8px; border-top: 1px dashed #e2e8f0; }
.rtl { direction: rtl; text-align: right; }
.card .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.card .actions button { font-size: 13px; }

.controls { background: #eef1f5; padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.ptt-row { display: flex; gap: 10px; }
.ptt {
  flex: 1; min-height: 92px; border: none; border-radius: 16px; color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 18px; font-weight: 700; touch-action: none; user-select: none;
}
.ptt-blue { background: var(--blue); }
.ptt-teal { background: var(--teal); }
.ptt.recording { background: var(--red) !important; animation: pulse 1s infinite; }
.ptt:disabled { opacity: .45; }
.ptt-hint { font-size: 12px; font-weight: 400; opacity: .9; }
@keyframes pulse { 50% { filter: brightness(1.25); } }

.row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: space-between; }
.mini {
  border: 1px solid #cfd8e3; background: #fff; color: var(--text);
  border-radius: 10px; padding: 8px 12px; font-size: 14px;
}
.mini.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.mini.ghost { border: none; background: transparent; font-size: 18px; line-height: 1; }

dialog {
  border: none; border-radius: 16px; padding: 16px; width: min(92vw, 560px);
  box-shadow: 0 12px 40px rgba(10, 25, 50, .25);
}
dialog::backdrop { background: rgba(12, 22, 40, .45); }
dialog h3 { margin: 0 0 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.summary-body { max-height: 55vh; overflow-y: auto; white-space: pre-wrap; font-size: 14px; line-height: 1.6; }
textarea, input[type="url"] {
  width: 100%; border: 1px solid #cfd8e3; border-radius: 10px; padding: 10px; font-size: 15px; font-family: inherit;
}
.field { display: block; margin: 10px 0; font-size: 14px; }
.field > span { display: block; margin-bottom: 6px; color: var(--muted); }
.row-inline { display: flex; align-items: center; justify-content: space-between; }
.row-inline input { width: auto; }

.full-dialog { width: 96vw; max-width: none; height: 88vh; }
/* 只在打开时用 flex 布局；否则 <dialog> 的默认隐藏会被 display:flex 覆盖 */
.full-dialog[open] { display: flex; flex-direction: column; justify-content: center; }
.full-dialog #full-text { font-size: calc(30px * var(--scale)); font-weight: 700; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.full-dialog .full-hint { margin-top: 16px; color: var(--muted); font-size: 12px; text-align: center; }

.busy { opacity: .8; }

/* 处理中卡片 */
.card.pending { border-left-color: #f0a500; background: #fffdf5; }
.waiting { display: flex; align-items: center; gap: 10px; margin-top: 8px; color: #8a6d3b; font-size: 14px; }
.waiting .stage { font-weight: 600; }
.waiting .elapsed { margin-left: auto; font-size: 12px; color: var(--muted); }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid #f0d9a8; border-top-color: #e08a00;
  animation: spin .8s linear infinite; flex: 0 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 失败卡片 */
.card.failed { border-left-color: var(--red); background: #fff6f6; }
.card-error { color: #b71c1c; font-size: 14px; margin-top: 6px; }
