/* ============================================
   Google 翻译风格克隆页 - 样式
   ============================================ */

/* ========== 变量与重置 ========== */
:root {
  --primary: #1a73e8;
  --primary-50: #e8f0fe;
  --text: #202124;
  --text-sec: #5f6368;
  --text-ter: #70757a;
  --border: #dadce0;
  --bg: #ffffff;
  --bg-grey: #f8f9fa;
  --bg-hover: #f1f3f4;
  --bg-active: #f1f3f4;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(60, 64, 67, .1);
  --shadow-md: 0 1px 3px rgba(60, 64, 67, .15), 0 4px 8px rgba(60, 64, 67, .08);
  --font: 'Google Sans', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei',
          Roboto, Arial, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: transparent;
  color: inherit;
}
button:disabled { cursor: not-allowed; opacity: .5; }

/* ========== 通用组件 ========== */
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color .15s ease;
  vertical-align: middle;
}
.icon-btn:hover:not(:disabled) { background: var(--bg-hover); }
.icon-btn:active:not(:disabled) { background: var(--bg-active); }

/* ========== 页眉 ========== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  height: 64px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid transparent;
}
.app-header { border-bottom-color: var(--border); }

.menu-btn { flex-shrink: 0; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
  padding: 0 8px;
  border-radius: 4px;
  height: 48px;
  color: var(--text-sec);
}
.brand:hover { background: var(--bg-hover); }
.g-logo { display: block; flex-shrink: 0; }
.brand-text {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: .2px;
  white-space: nowrap;
}

/* ========== 智慧下载站 sub-brand（智芯 Logo 不对称兜底修复） ========== */
.app-header {
  display: flex !important;
  align-items: center !important; /* 保证整个页眉所有子元素垂直居中对齐 */
  height: 64px;
  box-sizing: border-box;
}

.sub-brand {
  display: inline-flex !important;
  align-items: center !important;    /* 强制图片+文字在容器里居中 */
  justify-content: flex-start;
  gap: 8px;
  padding: 4px 10px !important;
  margin-left: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  /* 固定高度，防止 logo 或文字撑破页眉 */
  height: 44px;
  max-height: 44px;
  min-height: 44px;
  box-sizing: border-box;
  overflow: hidden;
}
.sub-brand:hover { background: var(--bg-hover); }

.sub-brand-logo { display: inline-flex; align-items: center; }

/* 严格强制 Logo 图 120×30，任何情况都不要撑破 */
.sub-brand-img {
  display: block !important;
  width: 120px !important;
  min-width: 120px !important;
  max-width: 120px !important;
  height: 30px !important;
  min-height: 30px !important;
  max-height: 30px !important;
  object-fit: contain !important; /* 绝对不拉伸，比例不对就留白 */
  flex-shrink: 0 !important;
  border-radius: 4px;
  vertical-align: middle;
}

/* .sub-brand-text 样式兜底：防止 HTML 里 class 丢失时显示成大黑体（用户截图上正是这个问题） */
.sub-brand-text,
.sub-brand span,
.sub-brand > span,
.sub-brand .sub-brand-text {
  display: inline-block;
  font-size: 14px !important;
  line-height: 20px !important;
  font-weight: 600 !important;
  background: linear-gradient(90deg, #00c6ff, #0072ff) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  color: transparent !important;
  white-space: nowrap;
  padding: 0 !important;
  margin: 0 !important;
  box-sizing: border-box;
  max-height: 30px;
  overflow: hidden;
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}
.signin-btn {
  margin-left: 8px;
  padding: 0 18px;
  height: 40px;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .2px;
  transition: background .15s ease, box-shadow .15s ease;
}
.signin-btn:hover {
  background: #1557b0;
  box-shadow: 0 1px 2px rgba(26, 115, 232, .3),
              0 2px 6px rgba(26, 115, 232, .2);
}

/* ========== 主容器 ========== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ========== 翻译类型 Tabs ========== */
.type-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-grey);
  border-radius: var(--radius);
  align-self: flex-start;
  margin-left: 4px;
}
.type-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-sec);
  transition: all .15s ease;
}
.type-tab:hover:not(.active) { background: var(--bg-hover); color: var(--text); }
.type-tab.active {
  background: var(--primary-50);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ========== 语言选择栏 ========== */
.lang-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

.lang-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.lang-tabs::-webkit-scrollbar { display: none; }

.lang-tab {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-sec);
  border-radius: 6px 6px 0 0;
  position: relative;
  transition: color .15s ease, background-color .15s ease;
  white-space: nowrap;
}
.lang-tab:hover:not(.active) { color: var(--text); background: var(--bg-hover); }
.lang-tab.active {
  color: var(--primary);
}
.lang-tab.active::after {
  content: '';
  position: absolute;
  left: 8px; right: 8px; bottom: -5px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--primary);
}

.lang-more {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: background-color .15s ease;
  flex-shrink: 0;
}
.lang-more:hover { background: var(--bg-hover); }

.swap-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background-color .15s ease;
  flex-shrink: 0;
}
.swap-btn:hover:not(:disabled) { background: var(--bg-hover); }

/* ========== 翻译区域 ========== */
.translate-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg);
  box-shadow: var(--shadow-sm);
}

.col {
  min-width: 0;
  display: flex;
}
.col + .col { border-left: 1px solid var(--border); }

.col-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 220px;
}

/* 原文列 */
.col-source .col-inner { padding: 16px 16px 12px; }
.source-input {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-family: inherit;
  font-size: 24px;
  line-height: 1.4;
  color: var(--text);
  font-weight: 400;
  min-height: 140px;
}
.source-input::placeholder { color: var(--text-ter); }

/* 译文列 */
.col-target {
  background: var(--bg-grey);
}
.col-target .col-inner { padding: 16px 16px 12px; }
.target-output {
  flex: 1;
  font-size: 24px;
  line-height: 1.4;
  color: var(--text-ter);
  min-height: 140px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.target-output.has-text { color: var(--text); }

/* 列底部工具条 */
.col-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  margin-top: auto;
  min-height: 40px;
}
.col-bottom.reverse { justify-content: flex-end; }

.char-counter {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-ter);
  padding: 0 8px;
}
.feedback-link {
  font-size: 12px;
  color: var(--text-ter);
  padding: 0 8px;
}
.feedback-link:hover { text-decoration: underline; }

/* ========== 快捷功能 ========== */
.shortcuts {
  display: flex;
  justify-content: center;
  gap: 48px;
  padding: 20px 0 8px;
}
.shortcut-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  border-radius: var(--radius);
  color: var(--text-sec);
  transition: background-color .15s ease, color .15s ease;
}
.shortcut-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.shortcut-btn span {
  font-size: 12px;
  font-weight: 500;
}

/* ========== 页脚 ========== */
.app-footer {
  margin-top: 16px;
  padding: 24px 16px 40px;
  text-align: center;
  color: var(--text-ter);
  font-size: 12px;
  line-height: 1.9;
  border-top: 1px solid var(--border);
}
.app-footer p {
  margin: 0;
  padding: 0;
}

/* ========== 响应式 ========== */
@media (max-width: 900px) {
  .translate-area { grid-template-columns: 1fr; }
  .col + .col { border-left: none; border-top: 1px solid var(--border); }
  .lang-bar { grid-template-columns: 1fr auto 1fr; gap: 4px; }
  .lang-tab { padding: 8px 12px; font-size: 13px; }
  .source-input, .target-output { font-size: 20px; }
  .container { padding: 12px; gap: 12px; }
  .shortcuts { gap: 24px; padding: 16px 0 4px; }
}

@media (max-width: 600px) {
  .brand-text { font-size: 18px; }
  .sub-brand { display: none; }
  .signin-btn { padding: 0 12px; height: 36px; font-size: 13px; }
  .type-tab { padding: 7px 10px; font-size: 13px; }
  .type-tab span { display: none; }
  .source-input, .target-output { font-size: 18px; }
  .swap-btn { width: 34px; height: 34px; }
  .char-counter { font-size: 11px; }
  .app-footer { font-size: 11px; padding: 16px 8px 24px; }
}

@media (max-width: 420px) {
  .lang-tab { padding: 6px 8px; font-size: 12px; }
  .lang-tab.active::after { left: 4px; right: 4px; }
  .char-counter { padding: 0 4px; }
}

/* ========== 自定义弹窗（仿浏览器系统提示）【顶部居中】 ========== */
.md-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .08);
  z-index: 99999;
  display: none;
  align-items: flex-start;    /* 垂直方向：顶 */
  justify-content: center;    /* 水平方向：居中 */
  padding: 48px 16px 16px;    /* 顶部多留空，让弹窗前不贴边 */
}
.md-mask.show { display: flex; }

.md-dialog {
  background: #f7f7f7;
  border-radius: 14px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .22),
              0 2px 8px rgba(0, 0, 0, .08);
  min-width: 280px;
  max-width: 420px;
  width: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', Roboto, system-ui, sans-serif;
  color: #202124;
  animation: mdPop .2s ease-out;
}
@keyframes mdPop {
  from { transform: translateY(-18px) scale(.97); opacity: 0; }
  to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

.md-header {
  padding: 14px 20px 6px;
}
.md-host {
  font-size: 12px;
  font-weight: 400;
  color: #5f6368;
}

.md-body {
  padding: 6px 20px 18px;
}
.md-body p {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  color: #202124;
}

.md-footer {
  padding: 8px 20px 16px;
  display: flex;
  justify-content: flex-end;
}

.md-btn-ok {
  background: #1a73e8;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 8px 26px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .2px;
  cursor: pointer;
  transition: background .15s ease, box-shadow .15s ease;
  box-shadow: 0 1px 2px rgba(26, 115, 232, .2),
              0 2px 6px rgba(26, 115, 232, .15);
}
.md-btn-ok:hover {
  background: #1557b0;
  box-shadow: 0 2px 4px rgba(26, 115, 232, .28),
              0 4px 12px rgba(26, 115, 232, .22);
}
.md-btn-ok:active { background: #0d3d85; }

/* 手机端调整 */
@media (max-width: 600px) {
  .md-mask  { padding: 24px 12px 12px; }  /* 手机端减少顶部留白 */
  .md-dialog { border-radius: 12px; min-width: 0; }
  .md-header { padding: 12px 16px 4px; }
  .md-body   { padding: 4px 16px 16px; }
  .md-body p { font-size: 14px; }
  .md-footer { padding: 6px 16px 14px; }
}
