:root {
  --gc-accent: #6366f1;
  --gc-green: #22c55e;
  --gc-red: #ef4444;
  --gc-amber: #f59e0b;
  --gc-radius: 16px;
}

/* ---------- themes (light is the default; toggle stored per browser) ---------- */
:root, [data-bs-theme="light"] {
  --gc-bg: #f4f5f8;
  --gc-surface: #ffffff;
  --gc-surface-2: #f1f2f6;
  --gc-hover: #e7e9ef;
  --gc-pressed: #dde0e8;
  --gc-border: rgba(15, 23, 42, .09);
  --gc-text: #1b1f27;
  --gc-text-dim: #667085;
  --gc-text-faint: #a3abb8;
  --gc-nav-bg: rgba(255, 255, 255, .85);
  --gc-glow: rgba(99, 102, 241, .08);
  --gc-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
  --gc-toast-bg: #1b1f27;
  --gc-toast-fg: #fff;
  --gc-invert-bg: #1b1f27;
  --gc-invert-fg: #fff;
}
[data-bs-theme="dark"] {
  --gc-bg: #0d0f12;
  --gc-surface: #15181d;
  --gc-surface-2: #1c2027;
  --gc-hover: #252a33;
  --gc-pressed: #2c323d;
  --gc-border: rgba(255, 255, 255, .07);
  --gc-text: #e6e8ec;
  --gc-text-dim: #8b93a1;
  --gc-text-faint: #4b5260;
  --gc-nav-bg: rgba(13, 15, 18, .8);
  --gc-glow: rgba(99, 102, 241, .10);
  --gc-shadow: none;
  --gc-toast-bg: #262b34;
  --gc-toast-fg: #fff;
  --gc-invert-bg: #fff;
  --gc-invert-fg: #111;
}

body {
  background: radial-gradient(1200px 600px at 10% -10%, var(--gc-glow), transparent 60%), var(--gc-bg);
  background-attachment: fixed;
  color: var(--gc-text);
  min-height: 100vh;
}

/* ---------- logo / nav ---------- */
.gc-logo {
  width: 56px; height: 56px; border-radius: 16px;
  display: grid; place-items: center; font-size: 1.5rem; color: #fff;
  background: linear-gradient(135deg, var(--gc-accent), var(--gc-green));
  box-shadow: 0 8px 24px rgba(99, 102, 241, .35);
}
.gc-logo-sm { width: 32px; height: 32px; border-radius: 10px; font-size: .95rem; box-shadow: none; }

.gc-nav {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: .75rem 1.25rem;
  background: var(--gc-nav-bg); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--gc-border);
}

.gc-pill {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .25rem .7rem; border-radius: 999px; font-size: .8rem;
  background: var(--gc-surface-2); border: 1px solid var(--gc-border);
}
.gc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gc-text-dim); }
.gc-pill[data-state="registered"] .gc-dot { background: var(--gc-green); box-shadow: 0 0 0 3px rgba(34, 197, 94, .2); }
.gc-pill[data-state="connecting"] .gc-dot { background: var(--gc-amber); animation: gc-pulse 1.2s infinite; }
.gc-pill[data-state="offline"] .gc-dot { background: var(--gc-red); }

/* ---------- cards ---------- */
.gc-card {
  background: var(--gc-surface);
  border: 1px solid var(--gc-border);
  border-radius: var(--gc-radius);
  box-shadow: var(--gc-shadow);
  overflow: hidden;
}
.gc-card-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: .85rem 1.1rem; font-weight: 600; color: inherit;
  border-bottom: 1px solid var(--gc-border);
}
button.gc-card-head[aria-expanded="true"] .bi-chevron-down { transform: rotate(180deg); }

/* ---------- phone ---------- */
.gc-phone { padding: 1.25rem 1.25rem 1.5rem; }
.gc-call-state { display: flex; justify-content: center; align-items: center; gap: .6rem; min-height: 1.5rem; font-size: .9rem; }
.gc-timer { font-variant-numeric: tabular-nums; color: var(--gc-green); font-weight: 600; }

.gc-number { display: flex; align-items: center; gap: .25rem; margin: .75rem 0 .25rem; }
.gc-cc { color: var(--gc-text-dim); font-size: 1.4rem; font-weight: 300; padding-left: .5rem; }
.gc-number input {
  flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--gc-text);
  font-size: 1.85rem; font-weight: 300; letter-spacing: .02em; text-align: center;
  font-variant-numeric: tabular-nums;
}
.gc-number input::placeholder { color: var(--gc-text-faint); }
.gc-icon-btn { color: var(--gc-text-dim); font-size: 1.25rem; }
.gc-icon-btn:hover { color: var(--gc-text); }

.gc-dialpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .65rem; max-width: 300px; margin: 0 auto; }
.gc-key {
  aspect-ratio: 1.35; border-radius: 14px; border: 1px solid var(--gc-border);
  background: var(--gc-surface-2); color: var(--gc-text);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: background .12s, transform .06s; user-select: none; -webkit-tap-highlight-color: transparent;
}
.gc-key span { font-size: 1.45rem; line-height: 1.1; }
.gc-key small { font-size: .6rem; letter-spacing: .15em; color: var(--gc-text-dim); }
.gc-key:hover { background: var(--gc-hover); }
.gc-key:active, .gc-key.is-pressed { transform: scale(.95); background: var(--gc-pressed); }

.gc-call-actions { display: flex; justify-content: center; align-items: center; gap: 1.5rem; margin-top: 1.25rem; }
.gc-round {
  border: 0; border-radius: 50%; display: grid; place-items: center; color: #fff;
  transition: transform .08s, opacity .15s, background .15s;
}
.gc-round:active { transform: scale(.94); }
.gc-round:disabled { opacity: .35; }
.gc-round-call, .gc-round-end { width: 68px; height: 68px; font-size: 1.6rem; }
.gc-round-call { background: var(--gc-green); box-shadow: 0 8px 20px rgba(34, 197, 94, .3); }
.gc-round-end { background: var(--gc-red); box-shadow: 0 8px 20px rgba(239, 68, 68, .3); }
.gc-round-sm { width: 46px; height: 46px; background: var(--gc-surface-2); border: 1px solid var(--gc-border); font-size: 1.1rem; color: var(--gc-text); }
.gc-round-sm.is-active { background: var(--gc-invert-bg); color: var(--gc-invert-fg); }

/* ---------- incoming ---------- */
.gc-incoming {
  position: fixed; left: 50%; top: 72px; transform: translateX(-50%); z-index: 30;
  width: min(560px, calc(100% - 32px));
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 1rem 1.1rem; border-radius: var(--gc-radius);
  background: var(--gc-surface-2); border: 1px solid rgba(34, 197, 94, .35);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
.gc-ring { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--gc-green); animation: gc-pulse 1s infinite; }

/* ---------- recents ---------- */
.gc-recents { list-style: none; margin: 0; padding: .25rem 0; max-height: 260px; overflow: auto; }
.gc-recents li {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  padding: .55rem 1.1rem; cursor: pointer;
}
.gc-recents li:hover { background: var(--gc-surface-2); }
.gc-recents .gc-meta { font-size: .75rem; color: var(--gc-text-dim); }
.gc-recents .gc-empty { cursor: default; }
.gc-recents .gc-empty:hover { background: transparent; }

/* ---------- translation ---------- */
.gc-lt-controls { display: flex; flex-direction: column; gap: .9rem; padding: 1rem 1.1rem; border-bottom: 1px solid var(--gc-border); }
.gc-lt-langs { display: grid; grid-template-columns: 1fr auto 1fr; gap: .5rem; align-items: end; }
.gc-lt-mix { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
.gc-switches { display: flex; flex-wrap: wrap; gap: .35rem 1.5rem; }
@media (max-width: 575.98px) {
  .gc-lt-mix { grid-template-columns: 1fr; }
  .gc-switches { flex-direction: column; }
}
.gc-transcripts { display: grid; grid-template-rows: 1fr 1fr; gap: 1rem; padding: 1rem 1.1rem 1.1rem; min-height: 420px; }
.gc-transcript-label { font-size: .8rem; font-weight: 600; margin-bottom: .35rem; }
.gc-transcript {
  height: calc(100% - 1.6rem); min-height: 160px; max-height: 38vh; overflow: auto;
  background: var(--gc-bg); border: 1px solid var(--gc-border); border-radius: 12px; padding: .75rem .9rem;
}
.gc-line { padding: .35rem 0; border-bottom: 1px dashed var(--gc-border); }
.gc-line:last-child { border-bottom: 0; }
.gc-line .gc-src { color: var(--gc-text-dim); font-size: .85rem; }
.gc-line .gc-tgt { font-size: 1rem; }
.gc-line.is-live .gc-tgt::after { content: ' ▍'; color: var(--gc-green); animation: gc-pulse 1s infinite; }
.gc-empty { color: var(--gc-text-faint); font-size: .85rem; }

.gc-echo { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.gc-echo .form-select { width: auto; flex: 1; min-width: 220px; }

/* ---------- caller ID + call context ---------- */
.gc-callerid { display: flex; align-items: center; justify-content: center; gap: .6rem; margin: .1rem auto .9rem; max-width: 300px; }
.gc-callerid label { white-space: nowrap; }
.gc-callerid .form-control { font-variant-numeric: tabular-nums; }
.gc-context {
  display: flex; align-items: center; gap: .65rem; max-width: 300px; margin: 0 auto 1rem;
  padding: .55rem .75rem; border-radius: 12px; background: var(--gc-surface-2); border: 1px solid var(--gc-border);
}
.gc-context > .bi-person-vcard { font-size: 1.25rem; color: var(--gc-accent); }
.min-w-0 { min-width: 0; }

/* ---------- theme toggle ---------- */
.gc-theme-btn { color: var(--gc-text-dim); border: 1px solid var(--gc-border); background: var(--gc-surface); }
.gc-theme-btn:hover { color: var(--gc-text); background: var(--gc-surface-2); }

/* ---------- call history ---------- */
.gc-history-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .75rem 1.1rem; border-bottom: 1px solid var(--gc-border); }
.gc-history-toolbar .form-control, .gc-history-toolbar .form-select { max-width: 220px; }
.gc-history { max-height: 420px; overflow: auto; }
.gc-history table { margin: 0; font-size: .875rem; --bs-table-bg: transparent; }
.gc-history th { position: sticky; top: 0; background: var(--gc-surface); color: var(--gc-text-dim); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; z-index: 1; }
.gc-history td, .gc-history th { padding: .55rem 1.1rem; border-color: var(--gc-border); vertical-align: middle; white-space: nowrap; }
.gc-history tbody tr { cursor: pointer; }
.gc-history tbody tr:hover td { background: var(--gc-surface-2); }
.gc-history .gc-num { font-variant-numeric: tabular-nums; font-weight: 500; }
.gc-badge-soft { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 600; }
.gc-badge-soft.ok { background: rgba(34, 197, 94, .14); color: #15803d; }
.gc-badge-soft.miss { background: rgba(239, 68, 68, .14); color: #b91c1c; }
.gc-badge-soft.neutral { background: var(--gc-surface-2); color: var(--gc-text-dim); }
[data-bs-theme="dark"] .gc-badge-soft.ok { color: #4ade80; }
[data-bs-theme="dark"] .gc-badge-soft.miss { color: #f87171; }

/* ---------- transcript viewer ---------- */
.gc-modal { background: var(--gc-surface); color: var(--gc-text); border: 1px solid var(--gc-border); border-radius: var(--gc-radius); }
.gc-modal .modal-header, .gc-modal .modal-footer { border-color: var(--gc-border); }
.gc-tline { padding: .55rem .75rem; margin-bottom: .5rem; border-radius: 12px; background: var(--gc-surface-2); max-width: 85%; }
.gc-tline.is-me { margin-left: auto; background: rgba(99, 102, 241, .10); }
.gc-tmeta { font-size: .72rem; color: var(--gc-text-dim); margin-bottom: .15rem; }
.gc-tsrc { font-size: .85rem; color: var(--gc-text-dim); }
.gc-ttgt { font-size: .98rem; }

/* ---------- console / toast ---------- */
.gc-log {
  margin: 0; padding: .85rem 1.1rem; max-height: 260px; overflow: auto;
  font-size: .75rem; color: var(--gc-text-dim); background: var(--gc-bg); white-space: pre-wrap;
}
.gc-toast-wrap { position: fixed; bottom: 20px; left: 0; right: 0; display: flex; justify-content: center; pointer-events: none; z-index: 40; }
.gc-toast {
  background: var(--gc-toast-bg); color: var(--gc-toast-fg); padding: .6rem 1rem; border-radius: 10px; font-size: .9rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4); border: 1px solid var(--gc-border); max-width: calc(100% - 32px);
}
.gc-toast.is-error { border-color: rgba(239, 68, 68, .5); }

/* ---------- login ---------- */
.gc-login { display: grid; place-items: center; padding: 16px; }
.gc-login-card {
  width: 100%; max-width: 380px; padding: 2rem 1.75rem;
  background: var(--gc-surface); border: 1px solid var(--gc-border); border-radius: 20px;
  box-shadow: var(--gc-shadow), 0 30px 80px rgba(0, 0, 0, .12);
}
.gc-login .form-control { background: var(--gc-bg); border-color: var(--gc-border); color: var(--gc-text); }
.gc-pw-toggle { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); color: var(--gc-text-dim); z-index: 5; }

@keyframes gc-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

@media (max-width: 400px) {
  .gc-number input { font-size: 1.5rem; }
  .gc-cc { font-size: 1.15rem; }
}

/* =====================================================================
   One-screen layout: phone | interpreter | history. On desktop the page
   never scrolls — each panel scrolls inside itself. Narrow screens stack.
   ===================================================================== */
:root { --gc-nav-h: 52px; }
.gc-nav { height: var(--gc-nav-h); padding: 0 1.1rem; }

.gc-app { display: flex; flex-direction: column; gap: 12px; padding: 12px; }
.gc-grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.gc-col { display: flex; flex-direction: column; min-height: 0; }
.gc-col-scroll { flex: 1; min-height: 0; overflow: auto; padding: 1rem 1.1rem; display: flex; flex-direction: column; justify-content: center; }
.gc-phone { padding: 0; }

@media (min-width: 1100px) {
  html, body { height: 100%; overflow: hidden; }
  .gc-app { height: calc(100vh - var(--gc-nav-h)); padding: 14px 16px; }
  .gc-grid { flex: 1; min-height: 0; grid-template-columns: minmax(290px, 330px) minmax(0, 1fr) minmax(290px, 360px); gap: 14px; }
}
@media (min-width: 768px) and (max-width: 1099.98px) {
  .gc-grid { grid-template-columns: minmax(290px, 340px) minmax(0, 1fr); }
  .gc-hist { grid-column: 1 / -1; max-height: 60vh; }
}

/* phone — scales with available height */
.gc-call-state { min-height: 1.25rem; }
.gc-number { margin: .35rem 0 .2rem; }
.gc-number input { font-size: clamp(1.4rem, 3.2vh, 1.85rem); }
.gc-callerid { margin: .1rem auto .6rem; }
.gc-context { margin-bottom: .6rem; }
.gc-dialpad { gap: clamp(.35rem, 1vh, .65rem); max-width: 280px; }
.gc-key { aspect-ratio: auto; height: clamp(40px, 6.6vh, 62px); }
.gc-key span { font-size: clamp(1.15rem, 2.4vh, 1.45rem); }
.gc-call-actions { margin-top: clamp(.6rem, 1.6vh, 1.25rem); }
.gc-round-call, .gc-round-end { width: clamp(54px, 7.5vh, 68px); height: clamp(54px, 7.5vh, 68px); }

/* interpreter */
.gc-interp .gc-lt-controls { gap: .6rem; padding: .75rem 1rem; }
.gc-lt-mix { padding-top: .25rem; }
.gc-lt-mix-wide { grid-column: 1 / -1; }
.gc-transcripts { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: none; gap: 12px; padding: .75rem 1rem 1rem; }
.gc-tcol { display: flex; flex-direction: column; min-height: 0; }
.gc-transcript { flex: 1; height: auto; max-height: none; min-height: 140px; }
@media (max-width: 1099.98px) { .gc-transcripts { min-height: 420px; } }
@media (max-width: 575.98px) { .gc-transcripts { grid-template-columns: 1fr; } }

/* history list */
.gc-hist .gc-history-toolbar { flex-wrap: nowrap; padding: .6rem .9rem; }
.gc-hist .gc-history-toolbar .form-control { max-width: none; flex: 1; }
.gc-hist .gc-history-toolbar .form-select { width: auto; max-width: 120px; }
.gc-history { flex: 1; min-height: 0; overflow: auto; max-height: none; }
@media (max-width: 1099.98px) { .gc-history { min-height: 240px; } }
.gc-hrow { display: flex; align-items: flex-start; gap: .65rem; padding: .55rem .9rem; border-bottom: 1px solid var(--gc-border); cursor: pointer; }
.gc-hrow:hover { background: var(--gc-surface-2); }
.gc-hicon { margin-top: .15rem; }
.gc-hmain { flex: 1; min-width: 0; }
.gc-htop { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.gc-hname { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gc-hsub { font-size: .75rem; color: var(--gc-text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gc-hbtn { display: flex; align-items: center; gap: .3rem; font-size: .75rem; padding: .15rem .45rem; align-self: center; }

/* console drawer */
.gc-console { height: 40vh !important; background: var(--gc-surface); color: var(--gc-text); }
.gc-console .gc-log { max-height: none; height: 100%; }

/* handoff to iPhone */
.gc-handoff { display: flex; flex-direction: column; gap: .5rem; margin-top: .75rem; padding: .6rem .75rem; border-radius: 12px;
  background: rgba(99, 102, 241, .10); border: 1px solid rgba(99, 102, 241, .25); }
.gc-handoff .bi-phone-vibrate { color: var(--gc-accent); font-size: 1.1rem; }
.gc-round-sm.is-active#handoffBtn { background: var(--gc-accent); color: #fff; }

/* =====================================================================
   v8 layout: [phone + history] | interpreter. The phone takes its natural
   height (no centring gaps); history fills what's left below it.
   ===================================================================== */
.gc-left { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.gc-phone { flex: none; }
.gc-phone-body { padding: .85rem 1rem 1rem; }
.gc-hist { flex: 1; min-height: 0; display: flex; flex-direction: column; }
@media (min-width: 1100px) {
  .gc-grid { grid-template-columns: minmax(320px, 360px) minmax(0, 1fr); }
  .gc-left { gap: 14px; }
  .gc-hist { min-height: 150px; }
}
@media (min-width: 768px) and (max-width: 1099.98px) {
  .gc-grid { grid-template-columns: minmax(300px, 340px) minmax(0, 1fr); }
  .gc-hist { grid-column: auto; max-height: none; }
}

.gc-state { font-size: .8rem; font-weight: 500; color: var(--gc-text-dim); }
.gc-number { margin: 0 0 .5rem; }
.gc-number input { font-size: clamp(1.35rem, 2.9vh, 1.75rem); }
.gc-number input::placeholder { font-size: .8em; letter-spacing: 0; }
.gc-callerid { margin: 0 auto .75rem; max-width: none; }
.gc-context { max-width: none; }
.gc-dialpad { max-width: none; gap: .45rem; }
.gc-key { height: clamp(38px, 5.2vh, 52px); border-radius: 12px; flex-direction: row; gap: .4rem; }
.gc-key small { min-width: 2.4em; text-align: left; }
.gc-call-actions { margin-top: .85rem; gap: 1.25rem; }
.gc-round-call, .gc-round-end { width: clamp(52px, 6.4vh, 62px); height: clamp(52px, 6.4vh, 62px); }
.gc-round-call:disabled { filter: grayscale(.6); }
.gc-kbd-hint { margin-top: .75rem; text-align: center; font-size: .7rem; color: var(--gc-text-faint); }
.gc-kbd-hint kbd { font-size: .65rem; padding: .05rem .3rem; background: var(--gc-surface-2); color: var(--gc-text-dim); border: 1px solid var(--gc-border); box-shadow: none; }
@media (max-height: 760px) and (min-width: 1100px) { .gc-kbd-hint { display: none; } }

/* status badges: soft, readable in both themes */
.gc-badge-soft.warn { background: rgba(245, 158, 11, .16); color: #b45309; }
[data-bs-theme="dark"] .gc-badge-soft.warn { color: #fbbf24; }

/* toasts bottom-right, clear of the transcripts */
.gc-toast-wrap { left: auto; right: 20px; bottom: 20px; justify-content: flex-end; }
@media (max-width: 575.98px) { .gc-toast-wrap { left: 0; right: 0; justify-content: center; } }

/* call button always centred; side slots hold mute / handoff / settings */
.gc-call-actions { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; }
.gc-side { display: flex; gap: .6rem; align-items: center; }
.gc-side-l { justify-content: flex-end; }
.gc-side-r { justify-content: flex-start; }
.gc-call-actions > .gc-round-call, .gc-call-actions > .gc-round-end { grid-column: 2; grid-row: 1; }
