:root {
  /* Colors */
  --primary: #1a73e8;
  --primary-light: #e3f2fd;
  --primary-dark: #1565c0;
  --card-bg: #fff;
  --background-light: #fafafa;
  --background-dark: #f5f5f5;
  --border: #e0e0e0;
  --border-light: #f0f0f0;
  --text: #212121;
  --text-secondary: #5f6368;
  --error: #c62828;
  --success: #388e3c;
  --icon: #5f6368;
  --icon-success: #388e3c;
  --icon-error: #c62828;
  /* Shadows */
  --shadow: 0 2px 8px rgba(60,64,67,.10);
  --shadow-strong: 0 4px 24px rgba(0,0,0,0.18);
  /* Typography */
  --font: 'Roboto', Arial, sans-serif;
  --font-size-base: 14px;
  --font-size-lg: 1.25rem;
  --font-size-md: 1.1rem;
  --font-size-sm: 0.98rem;
  --radius: 16px;
}

html,
body {
  width: 100vw;
  max-width: 100vw;
  min-width: 0;
  margin: 0;
  padding: 0;
  background: var(--background-dark);
  font-family: var(--font);
  font-size: var(--font-size-base);
  color: var(--text);
  overflow-x: hidden;
}

.mdc-top-app-bar {
  background: var(--card-bg);
  color: var(--primary);
  box-shadow: 0 2px 4px rgba(60,64,67,.15); /* keep as is for subtlety */
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 10;
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
  border-bottom: 1.5px solid var(--border);
}
.mdc-top-app-bar__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

/* --- Card Base Styles --- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 360px;
  min-width: 260px;
  margin: 0 auto;
}

.card__content {
  width: 100%;
  box-sizing: border-box;
  padding: 20px 14px 16px 14px;
}

/* Settings Card */
.settings-card {
  /* Inherits all .card styles */
  display: flex;
  flex-direction: column;
  position: relative;
  height: 100%;
  padding: 10px 14px 16px 14px;
  box-sizing: border-box;
}

.settings-card h2:first-of-type {
  margin-top: 0;
}

/* Result Card */
.result {
  display: none;
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  overflow: hidden;
  position: relative;
}

/* Screenshot Modal */
.screenshot-modal-content {
  position: relative;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--shadow-strong);
  padding: 24px 24px 16px 24px;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Provider Section */
.provider-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  background: var(--background-light);
  box-shadow: 0 1px 2px var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.provider-section.active {
  box-shadow: var(--shadow);
}

/* Context Section */
.context-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card-bg);
}

.select-row-horizontal {
  display: flex;
  flex-direction: row;
  gap: 12px;
  margin-bottom: 18px;
  width: 100%;
}
.select-row-horizontal .select-wrapper {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
}

/* --- Form Control Base Styles --- */
.form-control {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 40px;
  font-size: 1rem;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--background-light);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.form-control:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
  background: var(--card-bg);
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
  background: var(--card-bg);
  outline: none;
}

/* Apply form-control styles to all form elements */
input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 40px;
  font-size: 1rem;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--background-light);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

input[type="text"]:hover,
input[type="password"]:hover,
select:hover,
textarea:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
  background: var(--card-bg);
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
  background: var(--card-bg);
  outline: none;
}

/* Textarea specific overrides */
textarea {
  min-height: 60px;
  max-height: 120px;
  resize: vertical;
  overflow-y: auto;
  margin-bottom: 12px;
}

/* Remove duplicate styles from settings card inputs */
.settings-card input[type="text"],
.settings-card input[type="password"],
.settings-card textarea {
  margin-bottom: 10px;
}

/* Remove duplicate styles from prompt save row */
.prompt-save-row input[type="text"] {
  margin-bottom: 0;
}

.button-row {
  width: 100%;
}
#assist {
  width: 100%;
  margin: 0;
}

#snackbar {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  min-width: 200px;
  max-width: 320px;
  background: #323232;
  color: #fff;
  padding: 14px 24px;
  border-radius: 8px;
  font-size: 1rem;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  transition: opacity 0.3s, bottom 0.3s, transform 0.3s;
}
#snackbar.show {
  opacity: 1;
  pointer-events: auto;
  bottom: 40px;
  transform: translateX(-50%) scale(1.05);
}

input:focus, textarea:focus, select:focus, button:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.settings-section {
  margin-bottom: 18px;
}
.settings-section h2 {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--primary);
  margin: 0 0 10px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.settings-card input[type="text"],
.settings-card input[type="password"],
.settings-card textarea {
  width: 100%;
  font-size: 1rem;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--background-light);
  color: var(--text);
  margin-bottom: 10px;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.settings-card input:focus,
.settings-card textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
  background: var(--card-bg);
}
.settings-card button {
  margin: 0 8px 0 0;
  min-width: 110px;
}
.prompt-list {
  list-style: none;
  padding: 0;
  margin: 0 0 8px 0;
}
.prompt-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 4px 0;
  font-size: var(--font-size-sm);
  border-bottom: 1px solid var(--border-light);
  background: none;
  border-radius: 0;
  margin-bottom: 2px;
}
.prompt-list li:last-child {
  border-bottom: none;
}
.prompt-list .prompt-text {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 8px;
}
.prompt-list .prompt-actions {
  display: flex;
  gap: 4px;
  margin-left: 8px;
}
.prompt-list .edit-prompt, .prompt-list .delete-prompt {
  background: var(--primary-light);
  color: var(--primary);
  border: none;
  font-size: 1.05rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  min-width: 36px;
  height: 36px;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s, color 0.18s;
}
.prompt-list .edit-prompt:hover, .prompt-list .edit-prompt:focus {
  background: var(--primary);
  color: #fff;
}
.prompt-list .delete-prompt {
  background: #ffebee;
  color: var(--error);
}
.prompt-list .delete-prompt:hover, .prompt-list .delete-prompt:focus {
  background: var(--error);
  color: #fff;
}
.prompt-list .edit-prompt .material-icons,
.prompt-list .delete-prompt .material-icons {
  font-size: 1.2em;
  vertical-align: middle;
}
.settings-card .reset-prompts-btn {
  background: var(--primary-light) !important;
  color: var(--primary) !important;
  font-weight: 500;
  border-radius: 6px;
  transition: background 0.18s, color 0.18s;
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  padding: 0 10px;
  min-width: 80px;
  height: 32px;
  font-size: 0.97rem;
  box-sizing: border-box;
}
.settings-card .reset-prompts-btn .material-icons {
  font-size: 1.1em;
  vertical-align: middle;
  margin-right: 0;
}
.settings-card .reset-prompts-btn:hover,
.settings-card .reset-prompts-btn:focus {
  background: var(--primary) !important;
  color: #fff !important;
}
.settings-card .reset-prompts-btn:hover .material-icons,
.settings-card .reset-prompts-btn:focus .material-icons {
  color: #fff !important;
}

.prompt-save-row {
  display: flex;
  flex-direction: row;
  gap: 8px;
  /* margin-bottom: 10px; */
}
.prompt-save-row input[type="text"] {
  flex: 1 1 auto;
  margin-bottom: 0;
}
#savePromptBtn {
  flex: 0 0 auto;
  background: var(--primary-light);
  color: var(--primary);
  border: none;
  font-weight: 500;
  border-radius: 6px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  transition: background 0.2s, color 0.2s;
  height: 40px;
  min-width: 44px;
  box-shadow: none;
}
#savePromptBtn .material-icons {
  color: var(--primary);
  font-size: 1.2em;
  vertical-align: right;
}
#savePromptBtn:hover, #savePromptBtn:focus {
  background: var(--primary);
  color: #fff;
}
#savePromptBtn:hover .material-icons, #savePromptBtn:focus .material-icons {
  color: #fff;
}
#settingsCustomPrompt {
  margin-bottom: 0px;
}

.prompt-save-row button,
.prompt-list .edit-prompt,
.prompt-list .delete-prompt {
  min-width: 36px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reset-btn-center {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

.advanced-toggle {
  position: static;
  display: block;
  width: 100%;
  text-align: center;
  color: var(--primary);
  font-size: 0.95rem;
  user-select: none;
  cursor: pointer;
  background: none;
  border: none;
  transition: color 0.18s;
}
.advanced-toggle:hover, .advanced-toggle:focus {
  color: var(--primary-dark);
  text-decoration: underline;
}

.result-header {
  display: flex;
  justify-content: flex-end;
  padding: 8px;
  background: var(--background-light);
  border-bottom: 1px solid var(--border);
}

#copyResult {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--icon);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s, transform 0.2s;
  z-index: 2;
}
#copyResult:hover {
  background: var(--background-dark);
}
#copyResult:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--primary-light);
}
#copyResult .material-icons {
  font-size: 24px;
}
#copyResult.copied {
  color: var(--icon-success);
  animation: copied-bounce 0.5s;
}
@keyframes copied-bounce {
  0% { transform: scale(1); }
  30% { transform: scale(1.25); }
  60% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

#resultContent {
  padding: 16px;
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--text);
  overflow-x: auto;
}

#resultContent pre {
  margin: 8px 0;
  padding: 12px;
  background: var(--background-light);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow-x: auto;
}

#resultContent code {
  font-family: 'Roboto Mono', monospace;
  font-size: 13px;
}

.screenshot {
  display: none;
  max-width: 100%;
  border-radius: 8px;
  margin-top: 12px;
}
#resetPromptsBtn {
  display: none;
}

.mdc-layout-grid {
  margin-top: 3px;
}

.screenshot-modal {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.45);
  align-items: center;
  justify-content: center;
}
.screenshot-modal.show {
  display: flex;
}
.screenshot-modal-img {
  max-width: 80vw;
  max-height: 70vh;
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.screenshot-modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--card-bg);
  color: #333;
  border-radius: 50%;
  box-shadow: 0 1px 4px var(--shadow);
  z-index: 2;
}
.screenshot-modal-close:hover, .screenshot-modal-close:focus {
  background: var(--background-dark);
}

.button-spinner, .loading-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid #c3dafe;
  border-top: 2.5px solid var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-left: 6px;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Accordion Provider Settings */
.provider-settings {
  margin-bottom: 18px;
  border-radius: var(--radius);
  background: none;
}
.provider-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--font-size-md);
  font-weight: 500;
  padding: 12px 16px;
  cursor: pointer;
  background: var(--card-bg);
  user-select: none;
  outline: none;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.18s;
}
.provider-header:focus, .provider-header:hover {
  background: var(--primary-light);
}
.provider-logo {
  width: 22px;
  height: 22px;
  object-fit: contain;
  margin-right: 4px;
}
.accordion-arrow {
  margin-left: auto;
  color: var(--primary);
  font-size: 1.2em;
  transition: transform 0.2s;
}
.provider-section.active .accordion-arrow {
  transform: rotate(180deg);
}
.provider-body {
  padding: 16px 16px 10px 16px;
  background: var(--background-light);
  display: block;
  animation: accordion-expand 0.2s;
}
@keyframes accordion-expand {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.provider-body[style*="display:none"] {
  display: none !important;
  padding: 0;
}

/* Context Section Styles */
.context-container {
  margin-top: 16px;
  display: none;
}

.context-toggle {
  width: 100%;
  padding: 12px 16px;
  background: var(--primary-light);
  border: none;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--primary);
  transition: background 0.2s;
}

.context-toggle:hover {
  background: #d0e3ff;
}

.context-toggle .material-icons {
  transition: transform 0.2s;
}

.context-section.expanded .context-toggle .material-icons {
  transform: rotate(180deg);
}

.context-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
  background: var(--background-light);
}

.context-section.expanded .context-content {
  max-height: 500px;
  overflow-y: auto;
}

.context-metadata {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  line-height: 1.5;
}

.context-text {
  padding: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.context-text pre {
  margin: 8px 0 0 0;
  padding: 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 300px;
  overflow-y: auto;
}

/* Toggle Switch Styles */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: var(--card-bg);
  transition: .4s;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--primary);
}

input:checked + .slider:before {
  transform: translateX(26px);
}

.slider.round {
  border-radius: 24px;
}

.slider.round:before {
  border-radius: 50%;
}

.context-label {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.context-mode-toggle {
  background: var(--background-light);
  padding: 8px 16px;
  border-radius: 12px;
  box-shadow: 0 1px 2px var(--shadow);
}

/* Top bar toggle styles */
.mdc-top-app-bar .switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
}

.mdc-top-app-bar .slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
}

.mdc-top-app-bar .slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: var(--card-bg);
  transition: .4s;
}

.mdc-top-app-bar input:checked + .slider {
  background-color: #2563eb;
}

.mdc-top-app-bar input:checked + .slider:before {
  transform: translateX(20px);
}

.mdc-top-app-bar .context-label {
  color: var(--text-secondary);
  font-weight: 500;
}

/* --- Added/Standardized Classes for Consistency --- */
.feedback {
  color: var(--error);
  font-size: 0.95em;
  margin-top: 4px;
  min-height: 18px;
}
.provider-logo {
  width: 22px;
  height: 22px;
  object-fit: contain;
  margin-right: 4px;
  vertical-align: middle;
}
.accordion-arrow {
  margin-left: auto;
  color: var(--primary);
  font-size: 1.2em;
  transition: transform 0.2s;
}
.mdc-typography--headline6 {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--primary);
}
.mdc-snackbar {
  background: #323232;
  color: #fff;
  border-radius: 8px;
  font-size: 1rem;
  text-align: center;
  z-index: 9999;
}
.prompt-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  font-size: var(--font-size-sm);
  border-bottom: 1px solid var(--border-light);
  background: none;
  border-radius: 0;
  margin-bottom: 2px;
}
.prompt-item.editing {
  background: var(--primary-light);
}
.editing {
  background: var(--primary-light) !important;
}

/* --- Button Styles --- */
.btn {
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: white;
  box-shadow: 0 1px 2px var(--shadow);
}

.btn:hover {
  background: var(--primary-dark);
  box-shadow: var(--shadow);
}

.btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--primary-light);
}

.btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

/* --- Icon Button Styles --- */
.icon-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--icon);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.icon-btn:hover {
  background: var(--background-dark);
}

.icon-btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--primary-light);
}

.icon-btn .material-icons {
  font-size: 24px;
}

/* --- Typography System --- */
.text {
  font-family: var(--font);
  color: var(--text);
  line-height: 1.5;
}

.text--secondary {
  color: var(--text-secondary);
}

.text--primary {
  color: var(--primary);
}

.text--error {
  color: var(--error);
}

.text--success {
  color: var(--success);
}

/* Font Sizes */
.text--sm {
  font-size: var(--font-size-sm);
}

.text--base {
  font-size: var(--font-size-base);
}

.text--md {
  font-size: var(--font-size-md);
}

.text--lg {
  font-size: var(--font-size-lg);
}

/* Font Weights */
.text--regular {
  font-weight: 400;
}

.text--medium {
  font-weight: 500;
}

.text--semibold {
  font-weight: 600;
}

/* Apply typography system to existing elements */
.mdc-typography--headline6 {
  font-family: var(--font);
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--primary);
  margin: 0 0 10px 0;
}

.context-label {
  font-family: var(--font);
  font-size: var(--font-size-base);
  font-weight: 500;
  color: var(--text-secondary);
}

.feedback {
  font-family: var(--font);
  font-size: var(--font-size-sm);
  color: var(--error);
  margin-top: 4px;
  min-height: 18px;
}

.prompt-list li {
  font-family: var(--font);
  font-size: var(--font-size-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-light);
  background: none;
  border-radius: 0;
  margin-bottom: 2px;
}

#resultContent {
  font-family: var(--font);
  font-size: var(--font-size-base);
  padding: 16px;
  overflow-x: auto;
}

#resultContent pre {
  margin: 8px 0;
  padding: 12px;
  background: var(--background-light);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow-x: auto;
}

#resultContent code {
  font-family: 'Roboto Mono', monospace;
  font-size: 13px;
}

.advanced-toggle {
  font-family: var(--font);
  font-size: var(--font-size-sm);
  color: var(--primary);
  margin: 0 0 12px 0;
  position: static;
  display: block;
  width: 100%;
  text-align: center;
  user-select: none;
  cursor: pointer;
  background: none;
  border: none;
  transition: color 0.18s;
}

.advanced-toggle:hover,
.advanced-toggle:focus {
  color: var(--primary-dark);
  text-decoration: underline;
}

