:root {
  --porcelain: #ECEFF0;
  --surface: #FFFFFF;
  --ink: #142730;
  --muted: #5C6F76;
  --petrol: #0E2B33;
  --petrol-edge: #1C4654;
  --line-green: #1BA178;
  --line-green-deep: #0F7052;
  --coral: #D8472B;
  --hairline: rgba(20, 39, 48, 0.14);
  --radius: 14px;
  --sans: "Space Grotesk", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  background: var(--porcelain);
  color: var(--ink);
  min-height: 100vh;
  padding: 28px clamp(16px, 4vw, 48px) 64px;
}

.mono { font-family: var(--mono); }

.banner {
  background: #FFF4E8;
  border: 1px solid #E3B26A;
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
  font-size: 14.5px;
  line-height: 1.55;
}
.banner code { font-family: var(--mono); font-size: 13px; background: rgba(20,39,48,.07); padding: 1px 5px; border-radius: 4px; }
.banner strong { display: block; margin-bottom: 2px; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 26px;
  gap: 16px;
  flex-wrap: wrap;
}
.wordmark { display: flex; align-items: baseline; gap: 14px; }
.mark { font-weight: 600; letter-spacing: 0.22em; font-size: 19px; }
.divider { width: 1px; height: 16px; background: var(--hairline); align-self: center; }
.sub { color: var(--muted); font-size: 14px; }
.line-tag { font-size: 11.5px; letter-spacing: 0.14em; color: var(--muted); }

.grid {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: 20px;
  align-items: start;
}
.history { grid-column: 1 / -1; }

.panel {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 22px;
}
.panel-head { margin-bottom: 16px; }
h2 { font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.hint { color: var(--muted); font-size: 13.5px; line-height: 1.5; }

textarea {
  width: 100%;
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.5;
  padding: 12px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  resize: vertical;
  background: var(--porcelain);
  color: var(--ink);
}
textarea:focus { outline: 2px solid var(--petrol-edge); outline-offset: 1px; }

.btn {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  border: none;
  border-radius: 999px;
  padding: 12px 26px;
  cursor: pointer;
  transition: transform .06s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--line-green); color: #fff; }
.btn.danger { background: var(--coral); color: #fff; }
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--hairline);
  margin-top: 10px;
  padding: 9px 18px;
  font-size: 14px;
}
.btn.ghost:hover { border-color: var(--petrol-edge); }

.instruction-list { list-style: none; margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.instruction-list li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--porcelain);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 14px;
  line-height: 1.5;
}
.instruction-list .txt { flex: 1; }
.instruction-list .del {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 16px; line-height: 1; padding: 2px 4px;
}
.instruction-list .del:hover { color: var(--coral); }

/* Active/mute toggle on each instruction. */
.instruction-list .switch {
  position: relative;
  flex: none;
  width: 34px;
  height: 20px;
  margin-top: 1px;
  border: none;
  border-radius: 999px;
  background: var(--hairline);
  cursor: pointer;
  transition: background .15s ease;
}
.instruction-list .switch.on { background: var(--line-green); }
.instruction-list .switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(20, 39, 48, 0.25);
  transition: transform .15s ease;
}
.instruction-list .switch.on::after { transform: translateX(14px); }
/* Muted row: dim the text and badge so it reads as inactive at a glance. */
.instruction-list li.inactive .txt { opacity: 0.5; }
.instruction-list li.inactive .act { opacity: 0.4; }

.owner-profile { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.owner-profile .field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.owner-profile input {
  width: 100%;
  font-family: var(--sans);
  font-size: 14.5px;
  padding: 10px 12px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--porcelain);
  color: var(--ink);
}
.owner-profile input:focus { outline: 2px solid var(--petrol-edge); outline-offset: 1px; }

/* ——— Console: the signature panel ——— */
.console {
  background: var(--petrol);
  border-color: var(--petrol-edge);
  color: #E8F0EF;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.console-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: #9FB8BC;
}
.line-status.live { color: #5CE0AE; }
.voice-state { color: #6E8B90; font-size: 11px; }
.timer { font-size: 13px; }

.halo-wrap { text-align: center; padding: 10px 0 4px; }
.halo {
  position: relative;
  width: 132px; height: 132px;
  margin: 0 auto 16px;
}
.halo-core {
  position: absolute; inset: 30px;
  border-radius: 50%;
  background: #11363F;
  border: 1px solid var(--petrol-edge);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono);
  font-size: 26px;
  color: #5CE0AE;
}
.halo-ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(92, 224, 174, 0.35);
  opacity: 0;
}
.halo.speaking .halo-ring { animation: pulse 1.6s ease-out infinite; }
.halo.speaking .r2 { animation-delay: .8s; }
.halo.listening .halo-core { border-color: #5CE0AE; }
@keyframes pulse {
  0% { transform: scale(0.72); opacity: 0.9; }
  100% { transform: scale(1.12); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .halo.speaking .halo-ring { animation: none; opacity: .5; transform: scale(1); }
}

.status-text { font-size: 15px; color: #C8D8D8; min-height: 22px; }
.meter {
  width: 180px;
  height: 4px;
  margin: 8px auto 0;
  background: rgba(159, 184, 188, 0.25);
  border-radius: 999px;
  overflow: hidden;
}
#meterFill {
  height: 100%;
  width: 0%;
  background: #5CE0AE;
  border-radius: 999px;
  transition: width .08s linear;
}
.caption {
  margin: 10px auto 0;
  max-width: 420px;
  min-height: 24px;
  font-size: 15px;
  line-height: 1.5;
  opacity: 0;
  transition: opacity .35s ease;
}
.caption.show { opacity: 1; }
.caption.user { color: #E8F0EF; font-style: italic; }
.caption.user::before { content: "You: "; color: #9FB8BC; font-style: normal; }
.caption.maya { color: #5CE0AE; }
.caption.maya::before { content: "Maya: "; color: #9FB8BC; }
.decision {
  display: inline-block;
  margin-top: 10px;
  font-size: 11.5px;
  letter-spacing: 0.14em;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.decision.patch { color: #5CE0AE; }
.decision.message { color: #F0C26A; }
.decision.end { color: #F09583; }

.console-controls { display: flex; flex-direction: column; gap: 12px; }
.ctl { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #9FB8BC; }
.ctl select {
  font-family: var(--sans);
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--petrol-edge);
  background: #11363F;
  color: #E8F0EF;
}
.ctl.check { flex-direction: row; align-items: center; gap: 8px; }
.ctl.check input { accent-color: var(--line-green); width: 15px; height: 15px; }

.console-actions { display: flex; gap: 12px; }
.console-actions .btn { flex: 1; padding: 14px; font-size: 16px; }

.error { color: #F09583; font-size: 12.5px; line-height: 1.5; }

.history-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.history-list li.call {
  border: 1px solid var(--hairline);
  border-radius: 10px;
  font-size: 14px;
  overflow: hidden;
}
.call-row {
  display: grid;
  grid-template-columns: auto auto auto auto 1fr auto auto;
  gap: 8px 16px;
  align-items: center;
  padding: 13px 16px;
  cursor: pointer;
}
.call-row:hover { background: rgba(20, 39, 48, 0.025); }
.chevron {
  background: none; border: none; cursor: pointer;
  font-size: 17px; line-height: 1; padding: 2px 4px; color: var(--muted);
  transition: transform .15s ease, color .15s ease;
}
.call.open .chevron { transform: rotate(90deg); color: var(--ink); }
.call-transcript {
  border-top: 1px solid var(--hairline);
  padding: 14px 18px 16px;
  background: rgba(20, 39, 48, 0.02);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.call-transcript .turn {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: 10px;
  align-items: baseline;
  font-size: 14px;
  line-height: 1.5;
}
.call-transcript .who {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); padding-top: 2px;
}
.call-transcript .turn.maya .who { color: var(--line-green-deep); }
.call-transcript .say { color: var(--ink); }
.call-transcript .lat {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  white-space: nowrap; padding-top: 2px;
}
.latency-summary {
  margin-top: 4px; padding-top: 10px;
  border-top: 1px dashed var(--hairline);
  font-size: 12.5px; color: var(--muted); line-height: 1.5;
}
.transcript-empty { font-size: 13.5px; color: var(--muted); }
.history-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.btn.danger-ghost { color: var(--coral); border-color: rgba(216, 71, 43, 0.4); margin-top: 0; white-space: nowrap; }
.btn.danger-ghost:hover { border-color: var(--coral); background: #FBE4DE; }
.row-star {
  background: none; border: none; cursor: pointer;
  font-size: 17px; line-height: 1; padding: 2px 4px;
  color: var(--muted); transition: color .12s ease, transform .06s ease;
}
.row-star:hover { color: #E6A817; }
.row-star:active { transform: scale(0.9); }
.row-star.on { color: #E6A817; }
.row-menu { position: relative; justify-self: end; }
.kebab {
  background: none; border: none; cursor: pointer;
  font-size: 19px; line-height: 1; padding: 2px 9px; color: var(--muted);
  border-radius: 6px;
}
.kebab:hover { background: var(--porcelain); color: var(--ink); }
.menu {
  position: absolute; right: 0; top: 30px; z-index: 30;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(20, 39, 48, 0.16);
  padding: 6px;
  min-width: 160px;
  display: none;
}
.menu.open { display: block; }
.menu button {
  width: 100%; text-align: left;
  background: none; border: none; cursor: pointer;
  font-family: var(--sans); font-size: 14px;
  padding: 9px 10px; border-radius: 7px; color: var(--ink);
}
.menu button:hover { background: var(--porcelain); }
.menu button.danger-item { color: var(--coral); }
.menu button.danger-item:hover { background: #FBE4DE; }
.history-list .when { color: var(--ink); font-weight: 500; }
.history-list .dur { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.history-list .badge {
  justify-self: start;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  padding: 4px 10px;
  border-radius: 999px;
}
.badge.patch { background: #E0F4EC; color: #0E6B4E; }
.badge.message { background: #FBF0DC; color: #8A5B12; }
.badge.end { background: #FBE4DE; color: #99301A; }
.badge.none { background: var(--porcelain); color: var(--muted); }
.history-list audio { width: 240px; height: 34px; }

.empty { color: var(--muted); font-size: 14px; padding: 10px 2px; }

/* ——— Instruction confirmation card (natural language → structured) ——— */
.confirm-card {
  position: relative;
  border: 1px solid var(--line-green);
  background: #F1FAF6;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 12px 0 4px;
}
.confirm-dismiss {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
  padding: 2px 4px;
}
.confirm-dismiss:hover { color: var(--ink); }
.confirm-head {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--line-green-deep);
  margin-bottom: 8px;
}
.confirm-summary {
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  margin-bottom: 14px;
  padding-right: 18px;
}
.confirm-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.confirm-pills .pill {
  display: inline-flex;
  align-items: center;
  gap: 0;
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 15px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.confirm-pills .pill:hover { border-color: var(--line-green); }
.confirm-pills .pill.selected {
  background: var(--line-green);
  border-color: var(--line-green);
  color: #fff;
}
/* Tick on the active pill. Width animates in so the label doesn't jump. */
.confirm-pills .pill::before {
  content: "\2713"; /* ✓ */
  font-size: 12px;
  font-weight: 700;
  width: 0;
  margin-right: 0;
  overflow: hidden;
  opacity: 0;
  transition: width .12s ease, margin-right .12s ease, opacity .12s ease;
}
.confirm-pills .pill.selected::before {
  width: 12px;
  margin-right: 7px;
  opacity: 1;
}
.confirm-foot {
  font-size: 12px;
  color: var(--muted);
  margin-top: 12px;
}

/* Action badge on each saved instruction, so the customer sees how Maya behaves. */
.instruction-list .act {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  padding: 3px 8px;
  border-radius: 999px;
  margin-left: 8px;
  white-space: nowrap;
}
.act.bridge { background: #E0F4EC; color: #0E6B4E; }
.act.message { background: #FBF0DC; color: #8A5B12; }
.act.callback { background: #E6EEF6; color: #2A5A86; }
.act.decline { background: #FBE4DE; color: #99301A; }
.act.handle { background: #E7F0F0; color: #0E2B33; }
.act.directions { background: #E4F0EA; color: #0F6048; }
.act.legacy { background: var(--porcelain); color: var(--muted); }

/* Handle action: the editable line Maya speaks, shown only when handle is picked. */
.handle-edit {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
}
.handle-edit label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--petrol);
  margin-bottom: 7px;
}
.handle-edit #handleInstruction {
  width: 100%;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  padding: 9px 11px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--porcelain);
}
.handle-edit #handleInstruction:focus {
  outline: none;
  border-color: var(--line-green);
  background: var(--surface);
}
.handle-hint {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.45;
  margin-top: 7px;
}

/* Directions action: record button + status, and the editable transcript. */
.rec-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
  flex-wrap: wrap;
}
.rec-btn {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-green);
  background: var(--surface);
  color: var(--line-green-deep);
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.rec-btn:hover { background: #E4F0EA; }
.rec-btn.recording {
  background: var(--coral);
  border-color: var(--coral);
  color: #fff;
  animation: recpulse 1.1s ease-in-out infinite;
}
@keyframes recpulse { 0%,100% { opacity: 1; } 50% { opacity: 0.72; } }
.rec-status {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.4;
}
#directionsKnowledge {
  width: 100%;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  padding: 9px 11px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--porcelain);
  resize: vertical;
}
#directionsKnowledge:focus {
  outline: none;
  border-color: var(--line-green);
  background: var(--surface);
}

@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; }
  .call-row { grid-template-columns: auto auto 1fr auto auto; }
  .history-list audio { width: 100%; grid-column: 1 / -1; }
  .call-transcript .turn { grid-template-columns: 54px 1fr; }
  .call-transcript .lat { grid-column: 2; }
  .history-head { flex-direction: column; }
  .btn.danger-ghost { align-self: flex-start; }
}
