/*
 * LaoLive 视觉：沿用 LOOKMY 学习端手机版的设计语言。
 * 数值来源：LOOKMY english-material-preview-v1/src/styles.css 与 docs/CARD_MATERIAL_STANDARD.md
 *（暖白画布、森林绿、柔边白卡、44px 胶囊按钮、浮动底部胶囊、绿色下划线标签、带阻尼的连续动效）。
 * 只借设计语言，不引用主站任何代码或资源。
 */
:root {
  --canvas: #f7f7f3;
  --card: #ffffff;
  --ink: #182019;
  --ink-2: #4f574f;
  --muted: #6d726d;
  --faint: #8b918a;
  --green: #53785f;
  --green-hover: #466b52;
  --green-press: #3f624a;
  --green-deep: #233d2b;
  --green-tint: #edf2eb;
  --gold: #8b7650;
  --hairline: #e0e3dc;
  --ring: rgb(130 141 128 / 17%);
  --error: #a8473b;
  --shadow: 0 8px 26px -12px rgb(24 32 25 / 10%), 0 2px 5px -3px rgb(24 32 25 / 4%);
  --shadow-mobile: 0 10px 32px -12px #18201919;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-tab: cubic-bezier(0.2, 0.8, 0.2, 1);
  --serif: Georgia, 'Times New Roman', serif;
  --font:
    -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI',
    'Microsoft YaHei', 'Noto Sans SC', 'Noto Sans Lao', 'Lao Sangam MN', 'Phetsarath OT', system-ui,
    sans-serif;
  --font-lo:
    'Noto Sans Lao', 'Lao Sangam MN', 'Phetsarath OT', 'Saysettha OT', 'Noto Sans Lao UI',
    var(--font);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  height: 100%;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
h1,
h2,
h3,
p,
ol {
  margin: 0;
  padding: 0;
}
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}
a {
  color: inherit;
  text-decoration: none;
  touch-action: manipulation;
}
:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
  border-radius: 12px;
}
[hidden] {
  display: none !important;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.lo,
:lang(lo) {
  font-family: var(--font-lo);
}
.muted {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

/* ── 共用元件（LOOKMY 语法） ── */
.eyebrow {
  font-size: 12px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.06em;
}
.brand {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 34px;
  line-height: 1.15;
  letter-spacing: -0.6px;
}
.card {
  background: var(--card);
  border-radius: 26px;
  box-shadow: var(--shadow-mobile);
}
.primary-button,
.ghost-button {
  min-height: 44px;
  padding: 10px 20px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  transition:
    background-color 0.15s,
    transform 0.14s,
    box-shadow 0.15s;
}
.primary-button {
  background: var(--green);
  color: #fff;
}
.primary-button:hover {
  background: var(--green-hover);
  box-shadow: 0 4px 12px -5px #53785f66;
}
.primary-button:active {
  transform: scale(0.97);
  background: var(--green-press);
}
.ghost-button {
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px #a5b09e;
  font-weight: 500;
}
.ghost-button:active {
  transform: scale(0.97);
  background: #f3f6f1;
}
.primary-button.wide {
  width: 100%;
  min-height: 48px;
  font-size: 16px;
}
.icon-button {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #596159;
  transition:
    background-color 0.15s,
    transform 0.15s;
}
.icon-button:hover {
  background: #e8ede6;
}
.icon-button:active {
  transform: scale(0.94);
  background: #e8ede6;
}
.field {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 99px;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--ring);
  color: #7d847b;
  transition: box-shadow 0.18s;
}
.field:focus-within {
  box-shadow:
    inset 0 0 0 1.5px var(--green),
    0 0 0 4px #53785f0b;
}
.field input {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  border: 0;
  outline: none !important;
  background: transparent;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
}
.field input::placeholder,
textarea::placeholder {
  color: #81877e;
}

/* 页面进场：与 LOOKMY content-arrive 一致，轻微上浮、不遮正文 */
@keyframes content-arrive {
  from {
    opacity: 0.65;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes sheet-arrive {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 12px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}
@keyframes turn-arrive {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes listen-ring {
  0% {
    box-shadow:
      0 0 0 0 rgb(83 120 95 / 28%),
      0 8px 20px -8px rgb(35 61 43 / 45%);
  }
  70% {
    box-shadow:
      0 0 0 12px rgb(83 120 95 / 0%),
      0 8px 20px -8px rgb(35 61 43 / 45%);
  }
  100% {
    box-shadow:
      0 0 0 0 rgb(83 120 95 / 0%),
      0 8px 20px -8px rgb(35 61 43 / 45%);
  }
}

/* ── 视图 ── */
.view {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  max-width: 600px;
  margin: 0 auto;
  background: var(--canvas);
}
.view.entering {
  animation: content-arrive 0.28s var(--ease-out);
}

/* 登录 */
.view-login {
  justify-content: center;
  padding: 24px 20px;
}
.login-box {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
}
.login-box .brand {
  margin-top: 8px;
  font-size: 44px;
}
.lede {
  margin-top: 10px;
  font-size: 16px;
  color: var(--muted);
  line-height: 1.6;
}
.login-form {
  display: grid;
  gap: 12px;
  margin-top: 36px;
}
.error {
  color: var(--error);
  font-size: 14px;
}

/* 首页 */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: calc(18px + var(--safe-top)) 14px 4px 22px;
}
.topbar .brand {
  margin-top: 4px;
}
.subtitle {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 6px;
  min-height: 20px;
  font-size: 14px;
  color: var(--muted);
}
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: none;
  background: var(--green);
}
.live .dot {
  display: inline-block;
}
.live.ok .dot {
  animation: listen-dot 1.6s ease-in-out infinite;
}
@keyframes listen-dot {
  50% {
    opacity: 0.35;
  }
}
.live.warn .dot {
  background: var(--gold);
}
.live.error .dot {
  background: var(--error);
}
.live.error .subtitle {
  color: var(--error);
}

.tabs {
  display: flex;
  gap: 22px;
  padding: 0 22px;
  border-bottom: 1px solid var(--hairline);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tabs button {
  position: relative;
  flex-shrink: 0;
  min-height: 46px;
  padding: 0 1px;
  font-size: 14px;
  color: #70766c;
  transition: color 0.15s;
}
.tabs button::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--green);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s var(--ease-tab);
}
.tabs button[aria-checked='true'] {
  color: var(--green);
  font-weight: 600;
}
.tabs button[aria-checked='true']::after {
  transform: scaleX(1);
}

.stream {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 8px 22px calc(120px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
}
.empty {
  margin: auto 0;
  padding: 0 12px 40px;
  text-align: center;
}
.empty-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--green-tint);
  color: var(--green);
}
.empty-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 6px;
}

/* 历史句：细线分隔的连续列表 */
.turn {
  padding: 16px 2px;
  border-bottom: 1px solid var(--hairline);
  animation: turn-arrive 0.26s var(--ease-out);
}
.turn-source {
  font-size: 14px;
  line-height: 1.65;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.turn-time {
  margin-left: 8px;
  font-size: 11px;
  color: var(--faint);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.turn-translation {
  margin-top: 3px;
  font-size: 19px;
  line-height: 1.55;
  font-weight: 600;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.turn-translation.lo {
  font-size: 20px;
  line-height: 1.75;
}
/* 最新一句：唯一的一张柔边白卡，是眼睛的落点 */
.turn.latest {
  margin: 14px -4px 4px;
  padding: 18px 18px 20px;
  border-bottom: 0;
  border-radius: 26px;
  background: var(--card);
  box-shadow: var(--shadow-mobile);
}
.turn.latest .turn-translation {
  margin-top: 6px;
  font-size: 24px;
}
.turn.latest .turn-translation.lo {
  font-size: 26px;
}
.turn.pending .turn-translation:empty::after {
  content: '…';
  color: var(--faint);
}

/* 底部浮动胶囊：LOOKMY mobile-capsule 语法，中间是麦克风 */
.capsule {
  position: fixed;
  z-index: 20;
  left: max(16px, calc((100vw - 560px) / 2));
  right: max(16px, calc((100vw - 560px) / 2));
  bottom: calc(16px + var(--safe-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: 7px 10px;
  border-radius: 40px;
  background: rgb(255 255 255 / 82%);
  -webkit-backdrop-filter: blur(22px) saturate(125%);
  backdrop-filter: blur(22px) saturate(125%);
  box-shadow:
    inset 0 1px 0 #fff,
    0 10px 32px -12px #18201925;
  isolation: isolate;
}
.capsule-side {
  flex: 1;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 28px;
  color: #596159;
  font-size: 12px;
  transition:
    background-color 0.15s,
    transform 0.15s;
}
.capsule-side:active {
  background: #e8ede6;
  transform: scale(0.96);
}
.capsule-divider {
  width: 1px;
  height: 28px;
  background: #d8ddd2;
  flex-shrink: 0;
}
.mic-wrap {
  position: relative;
  flex: 0 0 auto;
  padding: 0 14px;
  display: grid;
  place-items: center;
}
.wave {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  width: 140px;
  height: 24px;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}
.live .wave {
  opacity: 1;
}
.mic {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--green);
  color: #fff;
  box-shadow: 0 8px 20px -8px rgb(83 120 95 / 60%);
  transition:
    background-color 0.22s var(--ease-out),
    transform 0.14s,
    box-shadow 0.22s;
}
.mic:hover {
  background: var(--green-hover);
}
.mic:active {
  transform: scale(0.94);
}
.mic svg {
  transition:
    transform 0.22s var(--ease-out),
    opacity 0.18s;
}
.mic .i-stop {
  position: absolute;
  opacity: 0;
  transform: scale(0.6);
}
.live .mic {
  background: var(--green-deep);
}
.live.ok .mic {
  animation: listen-ring 1.8s ease-out infinite;
}
.live .mic .i-mic {
  opacity: 0;
  transform: scale(0.6);
}
.live .mic .i-stop {
  opacity: 1;
  transform: none;
}

/* ── 对坐 ── */
.view-f2f {
  max-width: none;
}
.f2f-half {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 26px;
  overflow: hidden;
  text-align: center;
}
.f2f-lo {
  margin: calc(12px + var(--safe-top)) 12px 0;
  border-radius: 28px;
  background: var(--card);
  box-shadow: var(--shadow);
  transition: transform 0.36s var(--ease-out);
}
.f2f-lo.flipped {
  transform: rotate(180deg);
}
.f2f-zh {
  padding-bottom: calc(24px + var(--safe-bottom));
}
.f2f-text {
  max-height: 100%;
  overflow-y: auto;
  overflow-wrap: anywhere;
  scrollbar-width: none;
}
.f2f-text::-webkit-scrollbar {
  display: none;
}
.f2f-text.lo {
  font-size: clamp(30px, 8.4vw, 54px);
  line-height: 1.65;
  font-weight: 600;
  color: #0f1610;
}
.f2f-text.zh {
  font-size: clamp(22px, 6vw, 34px);
  line-height: 1.5;
  font-weight: 600;
}
.f2f-bar {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 16px 12px 4px;
  flex-wrap: wrap;
}
.f2f-status {
  min-height: 18px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* ── 次级页面 ── */
.view-sub.entering {
  animation: sheet-arrive 0.3s var(--ease-out);
}
.subbar {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  padding: calc(10px + var(--safe-top)) 10px 6px;
}
.subbar h2 {
  text-align: center;
  font-size: 17px;
  font-weight: 600;
}
.spacer {
  width: 44px;
}
.sub-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 18px calc(36px + var(--safe-bottom));
}
.section-label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 26px 6px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gold);
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--hairline);
}
.section-label:first-child {
  margin-top: 8px;
}
.list {
  overflow: hidden;
  padding: 4px 0;
}
.option,
.row-button {
  display: flex;
  width: 100%;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  font-size: 16px;
  text-align: left;
  transition: background-color 0.16s;
}
.option + .option,
.row-button + .row-button {
  box-shadow: inset 0 1px 0 var(--hairline);
}
.option:active,
.row-button:active {
  background: #53785f0c;
}
.option small {
  margin-left: 8px;
  color: var(--faint);
  font-size: 13px;
}
.check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1.5px #c3cbbf;
  color: transparent;
  font-size: 12px;
  transition:
    background-color 0.18s,
    box-shadow 0.18s,
    color 0.18s;
}
.option[aria-checked='true'] {
  color: var(--green-deep);
  font-weight: 600;
}
.option[aria-checked='true'] .check {
  background: var(--green);
  box-shadow: none;
  color: #fff;
}
.row-button {
  color: var(--green);
  font-weight: 500;
}
.row-button.danger {
  color: var(--error);
}
.hint {
  margin: 10px 6px 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--faint);
}
textarea {
  display: block;
  width: 100%;
  min-height: 92px;
  padding: 14px 18px;
  border: 0;
  border-radius: 22px;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--ring);
  font: inherit;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  resize: vertical;
  outline: none;
  transition: box-shadow 0.18s;
}
textarea:focus {
  box-shadow:
    inset 0 0 0 1.5px var(--green),
    0 0 0 4px #53785f0b;
}

/* 图片翻译 */
.view-sub .card:not(.list) {
  padding: 20px 18px;
}
.card-lede {
  margin-top: 6px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-2);
}
.pick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
.pick {
  position: relative;
  flex: 1 1 8rem;
  cursor: pointer;
}
.pick input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.pick:focus-within {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}
.preview {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  margin-top: 18px;
  border-radius: 22px;
  background: #eceee8;
  animation: content-arrive 0.28s var(--ease-out);
}
.status-line {
  margin-top: 16px;
  font-size: 15px;
  color: var(--muted);
  text-align: center;
}
.status-line.error {
  color: var(--error);
}
.rows {
  list-style: none;
  margin-top: 8px;
}
.rows li {
  padding: 16px 2px;
  border-bottom: 1px solid var(--hairline);
  animation: turn-arrive 0.26s var(--ease-out);
}
.rows li:last-child {
  border-bottom: 0;
}

/* 提示：LOOKMY toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(110px + var(--safe-bottom));
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 12px 20px;
  border-radius: 99px;
  background: var(--green-deep);
  color: #fff;
  font-size: 13px;
  text-align: center;
  z-index: 50;
  animation: toast-in 0.18s var(--ease-out);
}

/* 系统辅助设置：动效、透明度、对比度降级 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .primary-button:active,
  .ghost-button:active,
  .icon-button:active,
  .mic:active,
  .capsule-side:active {
    transform: none;
  }
}
@media (prefers-reduced-transparency: reduce) {
  .capsule {
    background: var(--canvas);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    outline: 1px solid #88947f;
  }
}
@media (prefers-contrast: more) {
  :root {
    --muted: #4f574f;
    --faint: #5d655d;
    --hairline: #9aa597;
  }
  .card,
  .turn.latest,
  .f2f-lo {
    box-shadow: none;
    outline: 1px solid #819084;
  }
  .capsule {
    background: var(--canvas);
    backdrop-filter: none;
    outline: 1px solid #88947f;
  }
}
