:root {
  --primary-blue: #007aff;
  --bg-color: #f2f2f7;
  --surface-color: #ffffff;
  --text-primary: #000000;
  --text-secondary: #8e8e93;
  --border-color: #c6c6c8;
  --green-call: #34c759;
  --bubble-sent: #007aff;
  --bubble-received: #e9e9eb;
  --bubble-system: #fff5dc;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: #000;
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  height: 100dvh;
  overflow: hidden;
}

.app-container {
  width: 100%;
  max-width: 430px;
  background-color: var(--surface-color);
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding-bottom: 86px;
  min-height: 0;
}

.hidden {
  display: none !important;
}

h1 {
  font-size: 32px;
  font-weight: 700;
  margin: 20px 20px 10px;
}

h2 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
}

p {
  margin: 0;
}

.subtext {
  color: var(--text-secondary);
  font-size: 13px;
}

.keypad-display {
  min-height: 28%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 10px 0 18px;
}

.dial-input {
  font-size: 40px;
  font-weight: 400;
  margin-bottom: 6px;
  min-height: 48px;
}

.add-number-txt {
  color: var(--primary-blue);
  font-size: 16px;
  font-weight: 500;
  border: 0;
  background: transparent;
}

.status-line {
  margin-top: 10px;
  color: #17873a;
  font-size: 13px;
  font-weight: 600;
}

.status-note {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 12px;
  min-height: 1em;
}

.dial-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  padding: 0 34px;
  justify-items: center;
}

.dial-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background-color: #ececf1;
  border: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: background-color 120ms ease;
}

.dial-btn:active {
  background-color: #d8d8de;
}

.num {
  font-size: 35px;
  line-height: 1;
  font-weight: 400;
}

.sub {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  margin-top: 2px;
}

.call-action-row {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 20px;
  position: relative;
}

.call-btn {
  width: 75px;
  height: 75px;
  border-radius: 50%;
  background-color: var(--green-call);
  border: none;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  box-shadow: 0 8px 20px rgba(52, 199, 89, 0.34);
}

.call-btn svg {
  width: 35px;
  height: 35px;
}

.backspace-btn {
  position: absolute;
  right: 52px;
  background: none;
  border: none;
  cursor: pointer;
  display: none;
}

.runtime-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 16px 0;
}

.runtime-btn {
  min-height: 40px;
  border-radius: 999px;
  border: 1px solid #d7d7dc;
  background: #f5f5f8;
  color: #243144;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.runtime-btn.danger {
  border-color: #ffc9ce;
  background: #ffeef0;
  color: #c6454f;
}

.runtime-btn.recording {
  animation: recordingPulse 900ms ease infinite;
}

.runtime-btn.auto-active {
  border-color: #34c759;
  background: #e8f9ee;
  color: #1d7a38;
}

.runtime-btn.is-disabled,
.runtime-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.small-icon {
  width: 14px;
  height: 14px;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid #e5e5e5;
}

.history-info h2 {
  margin-bottom: 4px;
}

.missed {
  color: #ff3b30;
}

.chat-header {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #ddd;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-title {
  text-align: center;
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.logs-toggle-btn {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid #d9d9de;
  background: #fff;
  color: #5b6475;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.logs-toggle-btn svg {
  width: 14px;
  height: 14px;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.logs-link-btn {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid #d9d9de;
  background: #fff;
  color: #5b6475;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.logs-link-btn svg {
  width: 14px;
  height: 14px;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.logs-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #2dbd56;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.mode-toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 10px 14px 0;
  background: #f0f0f3;
  border-radius: 999px;
  padding: 4px;
}

.mode-btn {
  border: 0;
  border-radius: 999px;
  min-height: 34px;
  padding: 0 14px;
  background: transparent;
  color: #5f6673;
  font-weight: 700;
}

.mode-btn.is-active {
  background: #fff;
  color: #131924;
  box-shadow: 0 4px 10px rgba(8, 10, 16, 0.12);
}

.task-logs {
  border: 1px solid #dfe2eb;
  border-radius: 14px;
  background: #fff;
  margin: 10px 14px 0;
  padding: 8px;
  display: grid;
  gap: 7px;
}

.task-logs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.task-logs-head p {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  color: #5a6373;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.task-logs-head button {
  border: 1px solid #d8dce8;
  background: #f8f9fc;
  color: #4d5a75;
  border-radius: 8px;
  min-height: 26px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 700;
}

.task-logs-list {
  max-height: 170px;
  overflow: auto;
  display: grid;
  gap: 6px;
}

.task-log-line {
  border-radius: 10px;
  padding: 6px 8px;
  background: #f7f8fb;
  border: 1px solid #eceef5;
  font-size: 12px;
  line-height: 1.34;
}

.task-log-line span {
  display: block;
}

.task-log-meta {
  color: #68748a;
  font-size: 10px;
  margin-bottom: 2px;
}

.task-log-line.stderr {
  background: #fff3f3;
  border-color: #ffd7da;
}

.messages-area {
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  min-height: 0;
}

.message {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 16px;
  line-height: 1.35;
  word-wrap: break-word;
}

.message.assistant {
  align-self: flex-start;
  background-color: var(--bubble-received);
  color: #000;
  border-bottom-left-radius: 4px;
}

.message.user {
  align-self: flex-end;
  background-color: var(--bubble-sent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message.system {
  align-self: center;
  max-width: 92%;
  background: var(--bubble-system);
  color: #544200;
  border-radius: 12px;
  font-size: 14px;
}

.input-area {
  position: absolute;
  bottom: 60px;
  left: 0;
  width: 100%;
  background-color: #f9f9f9;
  padding: 10px 15px;
  display: flex;
  align-items: center;
  border-top: 1px solid #ddd;
}

.voice-input-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #d8d8dd;
  background: #fff;
  color: #5c6373;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  flex: 0 0 auto;
}

.voice-input-btn svg {
  width: 14px;
  height: 14px;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.voice-input-btn.recording {
  border-color: #ff5d64;
  color: #ff3b30;
  background: #fff0f1;
}

.text-field {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 8px 15px;
  font-size: 16px;
  outline: none;
  background: #fff;
}

.send-btn {
  background: var(--primary-blue);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  margin-left: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.send-btn svg {
  width: 16px;
  height: 16px;
  fill: #fff;
  margin-left: 2px;
}

.bottom-nav {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 60px;
  background-color: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-secondary);
  background: none;
  border: none;
}

.nav-item.is-active {
  color: var(--primary-blue);
}

.nav-item svg {
  width: 24px;
  height: 24px;
  margin-bottom: 4px;
  fill: currentColor;
}

.nav-item span {
  font-size: 10px;
  font-weight: 500;
}

.incoming {
  position: fixed;
  inset: 0;
  background: rgba(13, 18, 23, 0.48);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 400;
}

.incoming-card {
  width: min(360px, 100%);
  border-radius: 24px;
  background: #fff;
  padding: 22px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.25);
}

.incoming-label {
  margin: 0 0 6px;
  color: #27a34b;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 11px;
  font-weight: 800;
}

.incoming-card h2 {
  margin: 0 0 8px;
}

#incomingSummary {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.4;
}

.incoming-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.answer-btn,
.decline-btn {
  border: 0;
  border-radius: 999px;
  min-height: 44px;
  font-weight: 800;
}

.answer-btn {
  background: #e6faeb;
  color: #1f9a44;
}

.decline-btn {
  background: #ffe8e9;
  color: #cd4348;
}

@keyframes recordingPulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.28);
  }
  50% {
    transform: scale(1.02);
    box-shadow: 0 0 0 8px rgba(52, 199, 89, 0.1);
  }
}

@media (max-width: 390px) {
  .dial-grid {
    padding: 0 22px;
    gap: 14px;
  }

  .dial-btn {
    width: 72px;
    height: 72px;
  }

  .backspace-btn {
    right: 38px;
  }
}

@media (min-width: 430px) and (pointer: fine) {
  .app-container {
    border-left: 1px solid #111;
    border-right: 1px solid #111;
  }
}
