:root {
  --ui-font: "UKIJTor", "utuqkarwanbold", "ALKATIP Basma Tom", "UKIJ Tuz", "Microsoft Uighur", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
  font-family: var(--ui-font);
}

body {
  margin: 0;
  background: #f7f8fa;
}

.page {
  width: 100%;
  min-height: 100vh;
  padding: 10px;
}

.border {
  border: 1px solid #ebeef3;
  border-radius: 8px;
  background: #fff;
}

.border-top {
  border-top: 1px solid #ebeef3;
}

.toolbar {
  height: 48px;
  padding: 6px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.left-tools,
.right-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand {
  margin-right: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ghost-btn {
  height: 32px;
  border: 1px solid #e2e6ef;
  background: #fff;
  color: #4a5568;
  padding: 0 10px;
  border-radius: 6px;
}

#provider {
  height: 32px;
  border: 1px solid #e2e6ef;
  background: #fff;
  color: #4a5568;
  padding: 0 10px;
  border-radius: 6px;
}

.brand-logo {
  height: 36px;
  width: auto;
  display: block;
  object-fit: contain;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  color: #23406a;
}

.lang-select {
  position: relative;
  min-width: 130px;
}

.lang-trigger {
  width: 100%;
  height: 40px;
  border: 1px solid #e2e6ef;
  border-radius: 14px;
  background: #f7f9fd;
  color: #2f3b52;
  font-size: 15px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.lang-caret {
  color: #5d73f7;
  font-size: 14px;
}

.lang-select.open .lang-caret {
  transform: rotate(180deg);
}

.lang-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 180px;
  padding: 8px;
  border: 1px solid #e6eaf2;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(35, 48, 78, 0.12);
  z-index: 20;
}

.lang-select.open .lang-menu {
  display: block;
}

.lang-option {
  width: 100%;
  border: none;
  background: #f3f5f9;
  color: #2d3445;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  text-align: left;
  font-size: 15px;
  cursor: pointer;
}

.lang-option:last-child {
  margin-bottom: 0;
}

.lang-option.active {
  background: #dfe8ff;
  color: #4f63f3;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-height: 520px;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 520px;
  overflow: hidden;
}

.input-panel {
  position: relative;
}

textarea {
  width: 100%;
  height: 100%;
  min-height: 430px;
  border: none;
  outline: none;
  resize: vertical;
  padding: 20px 22px;
  font-size: 15px;
  color: #2d3748;
  background: #fff;
  direction: ltr;
  text-align: left;
  unicode-bidi: plaintext;
  font-family: var(--ui-font);
}

textarea.lang-ug,
textarea.lang-kz {
  direction: rtl;
  text-align: right;
  /* Uyghur/Kazakh preferred font stack (webfont + system) */
  font-family: "UKIJTor", "utuqkarwanbold", "ALKATIP Basma Tom", "UKIJ Tuz", "Microsoft Uighur", "Segoe UI", Arial, sans-serif;
}

textarea.lang-zh {
  direction: ltr;
  text-align: left;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

textarea.lang-en,
textarea.lang-ru {
  direction: ltr;
  text-align: left;
  font-family: "Segoe UI", Arial, sans-serif;
}

textarea::placeholder {
  font-family: var(--ui-font);
  opacity: 0.9;
}

.panel-footer {
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: #fff;
}

.upload-zone {
  width: 100%;
  height: 100%;
  border: 1px dashed #e6e9ef;
  border-radius: 10px;
  background: #fafbfc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.upload-title {
  font-size: 14px;
  color: #8f98a8;
}

.upload-icons {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border: 1px solid #e2e6ef;
  border-radius: 7px;
  background: #ffffff;
  cursor: pointer;
  color: #7a8699;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.icon-btn .iconfont {
  font-size: 15px;
  color: #9aa4b2;
  line-height: 1;
}

.panel-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid #ebeef3;
  background: #fff;
}

.input-tools {
  display: none;
  align-items: center;
  gap: 8px;
  margin-right: auto;
}

.output-tools {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #fff;
}

.tool-icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px;
}

.tool-icon-btn .iconfont {
  font-size: 20px;
  color: #5e6b85;
}

.has-input .panel-footer {
  display: none;
}

.has-input #inputText {
  min-height: 560px;
}

.has-input .panel-actions {
  border-top: none;
}

.has-input #clearBtn,
.has-input #copyBtn {
  display: none;
}

.has-input .input-tools {
  display: flex;
}

.has-output .output-tools {
  display: flex;
}

.input-clear-icon {
  position: absolute;
  top: 16px;
  right: 18px;
  border: none;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  padding: 4px 6px;
  cursor: pointer;
  display: none;
  z-index: 2;
}

.input-clear-icon .iconfont {
  font-size: 13px;
  color: #a0a7b4;
}

.has-input .input-clear-icon {
  display: inline-flex;
}

.primary-btn,
.clear-btn,
.copy-btn,
.tag-btn {
  border: none;
  border-radius: 16px;
  padding: 8px 16px;
  cursor: pointer;
}

.primary-btn {
  background: linear-gradient(90deg, #6ba7ff 0%, #8ba8ff 100%);
  color: #fff;
}

.primary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.25);
}

.mobile-translate-wrap {
  display: none;
}

.app-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.app-modal.open {
  display: flex;
}

.app-modal-card {
  min-width: 260px;
  max-width: 90vw;
  background: #1f1f1f;
  color: #fff;
  border-radius: 10px;
  padding: 18px 16px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.app-modal-text {
  font-size: 18px;
  text-align: center;
  margin-bottom: 14px;
}

.app-modal-ok {
  width: 100%;
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: #6fa8ff;
  font-size: 16px;
  padding-top: 10px;
  cursor: pointer;
}

.clear-btn,
.copy-btn {
  background: #eef2f7;
  color: #445066;
}

.tag-btn {
  background: #ffffff;
  border: 1px solid #e6eaf0;
  color: #6d7788;
  padding: 6px 12px;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    height: auto;
    gap: 8px;
  }

  .right-tools {
    justify-content: center;
  }

  .left-tools {
    justify-content: center;
    flex-wrap: wrap;
  }

  .brand-name {
    font-size: 16px;
  }

  .brand-logo {
    height: 30px;
  }

  .primary-btn,
  .clear-btn,
  .copy-btn {
    padding: 6px 12px;
    font-size: 14px;
    border-radius: 14px;
  }

  .panel-actions {
    padding-inline: 10px;
  }

  textarea {
    min-height: 280px;
    padding: 14px 16px;
  }
}

@media (max-width: 600px) {
  .toolbar {
    padding-inline: 6px;
  }

  .left-tools {
    flex: 1;
    min-width: 0;
    justify-content: flex-start;
    gap: 6px;
  }

  .right-tools {
    flex: 0 0 auto;
    justify-content: flex-end;
  }

  .lang-trigger {
    height: 34px;
    font-size: 13px;
    border-radius: 12px;
    padding: 0 10px;
  }

  .lang-select {
    min-width: 110px;
  }

  .ghost-btn {
    height: 34px;
    padding: 0 8px;
  }

  .brand-name {
    display: none;
  }

  .brand {
    margin-right: 0;
    gap: 6px;
  }

  .brand-logo {
    height: 26px;
  }

  .primary-btn {
    flex: 1;
    text-align: center;
  }

  /* Mobile: hide extra small utility buttons */
  .input-tools,
  .input-clear-icon {
    display: none !important;
  }

  /* Mobile: hide upload block */
  .panel-footer {
    display: none !important;
  }

  .panel-actions {
    border-top: none;
  }

  /* Mobile: small textarea by default */
  #inputText {
    min-height: 100px !important;
    max-height: 56vh;
    overflow-y: auto;
    resize: none;
  }

  .workspace {
    min-height: auto;
  }

  .panel,
  .input-panel {
    min-height: auto;
  }

  /* Mobile: hide output panel until we have result */
  .output-panel {
    display: none;
  }

  .has-output .output-panel {
    display: flex;
  }

  .has-output #outputText {
    min-height: 160px;
    max-height: 40vh;
    overflow-y: auto;
    resize: none;
  }

  /* Mobile: translate button full width */
  .panel-actions {
    justify-content: center;
  }

  .panel-actions .primary-btn {
    width: 100%;
  }
}
