/* =====================================================================
   旅話通・Call Translator — 日系文青手繪插畫風格 (Japanese Editorial Washi)
   Warm washi paper, sumi ink borders, matcha sage, indigo & persimmon accents
   ===================================================================== */

:root {
  --bg: #F5EFE4;
  --bg-dot: rgba(112, 96, 76, 0.13);
  --card: #FFFDF8;
  --card-soft: #FAF5EC;
  --fg: #2E2925;
  --muted: #786E62;
  --line: #DFD5C3;
  --line-strong: #C9BBA3;
  --indigo: #36556D;
  --indigo-soft: #EAF1F6;
  --matcha: #4C7C66;
  --matcha-soft: #E9F3EC;
  --persimmon: #D45D3E;
  --persimmon-soft: #FCECE6;
  --yuzu: #F2D184;
  --yuzu-soft: #FDF5DF;
  --shadow: 0 3px 0 rgba(74, 62, 48, 0.08), 0 8px 24px rgba(74, 62, 48, 0.06);
  --shadow-sm: 0 2px 0 rgba(74, 62, 48, 0.07);
  --accent: var(--indigo);
  --radius: 16px;
  --tabH: 60px;
  --tabPad: calc(var(--tabH) + 1px + env(safe-area-inset-bottom, 0px));
  --font-display: "Zen Maru Gothic", "PingFang TC", "Hiragino Maru Gothic ProN", "Noto Sans TC", sans-serif;
  --font-body: "Noto Sans TC", -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1A1816;
    --bg-dot: rgba(255, 244, 224, 0.06);
    --card: #24211D;
    --card-soft: #2C2823;
    --fg: #F0E9DD;
    --muted: #A99F92;
    --line: #3C362E;
    --line-strong: #524A40;
    --indigo: #7BA6C7;
    --indigo-soft: #22303B;
    --matcha: #6FA68B;
    --matcha-soft: #1F3228;
    --persimmon: #E27A5E;
    --persimmon-soft: #3B231C;
    --yuzu: #D8B567;
    --yuzu-soft: #362E1C;
    --shadow: 0 3px 0 rgba(0, 0, 0, 0.35), 0 10px 28px rgba(0, 0, 0, 0.28);
    --shadow-sm: 0 2px 0 rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }
html { scroll-padding-bottom: var(--tabPad); }

body {
  font-family: var(--font-body);
  margin: 0 auto;
  max-width: 680px;
  min-height: 100dvh;
  padding: 12px 12px calc(var(--tabPad) + 14px);
  color: var(--fg);
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg-dot) 1px, transparent 1px);
  background-size: 18px 18px;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
h1, h2, h3, b.ttl { font-family: var(--font-display); letter-spacing: 0.02em; }
.row { display: flex; gap: 8px; margin: 8px 0; align-items: center; }
.row > * { min-width: 0; }

input, select, textarea, button {
  font-family: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  color: var(--fg);
  background: var(--card);
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.1s ease, box-shadow 0.16s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(54, 85, 109, 0.15);
}
#to, textarea { flex: 1; width: 100%; }
button { min-height: 44px; cursor: pointer; font-weight: 500; }
button:active:not(:disabled) { transform: translateY(1px); }

/* Primary / Semantic Buttons */
.green, .btnPrimary {
  background: var(--matcha);
  color: #FFFDF8;
  border-color: var(--matcha);
  box-shadow: 0 3px 0 rgba(42, 74, 59, 0.32);
  font-weight: 700;
  flex: 1;
}
.green:hover:not(:disabled), .btnPrimary:hover:not(:disabled) { filter: brightness(1.05); }

.btnAccent, .red {
  background: var(--persimmon);
  color: #FFFDF8;
  border-color: var(--persimmon);
  box-shadow: 0 3px 0 rgba(138, 49, 27, 0.3);
  font-weight: 700;
  flex: 1;
}
.btnIndigo, #sendBtn {
  background: var(--indigo);
  color: #FFFDF8;
  border-color: var(--indigo);
  box-shadow: 0 2px 0 rgba(33, 56, 74, 0.3);
  font-weight: 700;
}
.btnSubtle {
  background: var(--card-soft);
  border: 1.5px dashed var(--line-strong);
  color: var(--fg);
  font-size: 13.5px;
  padding: 8px 12px;
  min-height: 38px;
}
.btnSubtle:hover { border-color: var(--indigo); color: var(--indigo); }
.linkBtn {
  background: none;
  border: 0;
  padding: 2px 4px;
  min-height: 0;
  color: var(--persimmon);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

button:disabled, .green:disabled, .red:disabled, .btnPrimary:disabled, .btnAccent:disabled, #sendBtn:disabled {
  opacity: 1;
  background: var(--card-soft);
  color: var(--muted);
  border-color: var(--line);
  box-shadow: none;
  cursor: not-allowed;
}

/* ==================== Auth Welcome Card (日系插畫首頁) ==================== */
.authShell {
  max-width: 440px;
  margin: 18px auto 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.authCard {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
  padding: 0 0 20px;
}
.heroWrap {
  position: relative;
  background: #FAF6EE;
  border-bottom: 1.5px dashed var(--line);
  overflow: hidden;
}
.heroImg {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: linear-gradient(135deg, #FAF6EE 0%, #EFE6D5 100%);
}
.heroStamp {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--yuzu);
  color: #3A2C12;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1.5px solid rgba(58, 44, 18, 0.2);
  box-shadow: 0 2px 6px rgba(58, 44, 18, 0.14);
}
.brandHead {
  padding: 18px 22px 10px;
  text-align: center;
}
.brandBadge {
  display: inline-block;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  font-weight: 700;
  color: var(--matcha);
  background: var(--matcha-soft);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 6px;
}
.brandHead h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.3;
  color: var(--fg);
}
.brandSub {
  margin: 6px 0 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
}

/* Segmented Login / Register Switcher */
.authTabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 12px 22px 16px;
  padding: 5px;
  background: var(--card-soft);
  border: 1.5px solid var(--line);
  border-radius: 14px;
}
.authTabs button {
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  padding: 6px 8px;
}
.authTabs button[aria-selected="true"] {
  background: var(--card);
  color: var(--fg);
  box-shadow: 0 2px 8px rgba(46, 41, 37, 0.1);
}

.authForm {
  padding: 0 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.fGroup {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.fGroup label {
  font-size: 13px;
  font-weight: 700;
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: 6px;
}
.fGroup .req { color: var(--persimmon); }
.fGroup .opt {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  background: var(--card-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 7px;
}
.fGroup input {
  width: 100%;
  height: 46px;
  background: var(--card-soft);
}
.fGroup input:focus { background: var(--card); }

.authSwitch {
  margin: 4px 0 0;
  text-align: center;
  font-size: 13.5px;
  color: var(--muted);
}
.authErr {
  margin: 10px 22px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--persimmon-soft);
  border: 1px solid rgba(212, 93, 62, 0.35);
  color: var(--persimmon);
  font-size: 13.5px;
  font-weight: 500;
}
.err:empty { display: none; }

.privacyRibbon {
  margin: 16px 22px 0;
  padding: 9px 12px;
  border-radius: 12px;
  background: var(--matcha-soft);
  color: var(--matcha);
  font-size: 12.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.adminEntry {
  background: var(--card);
  border: 1.5px dashed var(--line-strong);
  border-radius: 16px;
  padding: 2px 16px;
}
.adminEntry summary {
  min-height: 44px;
  line-height: 44px;
  font-size: 13.5px;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
}
.adminInner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0 14px;
}
.adminInner input { width: 100%; }

/* ==================== Shared Paper Cards ==================== */
.card, .paperCard, .dialCard {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card { display: flex; flex-direction: column; gap: 10px; }

/* ==================== Top Bar ==================== */
#topBar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  min-height: 48px;
  flex-wrap: nowrap;
}
.brandMini {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.miniIcon { flex: none; border-radius: 8px; box-shadow: var(--shadow-sm); }
#topBar .ttl {
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#mode:empty { display: none; }
#mode {
  flex: none;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--yuzu);
  color: #3A2C12;
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}
.pill {
  flex: none;
  font-size: 12.5px;
  line-height: 1;
  padding: 6px 11px;
  border-radius: 999px;
  font-weight: 700;
  white-space: nowrap;
  margin: 0;
  color: #FFFDF8 !important;
}
.pill.s-idle { background: #968D80; }
.pill.s-dial { background: var(--indigo); }
.pill.s-live { background: var(--matcha); }
.pill.s-fail { background: var(--persimmon); }

#statusDetail { margin: -2px 4px 8px; word-break: break-all; }
.usage {
  flex: none;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--yuzu-soft);
  border: 1.5px solid var(--yuzu);
  color: var(--fg);
  white-space: nowrap;
}
.usage.low { background: var(--persimmon-soft); border-color: var(--persimmon); color: var(--persimmon); }

.gearWrap { position: relative; margin-left: auto; flex: none; }
.gear {
  position: relative;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}
.dot { position: absolute; top: 6px; right: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--persimmon); border: 2px solid var(--card); }
.dot.alert { background: #C93B2B; }
.dot.inl { position: static; display: inline-block; margin-left: 8px; vertical-align: middle; border: 0; }

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 226px;
  max-width: min(300px, 88vw);
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 25;
  display: flex;
  flex-direction: column;
}
.menuWho { font-size: 13px; color: var(--muted); padding: 8px 10px 10px; border-bottom: 1px dashed var(--line); margin-bottom: 4px; font-weight: 700; }
.menuItem {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--fg);
  font-size: 15px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menuItem:hover, .menuItem:focus-visible { background: var(--card-soft); outline: none; }
.menuItem.low { color: var(--persimmon); }

/* ==================== Dial Card & Controls ==================== */
.dialCard {
  margin-bottom: 10px;
  padding: 14px;
}
.modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  background: var(--card-soft);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  margin-bottom: 8px;
}
.modes button {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  padding: 8px 6px;
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
}
.modes button[aria-checked="true"] {
  background: var(--indigo);
  color: #FFFDF8;
  box-shadow: 0 2px 6px rgba(54, 85, 109, 0.25);
}
.modes.locked button { pointer-events: none; }
.modes.locked button[aria-checked="false"] { opacity: 0.35; }

.help { font-size: 13px; line-height: 1.5; color: var(--muted); margin: 4px 2px 8px; }
#dialNum { margin: 8px 0 8px; }
.dialLbl { display: block; font-size: 13px; font-weight: 700; margin: 0 0 5px; color: var(--muted); }
.dialTo { display: flex; gap: 8px; align-items: stretch; }
#cc { flex: none; width: 7.8em; min-width: 7.8em; height: 52px; padding: 0 8px; font-size: 15px; background: var(--card-soft); }
#to {
  display: block;
  flex: 1;
  width: 100%;
  min-width: 0;
  height: 52px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.6px;
  font-variant-numeric: tabular-nums;
  padding: 0 14px;
  background: var(--card-soft);
}
#to:focus { background: var(--card); }

.dialMetaRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 5px;
  min-height: 18px;
}
.toHint { font-size: 12.5px; color: var(--muted); }
#dialPreview:empty { display: none; }
#dialPreview.err { color: var(--persimmon); font-weight: 500; }
.rateBadge {
  flex: none;
  font-size: 12px;
  font-weight: 700;
  color: var(--indigo);
  background: var(--indigo-soft);
  padding: 2px 9px;
  border-radius: 999px;
}

.dial-opts { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin: 8px 0; }
.dial-opts > * { min-width: 0; width: 100%; }
.dial-opts select { height: 44px; background: var(--card-soft); }
@media (max-width: 380px) {
  .dial-opts { grid-template-columns: 1fr 1fr; }
  .dial-opts #voice { grid-column: 1 / -1; }
}

.field { position: relative; }
textarea.grow {
  display: block;
  width: 100%;
  font-size: 15px;
  line-height: 1.55;
  padding: 12px;
  resize: vertical;
  field-sizing: content;
  max-height: 40dvh;
  overflow-y: auto;
  background: var(--card-soft);
}
textarea.grow:focus { background: var(--card); }
#brief { min-height: 92px; }
#ctx { min-height: 70px; }
#agentBox textarea { margin: 5px 0; }
.count { position: absolute; right: 10px; bottom: 8px; font-size: 11.5px; color: var(--muted); background: var(--card); padding: 0 5px; border-radius: 6px; pointer-events: none; }
.count.warn { color: var(--persimmon); font-weight: 700; }

#taskBar { display: flex; width: 100%; height: 44px; align-items: center; gap: 8px; text-align: left; margin: 4px 0; font-size: 14.5px; background: var(--card-soft); }
#taskBarText { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#agentBox.collapsed #taskFields, #agentBox.collapsed #advBox { display: none; }
#agentBox.collapsed.open #taskFields, #agentBox.collapsed.open #advBox { display: block; }

#advBox { margin: 8px 0 4px; background: var(--card-soft); border: 1px dashed var(--line-strong); border-radius: 12px; padding: 0 12px; }
#advBox summary { min-height: 42px; line-height: 42px; cursor: pointer; font-size: 14px; color: var(--muted); font-weight: 600; }
#advBox .row { margin: 4px 0 10px; }
#maxMin { width: 4.5em; padding: 6px 8px; }

.dialRow { display: flex; gap: 8px; margin: 10px 0 4px; }
.big { flex: 1; min-height: 54px; font-family: var(--font-display); font-size: 18px; font-weight: 700; border-radius: 14px; letter-spacing: 0.06em; }
#stopBtn { flex: none; min-height: 54px; border-radius: 14px; background: var(--yuzu-soft); border-color: var(--yuzu); color: var(--fg); font-weight: 700; }

.quota { margin: 6px 2px 0; font-size: 12.5px; }
.quota.low { color: var(--persimmon); font-weight: 700; }

#banner {
  background: var(--yuzu-soft);
  color: #5C430C;
  border: 1.5px solid var(--yuzu);
  border-radius: 14px;
  padding: 10px 14px;
  margin: 6px 0 10px;
  font-size: 14px;
  font-weight: 500;
}
#banner.errBanner { background: var(--persimmon-soft); color: var(--persimmon); border-color: rgba(212, 93, 62, 0.45); }

/* ==================== Live Call Controls & Subtitles ==================== */
#callView { display: flex; flex-direction: column; min-height: calc(100dvh - var(--tabPad) - 24px); }
#pauseBtn { flex: 1; }
#pauseBtn[aria-pressed="true"] { background: var(--yuzu); color: #3A2C12; border-color: var(--yuzu); font-weight: 700; }
.listen #vol { flex: 1; padding: 0; accent-color: var(--indigo); }
#listenBtn[aria-pressed="true"] { background: var(--indigo); color: #FFFDF8; border-color: var(--indigo); }
#listenInfo { font-size: 12px; color: var(--muted); min-width: 3em; }
#micBtn[aria-pressed="true"] { background: var(--persimmon); color: #FFFDF8; border-color: var(--persimmon); }
#micMeter { display: inline-block; width: 72px; height: 10px; background: var(--line); border-radius: 6px; overflow: hidden; flex: none; }
#micLevel { display: block; height: 100%; width: 0; background: var(--matcha); transition: width 0.08s linear; }

#subs {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: inset 0 2px 6px rgba(74, 62, 48, 0.04);
  overflow-y: auto;
  padding: 12px;
  margin: 6px 0;
}
body:not(.incall) #subs { flex: none; height: 126px; }
body:not(.incall) #subs:not(:empty) { height: auto; min-height: 126px; max-height: 32dvh; }
#subs:empty::before {
  content: "📞 撥通電話後，即時雙語字幕會顯示在這裡";
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}
body.incall #subs { flex: 1; height: auto; min-height: 40dvh; }

.l {
  margin: 8px 0;
  padding: 10px 14px;
  border-radius: 16px;
  max-width: 88%;
  border: 1px solid transparent;
}
.them { background: var(--indigo-soft); border-color: rgba(54, 85, 109, 0.16); border-bottom-left-radius: 4px; }
.me { background: var(--matcha-soft); border-color: rgba(76, 124, 102, 0.2); margin-left: auto; text-align: right; border-bottom-right-radius: 4px; }
.voice { background: var(--yuzu-soft); border: 1.5px dashed var(--yuzu); }
.agent { background: var(--matcha-soft); }
.note { background: var(--yuzu-soft); font-style: italic; }
.dtmf { background: var(--persimmon-soft); font-family: ui-monospace, Menlo, monospace; }
.l .t { font-size: 16.5px; line-height: 1.45; font-weight: 500; }
.l .o { font-size: 13px; color: var(--muted); margin-top: 2px; }
.speaking { opacity: 0.65; }

#keypadBox { background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 6px 12px; margin: 6px 0; }
#keypadBox summary { font-size: 14.5px; padding: 6px 0; cursor: pointer; font-weight: 600; }
#keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 320px; margin: 8px auto; }
#keypad button { font-family: var(--font-display); font-size: 22px; padding: 10px 0; background: var(--card-soft); touch-action: manipulation; }
#keypad button:active { background: var(--indigo-soft); }
#dtmfStr { flex: 1; }
#dtmfLog { font-size: 13px; color: var(--muted); min-height: 1em; }

/* Dock (Quick Phrases + Composer) */
#dock {
  position: sticky;
  bottom: var(--tabPad);
  z-index: 6;
  background: var(--bg);
  padding: 8px 0 8px;
  margin-top: 6px;
}
#dock #quick {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin: 0 0 6px;
  -webkit-overflow-scrolling: touch;
}
#dock #quick button {
  flex: none;
  white-space: nowrap;
  font-size: 13px;
  padding: 6px 12px;
  min-height: 36px;
  border-radius: 999px;
  background: var(--card);
  border: 1.5px solid var(--line);
}
#dock #quick button:hover { border-color: var(--matcha); color: var(--matcha); }
#dock .compose textarea { display: block; margin: 0 0 6px; height: 52px; min-height: 0; background: var(--card); }
#sendBtn { white-space: nowrap; flex: none; margin-left: auto; padding: 8px 18px; }
label { font-size: 13px; color: var(--muted); }

#summary { margin-top: 10px; white-space: pre-wrap; }
#summary h3 { margin: 8px 0 6px; font-size: 16px; color: var(--indigo); }

/* ==================== Bottom Tab Bar (和紙霧面導覽) ==================== */
#tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: rgba(255, 253, 248, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1.5px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 10;
}
@media (prefers-color-scheme: dark) {
  #tabs { background: rgba(36, 33, 29, 0.92); }
}
#tabs button {
  flex: 1;
  height: var(--tabH);
  border: 0;
  border-radius: 0;
  background: none;
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--muted);
}
#tabs button[aria-selected="true"] {
  color: var(--matcha);
  font-weight: 700;
  box-shadow: inset 0 3px 0 var(--matcha);
}

/* ==================== Local Call History Tab ==================== */
.logTop { position: sticky; top: 0; background: var(--bg); padding: 8px 0; z-index: 3; }
#logQ { width: 100%; font-size: 15px; background: var(--card); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-top: 8px; }
.chip { flex: none; border-radius: 999px; padding: 6px 14px; min-height: 36px; font-size: 13.5px; background: var(--card); }
.chip[aria-checked="true"] { background: var(--indigo); color: #FFFDF8; border-color: var(--indigo); font-weight: 700; }

.costCard {
  background: var(--card);
  border: 1.5px dashed var(--line-strong);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 8px 0;
  font-size: 13px;
  color: var(--fg);
}
.costCard:empty { display: none; }
.privacyNote {
  background: var(--matcha-soft);
  color: var(--matcha);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 12px 0;
  font-size: 12.5px;
}

.dayH { font-family: var(--font-display); font-size: 13.5px; font-weight: 700; color: var(--muted); margin: 16px 4px 6px; }
.callCard {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  padding: 12px 14px;
  margin: 0 0 10px;
  min-height: 76px;
}
.callCard:hover { border-color: var(--indigo); }
.callCard .t1 { display: flex; gap: 8px; font-weight: 700; font-size: 15.5px; }
.callCard .t1 span:first-child { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.callCard .t1 span:last-child { font-weight: 500; color: var(--muted); font-size: 13px; }
.callCard .t2 { font-size: 13.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 4px 0 6px; }
.tag { display: inline-block; font-size: 12px; border: 1px solid var(--line); background: var(--card-soft); border-radius: 999px; padding: 2px 9px; margin-right: 4px; color: var(--muted); }
.tag.ok { color: var(--matcha); border-color: var(--matcha); background: var(--matcha-soft); }
.tag.bad { color: var(--persimmon); border-color: var(--persimmon); background: var(--persimmon-soft); }
mark { background: var(--yuzu); color: #2E2925; border-radius: 3px; padding: 0 2px; }

.detTop { display: flex; gap: 6px; align-items: center; position: sticky; top: 0; background: var(--bg); padding: 6px 0; z-index: 3; }
#detHead { flex: 1; min-width: 0; }
#detTitle { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 17px; }
#detPin[aria-pressed="true"] { background: var(--yuzu); border-color: var(--yuzu); }
.sumCard { background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 14px; margin: 8px 0; white-space: pre-wrap; box-shadow: var(--shadow-sm); }
#detResult { display: block; font-size: 16px; margin-bottom: 6px; }
#detSummary { font-size: 14.5px; line-height: 1.6; }
#detTaskBox summary { min-height: 40px; line-height: 40px; cursor: pointer; color: var(--indigo); font-weight: 600; }
#detTask, #detCtx { font-size: 13.5px; margin: 4px 0; }

.seg { display: flex; border: 1.5px solid var(--indigo); border-radius: 12px; overflow: hidden; margin: 10px 0; background: var(--card); }
.seg button { flex: 1; border: 0; border-radius: 0; background: none; min-height: 40px; }
.seg button[aria-checked="true"] { background: var(--indigo); color: #FFFDF8; font-weight: 700; }

.bub { max-width: 85%; margin: 8px 0; padding: 10px 14px; border-radius: 16px; background: var(--indigo-soft); }
.bub.me { margin-left: auto; background: var(--matcha-soft); }
.bub .ts { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.bub .tr { font-size: 15.5px; }
.bub .or { font-size: 13.5px; color: var(--muted); }
.v-orig .bub .tr, .v-tr .bub .or { display: none; }
.v-orig .bub .or { font-size: 15.5px; color: inherit; }

/* ==================== Sheets, Modals & Admin Cards ==================== */
.sheet { position: fixed; inset: 0; background: rgba(30, 26, 22, 0.48); backdrop-filter: blur(3px); display: flex; align-items: flex-end; z-index: 20; }
.sheetBody { background: var(--card); width: 100%; max-width: 680px; margin: auto auto 0; border-radius: 20px 20px 0 0; border-top: 1.5px solid var(--line); padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
.sheetBody h3 { margin: 4px 0; }
.sheetBody .danger { color: var(--persimmon); border-color: rgba(212, 93, 62, 0.35); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabH) + 16px + env(safe-area-inset-bottom)); background: var(--fg); color: var(--card); border-radius: 999px; padding: 10px 18px; z-index: 30; font-size: 14px; box-shadow: var(--shadow); }

#adminView { margin-bottom: 10px; gap: 8px; }
.cardHead { display: flex; align-items: center; justify-content: space-between; }
.cardHead h3 { margin: 0; }
.iconBtn { width: 40px; height: 40px; min-height: 40px; padding: 0; border: 0; background: transparent; font-size: 18px; color: var(--muted); }
#addBox { border: 1.5px dashed var(--line-strong); border-radius: 12px; padding: 0 12px; background: var(--card-soft); }
#addBox summary { min-height: 44px; line-height: 44px; cursor: pointer; color: var(--indigo); font-weight: 700; }
.ucards { display: flex; flex-direction: column; gap: 10px; }
.ucard { border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 12px; background: var(--card-soft); }
.ucard.off { opacity: 0.65; }
.uHead { display: flex; align-items: center; gap: 10px; }
.avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--matcha); color: #FFFDF8; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 700; font-size: 17px; }
.ucard.off .avatar { background: #968D80; }
.uName { flex: 1; min-width: 0; }
.uName b { display: block; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uName small { color: var(--muted); font-size: 12.5px; }
.uMore { flex: none; width: 42px; height: 42px; min-height: 42px; padding: 0; font-size: 22px; line-height: 1; border-radius: 10px; background: var(--card); }
.uMeta { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }
.uMeta .tag { margin: 0; }

.modal { z-index: 40; }
@media (min-width: 640px) { .modal { align-items: center; } .modal .sheetBody { margin: auto; border-radius: 20px; border: 1.5px solid var(--line); max-width: 460px; } }
.modal .sheetBody { max-height: 88dvh; overflow-y: auto; }
.modal .btns { display: flex; gap: 8px; flex-wrap: wrap; }
.modal .btns button { flex: 1; min-width: 120px; }
.modal .bigAct { width: 100%; min-height: 48px; text-align: left; font-size: 15px; background: var(--card-soft); }
.modal input[type=number], .modal input[type=text] { width: 100%; }
.pwBox { font: 600 24px/1.4 ui-monospace, Menlo, Consolas, monospace; letter-spacing: 1px; background: var(--card-soft); border: 1.5px dashed var(--line-strong); border-radius: 12px; padding: 14px 10px; text-align: center; user-select: all; word-break: break-all; }
.logEv { border-top: 1px dashed var(--line); padding: 8px 0; font-size: 14px; }
.logEv:first-of-type { border-top: 0; }
.logEv .new { color: var(--persimmon); font-weight: 700; margin-right: 6px; }
.logEv small { display: block; color: var(--muted); }

/* API Billing sub-page */
body.billing-page { max-width: 860px; padding: 16px 16px 32px; }
.bill-back { display: inline-flex; align-items: center; color: var(--indigo); text-decoration: none; font-size: 15px; min-height: 44px; font-weight: 600; }
.bill-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 16px; }
@media (max-width: 640px) { .bill-grid { grid-template-columns: 1fr; } }
.bill-card { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 18px 16px 16px; text-decoration: none; color: inherit; min-height: 168px; box-shadow: var(--shadow-sm); }
.bill-card:hover { border-color: var(--indigo); transform: translateY(-2px); }
.bill-icon, .bill-icon svg { width: 40px; height: 40px; display: block; }
.bill-name { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.bill-desc, .bill-meta { font-size: 13px; color: var(--muted); line-height: 1.45; }
.bill-go { position: absolute; top: 14px; right: 14px; color: var(--muted); }
.bill-meta { margin-top: auto; padding-top: 10px; }
.bill-meta.low { color: var(--persimmon); font-weight: 700; }

/* Auto-greet option & Guide links */
.autoGreetRow {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 11px;
  margin: 6px 0 2px;
  border-radius: 12px;
  background: var(--matcha-soft);
  color: var(--fg);
  font-size: 13px;
  line-height: 1.45;
  cursor: pointer;
}
.autoGreetRow input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--matcha); flex: none; }
.guideLinkRow { text-align: center; margin: 12px 22px 0; }
.guidePillLink {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--card-soft);
  border: 1.5px solid var(--line);
  color: var(--indigo);
  font-size: 13.5px;
  font-weight: 700;
  text-decoration: none;
}
.guidePillLink:hover { border-color: var(--indigo); background: var(--indigo-soft); }

/* Guide Page */
body.guide-page { max-width: 760px; padding: 14px 14px 48px; }
.guideHero { background: var(--card); border: 1.5px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); overflow: hidden; margin-bottom: 16px; }
.guideHeroBody { padding: 18px 20px 20px; }
.guideHeroBody h1 { margin: 6px 0; font-size: 24px; }
.guideHeroBody p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.6; }
.guideSection { background: var(--card); border: 1.5px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-sm); padding: 18px 18px 16px; margin-bottom: 14px; }
.guideSection h2 { margin: 0 0 10px; font-size: 18px; color: var(--indigo); display: flex; align-items: center; gap: 8px; }
.guideGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .guideGrid { grid-template-columns: 1fr; } }
.guideBox { background: var(--card-soft); border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.guideBox b { display: block; font-family: var(--font-display); font-size: 15.5px; margin-bottom: 5px; color: var(--fg); }
.guideBox p, .guideBox li { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--muted); }
.guideBox ul { margin: 6px 0 0; padding-left: 18px; }
.rateTable { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
.rateTable th, .rateTable td { text-align: left; padding: 9px 10px; border-bottom: 1px dashed var(--line); }
.rateTable th { color: var(--muted); font-size: 12.5px; }
.rateTable tr:last-child td { border-bottom: 0; }
.faqItem { border-top: 1px dashed var(--line); padding: 10px 0; }
.faqItem:first-of-type { border-top: 0; padding-top: 2px; }
.faqItem summary { font-weight: 700; font-size: 14.5px; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.faqItem summary::after { content: "▾"; color: var(--muted); }
.faqItem[open] summary::after { content: "▴"; }
.faqItem p { margin: 8px 0 2px; font-size: 13.5px; line-height: 1.6; color: var(--muted); }
.guideCta { display: flex; justify-content: center; margin-top: 18px; }
.guideCta a { display: inline-flex; align-items: center; justify-content: center; min-height: 50px; padding: 0 28px; border-radius: 14px; text-decoration: none; font-family: var(--font-display); font-size: 16px; }

.legalLinks {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 12px 22px 0;
  font-size: 12.5px;
  color: var(--muted);
}
.legalLinks a { color: var(--muted); text-decoration: none; }
.legalLinks a:hover { color: var(--indigo); text-decoration: underline; }
.dialWarn {
  margin-top: 6px;
  padding: 8px 11px;
  border-radius: 10px;
  background: var(--gold-soft, rgba(243, 213, 141, 0.25));
  border: 1px solid rgba(196, 152, 56, 0.35);
  color: var(--fg);
  font-size: 12.5px;
  line-height: 1.5;
}

/* In-call compact header */
body.adminOpen #dock { position: static; }
body.incall #modeHelp, body.incall #dialPreview, body.incall #dialNum .dialLbl, body.incall #rateBadge, body.incall #dialWarn, body.incall #autoGreetRow { display: none; }
body.incall .dialCard { padding: 10px 12px; }
body.incall #dialNum { margin: 4px 0; }
