:root{
  --accent:#ff7a1a;          /* Orange */
  --accent-600:#ff6a00;
  --accent-700:#e55f00;
  --bg:#ffffff;
  --text:#121212;
  --muted:#6b7280;
  --border:#e5e7eb;
  --surface:#fafafa;
  --radius:12px;
  --shadow:0 6px 18px rgba(0,0,0,0.06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body{ margin:0; background:var(--bg); color:var(--text); font-family:var(--font); }

/* Top bar */
.topbar{
  display:grid; grid-template-columns:auto 1fr auto; align-items:center;
  padding:12px 24px; border-bottom:1px solid var(--border); background:var(--bg); position:sticky; top:0; z-index:10;
  gap:20px;
}
.brand{ display:flex; align-items:center; gap:10px; font-weight:700; }
.logo{
  width:28px; height:28px; display:grid; place-items:center;
  border-radius:8px; box-shadow:var(--shadow);
  overflow: hidden;
}
.logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.brand-name{ letter-spacing:.3px; }
.header-controls{
  display:flex; align-items:center; justify-content:center;
  gap:20px;
}

/* Page */
.page{ margin:16px 0 8px; padding:0 16px; }

/* Rating section */
.rating-section {
  margin: 16px 16px 8px;
  display: flex;
  justify-content: center;
}

.full-stars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.full-stars .rate-text {
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.full-stars .rating-group {
  display: inline-flex;
  gap: 2px;
}

.full-stars input {
  position: absolute;
  left: -9999px;
  opacity: 0;
}

.full-stars label {
  margin: 0;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.full-stars label:hover {
  transform: scale(1.1);
}

.full-stars label a {
  display: block;
  text-decoration: none;
}

.full-stars label a svg {
  margin: 1px;
  height: 24px;
  width: 24px;
  fill: #ff8400;
  transition: fill 0.3s ease;
}

.full-stars input:checked ~ label a svg {
  fill: #ffc711;
}

.full-stars .rating-group:hover label a svg {
  fill: #ff8400;
}

.full-stars .rating-group input:hover ~ label a svg {
  fill: #ffc711;
}

/* Footer */
.footer {
  margin: 8px 16px 16px;
  text-align: center;
  color: var(--muted);
}

.footer-text {
  font-size: 13px;
  margin: 0;
  line-height: 1.5;
}

.footer-email {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
  white-space: nowrap;
}

.footer-email:hover {
  color: var(--accent-700);
  text-decoration: underline;
}

/* Enhanced Footer Sections */
.footer-feedback {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.footer-description {
  text-align: center;
  max-width: 800px;
  margin: 0 auto 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.footer-heading {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}

.footer-desc-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--muted);
  margin: 0;
}

.footer-languages {
  max-width: 900px;
  margin: 0 auto 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.footer-lang-heading {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 16px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.footer-lang-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
}

.footer-lang-list li {
  margin: 0;
}

.lang-link {
  display: inline-block;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.lang-link:hover {
  color: var(--accent);
  background: #fff6f0;
  border-color: var(--accent);
}

.lang-link:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.footer-copyright {
  text-align: center;
}

.footer-copyright p {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

/* Enhanced Description Section - Feature Cards */
.footer-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin: 24px 0;
  text-align: left;
}

.feature-item {
  padding: 20px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.feature-item h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
}

.feature-item p {
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  margin: 0;
}

.footer-subheading {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 24px 0 8px;
}

/* 4-Column Language Grid */
.footer-lang-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.footer-lang-grid li {
  margin: 0;
}

.footer-lang-grid .lang-link {
  display: block;
  text-align: center;
  font-size: 13px;
  padding: 10px 8px;
}

/* Responsive design for mobile */
@media (max-width: 768px) {
  .rating-section {
    margin: 24px 16px;
  }

  .full-stars {
    gap: 8px;
  }

  .full-stars .rate-text {
    font-size: 14px;
  }

  .full-stars label a svg {
    height: 20px;
    width: 20px;
  }

  /* Footer mobile styles */
  .footer {
    margin: 16px 12px;
  }

  .footer-feedback {
    padding-bottom: 20px;
    margin-bottom: 20px;
  }

  .footer-description {
    padding: 0 8px 20px;
    margin-bottom: 20px;
  }

  .footer-heading {
    font-size: 16px;
  }

  .footer-desc-text {
    font-size: 13px;
  }

  .footer-languages {
    padding: 0 8px 20px;
    margin-bottom: 20px;
  }

  .footer-lang-heading {
    font-size: 13px;
    margin-bottom: 12px;
  }

  .footer-lang-list {
    gap: 6px 10px;
  }

  .lang-link {
    font-size: 12px;
    padding: 5px 10px;
  }

  /* Feature cards - single column on mobile */
  .footer-features {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .feature-item {
    padding: 16px;
  }

  .feature-item h3 {
    font-size: 14px;
  }

  .feature-item p {
    font-size: 12px;
  }

  .footer-subheading {
    font-size: 15px;
    margin: 20px 0 8px;
  }

  /* 2-column language grid on mobile */
  .footer-lang-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .footer-lang-grid .lang-link {
    font-size: 11px;
    padding: 8px 6px;
  }
}

/* Very small screens - single column languages */
@media (max-width: 480px) {
  .footer-lang-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .footer-lang-grid .lang-link {
    font-size: 12px;
    padding: 10px 8px;
  }
}

/* Removed .lang-controls - now using direct .header-controls */
.lang-pill{
  display:inline-flex; align-items:center; gap:8px;
  padding:10px 14px; border:1px solid var(--border); background:#fff; border-radius:999px;
  font-weight:600; cursor:pointer;
}
.lang-pill:hover{ border-color:#d4d7dd; }
.swap-btn{
  font-size:18px; border-radius:50%; width:40px; height:40px;
  display:flex; align-items:center; justify-content:center;
  transition:all 0.2s ease;
}
.swap-btn:hover{
  background:var(--accent); color:white; border-color:var(--accent);
}

.actions{ display:flex; align-items:center; gap:10px;}
.icon-link{
  display:inline-flex; align-items:center; padding:8px; border-radius:8px;
  transition:background 0.2s; text-decoration:none;
}
.icon-link:hover{ background:rgba(255,132,0,0.1); }
.icon-link img{ width:24px; height:24px; opacity:0.6; }
button{ border:0; cursor:pointer; font:inherit; }
button.primary{
  padding:12px 18px; border-radius:10px; color:white;
  background:linear-gradient(135deg, var(--accent), var(--accent-700)); font-weight:700; box-shadow:var(--shadow);
}
button.primary:disabled{ opacity:.7; cursor:not-allowed; }
button.secondary{
  padding:10px 12px; border-radius:10px; background:var(--surface); border:1px solid var(--border); color:var(--text);
}
button.ghost{
  padding:8px 10px; border-radius:8px; background:transparent; border:1px solid var(--border); color:var(--text);
}
button.delete-btn{
  padding:6px 8px;
}
button.delete-btn .delete-icon{
  width:18px; height:18px; display:block; opacity:0.7;
}
button.delete-btn:hover .delete-icon{
  opacity:1;
}
.spinner{
  width:16px; height:16px; border-radius:50%;
  border:2px solid rgba(255,255,255,.6); border-top-color:#fff;
  animation:spin .8s linear infinite; vertical-align:-2px; margin-right:6px;
  display:none;
}
.spinner:not([hidden]){
  display:inline-block;
}
@keyframes spin { to { transform: rotate(360deg);} }

/* Panes */
.panes{ display:grid; grid-template-columns:1fr 1fr; gap:20px; }
.pane{
  position:relative; border:1px solid var(--border); border-radius:var(--radius); background:#fff; height:calc(100vh - 180px);
  box-shadow:var(--shadow); overflow:hidden;
}
.pane-body{ height:100%; display:flex; flex-direction:column; }
.pane textarea{
  flex:1; width:100%; resize:none; padding:18px; border:0; outline:none; font-size:16px; line-height:1.55;
  min-height:calc(100vh - 250px);
}
.pane textarea::placeholder{ color:#a8b0bb; }
.pane-footer{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:10px 14px; border-top:1px solid var(--border); background:var(--surface);
  color:var(--muted); font-size:13px;
  min-height: 48px;
}
.pane-footer.right{ justify-content:flex-end; }
.count{ font-variant-numeric: tabular-nums; }

/* Output overlay */
.overlay{
  position:absolute; inset:0; place-items:center; background:rgba(255,255,255,.7); backdrop-filter:saturate(1.1) blur(2px);
  display:none;
}
.overlay:not([hidden]){
  display:grid;
}
.loader{
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 20px 24px; border-radius: 16px; border: 1px solid var(--border);
  background: #fff; box-shadow: var(--shadow);
}

.loader-spinner {
  width: 60px; height: 60px;
  border: 6px solid var(--border);
  border-top: 6px solid var(--accent);
  border-radius: 50%;
  animation: loaderSpin 1s linear infinite;
}

.loader-text {
  font-weight: 700;
  color: var(--accent-600);
  font-size: 16px;
}

@keyframes loaderSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Modal */
.lang-dialog{ border:0; border-radius:16px; width:min(720px, 92vw); padding:0; box-shadow:var(--shadow); }
.lang-dialog::backdrop{ background:rgba(0,0,0,.25); }
.lang-dialog__inner{ display:flex; flex-direction:column; }
.lang-dialog__header{ display:flex; gap:8px; padding:12px; border-bottom:1px solid var(--border); background:#fff; }
#langSearch{ flex:1; padding:12px 14px; border:1px solid var(--border); border-radius:10px; outline:none; }
.lang-dialog__list{ max-height:min(60vh, 640px); overflow:auto; padding:6px; }

/* Rate Limit Warning Modal */
.rate-limit-dialog{
  border:0; border-radius:20px; width:min(500px, 90vw); padding:0;
  box-shadow:0 20px 40px rgba(0,0,0,0.15);
  background:#fff;
}
.rate-limit-dialog::backdrop{ background:rgba(0,0,0,.4); }
.rate-limit-dialog__inner{ display:flex; flex-direction:column; }
.rate-limit-dialog__header{
  display:flex; align-items:center; gap:12px; padding:20px 24px 16px;
  background:linear-gradient(135deg, #ff7a1a, #ff6a00); color:#fff; border-radius:20px 20px 0 0;
}
.rate-limit-dialog__icon{ font-size:24px; }
.rate-limit-dialog__title{
  flex:1; margin:0; font-size:18px; font-weight:700; letter-spacing:-0.025em;
}
.rate-limit-dialog__close{
  background:rgba(255,255,255,.2); border:0; color:#fff;
  width:32px; height:32px; border-radius:50%; cursor:pointer;
  font-size:20px; font-weight:700; display:flex; align-items:center; justify-content:center;
  transition:background-color 0.2s ease;
}
.rate-limit-dialog__close:hover{ background:rgba(255,255,255,.3); }
.rate-limit-dialog__body{ padding:24px; }
.rate-limit-dialog__message{
  margin:0; font-size:16px; line-height:1.6; color:var(--text);
}
.lang-item{
  display:flex; align-items:center; justify-content:space-between; gap:14px;
  padding:10px 12px; border-radius:10px; cursor:pointer;
}
.lang-item:hover{ background:#fff6f0; }
.lang-code{ color:var(--muted); font-variant-numeric: slashed-zero; }
.badge{ font-size:12px; padding:4px 6px; border-radius:999px; border:1px solid var(--border); color:var(--muted); }
.muted{ color:var(--muted); }

/* Hide mobile button by default (desktop) */
.mobile-translate-wrapper {
  display: none;
}

/* Mobile: Responsive layout with button between panes */
@media (max-width: 768px) {
  /* Hide source language selector and swap button */
  #sourceLangBtn,
  #swapBtn {
    display: none;
  }

  .header-controls {
    justify-content: center;
  }

  /* Hide entire actions div from header (cleaner mobile header) */
  .actions {
    display: none;
  }

  /* Show mobile translate button wrapper - compact spacing */
  .mobile-translate-wrapper {
    display: block;
    padding: 0;
    margin: 6px 0;
  }

  /* Full-width translate button for mobile - slightly reduced padding */
  #translateBtnMobile {
    width: 100%;
    padding: 14px 18px;
    font-size: 18px;
    font-weight: 700;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(255, 122, 26, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }

  /* Force no gap between panes (override 900px breakpoint) */
  .panes {
    gap: 0 !important;
  }

  /* Source pane: 30% taller than before, button still visible */
  .pane-input {
    margin-bottom: 0;
    height: auto;
    max-height: 52vh;
  }

  .pane-input textarea {
    min-height: 150px;
    max-height: 45.5vh;
  }

  /* Keep target pane flexible */
  .pane-output {
    margin-top: 0;
    height: auto;
  }
}

@media (max-width: 900px){
  .panes{ grid-template-columns:1fr; gap:16px; }
  .page{ padding:0 12px; }
  .header-controls{ flex-direction:column; gap:12px; }
  .topbar{ flex-direction:column; align-items:stretch; gap:12px; }
}
