/* ====== Google Translate Material 3 Theme for 速译星球 ====== */

/* --- Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --gt-bg: #f8fafc;
  --gt-surface: #ffffff;
  --gt-surface-variant: #f0f4f9;
  --gt-surface-container: #f8fafd;
  --gt-border: #dadce0;
  --gt-border-subtle: #e8eaed;
  --gt-text: #1f1f1f;
  --gt-text-subtle: #444746;
  --gt-text-muted: #747775;
  --gt-primary: #0b57d0;
  --gt-primary-hover: #0842a0;
  --gt-primary-container: #d3e3fd;
  --gt-on-primary-container: #041e49;
  --gt-icon-btn-hover: rgba(31, 31, 31, 0.08);
  --gt-icon-btn-active: rgba(31, 31, 31, 0.12);
  --gt-card-radius: 20px;
  --gt-shadow: 0 1px 3px 0 rgba(60,64,67,.08), 0 4px 8px 3px rgba(60,64,67,.04);
  --gt-shadow-focus: 0 1px 3px 0 rgba(60,64,67,.2), 0 4px 12px 3px rgba(60,64,67,.12);
}

body.dark {
  --gt-bg: #131314;
  --gt-surface: #1e1f20;
  --gt-surface-variant: #282a2c;
  --gt-surface-container: #1e1f20;
  --gt-border: #444746;
  --gt-border-subtle: #313335;
  --gt-text: #e3e3e3;
  --gt-text-subtle: #c4c7c5;
  --gt-text-muted: #8e918f;
  --gt-primary: #a8c7fa;
  --gt-primary-hover: #d3e3fd;
  --gt-primary-container: #004a77;
  --gt-on-primary-container: #c2e7ff;
  --gt-icon-btn-hover: rgba(227, 227, 227, 0.08);
  --gt-icon-btn-active: rgba(227, 227, 227, 0.12);
  --gt-shadow: 0 1px 3px 0 rgba(0,0,0,.3), 0 4px 8px 3px rgba(0,0,0,.15);
  --gt-shadow-focus: 0 1px 3px 0 rgba(0,0,0,.5), 0 4px 12px 3px rgba(0,0,0,.25);
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "Google Sans", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--gt-bg);
  color: var(--gt-text);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s, color 0.2s;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ====== Google Style App Header ====== */
.gt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 4px;
  border-bottom: 1px solid var(--gt-border-subtle);
  flex-shrink: 0;
}

.gt-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gt-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--gt-text-subtle);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
  touch-action: manipulation;
}

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

.gt-icon-btn:active {
  background-color: var(--gt-icon-btn-active);
  transform: scale(0.96);
}

.gt-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
}

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

.gt-brand-logo .logo-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--gt-text);
  letter-spacing: -0.3px;
}

.gt-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ====== Feature Pills / Subnav (Google Translate Style) ====== */
.gt-nav-pills {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 14px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 2px 0;
  flex-shrink: 0;
}

.gt-nav-pills::-webkit-scrollbar { display: none; }

.gt-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  min-height: 38px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--gt-border);
  background: var(--gt-surface);
  color: var(--gt-text-subtle);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
  touch-action: manipulation;
}

.gt-pill-btn:hover {
  background-color: var(--gt-surface-variant);
  color: var(--gt-text);
}

.gt-pill-btn.active {
  background-color: var(--gt-primary-container);
  color: var(--gt-on-primary-container);
  border-color: transparent;
  font-weight: 600;
}

.gt-pill-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ====== Main Translation Container ====== */
.gt-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.gt-translate-box {
  display: flex;
  flex-direction: column;
  background: var(--gt-surface);
  border: 1px solid var(--gt-border);
  border-radius: var(--gt-card-radius);
  box-shadow: var(--gt-shadow);
  overflow: hidden;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.gt-translate-box:focus-within {
  box-shadow: var(--gt-shadow-focus);
}

/* ====== Language Selection Bar (保留特色点选语言) ====== */
.gt-lang-bar {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--gt-border-subtle);
  padding: 0 12px;
  background: var(--gt-surface);
  flex-shrink: 0;
}

.gt-lang-half {
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.gt-lang-half::-webkit-scrollbar { display: none; }

.gt-swap-col {
  padding: 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.gt-swap-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--gt-text-subtle);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s, background-color 0.15s;
  touch-action: manipulation;
}

.gt-swap-btn:hover {
  background-color: var(--gt-icon-btn-hover);
  color: var(--gt-primary);
  transform: rotate(180deg);
}

/* 语言点选 Tab 按钮 */
.gt-lang-tab {
  display: inline-flex;
  align-items: center;
  padding: 14px 12px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gt-text-subtle);
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
  touch-action: manipulation;
}

.gt-lang-tab:hover {
  color: var(--gt-text);
  background-color: rgba(0, 0, 0, 0.02);
}

body.dark .gt-lang-tab:hover {
  background-color: rgba(255, 255, 255, 0.03);
}

.gt-lang-tab.active {
  color: var(--gt-primary);
  border-bottom-color: var(--gt-primary);
  font-weight: 600;
}

.detect-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.detect-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #34a853;
}

/* ====== Translation Editor Panels ====== */
.gt-editor-row {
  display: flex;
  min-height: 200px;
}

.gt-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  min-width: 0;
}

.gt-panel-source {
  background: var(--gt-surface);
  border-right: 1px solid var(--gt-border-subtle);
}

.gt-panel-target {
  background: var(--gt-surface-container);
}

/* 自动调节大小的自适应 Textarea */
.gt-textarea {
  width: 100%;
  min-height: 160px;
  padding: 16px 20px;
  font-size: 19px;
  line-height: 1.6;
  font-family: inherit;
  color: var(--gt-text);
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  overflow-y: hidden;
  box-sizing: border-box;
}

.gt-textarea::placeholder {
  color: var(--gt-text-muted);
  font-weight: 400;
}

.gt-textarea-out {
  color: var(--gt-text);
  font-weight: 400;
}

/* 卡片底栏 */
.gt-panel-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 12px;
  min-height: 48px;
}

.gt-action-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.gt-info-text {
  font-size: 12px;
  color: var(--gt-text-muted);
  user-select: none;
}

.gt-provider-badge {
  font-size: 12px;
  color: var(--gt-primary);
  background: var(--gt-primary-container);
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 500;
}

/* ====== Bottom Floating Actions (Google Translate Style) ====== */
.gt-floating-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 28px 0;
  flex-wrap: wrap;
}

.gt-fab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  min-height: 42px;
  border-radius: 999px;
  border: 1px solid var(--gt-border);
  background: var(--gt-surface);
  color: var(--gt-text-subtle);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: all 0.2s;
  touch-action: manipulation;
}

.gt-fab-btn:hover {
  background-color: var(--gt-surface-variant);
  border-color: var(--gt-primary);
  color: var(--gt-primary);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.gt-fab-btn:active {
  transform: scale(0.97);
}

/* ====== History & Help Tabs ====== */
.gt-tab-panel {
  padding: 20px 0;
}

.gt-history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gt-history-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--gt-surface);
  border: 1px solid var(--gt-border);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.gt-history-card:hover {
  border-color: var(--gt-primary);
  background-color: var(--gt-surface-variant);
}

.gt-history-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  font-size: 14px;
}

.gt-history-src {
  color: var(--gt-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.gt-history-arrow {
  color: var(--gt-text-muted);
  flex-shrink: 0;
}

.gt-history-out {
  color: var(--gt-primary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.gt-history-delete {
  color: var(--gt-text-muted);
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.gt-history-delete:hover {
  color: #ea4335;
  background-color: rgba(234, 67, 53, 0.1);
}

.gt-empty-hint {
  text-align: center;
  color: var(--gt-text-muted);
  padding: 60px 0;
  font-size: 15px;
}

.gt-help-content {
  max-width: 720px;
  margin: 0 auto;
  background: var(--gt-surface);
  border: 1px solid var(--gt-border);
  border-radius: 20px;
  padding: 24px;
}

.gt-help-content h2 {
  font-size: 18px;
  margin-bottom: 14px;
  color: var(--gt-text);
}

.gt-help-content p {
  font-size: 14px;
  line-height: 1.8;
  color: var(--gt-text-subtle);
  margin-bottom: 10px;
}

/* ====== Toast Message ====== */
.gt-toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 20px);
  background: #323232;
  color: #fff;
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
}

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

/* ====== Footer ====== */
.gt-footer {
  text-align: center;
  padding: 20px 0 calc(20px + env(safe-area-inset-bottom, 0px));
  font-size: 12px;
  color: var(--gt-text-muted);
}

.gt-footer a {
  color: var(--gt-primary);
  text-decoration: none;
}

.gt-footer a:hover {
  text-decoration: underline;
}

/* ========================================================
   极致移动端适配（<= 768px 手机与窄屏平板）
   ======================================================== */
@media (max-width: 768px) {
  .app-container {
    padding: 0 12px;
  }

  .gt-header {
    height: 54px;
  }
  .gt-brand-logo .logo-text {
    font-size: 17px;
  }

  .gt-nav-pills {
    margin: 10px 0 10px;
    gap: 8px;
  }
  .gt-pill-btn {
    padding: 6px 14px;
    font-size: 13px;
    min-height: 34px;
  }

  .gt-translate-box {
    border-radius: 16px;
  }

  .gt-lang-bar {
    padding: 0 6px;
  }
  .gt-lang-tab {
    padding: 12px 10px 10px;
    font-size: 13px;
  }
  .gt-swap-col {
    padding: 0 2px;
  }
  .gt-swap-btn {
    width: 32px;
    height: 32px;
  }

  /* 上下堆叠式双卡片布局 */
  .gt-editor-row {
    flex-direction: column;
    min-height: auto;
  }
  .gt-panel-source {
    border-right: none;
    border-bottom: 1px solid var(--gt-border-subtle);
  }
  .gt-textarea {
    font-size: 17px;
    padding: 14px 16px;
    min-height: 130px;
  }
  .gt-panel-bottom {
    padding: 6px 12px 10px;
    min-height: 42px;
  }
  .gt-icon-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
  }

  .gt-floating-bar {
    margin: 20px 0;
    gap: 10px;
  }
  .gt-fab-btn {
    padding: 8px 18px;
    font-size: 13px;
    min-height: 38px;
  }

  .gt-history-card {
    padding: 12px 14px;
    border-radius: 12px;
  }
  .gt-history-content {
    font-size: 13px;
    gap: 8px;
  }
}

@media (max-width: 400px) {
  .app-container {
    padding: 0 8px;
  }
  .gt-lang-tab {
    padding: 11px 8px 9px;
    font-size: 12px;
  }
  .gt-textarea {
    font-size: 16px; /* 防止 iOS Safari 自动放大页面 */
    padding: 12px 14px;
  }
}
