:root {
  --ink: #17212b;
  --muted: #75808c;
  --line: #e6ebf1;
  --blue: #4267f5;
  --blue-dark: #3154db;
  --soft: #f6f8fb;
  --cream: #fffdf8;
  --green: #31a874;
  --red: #d96262;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(135deg, #f8fbff 0%, #fefcf8 100%);
  font-family: Inter, "DM Sans", "Noto Sans SC", system-ui, sans-serif;
}

button, textarea, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.page-shell { width: min(920px, calc(100% - 36px)); margin: 0 auto; padding: 24px 0 34px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; letter-spacing: -.025em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; color: #fff; background: var(--blue); border-radius: 11px 11px 11px 3px; font-family: "Noto Sans SC", sans-serif; font-size: 18px; }
.top-actions, .status-pill { display: flex; align-items: center; gap: 12px; }
.status-pill { color: #66727e; font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #9aa6b2; box-shadow: 0 0 0 4px #edf0f3; }
.status-pill[data-tone="success"] .status-dot { background: var(--green); box-shadow: 0 0 0 4px #e4f7ee; }
.status-pill[data-tone="working"] .status-dot { background: #e6a832; box-shadow: 0 0 0 4px #fff3d8; }
.status-pill[data-tone="error"] .status-dot { background: var(--red); box-shadow: 0 0 0 4px #fde9e9; }
.settings-button, .text-button { border: 0; background: transparent; color: #6b7783; cursor: pointer; }
.settings-button { padding: 8px 0; font-size: 13px; }
.settings-button:hover, .text-button:hover { color: var(--blue); }

.translator-card { padding: 20px; background: rgba(255,255,255,.9); border: 1px solid rgba(220,227,234,.9); border-radius: 24px; box-shadow: 0 20px 55px rgba(30,50,80,.1); }
.card-toolbar, .card-footer, .manual-heading { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.card-toolbar { padding: 2px 4px 16px; }
.card-toolbar strong { display: block; font-size: 15px; }
.card-toolbar span, .card-footer span, .manual-heading span { color: #98a3ae; font-size: 12px; }
.toolbar-actions { display: flex; align-items: center; gap: 14px; }
.limit-hint { white-space: nowrap; }
.card-footer { padding: 14px 4px 0; }
.card-footer span { font-size: 11px; }
.input-mode-tabs { display: flex; gap: 5px; margin: 0 4px 14px; padding: 4px; border-radius: 10px; background: #f3f6fa; }
.input-mode-tab { flex: 1; border: 0; border-radius: 7px; padding: 9px 12px; color: #77838f; background: transparent; cursor: pointer; font-size: 13px; font-weight: 700; }
.input-mode-tab.active { color: var(--blue); background: #fff; box-shadow: 0 2px 8px rgba(30,50,80,.08); }
.input-mode-panel[hidden] { display: none; }

.language-panel { padding: 21px; border: 1px solid var(--line); border-radius: 18px; background: #fff; }
.en-panel { background: var(--soft); }
.transcript-window { min-height: 190px; max-height: 330px; overflow-y: auto; margin-top: 0; padding: 5px 2px; scroll-behavior: smooth; }
.window-placeholder { margin: 0; padding: 28px 0; color: #b3bdc7; font-size: 18px; line-height: 1.65; }
.live-line { margin: 0 0 14px; padding: 13px 15px; color: var(--blue-dark); background: #f1f4ff; border: 1px dashed #bdcaff; border-radius: 12px; font-size: 17px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.en-panel .live-line { color: #315c50; background: #eef8f4; border-color: #b8dfcf; }
.history-list { display: grid; gap: 12px; }
.history-item { padding: 13px 15px; border-radius: 12px; background: rgba(247,249,252,.85); border: 1px solid rgba(230,235,241,.9); font-size: 17px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.zh-panel .history-item { background: #fbfcff; }
.talk-row { margin-top: 16px; }
.hold-button { display: flex; align-items: center; width: 100%; min-height: 64px; padding: 10px 15px; border: 1px solid #cbd7ff; border-radius: 15px; color: var(--blue); background: #f4f6ff; cursor: pointer; text-align: left; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-user-drag: none; touch-action: none; transition: transform .16s, border-color .16s, background .16s, box-shadow .16s; }
.hold-button:hover { border-color: #9fb2ff; box-shadow: 0 7px 20px rgba(66,103,245,.1); }
.hold-button:active, .hold-button.is-recording { transform: translateY(1px) scale(.995); border-color: var(--blue); background: #e9edff; box-shadow: 0 0 0 4px rgba(66,103,245,.1); }
.hold-button:disabled { opacity: .48; cursor: not-allowed; box-shadow: none; }
.en-button { color: #267c61; border-color: #b9dfd0; background: #effaf5; }
.en-button:hover { border-color: #83c8ae; box-shadow: 0 7px 20px rgba(49,168,116,.1); }
.en-button:active, .en-button.is-recording { border-color: var(--green); background: #e1f6ec; box-shadow: 0 0 0 4px rgba(49,168,116,.1); }
.hold-icon { display: grid; place-items: center; width: 38px; height: 38px; margin-right: 12px; border-radius: 11px; color: #fff; background: var(--blue); font-size: 14px; font-weight: 800; }
.en-button .hold-icon { background: var(--green); font-size: 11px; }
.hold-copy { display: grid; gap: 3px; }
.hold-copy strong { font-size: 14px; }
.hold-copy small { color: #8794a1; font-size: 11px; font-weight: 500; }
.hold-state { margin-left: auto; color: #9aabff; font-size: 17px; line-height: 1; }
.en-button .hold-state { color: #8ac9b0; }
.hold-button.is-recording .hold-state { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.7); } }
.language-divider { display: grid; place-items: center; height: 42px; color: #aab4bf; }
.language-divider span { display: grid; place-items: center; width: 27px; height: 27px; border: 1px solid var(--line); border-radius: 50%; background: #fff; font-size: 17px; }

.manual-content { padding: 0 20px 20px; }
.manual-heading { padding: 2px 0 15px; }
.manual-heading strong { display: block; font-size: 14px; }
.manual-heading span { display: block; margin-top: 4px; }
.manual-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.manual-field { display: grid; gap: 7px; color: #77838f; font-size: 12px; font-weight: 700; }
.manual-field textarea, .settings-modal input, .settings-modal textarea { width: 100%; border: 1px solid #dbe3ec; border-radius: 10px; outline: 0; padding: 11px 12px; color: var(--ink); background: #fff; font: 14px/1.55 "Noto Sans SC", Inter, sans-serif; }
.manual-field textarea { min-height: 120px; resize: vertical; }
.manual-field textarea:focus, .settings-modal input:focus, .settings-modal textarea:focus { border-color: #9fb2ff; box-shadow: 0 0 0 3px rgba(66,103,245,.09); }
.manual-field-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: #9aa5b0; font-size: 11px; }
.manual-field-actions .primary-button { padding: 9px 12px; }
.primary-button, .secondary-button { border: 0; border-radius: 9px; padding: 10px 15px; cursor: pointer; font-size: 13px; font-weight: 700; }
.primary-button { color: #fff; background: var(--blue); }
.primary-button:hover { background: var(--blue-dark); }
.primary-button:disabled { opacity: .6; cursor: wait; }
.secondary-button { color: #5e6a76; background: #f0f3f7; }

.tips { display: flex; justify-content: center; align-items: center; gap: 8px; margin: 23px 0 0; color: #7e8995; font-size: 12px; text-align: center; }
.tips p { margin: 0; }
.tips strong { color: #4e5b68; }
.tip-icon { color: #f1b84b; font-size: 16px; }
footer { margin-top: 56px; color: #aab2ba; font-size: 11px; letter-spacing: .04em; text-align: center; }
footer span { padding: 0 8px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; background: rgba(20,32,48,.35); }
.modal-backdrop[hidden] { display: none; }
.settings-modal { width: min(480px, 100%); max-height: min(90vh, 760px); overflow-y: auto; padding: 25px; border-radius: 20px; background: #fff; box-shadow: 0 24px 70px rgba(20,32,48,.25); }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; }
.modal-header h2 { margin: 0; font-size: 24px; letter-spacing: -.04em; }
.modal-header .eyebrow { margin-bottom: 8px; text-align: left; }
.close-button { border: 0; background: transparent; color: #81909d; cursor: pointer; font-size: 28px; line-height: 1; }
.settings-note { margin: 17px 0; color: #7a8793; font-size: 12px; line-height: 1.6; }
.settings-modal label { display: block; margin-top: 13px; color: #586674; font-size: 12px; font-weight: 700; }
.settings-modal input, .settings-modal textarea { display: block; margin-top: 7px; }
.settings-modal textarea { resize: vertical; }
.settings-modal input:disabled, .settings-modal textarea:disabled { color: #9aa5b0; background: #f3f5f7; cursor: not-allowed; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 23px; }

@media (max-width: 680px) {
  .page-shell { width: min(100% - 24px, 920px); padding-top: 16px; }
  .topbar { align-items: flex-start; }
  .top-actions { gap: 8px; }
  .status-pill { max-width: 145px; }
  .translator-card { padding: 13px; border-radius: 19px; }
  .card-toolbar { align-items: flex-start; padding: 3px 3px 13px; }
  .toolbar-actions { display: grid; justify-items: end; gap: 4px; }
  .limit-hint { font-size: 10px !important; }
  .language-panel { padding: 12px 17px 17px; }
  .transcript-window { min-height: 150px; max-height: 270px; }
  .window-placeholder { padding: 20px 0; font-size: 16px; }
  .manual-heading { align-items: flex-start; flex-direction: column; }
  .manual-grid { grid-template-columns: 1fr; }
  .manual-content { padding: 0 14px 15px; }
  .tips { align-items: flex-start; text-align: left; }
  footer { margin-top: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
