@font-face {
  font-family: "Noto Sans Thai";
  src: url("/fonts/NotoSansThai.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0E00-0E7F;
}

:root {
  color-scheme: light dark;
  --bg: #e8e8ed;
  --ink: #1c1c1e;
  --secondary: rgba(60, 60, 67, 0.62);
  --glass: rgba(255, 255, 255, 0.58);
  --glass-solid: rgba(255, 255, 255, 0.86);
  --stroke: rgba(255, 255, 255, 0.72);
  --line: rgba(60, 60, 67, 0.16);
  --fill: rgba(120, 120, 128, 0.16);
  --blue: #007aff;
  --blue-ink: #fff;
  --red: #ff3b30;
  --wash-a: #d5e4f7;
  --wash-b: #f6e4d4;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Sukhumvit Set", Thonburi, "Noto Sans Thai", sans-serif;
  --radius: 22px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --ink: #f2f2f7;
    --secondary: rgba(235, 235, 245, 0.6);
    --glass: rgba(44, 44, 46, 0.62);
    --glass-solid: rgba(58, 58, 60, 0.9);
    --stroke: rgba(255, 255, 255, 0.16);
    --line: rgba(255, 255, 255, 0.12);
    --fill: rgba(120, 120, 128, 0.28);
    --blue: #0a84ff;
    --red: #ff453a;
    --wash-a: #142033;
    --wash-b: #2a2118;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  position: fixed;
  inset: 0;
  height: 100dvh;
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.35;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(70% 42% at 12% 0%, var(--wash-a), transparent 62%),
    radial-gradient(64% 46% at 100% 100%, var(--wash-b), transparent 58%),
    var(--bg);
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.glass {
  background: var(--glass);
  backdrop-filter: blur(28px) saturate(1.7);
  -webkit-backdrop-filter: blur(28px) saturate(1.7);
  border: 1px solid var(--stroke);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38), var(--shadow);
}
.card { border-radius: var(--radius); }

.lock {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(24px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
}
.lock-card {
  width: min(400px, 100%);
  padding: 28px 22px 22px;
  text-align: center;
}
.mark {
  margin: 0;
  font-size: 34px;
  line-height: 1.7;
  letter-spacing: 0;
  font-weight: 600;
}
.lock-card h1 {
  margin: 2px 0 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--secondary);
}
.quiet { margin: 0 0 18px; color: var(--secondary); font-size: 15px; }
.field { display: block; text-align: left; }
.field input, .field textarea {
  width: 100%;
  border: 0;
  border-radius: 14px;
  background: var(--fill);
  padding: 14px 16px;
  font-size: 17px;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}
.field textarea {
  min-height: 140px;
  resize: none;
  line-height: 1.55;
}
.field input:focus, .field textarea:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 35%, transparent);
}
.error { color: var(--red); font-size: 14px; min-height: 0; margin: 8px 0 0; }
.filled {
  width: 100%;
  margin-top: 14px;
  height: 50px;
  border: 0;
  border-radius: 14px;
  background: var(--blue);
  color: var(--blue-ink);
  font-weight: 600;
}
.filled:active { opacity: 0.82; }
.filled:disabled { opacity: 0.45; }

#app, .talk, .type { height: 100%; }
.talk { display: flex; flex-direction: column; }
.half {
  height: 50%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-inline: calc(16px + env(safe-area-inset-left)) calc(16px + env(safe-area-inset-right));
  gap: 8px;
}
.half.her {
  transform: rotate(180deg);
  padding-top: 8px;
  padding-bottom: calc(8px + env(safe-area-inset-top));
}
.half.him {
  padding-top: 8px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.who {
  margin: 0;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--secondary);
}
.lines {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  scrollbar-width: none;
}
.lines::-webkit-scrollbar { display: none; }
.hint {
  margin: 0;
  text-align: center;
  color: var(--secondary);
  font-size: 15px;
}
.hint[hidden] { display: none; }
.utter {
  margin: 0;
  font-size: 28px;
  font-weight: 560;
  letter-spacing: -0.02em;
  line-height: 1.28;
  user-select: text;
  -webkit-user-select: text;
}
.utter[lang="th"] {
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.75;
  font-size: 30px;
}
.bubble {
  padding: 12px 14px;
  border-radius: 18px;
}
.bubble .utter { font-size: 22px; }
.bubble .utter[lang="th"] { font-size: 24px; }
.bubble.latest .utter { font-size: 28px; }
.bubble.latest .utter[lang="th"] { font-size: 30px; }
.status-line {
  margin: 0;
  color: var(--secondary);
  font-size: 15px;
  font-weight: 600;
}
.actions, .tools { display: flex; gap: 8px; justify-content: flex-end; }
.tools { justify-content: center; }
.tool {
  border: 0;
  background: var(--fill);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 600;
}
.tool:active { transform: scale(0.97); }
.mic {
  align-self: center;
  width: 76px;
  height: 76px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--stroke);
  color: var(--ink);
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(1.7);
  -webkit-backdrop-filter: blur(24px) saturate(1.7);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), var(--shadow);
  display: grid;
  place-items: center;
  touch-action: none;
}
.mic svg { width: 30px; height: 30px; }
.mic:active { transform: scale(0.96); }
.mic[aria-pressed="true"] {
  background: var(--red);
  color: white;
  border-color: transparent;
  animation: pulse 1.2s ease-out infinite;
}
@keyframes pulse {
  50% { box-shadow: 0 0 0 12px color-mix(in srgb, var(--red) 22%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  .mic[aria-pressed="true"] { animation: none; }
}

.type {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
}
.bar, .sheet-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.bar h1, .sheet-bar h2 { margin: 0; font-size: 17px; text-align: center; }
.bar .tool { justify-self: start; }
.caption { margin: 4px 0 0; font-size: 13px; color: var(--secondary); font-weight: 600; }
.segment {
  display: flex;
  padding: 2px;
  border-radius: 10px;
  background: var(--fill);
}
.segment button {
  flex: 1;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 15px;
  font-weight: 600;
}
.segment button[aria-pressed="true"] {
  background: var(--glass-solid);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}
.grow { flex: 1; display: flex; min-height: 0; }
.grow textarea { height: 100%; }
.direction { margin: 0; min-height: 1.2em; color: var(--secondary); font-size: 13px; font-weight: 600; }
.result { padding: 16px; }
.result .actions { margin-top: 10px; }

#sheet-root[hidden] { display: none; }
.backdrop {
  position: fixed;
  inset: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.32);
  z-index: 20;
}
.sheet {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: 0;
  z-index: 21;
  max-height: 78dvh;
  border-radius: 28px 28px 0 0;
  padding: 8px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}
.grabber {
  width: 36px;
  height: 5px;
  border-radius: 99px;
  background: var(--fill);
  margin: 4px auto 8px;
}
.history { overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.turn {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.turn p { margin: 0 0 4px; user-select: text; -webkit-user-select: text; }
.turn .meta { color: var(--secondary); font-size: 12px; font-weight: 600; }
.turn .th { line-height: 1.7; }
.empty { color: var(--secondary); text-align: center; margin: 24px 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 30;
  margin: 0;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  max-width: calc(100% - 32px);
}
[hidden] { display: none !important; }
