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

html, body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #fff;
  overflow: hidden;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
  background: #fafafa;
}

.profile-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #333;
}

.profile-menu {
  position: absolute;
  top: 50px;
  right: 16px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  z-index: 1000;
  display: none;
  flex-direction: column;
  min-width: 180px;
}

.profile-menu button {
  padding: 12px 16px;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid #eee;
  font-size: 14px;
}

.profile-menu button:last-child {
  border-bottom: none;
}

.profile-menu button:hover {
  background: #f5f5f5;
}

.content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
}

.screen.active {
  display: flex;
}

#main {
  display: flex;
}

#transcript-container {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
  padding-right: 8px;
}

.transcript-message {
  padding: 12px;
  border-radius: 8px;
  max-width: 90%;
  word-wrap: break-word;
  font-size: 14px;
  line-height: 1.4;
}

.transcript-message.user {
  background: #007AFF;
  color: white;
  align-self: flex-end;
}

.transcript-message.assistant {
  background: #e5e5ea;
  color: #333;
  align-self: flex-start;
}

.transcript-message.system {
  background: #f0f0f0;
  color: #666;
  align-self: center;
  font-size: 12px;
  max-width: 100%;
  text-align: center;
}

.controls-row {
  display: flex;
  gap: 12px;
  padding-bottom: 20px;
}

#call-controls {
  display: none;
  gap: 12px;
  width: 100%;
}

#normal-controls {
  display: flex;
  gap: 12px;
  width: 100%;
}

.control-btn {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

#start-call-btn {
  background: #007AFF;
  color: white;
}

#start-call-btn:active {
  opacity: 0.8;
}

#mute-btn {
  background: #FF9500;
  color: white;
  font-size: 18px;
}

#mute-btn:active {
  opacity: 0.8;
}

#end-call-btn {
  background: #FF3B30;
  color: white;
  flex: 1;
}

#end-call-btn:active {
  opacity: 0.8;
}

.settings-group {
  margin-bottom: 24px;
}

.settings-group h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #333;
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: #333;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #007AFF;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.save-btn {
  width: 100%;
  padding: 14px;
  background: #007AFF;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
}

.save-btn:active {
  opacity: 0.8;
}

.usage-link {
  color: #007AFF;
  text-decoration: none;
  font-size: 14px;
  margin-top: 8px;
}

#tool-settings-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tool-settings-item {
  padding: 12px;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.tool-settings-item:active {
  background: #e5e5e5;
}

#tools-list-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tool-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: #f5f5f5;
  border-radius: 6px;
  border: 1px solid #ddd;
}

.tool-name {
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  flex: 1;
}

.tool-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.popup {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.popup.active {
  display: flex;
}

.popup-content {
  background: white;
  border-radius: 12px;
  padding: 20px;
  max-width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.popup-header {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.popup-description {
  font-size: 14px;
  color: #666;
  line-height: 1.5;
}

.popup-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.popup-toggle input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.popup-settings-link {
  color: #007AFF;
  text-decoration: none;
  font-size: 14px;
  display: none;
  padding: 8px 0;
}

#tool-fields-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.back-btn {
  padding: 10px 0;
  color: #007AFF;
  background: none;
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  margin-bottom: 16px;
}

.back-btn:before {
  content: '← ';
}

@media (max-width: 600px) {
  .header {
    padding: 10px 12px;
  }

  .screen {
    padding: 12px;
  }

  .control-btn {
    padding: 12px;
    font-size: 14px;
  }

  .transcript-message {
    font-size: 13px;
  }
}
