/* iOS Safari & Home Screen PWA adaptations */
html, body {
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  background: #f4f1ed;
}

.warm-header,
.chat-header,
.settings-header {
  padding-top: max(12px, env(safe-area-inset-top)) !important;
}

.voice-dock,
.chat-composer {
  padding-bottom: max(10px, env(safe-area-inset-bottom)) !important;
}

.talk-entry {
  bottom: max(18px, calc(12px + env(safe-area-inset-bottom))) !important;
}

/* Prevent iOS Safari auto-zoom on inputs < 16px */
input, textarea, select {
  font-size: 16px;
}

/* Account & Vault Setup Overlay (warm minimalist, matches 知还 aesthetic) */
#zhVaultGate {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  background: rgba(34, 29, 24, 0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#zhVaultGate[hidden] {
  display: none !important;
}

#zhVaultGate.is-locked {
  background: #f4f1ed;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.zh-gate-card {
  width: 100%;
  max-width: 420px;
  max-height: 90dvh;
  overflow-y: auto;
  background: #faf8f5;
  color: #26211c;
  border-radius: 22px;
  padding: 22px 20px 20px;
  box-shadow: 0 20px 56px rgba(34, 24, 14, 0.24);
  box-sizing: border-box;
}

.zh-gate-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.zh-gate-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.zh-gate-logo {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(145deg, #c98845, #a96728);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  display: grid;
  place-items: center;
  flex: none;
}

.zh-gate-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #241f1a;
}

.zh-gate-close {
  border: 0;
  background: rgba(38, 33, 28, 0.07);
  color: #5b5248;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.zh-gate-sub {
  margin: 4px 0 14px;
  font-size: 13px;
  line-height: 1.55;
  color: #776d62;
}

.zh-gate-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border-radius: 13px;
  background: #efeae3;
  margin-bottom: 14px;
}

.zh-gate-tabs button {
  border: 0;
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 14px;
  font-weight: 600;
  color: #6b6156;
  background: transparent;
  cursor: pointer;
}

.zh-gate-tabs button.active {
  background: #fff;
  color: #241f1a;
  box-shadow: 0 2px 8px rgba(34, 24, 14, 0.08);
}

.zh-gate-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.zh-gate-field span {
  font-size: 13px;
  font-weight: 600;
  color: #4a4138;
}

.zh-gate-field input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #e2d9ce;
  background: #fff;
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 15px;
  color: #241f1a;
  outline: none;
}

.zh-gate-field input:focus {
  border-color: #b87431;
  box-shadow: 0 0 0 3px rgba(184, 116, 49, 0.14);
}

.zh-gate-code-box {
  background: #f3ede4;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.zh-gate-code-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.zh-gate-code-top span {
  font-size: 12px;
  font-weight: 600;
  color: #6b5e50;
}

.zh-gate-code-val {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #241f1a;
  word-break: break-all;
}

.zh-gate-code-btns {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.zh-gate-code-btns button {
  flex: 1;
  border: 0;
  border-radius: 9px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  background: #fff;
  color: #4a4138;
  cursor: pointer;
}

.zh-gate-primary {
  width: 100%;
  border: 0;
  border-radius: 13px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #c17e3b, #a86526);
  cursor: pointer;
}

.zh-gate-primary:disabled {
  opacity: 0.6;
}

.zh-gate-secondary {
  width: 100%;
  margin-top: 8px;
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #6b6156;
  background: transparent;
  cursor: pointer;
}

.zh-gate-msg {
  margin: 10px 0 0;
  padding: 9px 11px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
}

.zh-gate-msg.err {
  background: #fdeceb;
  color: #a63228;
}

.zh-gate-switch-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  border: 1px solid rgba(166, 50, 40, 0.25);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
  color: #8f261d;
  background: #fff;
  cursor: pointer;
}

.zh-gate-msg.ok {
  background: #eaf5ee;
  color: #226b47;
}

.zh-gate-details {
  margin: 8px 0 12px;
  font-size: 12px;
  color: #776d62;
}

.zh-gate-details summary {
  cursor: pointer;
  padding: 4px 0;
  font-weight: 600;
}

.zh-gate-snap-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}

.zh-gate-snap-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  border: 1px solid #e4dcd2;
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
  color: #241f1a;
  cursor: pointer;
}

.zh-gate-snap-btn small {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: #7c7166;
}

.zh-gate-tip {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #ece5dc;
  font-size: 12px;
  line-height: 1.5;
  color: #857a6f;
}
