/* ====== 速译星球 · Light/Dark Theme ====== */

/* --- Reset --- */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}

/* --- Light Variables (default) --- */
:root{
  --c-bg:#f5f7fa;
  --c-surface:#ffffff;
  --c-surface2:#f0f2f6;
  --c-surface3:#e8ebf0;
  --c-text:#1a1a1a;
  --c-text2:#5b5f6b;
  --c-text3:#9499a6;
  --c-accent:#4080ff;
  --c-accent2:#10a37f;
  --c-border:rgba(0,0,0,.06);
  --c-border2:rgba(0,0,0,.10);
  --c-glass:rgba(255,255,255,.72);
  --c-glass-border:rgba(255,255,255,.5);
  --c-shadow:0 1px 3px rgba(0,0,0,.04),0 4px 20px rgba(0,0,0,.04);
  --c-shadow-lg:0 1px 3px rgba(0,0,0,.06),0 8px 40px rgba(0,0,0,.08);
  --c-accent-glow:rgba(64,128,255,.10);
  --safe-bottom:env(safe-area-inset-bottom,0px);
}

/* --- Dark Variables --- */
body.dark{
  --c-bg:#121826;
  --c-surface:#1a2133;
  --c-surface2:#1e2539;
  --c-surface3:#262e45;
  --c-text:#e5e7eb;
  --c-text2:#9ca3af;
  --c-text3:#6b7280;
  --c-accent:#4080ff;
  --c-accent2:#10a37f;
  --c-border:rgba(255,255,255,.06);
  --c-border2:rgba(255,255,255,.10);
  --c-glass:rgba(26,33,51,.72);
  --c-glass-border:rgba(255,255,255,.06);
  --c-shadow:0 1px 3px rgba(0,0,0,.2),0 4px 20px rgba(0,0,0,.15);
  --c-shadow-lg:0 1px 3px rgba(0,0,0,.3),0 8px 40px rgba(0,0,0,.25);
  --c-accent-glow:rgba(64,128,255,.14);
}

html{height:100%;-webkit-text-size-adjust:100%;scroll-behavior:smooth}
body{
  min-height:100%;min-height:100dvh;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"PingFang SC","Noto Sans SC","Noto Sans JP","Noto Sans KR","Microsoft YaHei",sans-serif;
  background:var(--c-bg);color:var(--c-text);
  -webkit-font-smoothing:antialiased;
  transition:background .35s,color .35s;
}

/* --- Background Decor --- */
.bg-decor{
  position:fixed;inset:0;pointer-events:none;z-index:0;
  background:
    radial-gradient(ellipse 80% 40% at 50% 0%,rgba(64,128,255,.04) 0,transparent 60%),
    radial-gradient(ellipse 50% 30% at 100% 60%,rgba(16,163,127,.03) 0,transparent 60%),
    radial-gradient(ellipse 40% 30% at 0% 80%,rgba(120,100,240,.02) 0,transparent 50%);
  opacity:.7;
}
body.dark .bg-decor{opacity:.4}

/* --- App Wrap --- */
.app-wrap{
  position:relative;z-index:1;
  display:flex;flex-direction:column;
  min-height:100vh;min-height:100dvh;
  max-width:1120px;margin:0 auto;padding:0 24px;
}

/* ====== Header ====== */
.header{
  position:sticky;top:0;z-index:50;
  display:flex;align-items:center;justify-content:space-between;
  gap:20px;padding:14px 20px;margin:12px 0 0;
  background:var(--c-glass);
  backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);
  border:1px solid var(--c-glass-border);
  border-radius:18px;
  transition:background .35s,box-shadow .3s;
}
.header.scrolled{box-shadow:0 4px 24px rgba(0,0,0,.06)}
.headerL{display:flex;align-items:center}
.logo{display:flex;align-items:center;gap:8px}
.logo svg{color:var(--c-accent)}
.logoName{font-size:16px;font-weight:700;color:var(--c-text)}
.logoSlogan{display:none;font-size:12px;color:var(--c-text3);margin-left:4px}
@media(min-width:640px){.logoSlogan{display:inline}}

.headerNav{display:flex;gap:4px;flex-wrap:wrap}
.navItem{
  font-size:13px;font-weight:500;color:var(--c-text2);
  border:0;background:transparent;cursor:pointer;
  padding:7px 14px;border-radius:10px;
  transition:all .18s;
  text-decoration:none;
  white-space:nowrap;
  -webkit-tap-highlight-color:transparent;touch-action:manipulation;
}
.navItem:hover{background:rgba(64,128,255,.08);color:var(--c-accent)}
.navItem.active{background:rgba(64,128,255,.12);color:var(--c-accent);font-weight:600}

.headerR{display:flex;align-items:center;gap:8px}
.themeBtn{
  width:38px;height:38px;
  display:flex;align-items:center;justify-content:center;
  background:transparent;border:1px solid var(--c-border);
  border-radius:12px;color:var(--c-text2);cursor:pointer;
  transition:all .2s;
  -webkit-tap-highlight-color:transparent;touch-action:manipulation;
}
.themeBtn:hover{border-color:var(--c-accent);color:var(--c-accent)}
.themeBtn .icon-sun{display:block}
.themeBtn .icon-moon{display:none}
body.dark .themeBtn .icon-sun{display:none}
body.dark .themeBtn .icon-moon{display:block}

/* ====== Main ====== */
.main{flex:1;display:flex;flex-direction:column;min-height:0;padding:16px 0 24px}
.tabPanel{flex:1;padding:32px 0}

/* ====== Translate Core ====== */
.translateCore{
  display:flex;align-items:stretch;gap:0;
  flex:1;min-height:0;
}

/* --- Panels --- */
.tPanel{
  flex:1;display:flex;flex-direction:column;
  background:var(--c-surface);border:1px solid var(--c-border);
  border-radius:20px;overflow:hidden;
  box-shadow:var(--c-shadow);
  transition:border-color .25s,box-shadow .25s,background .35s;
}
.tPanel:focus-within{
  border-color:rgba(64,128,255,.25);
  box-shadow:var(--c-shadow-lg),0 0 0 4px var(--c-accent-glow);
}
.tPanel--out{background:var(--c-surface2)}

.tPanelTop{
  padding:12px 16px;border-bottom:1px solid var(--c-border);
  flex-shrink:0;
}
.detectLabel{
  display:flex;align-items:center;gap:8px;
  font-size:13px;font-weight:600;color:var(--c-text2);
}
.detectDot{
  width:7px;height:7px;border-radius:50%;
  background:var(--c-accent2);
  box-shadow:0 0 0 3px rgba(16,163,127,.2);
  animation:pulse 2s ease-in-out infinite;
}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.4}}
.langPick{
  appearance:none;-webkit-appearance:none;
  background:transparent;border:0;outline:0;
  font-size:13px;font-weight:600;color:var(--c-text);
  cursor:pointer;
  padding-right:20px;
  background-image:url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239499a6' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:right center;
}
.langPick option{background:var(--c-surface);color:var(--c-text)}

.tTextarea{
  flex:1;width:100%;min-height:0;
  background:transparent;border:0;outline:0;resize:none;
  padding:20px;font-size:17px;line-height:1.8;color:var(--c-text);
  font-family:inherit;
}
.tTextarea::placeholder{color:var(--c-text3)}
.tTextarea--out{color:var(--c-text);font-weight:500}
.tTextarea::-webkit-scrollbar{width:5px}
.tTextarea::-webkit-scrollbar-thumb{background:rgba(0,0,0,.1);border-radius:10px}

.tPanelBot{
  display:flex;align-items:center;justify-content:space-between;
  padding:8px 16px;border-top:1px solid var(--c-border);
  flex-shrink:0;min-height:44px;
}
.charHint,.provider{font-size:12px;color:var(--c-text3);font-weight:500}
.tActions{display:flex;gap:2px}
.actBtn{
  width:34px;height:34px;
  display:flex;align-items:center;justify-content:center;
  background:transparent;border:0;color:var(--c-text3);
  border-radius:8px;cursor:pointer;
  transition:all .15s;
  -webkit-tap-highlight-color:transparent;touch-action:manipulation;
}
.actBtn:hover{background:rgba(0,0,0,.04);color:var(--c-text)}
.actBtn:active{transform:scale(.92)}
body.dark .actBtn:hover{background:rgba(255,255,255,.05)}

/* --- Swap Column --- */
.swapCol{
  flex-shrink:0;width:48px;
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:6px;position:relative;
}
.swapBtn{
  width:44px;height:44px;
  display:flex;align-items:center;justify-content:center;
  background:var(--c-surface);border:1px solid var(--c-border);
  border-radius:50%;color:var(--c-accent);cursor:pointer;
  z-index:2;box-shadow:var(--c-shadow);
  transition:all .25s cubic-bezier(.16,1,.3,1);
  -webkit-tap-highlight-color:transparent;touch-action:manipulation;
}
.swapBtn:hover{transform:rotate(180deg);box-shadow:var(--c-shadow-lg)}
.swapLine{width:1px;flex:1;min-height:20px;background:var(--c-border);border-radius:1px}

/* ====== Quick Langs ====== */
.quickLangs{
  display:flex;align-items:center;gap:14px;
  padding:18px 4px 0;flex-shrink:0;flex-wrap:wrap;
}
.quickLabel{font-size:13px;font-weight:600;color:var(--c-text3);white-space:nowrap}
.quickTags{display:flex;gap:8px;flex-wrap:wrap}
.quickTag{
  font-size:13px;font-weight:500;color:var(--c-text2);
  background:var(--c-surface);border:1px solid var(--c-border);
  border-radius:10px;padding:8px 15px;cursor:pointer;
  transition:all .18s;box-shadow:var(--c-shadow);
  -webkit-tap-highlight-color:transparent;touch-action:manipulation;
}
.quickTag:hover{transform:translateY(-1px);border-color:var(--c-accent);color:var(--c-accent);box-shadow:var(--c-shadow-lg)}
.quickTag.active{background:var(--c-accent);color:#fff;border-color:var(--c-accent)}

/* ====== History Tab ====== */
.historyList{display:flex;flex-direction:column;gap:8px}
.emptyHint{text-align:center;color:var(--c-text3);padding:60px 0;font-size:15px}
.historyItem{
  display:flex;align-items:center;gap:12px;
  background:var(--c-surface);border:1px solid var(--c-border);
  border-radius:14px;padding:14px 18px;cursor:pointer;
  box-shadow:var(--c-shadow);
  transition:all .18s;
}
.historyItem:hover{border-color:var(--c-accent);transform:translateY(-1px)}
.historyItem .hiSrc{flex:1;font-size:14px;color:var(--c-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.historyItem .hiArrow{color:var(--c-text3);flex-shrink:0}
.historyItem .hiOut{flex:1;font-size:14px;color:var(--c-accent);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500}
.historyItem .hiDelete{color:var(--c-text3);cursor:pointer;flex-shrink:0;padding:4px;border-radius:6px;transition:all .15s}
.historyItem .hiDelete:hover{color:#e74c3c;background:rgba(231,76,60,.06)}

/* ====== Help Tab ====== */
.helpContent{max-width:600px;margin:0 auto}
.helpContent h3{font-size:20px;margin-bottom:16px}
.helpContent p{font-size:15px;line-height:2;color:var(--c-text2)}

/* ====== Footer ====== */
.footer{
  display:flex;justify-content:space-between;align-items:flex-start;
  gap:20px;padding:18px 4px calc(18px + var(--safe-bottom));
  border-top:1px solid var(--c-border);
  font-size:12px;color:var(--c-text3);flex-shrink:0;
}
.footerL{flex:1;min-width:0}
.footerTitle{font-weight:600;color:var(--c-text2);display:block;margin-bottom:8px}
.footerHistory{display:flex;flex-direction:column;gap:4px}
.footerHistory .fhItem{
  font-size:12px;color:var(--c-text3);cursor:pointer;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
  padding:3px 0;transition:color .15s;
}
.footerHistory .fhItem:hover{color:var(--c-accent)}
.footerR{display:flex;flex-direction:column;gap:4px;text-align:right;flex-shrink:0}

/* ====== Toast ====== */
.toast{
  position:fixed;left:50%;bottom:calc(40px + var(--safe-bottom));
  transform:translate(-50%,14px);opacity:0;pointer-events:none;
  background:var(--c-text);color:var(--c-bg);
  font-size:13px;font-weight:600;
  border-radius:100px;padding:12px 26px;
  box-shadow:0 12px 40px rgba(0,0,0,.25);
  transition:all .22s cubic-bezier(.16,1,.3,1);
  z-index:200;
}
.toast.show{opacity:1;transform:translate(-50%,0)}

/* ====== Loading ====== */
@keyframes shimmer{
  0%{background-position:-300px 0}
  100%{background-position:300px 0}
}
.loading .tTextarea--out{
  animation:shimmer 1.6s infinite linear;
  background:linear-gradient(90deg,var(--c-surface2) 25%,var(--c-surface3) 50%,var(--c-surface2) 75%);
  background-size:600px 100%;
  color:transparent;border-radius:0;
}

/* ============================================
   MOBILE
   ============================================ */
@media(max-width:768px){
  .app-wrap{padding:0 12px}
  .header{padding:12px 14px;margin-top:8px;flex-wrap:wrap;gap:10px}
  .headerNav{gap:2px}
  .navItem{font-size:12px;padding:6px 10px}
  .logoName{font-size:15px}
  .logoSlogan{display:none}
  .translateCore{flex-direction:column;gap:0}
  .tPanel{border-radius:16px;min-height:0}
  .swapCol{
    width:100%;height:40px;flex-direction:row;justify-content:center;
  }
  .swapLine{width:40px;height:1px;min-height:unset}
  .swapBtn{width:40px;height:40px}
  .tTextarea{padding:14px;font-size:16px;line-height:1.7}
  .tPanelBot{padding:6px 12px}
  .quickLangs{padding:14px 0 0}
  .quickTag{padding:7px 12px;font-size:12px}
  .footer{flex-direction:column;padding:14px 0 calc(14px + var(--safe-bottom))}
}

@media(max-width:420px){
  .app-wrap{padding:0 8px}
  .header{padding:10px 10px;border-radius:14px}
  .navItem{font-size:11px;padding:5px 8px;border-radius:8px}
  .tPanel{border-radius:13px}
  .tTextarea{padding:12px;font-size:16px}
  .tPanelTop{padding:10px 12px}
  .quickTag{padding:6px 10px;font-size:11px;border-radius:8px}
  .quickLabel{display:none}
}
