:root {
  --bg: #eef5e8;
  --card: #ffffff;
  --ink: #1c2a16;
  --muted: #5c6b54;
  --line: #d5e3cb;
  --green: #5a8f3c;
  --green-dark: #3f6a28;
  --green-soft: #dceccb;
  --red: #d64545;
  --shadow: 0 10px 28px rgba(60, 90, 40, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  overscroll-behavior: none;
}

.hidden { display: none !important; }

.setup {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.setup-card,
.sheet-card {
  width: min(440px, 100%);
  background: var(--card);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.setup-icon {
  width: 64px;
  height: 64px;
  display: block;
  margin: 0 auto 12px;
}

.setup-card h1,
.sheet-head h2 {
  margin: 0 0 8px;
  text-align: center;
  font-size: 24px;
}

.setup-card p,
.muted,
.setup-msg {
  color: var(--muted);
  line-height: 1.5;
}

label {
  display: block;
  margin: 16px 0 6px;
  font-weight: 600;
}

input[type="password"],
input[type="text"] {
  width: 100%;
  font-size: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdf8;
}

.primary,
.send-btn {
  margin-top: 16px;
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  background: var(--green);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
}

.primary:active,
.send-btn:active { background: var(--green-dark); }

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 20px;
}

.brand img { width: 32px; height: 32px; }

.paper-chip {
  flex: 1;
  min-width: 0;
  border: 0;
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 600;
  box-shadow: var(--shadow);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--card);
  font-size: 20px;
  box-shadow: var(--shadow);
}

.status {
  margin: 10px 4px 8px;
  color: var(--muted);
  font-size: 15px;
}

.board {
  flex: 1;
  min-height: 0;
  background: var(--card);
  border-radius: 20px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.heard {
  margin: 0 0 12px;
  padding: 8px 12px;
  background: var(--green-soft);
  border-radius: 12px;
  color: var(--green-dark);
  font-size: 15px;
}

.answer {
  margin: 0;
  font-size: 22px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.dock { margin-top: 12px; }

.text-row {
  display: flex;
  gap: 8px;
}

.text-row input { flex: 1; }

.send-btn {
  margin: 0;
  width: auto;
  padding: 12px 16px;
}

.talk-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.side-btn {
  width: 72px;
  height: 72px;
  border: 0;
  border-radius: 18px;
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.side-btn:disabled { opacity: 0.45; }

.talk-btn {
  width: 128px;
  height: 128px;
  border: 0;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 12px 24px rgba(90, 143, 60, 0.35);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.talk-btn.recording {
  background: var(--red);
  transform: scale(1.04);
}

.talk-btn:disabled { opacity: 0.5; }

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(28, 42, 22, 0.35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sheet-head h2 { text-align: left; margin: 0; }

.paper-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  max-height: 50vh;
  overflow: auto;
}

.paper-list li {
  margin: 0 0 8px;
}

.paper-list button {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fbfdf8;
  border-radius: 12px;
  padding: 12px;
  font-size: 16px;
}

.paper-list button.active {
  border-color: var(--green);
  background: var(--green-soft);
}

.error { color: var(--red); }
.ok { color: var(--green-dark); }

@media (min-width: 900px) {
  .app { max-width: 720px; margin: 0 auto; }
  .answer { font-size: 24px; }
}
