/* =====================================================
   TinVin AI - home.css (complete)
   ===================================================== */

/* ---------- Base ---------- */
.workspace-panel[hidden] { display: none !important; }

html {
  background: #050a18 url("bg.jpg") center / cover no-repeat fixed !important;
}

body {
  background: transparent !important;
  background-attachment: fixed;
}

/* ---------- Themes ---------- */
:root {
  --tv-a: #3b82f6;
  --tv-b: #8b5cf6;
  --tv-bg: #080d1b;
  --tv-g1: rgba(69, 139, 255, .22);
  --tv-g2: rgba(154, 91, 255, .18);
  --tv-panel: 18, 27, 49;
}
html[data-theme="black"] {
  --tv-a: #9aa0ad; --tv-b: #4b5060; --tv-bg: #050506;
  --tv-g1: rgba(255,255,255,.07); --tv-g2: rgba(255,255,255,.04);
  --tv-panel: 20, 20, 24;
}
html[data-theme="navy"] {
  --tv-a: #e9bd63; --tv-b: #2d4a9a; --tv-bg: #060b1c;
  --tv-g1: rgba(233,189,99,.16); --tv-g2: rgba(50,90,200,.22);
  --tv-panel: 14, 22, 48;
}
html[data-theme="blue"] {
  --tv-a: #38bdf8; --tv-b: #2563eb; --tv-bg: #04101f;
  --tv-g1: rgba(56,189,248,.22); --tv-g2: rgba(37,99,235,.22);
  --tv-panel: 10, 26, 52;
}
html[data-theme="green"] {
  --tv-a: #34d399; --tv-b: #059669; --tv-bg: #04130e;
  --tv-g1: rgba(52,211,153,.2); --tv-g2: rgba(5,150,105,.2);
  --tv-panel: 10, 36, 28;
}
html[data-theme="pink"] {
  --tv-a: #f472b6; --tv-b: #c026d3; --tv-bg: #14060f;
  --tv-g1: rgba(244,114,182,.2); --tv-g2: rgba(192,38,211,.2);
  --tv-panel: 44, 14, 34;
}
html[data-theme="orange"] {
  --tv-a: #fb923c; --tv-b: #dc2626; --tv-bg: #140a04;
  --tv-g1: rgba(251,146,60,.2); --tv-g2: rgba(220,38,38,.18);
  --tv-panel: 44, 24, 10;
}

body:has(#homePanel:not([hidden])) .premium-top-btn { visibility: hidden; }

.app-shell::before { background: var(--tv-a); }
.app-shell::after { background: var(--tv-b); }

.topbar {
  background: rgba(var(--tv-panel), .78);
  padding-top: env(safe-area-inset-top, 0px) !important;
  height: auto !important;
  min-height: calc(64px + env(safe-area-inset-top, 0px)) !important;
  align-items: center !important;
}

.sidebar { background: rgba(var(--tv-panel), .96); }
.brand-icon { color: var(--tv-a); border-color: var(--tv-a); }
.status { color: var(--tv-a); }

.top-signin-btn {
  min-height: 40px;
  padding: 0 14px;
  margin-inline-end: 8px;
  border-radius: 14px;
  border: 1px solid rgba(120, 190, 255, .45);
  background: rgba(60, 110, 200, .18);
  color: #dfeeff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.sidebar-menu .menu-item[data-menu] { display: none; }
.sidebar-menu .menu-item[data-menu="history"] { display: flex !important; }

#authBox {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(190, 210, 255, .16);
  border-radius: 14px;
}
.auth-name { color: #dbe7ff; font-weight: 700; font-size: 14px; overflow-wrap: anywhere; }
.auth-btn {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(190, 210, 255, .2);
  background: rgba(255, 255, 255, .07);
  color: #eef3ff;
  cursor: pointer;
}
#historyList { display: grid; gap: 6px; margin-top: 10px; max-height: 40vh; overflow-y: auto; }
.history-item {
  text-align: start;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(190, 210, 255, .14);
  background: rgba(255, 255, 255, .05);
  color: #dbe7ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Panels ---------- */
#workspacePage,
#settingsPage { padding-top: 12px; }

#homePanel {
  position: relative;
  display: block;
  min-height: calc(100dvh - 90px);
  padding: 18px 16px calc(110px + env(safe-area-inset-bottom, 0px));
  border-radius: 26px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(5, 10, 24, .45) 0%, rgba(5, 10, 24, .25) 50%, rgba(5, 10, 24, .65) 100%) !important;
}
#homePanel[hidden] { display: none !important; }

#chatPage,
#translatorPage,
#scannerPanel,
#settingsPage {
  background:
    linear-gradient(145deg, rgba(255,255,255,.07), transparent 42%),
    rgba(var(--tv-panel), .62) !important;
}

/* while Home shows, the tools stay hidden */
#chatPage[hidden],
#translatorPage[hidden],
#scannerPanel[hidden] { display: none !important; }

body:has(#homePanel:not([hidden])) #chatPage,
body:has(#homePanel:not([hidden])) #translatorPage,
body:has(#homePanel:not([hidden])) #scannerPanel { display: none !important; }

/* ---------- Back button ---------- */
.back-home {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  min-height: 42px !important;
  padding: 0 16px !important;
  margin: 0 0 12px !important;
  color: #ffffff !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  border: 1px solid rgba(160, 200, 255, .75) !important;
  border-radius: 14px !important;
  background: rgba(30, 50, 95, .95) !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35) !important;
  align-self: flex-start;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

/* ---------- Home: head, sidebar and cards ---------- */
#homePanel .hx-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 6px 0 16px;
}

.hx-logo {
  font-size: 2rem;
  color: #7fc8ff;
  text-shadow: 0 0 18px rgba(80, 170, 255, .7);
}

.hx-title {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 800;
  background: linear-gradient(90deg, #f5d27a, #7fc8ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hx-sub {
  margin: 0;
  color: #b9c6e0;
  font-size: .9rem;
  letter-spacing: .3px;
}

.hx-premium {
  padding: 10px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255, 205, 100, .8);
  background: linear-gradient(135deg, #f6d77a, #d9a441);
  color: #1b1607;
  font: inherit;
  font-weight: 800;
  box-shadow: 0 0 26px rgba(255, 200, 90, .6), 0 0 60px rgba(255, 200, 90, .25);
  cursor: pointer;
  animation: hxPulse 3s ease-in-out infinite;
}

@keyframes hxPulse {
  0%, 100% { box-shadow: 0 0 22px rgba(255, 200, 90, .5); }
  50% { box-shadow: 0 0 34px rgba(255, 200, 90, .85); }
}

.hx-body {
  display: grid;
  grid-template-columns: minmax(0, 38%) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.hx-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 8px;
  min-height: 260px;
  border-radius: 22px;
  border: 1px solid rgba(150, 220, 255, .4);
  background: linear-gradient(160deg, rgba(20, 30, 58, .6), rgba(8, 14, 30, .6));
  box-shadow: 0 0 24px rgba(80, 170, 255, .25), inset 0 1px 0 rgba(255, 255, 255, .2);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.hx-nav {
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #aab8d6;
  font: inherit;
  font-size: 14px;
  text-align: start;
  cursor: pointer;
}

.hx-nav.active {
  color: #f5d27a;
  background: rgba(255, 200, 90, .12);
  box-shadow: inset 0 0 0 1px rgba(255, 205, 100, .45);
}

.hx-cards {
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
}

/* each card: image centred, no cropping */
.hx-card {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  position: relative;
  padding: 8px !important;
  min-height: 0 !important;
  height: auto !important;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(150, 220, 255, .55) !important;
  background: rgba(8, 14, 30, .55) !important;
  box-shadow:
    0 0 22px rgba(80, 180, 255, .45),
    0 0 48px rgba(80, 180, 255, .18),
    inset 0 1px 0 rgba(255, 255, 255, .35) !important;
  color: #eaf2ff;
  font: inherit;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}

.hx-card:active { transform: scale(.98); }

.hx-card:hover,
.hx-card:focus-visible {
  transform: translateY(-2px);
  box-shadow:
    0 0 30px rgba(110, 210, 255, .65),
    0 0 70px rgba(110, 210, 255, .25),
    inset 0 1px 0 rgba(255, 255, 255, .45) !important;
}

/* glass shine that sweeps across each card */
.hx-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, .28) 50%, transparent 65%);
  transform: translateX(-120%);
  animation: hxShine 4.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes hxShine {
  0%, 60% { transform: translateX(-120%); }
  100% { transform: translateX(120%); }
}

/* the label is already inside the image */
.hx-card .hx-label { display: none !important; }

.hx-ico {
  display: block !important;
  width: auto !important;
  max-width: 150% !important;
  height: 170px !important;
  object-fit: contain !important;
  margin: 0 auto !important;
  border-radius: 14px;
  filter: none !important;
}

/* ---------- Home prompt bar ---------- */
.home-bar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 22px;
  background: rgba(20, 28, 60, .55);
  border: 1px solid rgba(150, 220, 255, .6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow:
    0 0 26px rgba(90, 170, 255, .45),
    inset 0 1px 0 rgba(255, 255, 255, .3);
}

.home-input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--tv-a);
  background: rgba(255, 255, 255, .08);
  color: #fff;
  font: inherit;
  font-size: 16px;
}
.home-input::placeholder { color: rgba(220, 230, 255, .6); }
.home-input:focus { outline: none; box-shadow: 0 0 0 3px rgba(110, 170, 255, .3); }

.home-send {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--tv-a), var(--tv-b));
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
}

/* ---------- Mic buttons (round, line icon; white wave when listening) ---------- */
#homeMicBtn,
.chat-mic-btn,
.translator-mic-btn {
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 50% !important;
  font-size: 0 !important;
  color: transparent !important;
  background-color: rgba(255, 255, 255, .12) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d0d4dc' stroke-width='1.8' stroke-linecap='round'%3E%3Crect x='9' y='3' width='6' height='11' rx='3'/%3E%3Cpath d='M5 11a7 7 0 0 0 14 0M12 18v3'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  background-size: 22px 22px !important;
  box-shadow: none !important;
  animation: none !important;
}

#homeMicBtn.listening,
.chat-mic-btn.listening,
.translator-mic-btn.listening {
  background-color: #fafaf7 !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23111' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M3 12v0M6 9v6M9 6v12M12 3v18M15 7v10M18 10v4M21 12v0'/%3E%3C/svg%3E") !important;
  background-size: 24px 24px !important;
}

#homeStatus,
#chatStatus,
#translatorStatus {
  font-size: 14px;
  min-height: 18px;
}

/* ---------- AI Chat: [+] [text] [mic] [send] ---------- */
#chatPage .chat-compose {
  display: flex !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 8px !important;
}

#chatPage .chat-compose > #chatInput {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  width: auto !important;
  height: 44px !important;
  min-height: 44px !important;
  max-height: 110px !important;
  padding: 11px 12px !important;
  resize: none !important;
}

#chatPage .chat-attachment-controls {
  display: flex !important;
  flex: 0 0 auto !important;
  gap: 6px !important;
}

/* the old 📎 and 📷 live in the "+" menu now */
#chatPage .chat-attachment-controls > .chat-attach-btn:not(.chat-mic-btn) {
  display: none !important;
}

#chatPage #sendBtn {
  flex: 0 0 auto !important;
  width: 44px !important;
  min-width: 44px !important;
  height: 44px !important;
  min-height: 44px !important;
  padding: 0 !important;
}

#chatPage { position: relative; }

#chatPage #newChatBtn {
  position: absolute;
  top: 22px;
  inset-inline-end: 22px;
  z-index: 3;
  min-height: 38px;
  padding: 0 14px;
}

#chatPage #chatStatus { min-height: 0; margin: 0; }

#chatPage .chat-layout {
  flex: 1 1 0 !important;
  height: auto !important;
  min-height: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

#chatPage .chat-mic-btn.listening { border-color: transparent !important; }

/* "+" button and its menu (chat and translator) */
.plus-wrap {
  position: relative;
  flex: 0 0 auto;
}

.plus-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(190, 210, 255, .3);
  background: rgba(255, 255, 255, .08);
  color: #eaf1ff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.plus-menu {
  position: absolute;
  bottom: 52px;
  left: 0;
  z-index: 50;
  display: grid;
  gap: 6px;
  min-width: 170px;
  padding: 8px;
  border-radius: 16px;
  border: 1px solid rgba(190, 210, 255, .25);
  background: rgba(12, 18, 38, .97);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
}

.plus-menu[hidden] { display: none !important; }

.plus-item {
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, .06);
  color: #eaf1ff;
  font: inherit;
  font-size: 15px;
  text-align: start;
  cursor: pointer;
}

/* ---------- Translator: [+] [text] [🎤] [↑], Clear under ---------- */
#translatorPage .translator-compose {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 8px !important;
}

/* hide the old 📎 and 📷 (the "+" replaces them) */
#translatorPage .translator-compose .tr-hidden { display: none !important; }

#translatorPage .translator-compose .plus-wrap {
  order: 0 !important;
  flex: 0 0 auto !important;
}

#translatorPage .translator-compose #translatorInput {
  order: 1 !important;
  flex: 1 1 0 !important;
  width: auto !important;
  min-width: 0 !important;
  height: 46px !important;
  min-height: 46px !important;
  max-height: 120px !important;
  padding: 12px !important;
  resize: none !important;
}

#translatorPage .translator-compose .translator-mic-btn {
  order: 2 !important;
  flex: 0 0 auto !important;
}

#translatorPage .translator-compose #translatorRunBtn {
  order: 3 !important;
  flex: 0 0 auto !important;
  width: 50px !important;
  height: 46px !important;
  min-width: 50px !important;
  padding: 0 !important;
  font-size: 1.5rem !important;
  font-weight: 700 !important;
  border-radius: 14px !important;
}

#translatorPage .translator-compose #translatorClearBtn {
  order: 4 !important;
  flex: 0 0 auto !important;
  min-height: 36px !important;
  padding: 0 12px !important;
  font-size: 13px !important;
}

#translatorPage .translator-compose #translatorStatus {
  order: 9 !important;
  flex: 1 1 100% !important;
}

#translatorPage #translatorHistory {
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
  padding: 12px !important;
  overflow-y: auto !important;
}

/* translator messages: same bubble style as AI Chat */
#translatorPage #translatorHistory > * {
  max-width: 86% !important;
  padding: 12px 15px !important;
  border-radius: 18px !important;
  line-height: 1.7 !important;
  overflow-wrap: anywhere !important;
  border: 1px solid rgba(190, 210, 255, .18) !important;
  background: linear-gradient(145deg, rgba(255, 255, 255, .09), rgba(255, 255, 255, .03)) !important;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25), inset 0 1px 0 rgba(255, 255, 255, .08) !important;
  color: #eef3ff !important;
}

/* your text: right, blue-violet glass */
#translatorPage #translatorHistory > .translator-user-message,
#translatorPage #translatorHistory > .user-message {
  align-self: flex-end !important;
  border-bottom-right-radius: 6px !important;
  background: linear-gradient(135deg, rgba(64, 119, 220, .35), rgba(111, 77, 190, .28)) !important;
  border-color: rgba(120, 180, 255, .35) !important;
}

/* translation: left, gold-tinted glass */
#translatorPage #translatorHistory > .translator-ai-message,
#translatorPage #translatorHistory > .translator-message:not(.translator-user-message),
#translatorPage #translatorHistory > .assistant-message {
  align-self: flex-start !important;
  border-bottom-left-radius: 6px !important;
  background: linear-gradient(135deg, rgba(255, 200, 90, .14), rgba(255, 255, 255, .04)) !important;
  border-color: rgba(255, 205, 100, .3) !important;
}

/* ---------- Scanner ---------- */
#scannerPanel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  padding: 13px !important;
  overflow-x: hidden;
}

#scannerPanel * { max-width: 100%; box-sizing: border-box; }

#scannerPanel #qrPage {
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

#scannerPanel .qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  padding: 22px 16px !important;
  border-radius: 22px;
  text-align: center;
}

#scannerPanel button,
#qrPage button {
  min-width: 150px;
  min-height: 48px;
  padding: 0 18px !important;
  border-radius: 16px !important;
  font-weight: 700;
}

#scannerPanel input[type="file"],
#qrPage input[type="file"] {
  width: 100%;
  max-width: 340px;
  margin: 6px auto;
  color: #dbe7ff;
}

#scannerPanel .qr-status,
#qrPage .qr-status,
#scannerPanel .qr-note,
#qrPage .qr-note {
  text-align: center;
  line-height: 1.6;
  max-width: 420px;
  margin: 0 auto;
}

#scannerPanel h2,
#scannerPanel h1,
#qrPage h2 { margin: 0 0 6px; }

#scannerPanel p,
#qrPage p {
  margin: 0 0 8px;
  color: #aebbd5;
  font-size: .95rem;
}

/* ---------- Premium upgrade page ---------- */
.upgrade-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, .6);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.upgrade-overlay[hidden] { display: none !important; }

.upgrade-card {
  width: min(460px, 100%);
  max-height: 92dvh;
  overflow-y: auto;
  padding: 20px;
  border-radius: 24px;
  border: 1px solid rgba(255, 205, 100, .4);
  background: linear-gradient(160deg, rgba(30, 36, 70, .98), rgba(14, 18, 40, .99));
  box-shadow: 0 25px 80px rgba(0, 0, 0, .5);
  color: #eef3ff;
}

.upgrade-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.upgrade-title { margin: 0; font-size: 1.4rem; color: #ffd98a; }
.upgrade-close {
  min-height: 38px; padding: 0 14px; border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .2);
  background: rgba(255, 255, 255, .08); color: #fff; font-size: 14px; cursor: pointer;
}
.upgrade-sub { color: #aebbd5; font-size: .9rem; margin: 8px 0 14px; }

.upgrade-features { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.upgrade-features li { color: #dbe7ff; }

.upgrade-plans { display: grid; gap: 10px; margin-bottom: 16px; }
.plan-card {
  display: grid; gap: 4px; text-align: start; padding: 14px 16px;
  border-radius: 16px; cursor: pointer; color: #eef3ff;
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .05);
}
.plan-card strong { font-size: 1.05rem; }
.plan-card .plan-price { color: #ffd98a; font-weight: 700; }
.plan-card small { color: #9fb0d0; }
.plan-card.selected {
  border-color: rgba(255, 205, 100, .8);
  background: linear-gradient(135deg, rgba(255, 200, 90, .18), rgba(150, 90, 255, .14));
  box-shadow: 0 0 20px rgba(255, 190, 80, .25);
}

.upgrade-pay {
  width: 100%; min-height: 50px; border: 0; border-radius: 16px;
  color: #6b5a2c; font-weight: 800; background: #e9d3a0; cursor: not-allowed; opacity: .75;
}
.upgrade-status { margin-top: 10px; font-size: .85rem; color: #9fb0d0; text-align: center; }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  #chatPage,
  #translatorPage {
    height: calc(100dvh - 100px) !important;
    min-height: 0 !important;
    padding: 13px !important;
  }
  #chatPage #newChatBtn { top: 13px; inset-inline-end: 13px; }
}

@media (max-width: 380px) {
  .top-signin-btn { padding: 0 10px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .hx-card, .hx-card::after, .hx-premium { animation: none !important; transition: none !important; }
}

/* Translator: the run button shows only the arrow and sits on the right */
#translatorPage #translatorRunBtn {
  font-size: 0 !important;
  color: transparent !important;
  width: 50px !important;
  min-width: 50px !important;
  height: 46px !important;
  position: relative;
}

#translatorPage #translatorRunBtn::before {
  content: "↑";
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* keep the row in one line: + | text | 🎤 | ↑ */
#translatorPage .translator-compose {
  display: flex !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 8px !important;
}

#translatorPage .translator-compose #translatorInput {
  flex: 1 1 0 !important;
  min-width: 0 !important;
  width: auto !important;
}

#translatorPage .translator-compose .translator-mic-btn,
#translatorPage .translator-compose #translatorRunBtn,
#translatorPage .translator-compose .plus-wrap {
  flex: 0 0 auto !important;
}

/* Clear goes on its own line under the row */
#translatorPage .translator-compose #translatorClearBtn {
  flex: 1 1 100% !important;
  order: 9 !important;
  min-height: 36px !important;
}

/* ===== Translator: final clean layout (like AI Chat) ===== */
#translatorPage .translator-compose {
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr) auto auto !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 10px !important;
}

#translatorPage .translator-compose .plus-wrap {
  grid-column: 1 !important;
  grid-row: 1 !important;
}

#translatorPage .translator-compose #translatorInput {
  grid-column: 2 !important;
  grid-row: 1 !important;
  width: 100% !important;
  min-width: 0 !important;
  height: 46px !important;
  min-height: 46px !important;
  max-height: 120px !important;
  padding: 12px !important;
  resize: none !important;
}

#translatorPage .translator-compose .translator-mic-btn {
  grid-column: 3 !important;
  grid-row: 1 !important;
  width: 46px !important;
  height: 46px !important;
  min-width: 46px !important;
  border-radius: 50% !important;
}

#translatorPage .translator-compose #translatorRunBtn {
  grid-column: 4 !important;
  grid-row: 1 !important;
  width: 50px !important;
  min-width: 50px !important;
  height: 46px !important;
  padding: 0 !important;
  font-size: 1.5rem !important;
  font-weight: 700 !important;
  color: #fff !important;
  border-radius: 14px !important;
}

#translatorPage .translator-compose #translatorRunBtn::before {
  content: none !important;
}

#translatorPage .translator-compose #translatorClearBtn {
  grid-column: 1 / -1 !important;
  grid-row: 2 !important;
  justify-self: end !important;
  min-height: 36px !important;
  padding: 0 14px !important;
  font-size: 13px !important;
}

#translatorPage .translator-compose #translatorStatus {
  grid-column: 1 / -1 !important;
  grid-row: 3 !important;
  font-size: 13px !important;
  line-height: 1.5 !important;
  text-align: center !important;
}

#translatorPage .translator-compose #translatorStatus:empty {
  display: none !important;
}

#translatorPage .translator-compose .tr-hidden {
  display: none !important;
}

/* ===== Translator: Claude-style composer ===== */
#translatorPage .translator-compose {
  display: grid !important;
  grid-template-columns: auto 1fr auto auto !important;
  grid-template-areas:
    "input input input input"
    "plus clear mic send"
    "status status status status" !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 12px !important;
  border-radius: 22px !important;
  border: 1px solid rgba(150, 190, 255, .25) !important;
  background: rgba(7, 13, 30, .72) !important;
}

/* big writing area on top */
#translatorPage .translator-compose #translatorInput {
  grid-area: input !important;
  width: 100% !important;
  min-height: 64px !important;
  max-height: 180px !important;
  padding: 14px 16px !important;
  resize: none !important;
  border-radius: 16px !important;
}

/* + on the left */
#translatorPage .translator-compose .plus-wrap {
  grid-area: plus !important;
}

/* Clear (small) between + and the mic */
#translatorPage .translator-compose #translatorClearBtn {
  grid-area: clear !important;
  justify-self: start !important;
  min-height: 34px !important;
  padding: 0 12px !important;
  font-size: 13px !important;
  border-radius: 12px !important;
}

/* 🎤 on the right */
#translatorPage .translator-compose .translator-mic-btn {
  grid-area: mic !important;
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  border-radius: 50% !important;
}

/* ↑ only (hide the text "Send"/"Translate") */
#translatorPage .translator-compose #translatorRunBtn {
  grid-area: send !important;
  width: 48px !important;
  height: 44px !important;
  min-width: 48px !important;
  padding: 0 !important;
  font-size: 0 !important;
  color: transparent !important;
  border-radius: 14px !important;
  position: relative;
}

#translatorPage .translator-compose #translatorRunBtn::before {
  content: "↑";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
}

/* status line under the row */
#translatorPage .translator-compose #translatorStatus {
  grid-area: status !important;
  font-size: 13px !important;
  text-align: center !important;
}

#translatorPage .translator-compose #translatorStatus:empty {
  display: none !important;
}

/* keep the old 📎 and 📷 hidden */
#translatorPage .translator-compose .tr-hidden {
  display: none !important;
}

/* Translator: remove the "Send" text, keep only the arrow */
#translatorPage .translator-compose #translatorRunBtn {
  font-size: 0 !important;
  color: transparent !important;
  text-indent: -9999px !important;
  overflow: hidden !important;
}

#translatorPage .translator-compose #translatorRunBtn::before {
  content: "↑" !important;
  text-indent: 0 !important;
  font-size: 1.5rem !important;
  font-weight: 700 !important;
  color: #fff !important;
}

#translatorPage .translator-compose #translatorRunBtn::after {
  content: none !important;
}

/* ===== Home fits one screen (no scroll), rounded cards ===== */
#homePanel {
  min-height: 100dvh !important;
  height: 100dvh;
  padding: 10px 14px 96px !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column;
  justify-content: flex-start;
}

/* smaller top block so there is room for all three cards */
#homePanel .hx-head {
  margin: 2px 0 8px !important;
  gap: 4px !important;
}

.hx-premium {
  padding: 7px 14px !important;
  font-size: 14px !important;
}

.hx-logo { font-size: 1.4rem !important; }

.hx-title { font-size: 1.4rem !important; }

.hx-sub { font-size: .78rem !important; }

/* sidebar and cards share the remaining height */
.hx-body {
  flex: 1 1 auto;
  min-height: 0;
  align-items: stretch !important;
}

.hx-side {
  min-height: 0 !important;
  height: 100%;
  border-radius: 22px !important;
}

.hx-cards {
  height: 100%;
  min-height: 0;
  gap: 8px !important;
}

/* each card: rounded corners on all four sides, image fits inside */
.hx-card {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  border-radius: 24px !important;
  padding: 6px !important;
  overflow: hidden !important;
}

.hx-card .hx-ico {
  height: 100% !important;
  width: auto !important;
  max-width: 100% !important;
  max-height: 100%;
  object-fit: contain !important;
  border-radius: 16px;
}

/* keep the bottom prompt bar visible */
.home-bar {
  bottom: calc(10px + env(safe-area-inset-bottom, 0px)) !important;
}

/* Leave room for the prompt bar at the bottom, so nothing is cut off */
#homePanel {
  height: calc(100dvh - 60px) !important;
  padding-bottom: 104px !important;
}

/* a little shorter cards so all three fit above the bar */
.hx-cards {
  height: calc(100% - 4px) !important;
}

.hx-card {
  max-height: 31% !important;
}

/* prompt bar: fully visible above the bottom edge */
.home-bar {
  bottom: calc(18px + env(safe-area-inset-bottom, 0px)) !important;
  left: 14px !important;
  right: 14px !important;
  z-index: 30 !important;
}

/* Cards: the image fills the whole card, all four corners */
.hx-cards {
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
  height: calc(100% - 4px) !important;
}

.hx-card {
  flex: 1 1 0 !important;
  width: 100% !important;
  max-height: none !important;
  min-height: 0 !important;
  height: auto !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
  border-radius: 22px !important;
  display: block !important;
}

.hx-card .hx-ico {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: cover !important;
  object-position: center 45% !important;
  border-radius: 0 !important;
  margin: 0 !important;
}

/* Show the full image (names included), no cropping */
.hx-card .hx-ico {
  object-fit: contain !important;
  object-position: center !important;
  background: rgba(5, 10, 24, .92) !important;
  border-radius: 18px !important;
}

/* Home fits one screen: no scroll */
body:has(#homePanel:not([hidden])) {
  overflow: hidden !important;
}

#homePanel {
  height: calc(100dvh - 150px) !important;
  min-height: 0 !important;
  padding-bottom: 96px !important;
  overflow: hidden !important;
}

.hx-body {
  height: calc(100% - 130px) !important;
  min-height: 0 !important;
}

.hx-cards {
  height: 100% !important;
  min-height: 0 !important;
}

.hx-card {
  min-height: 0 !important;
  overflow: hidden !important;
}

/* Cards are always tappable */
.hx-card {
  position: relative;
  z-index: 2;
  cursor: pointer;
  pointer-events: auto !important;
}

.hx-card .hx-ico,
.hx-card .hx-label {
  pointer-events: none;
}

.hx-card::after {
  pointer-events: none !important;
}

/* Left menu back to the earlier, wider size */
.hx-body {
  grid-template-columns: minmax(0, 27%) minmax(0, 1fr) !important;
  gap: 10px !important;
}

.hx-nav {
  font-size: 14px !important;
  min-height: 44px !important;
  padding: 0 10px !important;
  white-space: normal !important;
}

/* Cards: the image fills the whole card, no black side bands */
.hx-card {
  position: relative !important;
  overflow: hidden !important;
  padding: 0 !important;
  border-radius: 22px !important;
}

.hx-card .hx-ico {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: cover !important;
  object-position: center 40% !important;
  border-radius: 0 !important;
  margin: 0 !important;
}

/* Home bar: [+] [text] [🎤] [↑] like AI Chat */
.home-bar {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
}

/* 🖼 becomes a "+" button on the left */
#homeImageBtn {
  order: 0 !important;
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  padding: 0 !important;
  border: 1px solid rgba(190, 210, 255, .3) !important;
  border-radius: 14px !important;
  background: rgba(255, 255, 255, .08) !important;
  font-size: 0 !important;
  color: transparent !important;
  position: relative;
}

#homeImageBtn::before {
  content: "+";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  line-height: 1;
  color: #eaf1ff;
}

/* text box in the middle */
#homeInput {
  order: 1 !important;
  flex: 1 1 0 !important;
  min-width: 0 !important;
}

/* 🎤 on the right, next to send */
#homeMicBtn {
  order: 2 !important;
}

/* ↑ on the far right */
#homeSendBtn {
  order: 3 !important;
  width: 44px !important;
  min-width: 44px !important;
  height: 44px !important;
}

/* Cards: whole image visible, centred, not zoomed or cut */
.hx-card {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 6px !important;
  overflow: hidden !important;
  background: linear-gradient(160deg, rgba(20, 34, 66, .55), rgba(8, 14, 30, .75)) !important;
}

.hx-card .hx-ico {
  position: static !important;
  inset: auto !important;
  width: auto !important;
  height: 92% !important;
  max-width: 100% !important;
  max-height: none !important;
  object-fit: contain !important;
  object-position: center !important;
  margin: 0 auto !important;
  border-radius: 14px !important;
}

/* keep "Settings" on one line in the left menu */
.hx-nav {
  white-space: nowrap !important;
  font-size: 13px !important;
}

/* ===== Home: full-screen layout, three wide cards, bottom bar ===== */
#homePanel {
  display: flex !important;
  flex-direction: column !important;
  height: calc(100dvh - 92px) !important;
  min-height: 0 !important;
  padding: 12px 12px 96px !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  border-radius: 26px !important;
}

#homePanel .hx-head {
  flex: 0 0 auto !important;
  margin: 0 0 10px !important;
}

#homePanel .hx-body {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
}

#homePanel .hx-side { display: none !important; }

#homePanel .hx-cards {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
}

#homePanel .hx-card {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  width: 100% !important;
  padding: 0 !important;
  overflow: hidden !important;
  border-radius: 22px !important;
  display: block !important;
}

/* each card shows the whole picture, label included */
#homePanel .hx-card .hx-ico {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: contain !important;
  object-position: center !important;
  border-radius: 0 !important;
  margin: 0 !important;
}

/* bottom bar stays above the edge */
#homePanel .home-bar {
  bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important;
}

/* History list: show it properly under the menu, and let the drawer scroll */
#historyList[hidden] {
  display: none !important;
}

#historyList:not([hidden]) {
  display: grid !important;
  margin-top: 10px;
  max-height: 45vh;
  overflow-y: auto;
  padding: 4px;
}

.sidebar {
  overflow-y: auto !important;
}
/* Home top: no ✧ icon, Premium and the name are compact, cards move up */
#homePanel .hx-logo {
  display: none !important;
}

#homePanel .hx-head {
  margin: 0 0 4px !important;
  gap: 4px !important;
  padding-top: 0 !important;
}

#homePanel .hx-premium {
  margin-bottom: 2px !important;
  padding: 6px 16px !important;
  font-size: 14px !important;
}

#homePanel .hx-title {
  margin: 0 !important;
  font-size: 1.4rem !important;
  line-height: 1.1 !important;
}

#homePanel .hx-sub {
  margin: 0 !important;
  font-size: .75rem !important;
  line-height: 1.1 !important;
}

#homePanel .hx-body {
  margin-top: 0 !important;
}

/* Drawer footer: under Sign out, no extra gap, no stray line */
.sidebar-bottom {
  position: static !important;
  margin: 10px 0 0 !important;
  padding: 14px 16px !important;
  border-radius: 18px !important;
  border: 1px solid rgba(190, 210, 255, .2) !important;
  background: rgba(20, 30, 58, .6) !important;
}

#authBox {
  margin-bottom: 0 !important;
}

/* (removed: the rule that always hid #historyList) */

/* Drawer: TinVin AI card on top, X on the right */
.sidebar {
  display: flex !important;
  flex-direction: column !important;
}

.sidebar-header {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
}

.sidebar-header .sidebar-bottom {
  flex: 1 !important;
  min-width: 0 !important;
  margin: 0 !important;
}

.sidebar-header #closeMenu {
  flex: 0 0 auto !important;
}

/* keep menu icons aligned */
.sidebar-menu .menu-item {
  display: flex !important;
  align-items: center !important;
  gap: 16px !important;
}

.sidebar-menu .menu-item > span {
  width: 28px !important;
  min-width: 28px !important;
  text-align: center !important;
}

/* ===== Home: big cards, page can scroll ===== */
body:has(#homePanel:not([hidden])) {
  overflow: auto !important;
}

#homePanel {
  height: auto !important;
  min-height: calc(100dvh - 92px) !important;
  overflow: visible !important;
  padding: 12px 12px 120px !important;
}

#homePanel .hx-body {
  height: auto !important;
  flex: 0 0 auto !important;
}

#homePanel .hx-cards {
  height: auto !important;
  flex: 0 0 auto !important;
  gap: 14px !important;
}

#homePanel .hx-card {
  flex: 0 0 auto !important;
  height: 230px !important;
  min-height: 230px !important;
  width: 100% !important;
  position: relative !important;
  border-radius: 24px !important;
  overflow: hidden !important;
}

#homePanel .hx-card .hx-ico {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: cover !important;
  object-position: center 55% !important;
  border-radius: 0 !important;
  margin: 0 !important;
}

/* ===== Home: medium cards ===== */
#homePanel .hx-card {
  height: 150px !important;
  min-height: 150px !important;
}

#homePanel .hx-cards {
  gap: 10px !important;
}

#homePanel .hx-card .hx-ico {
  object-fit: cover !important;
  object-position: center 50% !important;
}

/* ===== Home: fix card crop + bottom bar ===== */
#homePanel .hx-card {
  height: 180px !important;
  min-height: 180px !important;
}

#homePanel .hx-card .hx-ico {
  object-fit: cover !important;
  object-position: center 35% !important;
}

/* show the card name as text, since the image gets cropped */
#homePanel .hx-card .hx-label {
  display: block !important;
  position: absolute !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  z-index: 3 !important;
  padding: 22px 0 10px !important;
  text-align: center !important;
  font-size: 18px !important;
  font-weight: 800 !important;
  color: #fff !important;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .8) !important;
  background: linear-gradient(transparent, rgba(5, 10, 24, .85)) !important;
  pointer-events: none !important;
}

/* prompt bar stays visible at the bottom while scrolling */
#homePanel {
  padding-bottom: 12px !important;
}

#homePanel .home-bar {
  position: sticky !important;
  left: auto !important;
  right: auto !important;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
  margin-top: 14px !important;
  z-index: 30 !important;
}

/* ===== Drawer: one scroll only, page behind stays still ===== */
body.sidebar-open,
body.sidebar-open:has(#homePanel:not([hidden])) {
  overflow: hidden !important;
}

html:has(body.sidebar-open) {
  overflow: hidden !important;
}

.sidebar {
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
  -webkit-overflow-scrolling: touch;
}

/* the list no longer scrolls by itself, the drawer does */
#historyList:not([hidden]) {
  max-height: none !important;
  overflow: visible !important;
}

/* Drawer: only History and Settings */
.sidebar-menu .menu-item[data-open] {
  display: none !important;
}

/* Translator: Clear button, same size and square like the + button */
#translatorPage .translator-compose #translatorClearBtn {
  width: 44px !important;
  min-width: 44px !important;
  height: 44px !important;
  min-height: 44px !important;
  padding: 0 !important;
  border-radius: 14px !important;
  border: 1px solid rgba(190, 210, 255, .3) !important;
  background: rgba(255, 255, 255, .08) !important;
  font-size: 0 !important;
  color: transparent !important;
  position: relative !important;
  overflow: hidden !important;
  justify-self: start !important;
}

#translatorPage .translator-compose #translatorClearBtn::before {
  content: "✕";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  color: #eaf1ff;
}

/* Code blocks in AI Chat, with a Copy button */
.code-block {
  margin: 10px 0;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(190, 210, 255, .2);
  background: rgba(5, 10, 24, .85);
  direction: ltr;
  text-align: left;
}

.code-block .code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, .07);
}

.code-block .code-lang {
  font-size: 12px;
  color: #aebbd5;
}

.code-block .code-copy {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(190, 210, 255, .3);
  background: rgba(255, 255, 255, .08);
  color: #eaf1ff;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.code-block .code-copy.copied {
  color: #7dffb0;
  border-color: rgba(125, 255, 176, .5);
}

.code-block pre {
  margin: 0;
  padding: 12px;
  overflow-x: auto;
  max-width: 100%;
}

.code-block code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
  color: #dbe7ff;
}
