@font-face {
  font-family: 'Bookerly';
  src: url('fonts/Bookerly.woff') format('woff');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Bookerly';
  src: url('fonts/Bookerly-Bold.woff') format('woff');
  font-weight: bold;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Bookerly';
  src: url('fonts/Bookerly-Italic.woff') format('woff');
  font-weight: normal;
  font-style: italic;
  font-display: swap;
}

:root,
[data-theme="dark"] {
  --bg-page: #202124;
  --bg-header: #202124;
  --bg-source-card: #202124;
  --bg-target-card: #303134;
  --border-card: #3c4043;
  --border-subtle: #3c4043;
  --text-primary: #e8eaed;
  --text-secondary: #9aa0a6;
  --text-muted: #80868b;
  --primary: #8ab4f8;
  --primary-hover: #aecbfa;
  --primary-glow: rgba(138, 180, 248, 0.2);
  --btn-primary-bg: #8ab4f8;
  --btn-primary-text: #202124;
  --menu-bg: #303134;
  --radius-card: 16px;
  --transition: all 0.15s ease;
}

[data-theme="light"] {
  --bg-page: #ffffff;
  --bg-header: #ffffff;
  --bg-source-card: #ffffff;
  --bg-target-card: #f1f4f9;
  --border-card: #dadce0;
  --border-subtle: #e8eaed;
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --text-muted: #80868b;
  --primary: #1a73e8;
  --primary-hover: #1557b0;
  --primary-glow: rgba(26, 115, 232, 0.12);
  --btn-primary-bg: #1a73e8;
  --btn-primary-text: #ffffff;
  --menu-bg: #ffffff;
}

[data-theme="yellow"] {
  --bg-page: #fbf0d9;
  --bg-header: #fbf0d9;
  --bg-source-card: #fbf0d9;
  --bg-target-card: #f4e7cc;
  --border-card: #e5d5b7;
  --border-subtle: #ebdcc0;
  --text-primary: #3c2c1c;
  --text-secondary: #5c4c3c;
  --text-muted: #8c7c6c;
  --primary: #805c2c;
  --primary-hover: #604018;
  --primary-glow: rgba(128, 92, 44, 0.15);
  --btn-primary-bg: #805c2c;
  --btn-primary-text: #ffffff;
  --menu-bg: #f7edd5;
}

[data-theme="blue"] {
  --bg-page: #edf2fa;
  --bg-header: #edf2fa;
  --bg-source-card: #ffffff;
  --bg-target-card: #f1f4f9;
  --border-card: #cbdcf2;
  --border-subtle: #dbe7f7;
  --text-primary: #18202c;
  --text-secondary: #3b4856;
  --text-muted: #6b7886;
  --primary: #1a73e8;
  --primary-hover: #1557b0;
  --primary-glow: rgba(26, 115, 232, 0.12);
  --btn-primary-bg: #1a73e8;
  --btn-primary-text: #ffffff;
  --menu-bg: #ffffff;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  box-shadow: none !important;

}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-card);
  border-radius: 999px;
  transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-card) transparent;
}

:root {
  --app-font: 'Google Sans', 'Inter', 'Roboto', system-ui, -apple-system, sans-serif;
}

body {
  font-family: var(--app-font);
  background-color: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background-color 0.2s ease, color 0.2s ease;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.app-wrapper {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 8px 20px 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.brand-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.brand-name {
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

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

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon:hover {
  background: rgba(125, 125, 125, 0.1);
  color: var(--text-primary);
}

.gt-workspace {
  display: flex;
  flex-direction: column;
  gap: 0px;
  flex: 1;
}

.gt-lang-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  padding: 0 4px;
}

.gt-tab-group {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.gt-tab {
  background: transparent;
  border: none;
  padding: 8px 10px 14px 10px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 400;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  transition: color 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.gt-tab.active {
  color: var(--primary);
  font-weight: 500;
}

.gt-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 2px;
  background-color: var(--primary);
  border-radius: 2px;
}

.detected-badge {
  font-size: 0.86rem;
  font-weight: 400;
  color: var(--text-muted);
}

.gt-more-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  transition: var(--transition);
}

.gt-more-btn:hover {
  background: rgba(125, 125, 125, 0.12);
  color: var(--text-primary);
}

.gt-more-btn[aria-expanded="true"] {
  background: var(--primary-glow);
  color: var(--primary);
}

.gt-more-btn::after {
  display: none !important;
}

.gt-dropdown-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.gt-lang-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--menu-bg);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  width: 250px;
  max-height: 340px;
  z-index: 100;
  flex-direction: column;
  overflow: hidden;
}

.tgt-tab-group .gt-lang-menu {
  left: auto;
  right: 0;
}

.gt-lang-menu.open {
  display: flex;
}

.menu-search-box {
  padding: 10px;
  border-bottom: none;
}

.menu-search-box input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition);
}

.menu-search-box input:focus {
  border-color: var(--primary);
}

.menu-lang-list {
  overflow-y: auto;
  max-height: 270px;
  scrollbar-width: none;

  -ms-overflow-style: none;

}

.menu-lang-list::-webkit-scrollbar {
  display: none;

}

.menu-lang-item {
  padding: 9px 16px;
  font-size: 0.88rem;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.12s ease;
}

.menu-lang-item:hover {
  background: var(--primary-glow);
  color: var(--primary);
}

.menu-lang-item.selected {
  font-weight: 500;
  color: var(--primary);
  background: var(--primary-glow);
}

.gt-swap-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  transition: var(--transition);
  margin: 0 auto;
}

.gt-swap-btn:hover {
  background: rgba(125, 125, 125, 0.1);
  color: var(--text-primary);
}

.gt-cards-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  flex: 1;
}

@media (max-width: 820px) {
  .gt-cards-container {
    grid-template-columns: 1fr;
  }

  .gt-lang-bar {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .gt-swap-btn {
    display: none;
  }
}

.gt-card {
  border-radius: var(--radius-card);
  border: 1px solid var(--border-card);
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 340px;
}

.gt-source-card {
  background-color: var(--bg-source-card);
}

.gt-target-card {
  background-color: var(--bg-target-card);
}

.gt-card-body {
  padding: 16px 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

.output-text {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.6;
  resize: none;
  outline: none;
  font-family: inherit;
  overflow-y: hidden;
  padding: 0;
  margin: 0;
  display: block;
}

.gt-source-card .output-text,
.gt-source-card .segments-layer {
  padding-right: 32px;
}

.output-text::placeholder {
  color: var(--text-muted);
  font-weight: 400;
  opacity: 1;
  font-family: inherit;
}

.segments-layer {
  width: 100%;
  min-height: 260px;
  white-space: pre-wrap;
  word-break: break-word;
  cursor: text;
  position: relative;
  font-size: 1rem;
  line-height: 1.6;
  padding: 0;
  margin: 0;
}

.sentence-segment {
  border-radius: 4px;
  padding: 2px 4px;
  margin: -2px -4px;
  transition: background-color 0.15s ease;
  cursor: text;
}

.sentence-segment:hover,
.sentence-segment.active-sentence {
  background-color: var(--primary-glow);
}

.gt-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 14px;
  min-height: 48px;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 4px;
}

.footer-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.char-count-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  user-select: none;
}

.gt-btn-clear {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.gt-clear-top {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 5;
}

.gt-btn-clear:hover {
  background: rgba(125, 125, 125, 0.1);
  color: var(--text-primary);
}

.gt-btn-translate {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border: none;
  padding: 8px 20px;
  border-radius: 20px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.gt-btn-translate:hover {
  opacity: 0.9;
}

.gt-btn-icon-action {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  outline: none;
}

.gt-btn-icon-action:hover:not(:disabled) {
  background: rgba(125, 125, 125, 0.12);
  color: var(--text-primary);
}

.gt-btn-icon-action:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.gt-btn-icon-action.active {
  color: #ea4335;
  background: rgba(234, 67, 53, 0.12);
}

.gt-btn-icon-action.playing {
  color: var(--primary);
  background: var(--primary-glow);
}

.gt-action-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 16px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.gt-action-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.gt-action-btn.copied {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-glow);
}

.gt-target-card {
  transition: opacity 0.3s ease, border-color 0.3s ease;
}

.gt-target-card.is-translating {
  animation: cardFadePulse 1.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes cardFadePulse {

  0%,
  100% {
    opacity: 0.45;
  }

  50% {
    opacity: 0.85;
  }
}

.font-sans {
  font-family: 'Google Sans', 'Roboto', 'Inter', system-ui, sans-serif;
}

.font-poppins {
  font-family: 'Poppins', sans-serif;
}

.font-serif {
  font-family: 'Lora', 'Georgia', serif;
}

.font-comic {
  font-family: 'Patrick Hand', cursive, sans-serif;
}

.font-dyslexic {
  font-family: 'Lexend', sans-serif;
}

.font-mono {
  font-family: 'Consolas', 'Courier New', monospace;
}

.font-bookerly {
  font-family: 'Bookerly', serif;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 40px);
  background: #323232;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 2000;
  opacity: 0;
  transition: all 0.2s ease;
  pointer-events: none;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(3px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-source-card);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  overflow: visible;
  position: relative;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.28);
}

.modal-header {
  padding: 16px 20px 6px 20px;
  border-bottom: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: var(--transition);
}

.modal-close-btn:hover {
  background: rgba(125, 125, 125, 0.1);
  color: var(--text-primary);
}

.modal-body {
  padding: 10px 20px 4px 20px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  max-height: 75vh;
  overflow-y: visible;
  position: relative;
}

.modal-divider {
  display: none;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  border: none;
  padding: 0;
  margin: 0;
}

.form-group label,
.form-group legend {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0;
  margin-bottom: 1px;
}

.custom-select-wrap {
  position: relative;
  width: 100%;
  z-index: 50;
}

.custom-select-wrap:has(.custom-select-menu.open) {
  z-index: 2000;
}

.custom-select-btn {
  width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 400;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  outline: none;
  transition: var(--transition);
  user-select: none;
}

.custom-select-btn:hover {
  border-color: var(--primary);
}

.custom-select-btn[aria-expanded="true"] {
  border-color: var(--primary);
  background: var(--primary-glow);
}

.custom-select-chevron {
  color: var(--text-secondary);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.custom-select-btn[aria-expanded="true"] .custom-select-chevron {
  transform: rotate(180deg);
  color: var(--primary);
}

.custom-select-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--menu-bg);
  border: 1px solid var(--border-card);
  border-radius: 10px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 3000;
  padding: 4px 0;
  scrollbar-width: none;

  -ms-overflow-style: none;

}

.custom-select-menu::-webkit-scrollbar {
  display: none;

}

.custom-select-menu.open {
  display: block;
}

.custom-select-option {
  padding: 10px 16px;
  font-size: 0.86rem;
  font-weight: 400;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.custom-select-option:hover {
  background: var(--primary-glow);
  color: var(--primary);
}

.custom-select-option.selected {
  font-weight: 500;
  color: var(--primary);
  background: var(--primary-glow);
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.theme-card-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 4px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.theme-card-btn:hover {
  border-color: var(--primary);
}

.theme-card-btn.active {
  border-color: var(--primary);
  background: var(--primary-glow);
}

.swatch-preview {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(125, 125, 125, 0.3);
}

.swatch-dark-preview {
  background: #202124;
}

.swatch-light-preview {
  background: #ffffff;
}

.swatch-yellow-preview {
  background: #fbf0d9;
}

.swatch-blue-preview {
  background: #edf2fa;
}

.input-password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-password-wrapper input {
  width: 100%;
  padding: 8px 36px 8px 12px;
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition);
}

.input-password-wrapper input:focus {
  border-color: var(--primary);
}

.btn-toggle-visibility {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-toggle-visibility:hover {
  color: var(--text-primary);
}

.btn-xs {
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
}

.btn-xs:hover {
  background: var(--primary-glow);
  color: var(--primary);
}

.modal-status-msg {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 2px;
}

.modal-status-msg:empty {
  display: none;
}

.modal-footer {
  padding: 8px 20px 18px 20px;
  border-top: none;
  display: flex;
  justify-content: flex-end;
}
