:root {
  color-scheme: light;
  --page: #f5f7f5;
  --paper: #fff;
  --ink: #1c2821;
  --muted: #68756d;
  --line: #e4e9e5;
  --green: #24734c;
  --green-dark: #19593a;
  --mint: #eaf4ed;
  --notice: #fff7e6;
  --error: #a5382d;
  --radius: 18px;
  --header-height: 62px;
  --nav-space: 96px;
  font-family: Inter, "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; padding-bottom: var(--nav-space); }
button, input, textarea, select { font: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
button { min-height: 44px; border: 1px solid transparent; border-radius: 12px; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: wait; opacity: .62; }
button, a, select { -webkit-tap-highlight-color: transparent; }

.topbar {
  position: sticky;
  z-index: 5;
  top: 0;
  display: flex;
  height: var(--header-height);
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 max(20px, calc((100vw - 980px) / 2));
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 96%, transparent);
  backdrop-filter: blur(12px);
}
.brand { display: flex; flex: 0 0 auto; align-items: center; gap: 10px; text-decoration: none; font-weight: 720; letter-spacing: .015em; white-space: nowrap; }
.mark { display: inline-grid; width: 29px; height: 29px; flex: 0 0 auto; place-items: center; border-radius: 36% 44% 36% 44%; background: var(--green); color: #e7f3e9; }
.mark::before { content: ""; width: 47%; height: 47%; border-radius: 2px 65% 2px 65%; background: currentColor; transform: rotate(-22deg); }
.mark-large { width: 52px; height: 52px; }
.topbar-caption { color: var(--muted); font-size: .88rem; }

.login-view { display: grid; min-height: calc(100dvh - var(--header-height)); place-items: center; padding: 26px 18px 60px; }
.login-panel { width: min(100%, 430px); padding: clamp(25px, 7vw, 46px); border: 1px solid var(--line); border-radius: 25px; background: var(--paper); box-shadow: 0 20px 60px #2436290c; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.8rem, 5vw, 2.35rem); letter-spacing: -.045em; line-height: 1.18; }
h2 { margin-bottom: 0; font-size: 1.08rem; letter-spacing: -.02em; }
.login-panel h1 { margin: 19px 0 28px; font-size: clamp(1.55rem, 4.7vw, 2rem); }
.login-panel form { display: grid; gap: 10px; }
label { font-weight: 630; }
input, textarea, select { color: var(--ink); background: var(--paper); }
input { width: 100%; height: 49px; margin-bottom: 11px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 11px; }
.error { color: var(--error); margin: 0 0 8px; }
.login-panel .primary { min-height: 49px; margin-top: 6px; }
.register-link { display: block; margin: 9px auto 0; }

.primary { padding: 10px 18px; color: #fff; background: var(--green); font-weight: 650; transition: background 180ms ease, transform 180ms ease; }
.primary:hover:not(:disabled) { background: var(--green-dark); }
.primary:active:not(:disabled) { transform: scale(.98); }
.quiet { padding: 8px 12px; color: var(--green-dark); background: transparent; font-weight: 600; }
.quiet:hover { background: var(--mint); }
.status { min-height: 24px; margin: 0 0 3px; color: var(--muted); font-size: .9rem; }
.status[data-error="true"] { color: var(--error); }

.chat-view { display: grid; width: min(100%, 920px); height: calc(100dvh - var(--header-height) - var(--nav-space)); margin: 0 auto; grid-template-rows: minmax(0, 1fr) auto; }
.feed { min-height: 0; overflow-y: auto; overflow-wrap: anywhere; overscroll-behavior: contain; }
.feed-inner { display: flex; width: min(100%, 790px); min-height: 100%; margin: auto; padding: 24px 22px 30px; flex-direction: column; }
.earlier { align-self: center; margin-bottom: 12px; }
.intro { margin: auto 0; padding: 25px 0 40px; text-align: center; }
.intro h1 { margin-top: 19px; }
.intro p { margin: 12px 0 22px; color: var(--muted); line-height: 1.55; }
.suggestion { max-width: 100%; min-height: 44px; padding: 10px 16px; border-color: var(--line); color: var(--green-dark); background: var(--paper); }
.suggestion:hover { background: var(--mint); }
.message { display: flex; width: fit-content; max-width: min(88%, 640px); margin-bottom: 17px; padding: 10px 16px 13px; flex-direction: column; border: 1px solid var(--line); border-radius: 4px 17px 17px; background: var(--paper); }
.message.user { margin-left: auto; border-color: #d8e8dc; border-radius: 17px 4px 17px 17px; background: var(--mint); }
.message.reminder { background: var(--notice); border-color: #efe1c0; }
.message figcaption { margin-bottom: 3px; color: var(--muted); font-size: .78rem; font-weight: 650; }
.message p { margin: 0; line-height: 1.68; white-space: pre-wrap; }
.compose-zone { width: min(100%, 790px); margin: 0 auto; padding: 0 22px 16px; }
#compose { display: grid; grid-template-columns: minmax(0, 1fr) 46px auto; gap: 7px; align-items: end; padding: 7px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: 0 6px 21px #2436290a; }
textarea { display: block; width: 100%; min-width: 0; min-height: 46px; max-height: 8rem; padding: 12px 10px; resize: none; border: 0; border-radius: 9px; line-height: 1.4; field-sizing: content; }
.voice-shortcut { display: grid; width: 46px; height: 46px; place-items: center; border-radius: 13px; color: var(--green-dark); background: #f2f6f3; transition: background 180ms ease; }
.voice-shortcut:hover { background: var(--mint); }
.voice-shortcut svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.send { min-height: 46px; }

.app-page { min-height: calc(100dvh - var(--header-height)); padding: 30px 22px 35px; }
.page-inner { width: min(100%, 720px); margin: 0 auto; }
.page-heading { margin-bottom: 25px; }
.page-heading p { margin: 9px 0 0; color: var(--muted); line-height: 1.6; }
.back-link { display: inline-flex; min-height: 44px; align-items: center; margin: -7px 0 13px; color: var(--green-dark); text-decoration: none; font-size: .92rem; font-weight: 630; }
.back-link::before { content: "‹"; margin-right: 8px; font-size: 1.5rem; line-height: .7; }

.voice-view { min-height: calc(100dvh - var(--header-height)); padding: clamp(25px, 6vh, 60px) 22px 36px; }
.voice-page-inner { width: min(100%, 740px); margin: 0 auto; }
.voice-heading { margin-bottom: 23px; }
.voice-heading p { margin: 9px 0 0; color: var(--muted); line-height: 1.6; }
.voice-channels { display: grid; gap: 12px; }
.voice-card { display: flex; min-height: 146px; align-items: center; justify-content: space-between; gap: 20px; padding: 23px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); transition: border-color 180ms ease, box-shadow 180ms ease; }
.voice-card.is-preferred { border-color: #8fb69b; box-shadow: 0 0 0 2px #24734c10; }
.voice-card p { margin: 8px 0 0; color: var(--muted); line-height: 1.55; }
.preferred-label { display: inline-block; margin-top: 8px; color: var(--green-dark); font-size: .8rem; font-weight: 650; }
.voice-action { flex: none; min-width: 118px; }
#voice-toggle:disabled { background: var(--line); color: #59625c; cursor: not-allowed; opacity: 1; }
.voice-view .status { margin-top: 16px; }
.voice-captions { padding: 4px 18px; border-left: 2px solid var(--line); overflow-wrap: anywhere; }
.voice-captions p { margin: 8px 0; line-height: 1.6; white-space: pre-wrap; }
.voice-captions p:empty { display: none; }
#mimo-transcript { color: var(--muted); }

.segmented { display: inline-flex; gap: 4px; margin: 0 0 13px; padding: 4px; border-radius: 13px; background: #e9eeea; }
.segment { min-height: 38px; padding: 6px 14px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; font-size: .9rem; }
.segment.is-selected { color: var(--ink); background: var(--paper); box-shadow: 0 1px 4px #15291b13; }
.record-list { overflow: hidden; border-top: 1px solid var(--line); }
.record-item { display: flex; min-height: 80px; align-items: center; justify-content: space-between; gap: 16px; padding: 17px 2px; border-bottom: 1px solid var(--line); }
.record-content { min-width: 0; }
.record-content small { color: var(--muted); font-size: .82rem; line-height: 1.5; }
.record-content p { margin: 5px 0 0; line-height: 1.62; overflow-wrap: anywhere; }
.record-action { flex: 0 0 auto; min-height: 40px; padding: 6px 12px; border-color: #d8e3db; color: var(--green-dark); background: var(--paper); font-size: .87rem; font-weight: 620; }
.record-action:hover { background: var(--mint); }
.empty-state { padding: 48px 16px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink); font-weight: 650; }
.empty-state p { margin: 8px 0 0; line-height: 1.6; }

.account-summary { display: flex; align-items: center; gap: 15px; margin: 1px 0 27px; padding: 20px; border-radius: var(--radius); background: var(--paper); }
.account-avatar { display: grid; width: 54px; height: 54px; flex: 0 0 auto; place-items: center; border-radius: 50%; color: var(--green-dark); background: var(--mint); font-size: 1.35rem; font-weight: 700; }
.account-details { display: grid; min-width: 0; gap: 5px; }
.account-details strong { overflow: hidden; font-size: 1.05rem; text-overflow: ellipsis; white-space: nowrap; }
.account-details span { overflow: hidden; color: var(--muted); font-size: .9rem; text-overflow: ellipsis; white-space: nowrap; }
.settings-section { margin-top: 24px; }
.settings-section h2 { margin: 0 2px 9px; color: var(--muted); font-size: .9rem; font-weight: 650; }
.settings-row { display: flex; width: 100%; min-height: 68px; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; color: var(--ink); background: var(--paper); text-align: left; text-decoration: none; }
.settings-row:first-of-type { border-radius: 15px 15px 0 0; }
.settings-row:last-of-type { border-bottom: 0; border-radius: 0 0 15px 15px; }
.settings-row > span:first-child { display: grid; min-width: 0; gap: 4px; }
.settings-row strong { font-size: .96rem; font-weight: 630; }
.settings-row small { color: var(--muted); font-size: .82rem; font-weight: 400; line-height: 1.45; }
.settings-row:hover { background: #fbfcfb; }
.row-value { overflow: hidden; margin-left: auto; color: var(--muted); font-size: .86rem; text-overflow: ellipsis; white-space: nowrap; }
.chevron { flex: 0 0 auto; color: #8a968e; font-size: 1.45rem; line-height: 1; }
.preference-select select { width: auto; max-width: 150px; min-height: 42px; margin-left: auto; padding: 6px 28px 6px 9px; border: 1px solid var(--line); border-radius: 10px; font-size: .88rem; }
.preference-toggle input { width: 46px; height: 26px; flex: 0 0 auto; appearance: none; margin: 0 2px 0 auto; border: 0; border-radius: 99px; background: #d8dfda; cursor: pointer; transition: background 180ms ease; }
.preference-toggle input::after { content: ""; display: block; width: 20px; height: 20px; margin: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px #0002; transition: transform 180ms ease; }
.preference-toggle input:checked { background: var(--green); }
.preference-toggle input:disabled:checked { background: #aeb8b1; }
.preference-toggle input:checked::after { transform: translateX(20px); }
.preference-toggle input:disabled { cursor: not-allowed; opacity: .5; }
.save-preferences { display: block; width: 100%; margin-top: 12px; }
.session-section { margin-top: 27px; }
.sign-out-row { border-radius: 15px !important; color: var(--error); font-weight: 650; }
.profile-memory { margin-bottom: 22px; padding: 17px 18px; border-radius: 15px; background: var(--mint); }
.profile-memory h2 { margin-bottom: 7px; color: var(--green-dark); font-size: .92rem; }
.profile-memory p { margin: 0; line-height: 1.65; }
.memory-source { margin-top: 10px; color: var(--muted); font-size: .85rem; }
.memory-source summary { min-height: 35px; display: inline-flex; align-items: center; color: var(--green-dark); cursor: pointer; font-weight: 600; }
.memory-source p { margin: 5px 0 0; padding: 10px; border-radius: 10px; background: #f5f7f5; }
.memory-item { align-items: flex-start; }

.bottom-nav { position: fixed; z-index: 10; right: 0; bottom: 0; left: 0; display: grid; height: calc(68px + env(safe-area-inset-bottom)); padding: 4px 10px env(safe-area-inset-bottom); grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 97%, transparent); backdrop-filter: blur(16px); }
.bottom-nav-item { display: flex; min-height: 54px; align-items: center; justify-content: center; gap: 4px; flex-direction: column; border-radius: 13px; color: #77837b; text-decoration: none; font-size: .72rem; font-weight: 570; transition: color 180ms ease, background 180ms ease; }
.bottom-nav-item svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.bottom-nav-item[aria-current="page"] { color: var(--green-dark); background: #f0f6f1; font-weight: 700; }

dialog { width: min(580px, calc(100vw - 28px)); max-height: min(82dvh, 730px); padding: 22px; border: 1px solid var(--line); border-radius: 20px; color: var(--ink); background: var(--paper); }
dialog::backdrop { background: #202b2377; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-header h2 { font-size: 1.35rem; }
.email-bound { margin: 12px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.email-form, .email-password { display: grid; gap: 8px; }
.email-form { margin-top: 14px; }
.email-form input { min-width: 0; margin-bottom: 4px; }
.email-code-row { display: grid; align-items: start; gap: 8px; grid-template-columns: minmax(0, 1fr) auto; }
.email-send { min-height: 49px; border-color: var(--line); background: #f7f9f7; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

@media (min-width: 720px) {
  :root { --nav-space: 104px; }
  .bottom-nav { right: auto; bottom: 17px; left: 50%; width: min(390px, calc(100% - 32px)); height: 68px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 12px 40px #16271b19; transform: translateX(-50%); }
  .bottom-nav-item { flex-direction: row; gap: 8px; font-size: .83rem; }
  .compose-zone { padding-bottom: 14px; }
}

@media (max-width: 560px) {
  :root { --header-height: 56px; --nav-space: calc(68px + env(safe-area-inset-bottom)); }
  .topbar { padding: 0 16px; }
  .brand { gap: 8px; font-size: .94rem; }
  .topbar-caption { font-size: .78rem; }
  .chat-view { width: 100%; height: calc(100dvh - var(--header-height) - var(--nav-space)); }
  .feed-inner { padding: 20px 16px 24px; }
  .compose-zone { padding: 0 12px 10px; }
  #compose { grid-template-columns: minmax(0, 1fr) 42px auto; gap: 5px; padding: 6px; }
  .voice-shortcut { width: 42px; height: 44px; }
  #compose textarea { min-height: 44px; padding-inline: 8px; }
  #compose .send { min-height: 44px; padding-inline: 12px; }
  .app-page, .voice-view { padding: 23px 16px 30px; }
  .voice-card { align-items: flex-start; flex-direction: column; gap: 16px; padding: 19px; }
  .login-view { min-height: calc(100dvh - var(--header-height)); }
  .message { max-width: 94%; }
  .account-summary { padding: 16px; }
  .settings-row { gap: 8px; padding-inline: 11px; }
  .preference-select select { max-width: 132px; padding-right: 21px; font-size: .82rem; }
  .row-value { max-width: 44%; font-size: .78rem; }
  .record-item { gap: 10px; }
  .record-action { min-height: 38px; padding-inline: 9px; font-size: .82rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
