:root {
  --bg-app: var(--bg);
  --card-radius: 24px;
  --input-radius: 16px;
}

.translator-app {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-bottom: 80px;
}

/* Common Card Style */
.app-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 25px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.app-card:hover {
  box-shadow: 0 12px 32px rgba(0,0,0,0.08);
}

.card-header {
  display: flex;
  position: relative;
  padding-left: 0;
  padding: 16px 24px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
    align-items: center;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.check--compact.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.3);
  pointer-events: none;
}

.check--compact.is-disabled:hover {
  transform: none;
  box-shadow: none;
}

/* Screen reader only class */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.header-actions {
  margin-left: auto;
  display: flex;
}

.input-area {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: transparent;
  border: none;
}

#source-text {
  width: 100%;
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
  font-size: 1.4rem;
  line-height: 1.6;
  color: var(--text);
  resize: none;
  overflow: hidden;
  height: auto;
  min-height: 180px;
  outline: none;
  font-family: inherit;
  border-radius: 0;
}

#source-text:focus {
  outline: none !important;
  box-shadow: none !important;
  border: none !important;
}

#source-text::placeholder {
  color: var(--muted);
  font-weight: 300;
}

.input-footer {
  display: flex;
  justify-content: flex-end;
  border-top: 1px dashed var(--border);
  padding-top: 16px;
}

/* Primary Translate Button */
.primary-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 100px;
  padding: 12px 32px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.primary-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.primary-btn:active {
  transform: translateY(0);
}

/* --- Advanced Settings (Accordion) --- */
.advanced-settings {
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.advanced-settings summary {
  padding: 12px 24px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.advanced-settings summary:hover {
  color: var(--text);
  background: rgba(0,0,0,0.04);
}

.advanced-settings summary:focus-visible {
  outline: none;
  box-shadow: none;
}

.advanced-settings[open] summary {
  color: var(--text);
}

.advanced-settings[open] .settings-body {
  animation: advancedSlide 0.25s ease;
}

@keyframes advancedSlide {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.settings-body {
  padding: 0 24px 32px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.api-field {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: auto;
}

.api-field .input[type="text"]:not(.main-search-input):not(.pill-input):not(#tool-search),
.api-field .input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 25px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  box-sizing: border-box;
  min-width: 0;
  height: 50px;
  line-height: 1.2;
  appearance: none;
  -webkit-appearance: none;
}

.api-field .input[type="text"]:not(.main-search-input):not(.pill-input):not(#tool-search):focus,
.api-field .input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.api-field .input-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

.api-field .input-group .input {
  width: 100%;
}

.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.setting-label {
  font-weight: 600;
  font-size: 0.95rem;
}

.setting-hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.setting-row {
  display: flex;
  align-items: center;
}

.setting-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin-top: 4px;
  pointer-events: auto;
}

.check--compact {
  height: 44px;
  border-radius: 14px;
  padding: 0 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
}

/* Small versions of controls */
.sm-check {
  height: auto !important;
  background: transparent !important;
  padding: 0 !important;
  border: none !important;
}

.sm-check:hover {
  transform: none !important;
}

.sm-check span {
  font-size: 0.85rem;
  font-weight: 500;
}

.text-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
}

.text-btn:hover {
  color: var(--error);
  background: rgba(255,0,0,0.05);
}

/* --- 2. Target Card --- */
.target-card {
  min-height: auto;
}

.sm-header {
  padding: 12px 24px;
  justify-content: space-between;
  background: var(--surface); /* clean white */
}

.section-title {
  font-weight: 700;
  color: var(--text);
  font-size: 1rem;
}

.lang-picker-wrapper {
  padding: 24px;
}

.chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

/* Language chip with parenthesis on second line */
.chip-grid .check span {
  text-align: center;
  line-height: 1.3;
}

.chip-grid .check span .lang-sub {
  display: block;
  font-size: 0.85em;
  color: var(--muted);
  margin-top: 2px;
}

.lang-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lang-actions .divider {
  color: var(--border);
  font-size: 0.8rem;
}

.lang-actions .text-btn {
  color: var(--primary);
  font-weight: 500;
}

.lang-actions .text-btn:hover {
  background: var(--surface-2);
  color: var(--primary);
}

/* --- 3. Results Section --- */
.results-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 8px;
}

.results-header h3 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--text);
}

.results-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hint-text {
  font-size: 0.9rem;
  color: var(--muted);
}

.sm-btn {
  padding: 6px 16px;
  font-size: 0.9rem;
  height: 36px;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 20px;
  align-items: start;
}

/* Result Card Styling */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 20px;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.result-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 25px rgba(0,0,0,0.06);
  border-color: var(--primary);
  z-index: 1;
}

.result-card__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border);
}

.result-title {
  display: flex;
  flex-direction: column;
}

.result-title strong {
  color: var(--primary);
  font-size: 1.05rem;
}

.result-title span {
  font-size: 0.8rem;
  color: var(--muted);
}

.result-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.result-text {
  width: 100%;
  border: none;
  background: transparent;
  resize: none;
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--text);
  min-height: 80px;
  outline: none;
  font-family: inherit;
}

/* Custom select display sizing */
.custom-select-wrapper .select-selected {
  width: 100%;
  min-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 768px) {
  .card-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .header-actions {
    margin-left: 0;
    justify-content: flex-end;
  }
  
  .results-grid {
    grid-template-columns: 1fr;
  }
  
  .input-area {
    padding: 16px;
  }
  
  #source-text {
    font-size: 1.2rem;
  }
}