/* =========================================
   FRUIT QUALITY ANALYZER — style.css
   Raspberry Pi 4 · 800×480 · Touch UI
   ========================================= */


/* ── DARK MODE (default) ── */
:root,
[data-theme="dark"] {
  --bg: #0d0d0d;
  --surface: #161616;
  --card: rgba(255,255,255,0.07);
  --card-border: rgba(255,255,255,0.12);
  --accent: #00ffcc;
  --accent2: #ff6b35;
  --accent-deep: #c4b5fd;
  --text: #f4f4f4;
  --text-sub: #c8c8c8;
  --text-muted: rgba(255,255,255,0.5);
  --grade-a: #00ffcc;
  --grade-b: #fbbf24;
  --grade-c: #f87171;
  --radius: 18px;
  --radius-sm: 10px;
  --font: 'Prompt', sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --shadow-card: 0 4px 24px rgba(0,0,0,0.4);
  --btn-ghost-bg: rgba(255,255,255,0.07);
  --btn-ghost-border: rgba(255,255,255,0.12);
  --btn-ghost-text: #f4f4f4;
  --header-bg: rgba(255,255,255,0.03);
  --header-border: rgba(255,255,255,0.1);
  --score-bar-bg: rgba(255,255,255,0.1);
  --step-inactive: rgba(255,255,255,0.25);
  --metric-val: #00ffcc;
  --usage-title-color: rgba(255,255,255,0.55);
}


/* ── LIGHT MODE ── */
[data-theme="light"] {
  --bg: #f0f2f0;
  --surface: #ffffff;
  --card: rgba(0,0,0,0.04);
  --card-border: rgba(0,0,0,0.1);
  --accent: #009e7f;
  --accent2: #e05a20;
  --accent-deep: #7c3aed;
  --text: #111111;
  --text-sub: #333333;
  --text-muted: rgba(0,0,0,0.5);
  --grade-a: #00897b;
  --grade-b: #d97706;
  --grade-c: #dc2626;
  --shadow-card: 0 2px 16px rgba(0,0,0,0.1);
  --btn-ghost-bg: rgba(0,0,0,0.05);
  --btn-ghost-border: rgba(0,0,0,0.12);
  --btn-ghost-text: #111111;
  --header-bg: rgba(255,255,255,0.8);
  --header-border: rgba(0,0,0,0.1);
  --score-bar-bg: rgba(0,0,0,0.1);
  --step-inactive: rgba(0,0,0,0.3);
  --metric-val: #009e7f;
  --usage-title-color: rgba(0,0,0,0.5);
}


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


html {
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  background: #0a0a0a;
  overflow: hidden;
}
[data-theme="light"] html { background: #d8dbd8; }


body {
  width: 800px;
  height: 480px;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.4s ease, color 0.4s ease;
  position: fixed;
  left: var(--ui-left, 0px);
  top: var(--ui-top, 0px);
  flex-shrink: 0;
  transform-origin: top left;
  transform: scale(var(--ui-scale, 1));
}


/* =========================================
   SCREEN SYSTEM
   ========================================= */
.screen {
  display: none !important;
  flex-direction: column;
  position: absolute;
  inset: 0;
  width: 800px;
  height: 480px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  z-index: 0;
  transform: translateX(30px);
  transition: opacity 0.35s cubic-bezier(.4,0,.2,1),
              transform 0.35s cubic-bezier(.4,0,.2,1);
}
.screen.active {
  display: flex !important;
  flex-direction: column;
  opacity: 1;
  pointer-events: all;
  visibility: visible;
  z-index: 10;
  transform: translateX(0);
}

.screen.prewarm {
  display: flex !important;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  z-index: -1;
  transform: translateX(0);
  transition: none;
}

#screen-dashboard {
  transform: translateX(0);
  transition: opacity 0.12s ease;
}


/* screens ที่ต้องการ row layout */
#screen-std-result.active,
#screen-deep-result.active {
  flex-direction: row;
}


/* screens ที่ต้องการ center */
#screen-splash.active,
#screen-login.active,
#screen-std-analyze.active {
  flex-direction: column;
  align-items: center;
  justify-content: center;
}


/* =========================================
   THEME TOGGLE
   ========================================= */
.theme-toggle {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 100;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-card);
}
.theme-toggle:hover { background: var(--btn-ghost-bg); transform: scale(1.1); }
.theme-toggle:active { transform: scale(0.95); }


/* =========================================
   LUCIDE ICONS
   ========================================= */
i[data-lucide] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}
i[data-lucide] svg {
  width: 1em; height: 1em;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}


/* =========================================
   SPLASH
   ========================================= */
#screen-splash {
  z-index: 20;
  background: radial-gradient(ellipse at 50% 60%, #0d2b25 0%, #0a0a0a 70%);
}
[data-theme="light"] #screen-splash {
  background: radial-gradient(ellipse at 50% 60%, #d0f5ee 0%, #f0f2f0 70%);
}
.splash-inner { text-align: center; }
.splash-icon {
  width: 72px; height: 72px;
  animation: splashBounce 1s ease-in-out infinite alternate;
  display: block;
  margin: 0 auto 12px;
}
@keyframes splashBounce {
  from { transform: translateY(0) scale(1); }
  to   { transform: translateY(-10px) scale(1.07); }
}
.splash-title {
  font-size: 28px; font-weight: 700;
  line-height: 1.2; letter-spacing: -0.5px;
  color: var(--text);
}
.splash-title span { color: var(--accent); }
.splash-loader {
  margin: 24px auto 0;
  width: 180px; height: 3px;
  background: var(--score-bar-bg);
  border-radius: 99px; overflow: hidden;
}
.loader-bar {
  height: 100%; background: var(--accent);
  border-radius: 99px;
  animation: loadProgress 1.8s ease forwards;
}
@keyframes loadProgress {
  from { width: 0%; } to { width: 100%; }
}


/* =========================================
   LOGIN
   ========================================= */
#screen-login {
  z-index: 18;
  background: url("images/login background.png") center / cover no-repeat;
  color: #f4f4f4;
  transform: translateY(18px) scale(0.985);
}

#screen-login.active {
  animation: loginScreenIn 0.55s cubic-bezier(.22,1,.36,1) both;
}

@keyframes loginScreenIn {
  from { opacity: 0; transform: translateY(20px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-card {
  --login-card-scale: 1;
  position: relative;
  z-index: 2;
  width: min(292px, calc(100% - 44px));
  padding: 9px 12px 12px;
  border-radius: 8px;
  border: 1px solid rgba(0,255,204,0.55);
  background:
    linear-gradient(145deg, rgba(255,255,255,0.075), rgba(255,255,255,0.018)),
    linear-gradient(180deg, rgba(3, 17, 20, 0.58), rgba(2, 10, 12, 0.42));
  box-shadow:
    0 1px 0 rgba(255,255,255,0.12) inset,
    0 0 0 1px rgba(0,255,204,0.08) inset,
    0 0 34px rgba(0,255,204,0.18),
    0 24px 64px rgba(0,0,0,0.48);
  backdrop-filter: blur(20px) saturate(135%);
  -webkit-backdrop-filter: blur(20px) saturate(135%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  transform-origin: center center;
  animation: loginCardIn 0.68s cubic-bezier(.22,1,.36,1) 0.08s both;
}

@keyframes loginCardIn {
  from { opacity: 0; transform: translateY(16px) scale(var(--login-card-scale)); }
  to   { opacity: 1; transform: translateY(0) scale(var(--login-card-scale)); }
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: #f7fbfb;
  font-weight: 800;
  font-size: 11px;
  margin-bottom: 3px;
}

.login-logo {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 0 10px rgba(255,140,0,0.45));
}

.login-logo svg {
  width: 20px;
  height: 20px;
  display: block;
}

.login-title {
  text-align: center;
  color: #ffffff;
  font-size: 20px;
  line-height: 1.05;
  font-weight: 800;
  margin-bottom: 5px;
}

.login-subtitle {
  text-align: center;
  color: rgba(255,255,255,0.74);
  font-size: 8px;
  margin-bottom: 8px;
}

.login-feedback {
  min-height: 8px;
  color: var(--accent);
  font-size: 8px;
  text-align: center;
  margin-bottom: 1px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.login-feedback.show { opacity: 1; }

.login-field {
  margin-bottom: 3px;
}

.login-input-wrap {
  height: 27px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.035);
  color: var(--accent);
  padding: 0 10px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.login-input-wrap:focus-within {
  border-color: rgba(0,255,204,0.78);
  box-shadow: 0 0 20px rgba(0,255,204,0.16);
  background: rgba(0,255,204,0.045);
}

.login-field.has-error .login-input-wrap {
  border-color: rgba(248,113,113,0.88);
  box-shadow: 0 0 18px rgba(248,113,113,0.14);
}

.login-input-wrap > i[data-lucide],
.login-input-wrap > svg[data-lucide] {
  width: 11px;
  height: 11px;
  min-width: 11px;
  flex: 0 0 11px;
  font-size: 11px;
}

.login-input-wrap > i[data-lucide] svg,
.login-input-wrap > svg[data-lucide] {
  width: 11px !important;
  height: 11px !important;
  stroke-width: 2;
}

.login-input-wrap input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #f4f4f4;
  font: 300 8.5px var(--font);
}

.login-input-wrap input[type="password"] {
  appearance: none;
  -webkit-appearance: none;
}

.login-input-wrap input[type="password"]::-ms-reveal,
.login-input-wrap input[type="password"]::-ms-clear {
  display: none;
}

.login-input-wrap input[type="password"]::-webkit-credentials-auto-fill-button {
  visibility: hidden;
  display: none !important;
  pointer-events: none;
}

.login-input-wrap input::placeholder {
  color: rgba(255,255,255,0.34);
  font-weight: 300;
}

.login-eye {
  width: 15px;
  height: 100%;
  flex: 0 0 15px;
  margin-left: auto;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  border-radius: 5px;
  transition: color 0.2s ease, background 0.2s ease;
}

.login-eye:hover {
  color: var(--accent);
  background: rgba(0,255,204,0.08);
}

.login-eye i[data-lucide],
.login-eye svg[data-lucide] {
  width: 10px;
  height: 10px;
  min-width: 10px;
  flex: 0 0 10px;
  font-size: 10px;
}

.login-eye i[data-lucide] svg,
.login-eye svg[data-lucide] {
  width: 10px !important;
  height: 10px !important;
  stroke-width: 2;
}

.login-error {
  min-height: 8px;
  padding: 1px 2px 0 28px;
  color: #fca5a5;
  font-size: 7px;
  line-height: 1.1;
}

.login-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 1px 0 8px;
}

.login-check {
  display: flex;
  align-items: center;
  gap: 5px;
  color: rgba(255,255,255,0.82);
  font-size: 8.5px;
  cursor: pointer;
  white-space: nowrap;
}

.login-check input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.login-checkmark {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  border: 1px solid rgba(0,255,204,0.8);
  display: grid;
  place-items: center;
  box-shadow: 0 0 12px rgba(0,255,204,0.12);
}

.login-check input:checked + .login-checkmark::after {
  content: "";
  width: 5px;
  height: 3px;
  border-left: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg) translateY(-1px);
}

.login-link,
.login-register button {
  border: 0;
  background: transparent;
  color: var(--accent);
  font: 500 8.5px var(--font);
  cursor: pointer;
}

.login-link:hover,
.login-register button:hover {
  text-decoration: underline;
}

.login-submit {
  height: 27px;
  border: 0;
  border-radius: 4px;
  background: linear-gradient(135deg, #00ffcc, #12dcb9);
  color: #001412;
  font: 800 8.5px var(--font);
  cursor: pointer;
  box-shadow: 0 0 22px rgba(0,255,204,0.28);
  transition: transform 0.16s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.login-submit:hover {
  filter: brightness(1.06);
  box-shadow: 0 0 30px rgba(0,255,204,0.44);
}

.login-submit:active {
  transform: scale(0.98);
}

.login-register {
  margin: 7px 0 6px;
  text-align: center;
  color: rgba(255,255,255,0.78);
  font-size: 8.5px;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255,255,255,0.38);
  font-size: 8px;
  margin-bottom: 7px;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.16);
}

.login-google {
  height: 24px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.035);
  color: #f4f4f4;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font: 700 8.5px var(--font);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.16s ease;
}

.login-google:hover {
  border-color: rgba(0,255,204,0.58);
  background: rgba(0,255,204,0.06);
}

.login-google:active {
  transform: scale(0.98);
}

.google-mark {
  color: #ffffff;
  font: 800 12px Arial, sans-serif;
  line-height: 1;
}

.register-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 5, 7, 0.52);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}

.register-overlay.open { display: flex; }

.register-card {
  width: 292px;
  max-width: calc(100% - 24px);
  border-radius: 10px;
  border: 1px solid rgba(0,255,204,0.48);
  background:
    linear-gradient(145deg, rgba(255,255,255,0.1), rgba(255,255,255,0.025)),
    linear-gradient(180deg, rgba(4, 22, 25, 0.74), rgba(1, 10, 12, 0.62));
  box-shadow:
    0 1px 0 rgba(255,255,255,0.12) inset,
    0 0 28px rgba(0,255,204,0.18),
    0 24px 70px rgba(0,0,0,0.58);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  padding: 13px;
  color: #f7fbfb;
  animation: registerIn 0.24s ease both;
}

@keyframes registerIn {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.register-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.register-head h2 {
  font-size: 17px;
  line-height: 1;
  font-weight: 800;
  margin-bottom: 4px;
}

.register-head p {
  font-size: 8px;
  color: rgba(255,255,255,0.62);
}

.register-close {
  width: 22px;
  height: 22px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.78);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.register-close:hover {
  color: var(--accent);
  border-color: rgba(0,255,204,0.42);
}

.register-close i[data-lucide],
.register-close svg[data-lucide],
.register-close i[data-lucide] svg {
  width: 11px !important;
  height: 11px !important;
  stroke-width: 2.2;
}

.register-feedback {
  min-height: 10px;
  margin-bottom: 3px;
  color: var(--accent);
  font-size: 8px;
  line-height: 1.2;
  text-align: center;
}

.register-feedback.error { color: #fca5a5; }

.register-field {
  display: block;
  margin-bottom: 7px;
}

.register-field span {
  display: block;
  margin-bottom: 3px;
  color: rgba(255,255,255,0.72);
  font-size: 8px;
  font-weight: 500;
}

.register-field input {
  width: 100%;
  height: 28px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 5px;
  background: rgba(255,255,255,0.045);
  color: #f7fbfb;
  outline: 0;
  padding: 0 9px;
  font: 400 8.5px var(--font);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.register-password-wrap {
  position: relative;
}

.register-password-wrap input {
  padding-right: 30px;
  appearance: none;
  -webkit-appearance: none;
}

.register-password-wrap input::-ms-reveal,
.register-password-wrap input::-ms-clear {
  display: none;
}

.register-password-wrap input::-webkit-credentials-auto-fill-button {
  visibility: hidden;
  display: none !important;
  pointer-events: none;
}

.register-eye {
  position: absolute;
  top: 1px;
  right: 4px;
  width: 24px;
  height: 26px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: rgba(255,255,255,0.68);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.register-eye:hover {
  color: var(--accent);
  background: rgba(0,255,204,0.08);
}

.register-eye i[data-lucide],
.register-eye svg[data-lucide],
.register-eye i[data-lucide] svg {
  width: 11px !important;
  height: 11px !important;
  stroke-width: 2.2;
}

.register-field input:focus {
  border-color: rgba(0,255,204,0.78);
  box-shadow: 0 0 18px rgba(0,255,204,0.16);
  background: rgba(0,255,204,0.055);
}

.register-field.has-error input {
  border-color: rgba(248,113,113,0.88);
  box-shadow: 0 0 16px rgba(248,113,113,0.14);
}

.register-field em {
  display: block;
  min-height: 8px;
  padding-top: 2px;
  color: #fca5a5;
  font-style: normal;
  font-size: 7px;
  line-height: 1;
}

.register-submit {
  width: 100%;
  height: 28px;
  border: 0;
  border-radius: 5px;
  background: linear-gradient(135deg, #00ffcc, #12dcb9);
  color: #001412;
  font: 800 8.5px var(--font);
  cursor: pointer;
  box-shadow: 0 0 22px rgba(0,255,204,0.28);
}

.register-submit:hover { filter: brightness(1.06); }

.register-submit:disabled {
  cursor: wait;
  opacity: 0.72;
}


/* =========================================
   LOBBY
   ========================================= */
#screen-lobby {
  background: radial-gradient(ellipse at 10% 80%, rgba(0,255,204,0.06) 0%, transparent 60%);
}
[data-theme="light"] #screen-lobby {
  background: radial-gradient(ellipse at 10% 80%, rgba(0,158,127,0.07) 0%, transparent 60%);
}
.lobby-bg-circle {
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0,255,204,0.05) 0%, transparent 70%);
  right: -80px; top: -80px;
  pointer-events: none;
}
.lobby-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 16px 40px;
  height: 100%;
  gap: 8px;
}
.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
}
.lobby-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.logo-icon { width: 48px; height: 48px; flex-shrink: 0; }
.lobby-title {
  font-size: 26px; font-weight: 700;
  letter-spacing: -0.5px; line-height: 1;
  color: var(--text);
}
.lobby-sub { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.lobby-user-area {
  position: absolute;
  top: 10px;
  right: 56px;
  z-index: 120;
  flex-shrink: 0;
}
.user-profile-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 8px 26px rgba(0,0,0,0.35);
  transition: transform 0.18s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  backdrop-filter: blur(12px);
}
.user-profile-btn:hover,
.user-profile-btn.is-open {
  border-color: rgba(0,255,204,0.7);
  box-shadow: 0 0 22px rgba(0,255,204,0.22), 0 10px 30px rgba(0,0,0,0.38);
  transform: translateY(-1px);
}
.user-profile-btn:active { transform: scale(0.96); }
.user-avatar,
.user-menu-avatar {
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #ff8c00, #ff6b35);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18);
}
.user-avatar {
  width: 30px;
  height: 30px;
  font-size: 14px;
}
.user-menu-avatar {
  width: 46px;
  height: 46px;
  font-size: 18px;
  flex-shrink: 0;
}
.user-avatar img,
.user-menu-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.user-menu-card {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 272px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.16);
  background:
    linear-gradient(180deg, rgba(22,26,28,0.96), rgba(13,17,18,0.92)),
    rgba(255,255,255,0.06);
  box-shadow: 0 22px 54px rgba(0,0,0,0.48), 0 0 28px rgba(0,255,204,0.10);
  backdrop-filter: blur(18px);
  padding: 14px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px) scale(0.98);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}
.user-menu-card.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.user-menu-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.user-menu-copy {
  min-width: 0;
  flex: 1;
}
.user-menu-name {
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.1;
}
.user-menu-email {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.25;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-menu-divider {
  height: 1px;
  background: var(--card-border);
  margin: 13px 0 10px;
}
.user-logout-btn {
  width: 100%;
  height: 38px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  font: 700 12px var(--font);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}
.user-logout-btn:hover {
  background: rgba(248,113,113,0.12);
  color: #fca5a5;
}
.user-logout-btn i[data-lucide] svg {
  width: 16px;
  height: 16px;
}
.lobby-buttons { display: flex; flex-direction: column; gap: 6px; }
.lobby-btn-row { display: flex; gap: 10px; }
.btn-half { flex: 1; }
.lobby-btn-row-main .btn-half { min-width: 0; }
.btn-lobby-icon {
  flex: 0 0 58px;
  width: 58px;
  min-width: 58px;
  height: 54px;
  justify-content: center;
  align-items: center;
  padding: 0;
}
.btn-lobby-icon .btn-icon { width: 24px; height: 24px; }


.lobby-stats-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 7px 20px;
  margin-bottom: 0;
}
.lsb-item { flex: 1; text-align: center; }
.lsb-val { font-size: 18px; font-weight: 800; font-family: var(--mono); color: var(--text); }
.lsb-val.accent { color: var(--accent); }
.lsb-label { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.lsb-divider { width: 1px; height: 32px; background: var(--card-border); }


.fruit-picker-row {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap; margin-bottom: 0;
}
.fp-label { font-size: 11px; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.fp-item {
  padding: 5px 12px; border-radius: 99px;
  border: 1px solid var(--card-border);
  background: var(--card); font-size: 12px;
  cursor: pointer; transition: all 0.2s;
  color: var(--text-sub); font-family: var(--font);
}
.fp-item:hover { border-color: var(--accent); color: var(--accent); }
.fp-item.active {
  background: rgba(0,255,204,0.12);
  border-color: var(--accent);
  color: var(--accent); font-weight: 600;
}
[data-theme="light"] .fp-item.active { background: rgba(0,158,127,0.12); }


/* watermark */
.watermark-logo {
  position: absolute; bottom: 10px; right: 12px;
  z-index: 5; pointer-events: none;
}
.watermark-logo img {
  width: 36px; height: 36px;
  object-fit: cover;
  border-radius: 50%;
  opacity: 1;                           /* ← เพิ่มจาก 0.2 */
  border: 1.5px solid var(--card-border);
  background-color: rgb(255, 255, 255);
}
.watermark-logo:hover img { opacity: 1; }
.login-watermark { z-index: 3; }


/* =========================================
   BUTTONS
   ========================================= */
.btn {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 20px;
  border: none; border-radius: var(--radius);
  cursor: pointer; font-family: var(--font); font-size: 14px;
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
  text-align: left;
}
.btn:active { transform: scale(0.97); }


.btn-primary {
  background: var(--accent); color: #000; font-weight: 700;
  box-shadow: 0 0 24px rgba(0,255,204,0.25);
}
[data-theme="light"] .btn-primary { box-shadow: 0 4px 20px rgba(0,158,127,0.3); }
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 0 32px rgba(0,255,204,0.4); }
.btn-primary i[data-lucide] svg { stroke: #000; }


.btn-ghost {
  background: var(--btn-ghost-bg); color: var(--btn-ghost-text);
  border: 1px solid var(--btn-ghost-border);
  backdrop-filter: blur(10px); box-shadow: var(--shadow-card);
}
.btn-ghost:hover { background: var(--card); }


.btn-large { padding: 14px 22px; }
.btn-icon {
  font-size: 22px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
}
.btn-icon i[data-lucide] svg { width: 22px; height: 22px; }
.btn-label { font-weight: 600; font-size: 15px; color: inherit; }
.btn-desc { font-size: 11px; color: rgba(0,0,0,0.55); margin-top: 1px; }
.btn-ghost .btn-desc { color: var(--text-muted); }


/* =========================================
   SCREEN HEADER
   ========================================= */
.screen-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 10px 20px 8px;
  border-bottom: 1px solid var(--header-border);
  background: var(--header-bg);
  flex-shrink: 0;
  min-height: 44px;
}
.screen-header .back-btn { justify-self: start; }
.screen-header .screen-title { justify-self: center; font-size: 16px; font-weight: 600; }
.screen-header > div:last-child,
.screen-header > button:last-child { justify-self: end; }


.screen-title { font-size: 16px; font-weight: 600; color: var(--text); }
.back-btn {
  display: flex; align-items: center; gap: 4px;
  background: var(--btn-ghost-bg);
  border: 1px solid var(--btn-ghost-border);
  color: var(--accent);
  padding: 6px 12px; border-radius: var(--radius-sm);
  cursor: pointer; font-family: var(--font);
  font-size: 14px; font-weight: 500;
  transition: background 0.2s;
}
.back-btn i[data-lucide] svg { stroke: var(--accent); width: 16px; height: 16px; }
.back-btn:hover { background: var(--card); }
.back-btn:active { transform: scale(0.96); }


/* =========================================
   MODE SELECTION
   ========================================= */
.mode-cards {
  flex: 1; display: flex; gap: 16px;
  padding: 16px 24px 20px; overflow: hidden;
}
.mode-card {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 20px;
  cursor: pointer; display: flex; flex-direction: column; gap: 8px;
  position: relative; box-shadow: var(--shadow-card);
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  overflow: hidden;
}
[data-theme="light"] .mode-card { background: var(--surface); }
.mode-card::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(0,255,204,0.05) 0%, transparent 60%);
  pointer-events: none;
}
[data-theme="light"] .mode-card::before {
  background: linear-gradient(135deg, rgba(0,158,127,0.04) 0%, transparent 60%);
}
.mode-card:hover { transform: translateY(-3px); border-color: rgba(0,158,127,0.4); box-shadow: 0 8px 32px rgba(0,158,127,0.15); }
.mode-card:active { transform: scale(0.98); }
.mode-card-deep::before { background: linear-gradient(135deg, rgba(167,139,250,0.07) 0%, transparent 60%); }
.mode-card-deep:hover { border-color: rgba(167,139,250,0.4); box-shadow: 0 8px 32px rgba(167,139,250,0.15); }


.mode-badge {
  display: inline-block; background: rgba(0,255,204,0.15);
  color: var(--accent); border-radius: 99px;
  padding: 3px 10px; font-size: 10px; font-weight: 700;
  letter-spacing: 0.5px; width: fit-content;
}
[data-theme="light"] .mode-badge { background: rgba(0,158,127,0.15); }
.mode-badge-deep { background: rgba(167,139,250,0.15); color: var(--accent-deep); }


.mode-icon { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; margin: 4px 0; }
.mode-icon i[data-lucide] svg { width: 36px; height: 36px; stroke: var(--accent); }
.mode-card-deep .mode-icon i[data-lucide] svg { stroke: var(--accent-deep); }
.mode-name { font-size: 20px; font-weight: 700; color: var(--text); }
.mode-name-en { font-family: var(--mono); font-size: 10px; color: var(--text-muted); margin-top: -6px; letter-spacing: 2px; }


.mode-sensors { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.sensor-tag {
  display: flex; align-items: center; gap: 4px;
  background: rgba(0,255,204,0.1); border: 1px solid rgba(0,255,204,0.25);
  color: var(--accent); border-radius: 99px;
  padding: 3px 10px; font-size: 11px; font-weight: 500;
}
[data-theme="light"] .sensor-tag { background: rgba(0,158,127,0.1); border-color: rgba(0,158,127,0.25); }
.sensor-tag i[data-lucide] svg { width: 12px; height: 12px; stroke: var(--accent); }
.sensor-tag-deep { background: rgba(167,139,250,0.1); border-color: rgba(167,139,250,0.25); color: var(--accent-deep); }
.sensor-tag-deep i[data-lucide] svg { stroke: var(--accent-deep); }


.mode-desc { font-size: 12px; color: var(--text-sub); line-height: 1.5; flex: 1; }
.mode-desc strong { color: var(--text); font-weight: 700; }


.mode-arrow {
  position: absolute; bottom: 18px; right: 20px;
  font-size: 22px; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s, color 0.2s;
}
.mode-arrow i[data-lucide] svg { width: 22px; height: 22px; stroke: var(--text-muted); }
.mode-card:hover .mode-arrow { transform: translateX(5px); color: var(--accent); }
.mode-card:hover .mode-arrow i[data-lucide] svg { stroke: var(--accent); }
.mode-card-deep:hover .mode-arrow { color: var(--accent-deep); }
.mode-card-deep:hover .mode-arrow i[data-lucide] svg { stroke: var(--accent-deep); }


/* =========================================
   STANDARD ANALYZE
   ========================================= */
#screen-std-analyze {
  background: radial-gradient(ellipse at 50% 50%, rgba(0,255,204,0.05) 0%, transparent 70%);
}
[data-theme="light"] #screen-std-analyze {
  background: radial-gradient(ellipse at 50% 50%, rgba(0,158,127,0.06) 0%, transparent 70%);
}
.analyze-center { text-align: center; }
.fruit-bounce {
  width: 80px; height: 80px;
  display: flex; align-items: center; justify-content: center;
  animation: fruitAnim 0.6s ease-in-out infinite alternate;
  margin: 0 auto 16px;
}
@keyframes fruitAnim {
  from { transform: translateY(0) scale(1) rotate(-5deg); }
  to   { transform: translateY(-16px) scale(1.08) rotate(5deg); }
}
.analyze-label { font-size: 22px; font-weight: 600; color: var(--accent); }
.analyze-sub { font-size: 12px; color: var(--text-muted); margin: 4px 0 20px; }
.analyze-progress {
  width: 300px; height: 4px;
  background: var(--score-bar-bg);
  border-radius: 99px; margin: 0 auto 20px; overflow: hidden;
}
.analyze-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #00d4a8);
  border-radius: 99px; width: 0%;
  transition: width 0.3s ease;
}
.analyze-steps { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; }
.step {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--step-inactive);
  font-family: var(--mono);
  transition: color 0.5s, transform 0.3s;
}
.step i[data-lucide] svg { width: 11px; height: 11px; }
.step.active { color: var(--accent); transform: scale(1.05); }
.step.active i[data-lucide] svg { stroke: var(--accent); }
.step.done { color: var(--accent); opacity: 0.5; }
.step.done i[data-lucide] svg { stroke: var(--accent); }


/* =========================================
   RESULT LAYOUT (shared)
   ========================================= */
.result-layout { display: flex; height: 100%; width: 100%; }
.result-left {
  width: 220px; flex-shrink: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 20px 16px;
  border-right: 1px solid var(--card-border);
  gap: 10px; background: var(--header-bg);
}
.result-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 20px 20px 24px;  /* ← ลด padding ขวาลง */
  gap: 16px;
  justify-content: flex-start;
  min-height: 0;
  overflow: hidden;
}
.result-title {
  font-size: 15px; color: var(--text-muted); font-weight: 600;
  padding-bottom: 14px; border-bottom: 1px solid var(--card-border);
}
.grade-badge {
  width: 90px; height: 90px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 44px; font-weight: 800;
  background: var(--card); border: 3px solid var(--grade-a); color: var(--grade-a);
  box-shadow: 0 0 28px rgba(0,255,204,0.3);
  animation: gradePulse 2s ease-in-out infinite;
}
@keyframes gradePulse {
  0%,100% { box-shadow: 0 0 20px rgba(0,255,204,0.25); }
  50%      { box-shadow: 0 0 40px rgba(0,255,204,0.55); }
}
.grade-badge.grade-b-style { border-color: var(--grade-b); color: var(--grade-b); animation: gradePulseB 2s ease-in-out infinite; }
@keyframes gradePulseB {
  0%,100% { box-shadow: 0 0 20px rgba(251,191,36,0.25); }
  50%      { box-shadow: 0 0 40px rgba(251,191,36,0.55); }
}
.grade-badge.grade-c-style { border-color: var(--grade-c); color: var(--grade-c); animation: gradePulseC 2s ease-in-out infinite; }
@keyframes gradePulseC {
  0%,100% { box-shadow: 0 0 20px rgba(248,113,113,0.25); }
  50%      { box-shadow: 0 0 40px rgba(248,113,113,0.55); }
}
.grade-label { font-size: 11px; color: var(--text-muted); letter-spacing: 1px; text-transform: uppercase; font-weight: 600; }


.usage-box {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 12px; width: 100%;
  box-shadow: var(--shadow-card);
}
.usage-title {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--usage-title-color);
  margin-bottom: 6px; font-weight: 600;
}
.usage-title i[data-lucide] svg { width: 12px; height: 12px; stroke: var(--text-muted); }
.usage-text {
  font-size: 11px;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
}


.metrics-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.metric-card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 22px 10px;
  text-align: center; box-shadow: var(--shadow-card); transition: transform 0.2s;
  display: flex;              /* ← เพิ่ม */
  flex-direction: column;     /* ← เพิ่ม */
  align-items: center;        /* ← เพิ่ม */
  justify-content: center;    /* ← เพิ่ม ← นี่คือตัวหลัก */
}
.metric-card:hover { transform: translateY(-2px); }
.metric-icon { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; margin: 0 auto 6px; }
.metric-icon i[data-lucide] svg { width: 26px; height: 26px; stroke: var(--metric-val); }
.metric-val { font-size: 26px; font-weight: 700; font-family: var(--mono); color: var(--metric-val); }
.metric-label { font-size: 10px; color: var(--text-muted); margin-top: 3px; font-weight: 500; }


.bar-row { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 10px; color: var(--text-sub); font-weight: 500; }
.score-bar { height: 12px; background: var(--score-bar-bg); border-radius: 99px; overflow: hidden; }
.score-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), #00e6b8); transition: width 1s cubic-bezier(.4,0,.2,1); width: 0%; }
.result-timestamp { display: flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 12px; color: var(--text-muted); margin-top: 8px; }


/* ── Deep Result compact ── */
#screen-deep-result .result-left {
  width: 200px;
  padding: 12px 10px;
  gap: 8px;
  justify-content: center; /* ← เปลี่ยนจาก flex-start เป็น center */
  align-items: center;
  overflow: hidden;
}


#screen-deep-result .result-left .btn-primary {
  margin-top: 0 !important;
  width: 100%;
  flex-shrink: 0;
}
#screen-deep-result .grade-badge { width: 90px; height: 90px; font-size: 44px; font-weight: 800; flex-shrink: 0; }
#screen-deep-result .usage-box { padding: 8px 10px; flex-shrink: 0; }
#screen-deep-result .usage-text { font-size: 11px; line-height: 1.4; }
#screen-deep-result .voc-summary { padding: 7px 10px; flex-shrink: 0; }
#screen-deep-result .voc-sum-title { margin-bottom: 5px; font-size: 10px; }
#screen-deep-result .voc-sum-row { font-size: 11px; padding: 1px 0; }
#screen-deep-result .btn { padding: 9px 14px; font-size: 13px; flex-shrink: 0; }
#screen-deep-result .result-right { padding: 12px 16px; gap: 8px; overflow: hidden; justify-content: flex-start; }
#screen-deep-result .metrics-grid { gap: 7px;  }
#screen-deep-result .metric-card { padding: 8px 6px; }
#screen-deep-result .metric-val { font-size: 16px; }
#screen-deep-result .metric-label { font-size: 9px; }
#screen-deep-result .result-title   { font-size: 15px; color: var(--text-muted); font-weight: 600;
  padding-bottom: 14px; border-bottom: 1px solid var(--card-border);}


/* =========================================
   DEEP ANALYZE
   ========================================= */
.deep-header {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--header-border);
  background: var(--header-bg); flex-shrink: 0;
}
.deep-header-text { display: flex; align-items: center; gap: 8px; }
.deep-badge {
  display: flex; align-items: center; gap: 6px;
  background: rgba(167,139,250,0.15); color: var(--accent-deep);
  border-radius: 99px; padding: 4px 14px;
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
}
.deep-badge i[data-lucide] svg { width: 13px; height: 13px; stroke: var(--accent-deep); }
.deep-timer { font-size: 30px; font-weight: 800; font-family: var(--mono); color: var(--accent-deep); line-height: 1; }
.deep-timer-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.analyzing-pulse { margin-left: auto; font-size: 13px; color: var(--accent-deep); animation: blink 1.2s ease-in-out infinite; font-weight: 600; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }


.deep-body { flex: 1; display: flex; gap: 10px; padding: 10px 14px; overflow: hidden; }
.deep-left { display: flex; flex-direction: column; gap: 10px; width: 300px; flex-shrink: 0; }
.deep-right { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; overflow: hidden; }


.camera-box {
  flex: 1; background: #000;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  position: relative; overflow: hidden; min-height: 200px;
}
[data-theme="light"] .camera-box { background: #1a1a1a; }
.camera-scan-line {
  position: absolute; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-deep), transparent);
  animation: scanLine 2s linear infinite;
  z-index: 2; top: 0;
}
@keyframes scanLine { 0%{ top:0% } 100%{ top:100% } }
.camera-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
}
.cam-icon { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; opacity: 0.3; }
.cam-icon i[data-lucide] svg { width: 28px; height: 28px; stroke: #fff; }
.cam-label { font-size: 11px; color: rgba(255,255,255,0.4); font-family: var(--mono); letter-spacing: 1px; }
.cam-fruit { width: 60px; height: 60px; display: flex; align-items: center; justify-content: center; animation: camFruit 3s ease-in-out infinite; }
@keyframes camFruit { 0%,100%{ transform: scale(1) rotate(0deg) } 50%{ transform: scale(1.06) rotate(3deg) } }
.cam-corners { position: absolute; inset: 10px; }
.corner { position: absolute; width: 18px; height: 18px; border-color: var(--accent-deep); border-style: solid; opacity: 0.7; }
.corner.tl { top:0;left:0; border-width: 2px 0 0 2px; }
.corner.tr { top:0;right:0; border-width: 2px 2px 0 0; }
.corner.bl { bottom:0;left:0; border-width: 0 0 2px 2px; }
.corner.br { bottom:0;right:0; border-width: 0 2px 2px 0; }


.weight-realtime {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 12px 16px;
  flex-shrink: 0; box-shadow: var(--shadow-card);
}
.weight-label { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; font-weight: 600; }
.weight-label i[data-lucide] svg { width: 12px; height: 12px; stroke: var(--text-muted); }
.weight-val { font-size: 28px; font-weight: 700; font-family: var(--mono); color: var(--metric-val); }
.weight-bar-wrap { height: 4px; background: var(--score-bar-bg); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.weight-bar-fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.5s ease; width: 0%; }


.chart-card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 12px; flex: 1;
  box-shadow: var(--shadow-card); min-height: 0;
}
.chart-label { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-muted); margin-bottom: 8px; font-weight: 600; }
.chart-label i[data-lucide] svg { width: 12px; height: 12px; stroke: var(--text-muted); }


.voc-live-row { display: flex; gap: 8px; flex-shrink: 0; }
.voc-live-item {
  flex: 1; background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 10px;
  text-align: center; box-shadow: var(--shadow-card);
}
.voc-live-label { font-size: 10px; color: var(--text-muted); margin-bottom: 4px; font-weight: 600; }
.voc-live-val { font-size: 18px; font-weight: 700; font-family: var(--mono); color: var(--text); }
.voc-live-val.accent { color: var(--accent-deep); }


/* =========================================
   DEEP RESULT EXTRAS
   ========================================= */
.voc-summary {
  background: rgba(167,139,250,0.07);
  border: 1px solid rgba(167,139,250,0.25);
  border-radius: var(--radius-sm); padding: 12px; width: 100%;
}
[data-theme="light"] .voc-summary { background: rgba(124,58,237,0.05); border-color: rgba(124,58,237,0.2); }
.voc-sum-title { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--accent-deep); margin-bottom: 8px; font-weight: 700; }
.voc-sum-title i[data-lucide] svg { width: 12px; height: 12px; stroke: var(--accent-deep); }
.voc-sum-row { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 0; border-bottom: 1px solid var(--card-border); color: var(--text-sub); }
.voc-sum-row:last-child { border-bottom: none; }
.accent { color: var(--accent-deep); font-family: var(--mono); font-weight: 700; }


/* =========================================
   USER GUIDE
   ========================================= */
.info-body { flex: 1; display: flex; gap: 12px; padding: 14px 20px; overflow: hidden; }
.info-col { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.info-card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 14px;
  display: flex; align-items: flex-start; gap: 12px;
  flex: 1; min-height: 0; box-shadow: var(--shadow-card); transition: border-color 0.2s;
}
[data-theme="light"] .info-card { background: var(--surface); }
.info-card:hover { border-color: rgba(0,158,127,0.3); }
.info-num { font-size: 20px; font-weight: 800; font-family: var(--mono); color: var(--accent); opacity: 0.6; min-width: 28px; line-height: 1; flex-shrink: 0; }
.info-num-icon { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; color: var(--accent); opacity: 0.7; flex-shrink: 0; }
.info-num-icon i[data-lucide] svg { width: 22px; height: 22px; stroke: var(--accent); }
.info-content { flex: 1; }
.info-title { font-size: 14px; font-weight: 700; margin-bottom: 4px; color: var(--text); }
.info-text { font-size: 11px; color: var(--text-sub); line-height: 1.6; }
.mode-info-std { border-color: rgba(0,158,127,0.25); background: rgba(0,158,127,0.04) !important; }
.mode-info-deep { border-color: rgba(167,139,250,0.25); background: rgba(167,139,250,0.04) !important; }
.mode-tag {
  display: flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700;
  padding: 3px 10px; border-radius: 99px;
  background: rgba(0,255,204,0.15); color: var(--accent);
  min-width: 70px; justify-content: center;
  letter-spacing: 0.5px; flex-shrink: 0;
}
[data-theme="light"] .mode-tag { background: rgba(0,158,127,0.15); }
.mode-tag i[data-lucide] svg { width: 11px; height: 11px; stroke: var(--accent); }
.mode-tag-deep { background: rgba(167,139,250,0.15); color: var(--accent-deep); }
.mode-tag-deep i[data-lucide] svg { stroke: var(--accent-deep); }


/* =========================================
   DATA RANGE INFO
   ========================================= */
.range-fruit-tabs {
  display: flex; gap: 6px; padding: 8px 20px 6px;
  border-bottom: 1px solid var(--card-border);
  background: var(--header-bg); flex-shrink: 0; overflow-x: auto;
}
.range-fruit-tabs::-webkit-scrollbar { display: none; }


.rftab {
  padding: 5px 16px; border-radius: 99px;
  border: 1px solid var(--card-border); background: var(--card);
  color: var(--text-muted); font-family: var(--font); font-size: 13px;
  cursor: pointer; transition: all 0.2s; white-space: nowrap; flex-shrink: 0;
}
.rftab:hover { border-color: var(--accent); color: var(--accent); }
.rftab.active {
  background: rgba(0,255,204,0.15); border-color: var(--accent);
  color: var(--accent); font-weight: 700;
}
[data-theme="light"] .rftab.active { background: rgba(0,158,127,0.15); }


.range-body { flex: 1; display: flex; gap: 14px; padding: 14px 20px; overflow: hidden; }
.range-col { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.range-title-sec { font-size: 11px; color: var(--text-muted); letter-spacing: 1px; text-transform: uppercase; padding-bottom: 4px; border-bottom: 1px solid var(--card-border); font-weight: 700; }
.range-card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 10px 14px;
  display: flex; align-items: center; gap: 14px;
  flex: 1; box-shadow: var(--shadow-card);
}
[data-theme="light"] .range-card { background: var(--surface); }
.grade-a { border-color: rgba(0,255,204,0.3); }
[data-theme="light"] .grade-a { border-color: rgba(0,142,107,0.3); }
.grade-b { border-color: rgba(251,191,36,0.3); }
.grade-c { border-color: rgba(248,113,113,0.3); }
.range-grade { font-size: 32px; font-weight: 900; font-family: var(--mono); min-width: 36px; line-height: 1; }
.grade-a .range-grade { color: var(--grade-a); }
.grade-b .range-grade { color: var(--grade-b); }
.grade-c .range-grade { color: var(--grade-c); }
.range-detail { flex: 1; }
.range-row { display: flex; justify-content: space-between; font-size: 11px; padding: 2px 0; color: var(--text-muted); }
.range-row span:last-child { color: var(--text); font-family: var(--mono); font-size: 11px; font-weight: 600; }


.usage-range-card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 12px;
  display: flex; align-items: center; gap: 12px;
  flex: 1; box-shadow: var(--shadow-card);
}
[data-theme="light"] .usage-range-card { background: var(--surface); }
.ur-grade { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 900; font-family: var(--mono); flex-shrink: 0; }
.ur-a { background: rgba(0,255,204,0.1); color: var(--grade-a); border: 2px solid rgba(0,255,204,0.35); }
[data-theme="light"] .ur-a { background: rgba(0,142,107,0.1); border-color: rgba(0,142,107,0.35); }
.ur-b { background: rgba(251,191,36,0.1); color: var(--grade-b); border: 2px solid rgba(251,191,36,0.35); }
.ur-c { background: rgba(248,113,113,0.1); color: var(--grade-c); border: 2px solid rgba(248,113,113,0.35); }
.ur-title { font-size: 13px; font-weight: 700; margin-bottom: 3px; color: var(--text); }
.ur-desc { font-size: 11px; color: var(--text-sub); line-height: 1.5; }


.range-note {
  background: rgba(251,191,36,0.07); border: 1px solid rgba(251,191,36,0.25);
  border-radius: var(--radius-sm); padding: 10px 12px;
  font-size: 11px; color: var(--text-sub);
  display: flex; gap: 8px; align-items: flex-start; font-weight: 500;
}
.range-note > span { flex-shrink: 0; display: flex; align-items: center; }
.range-note i[data-lucide] svg { width: 14px; height: 14px; stroke: var(--grade-b); }


/* =========================================
   HISTORY SCREEN
   ========================================= */
.fruit-filter-row {
  display: flex; gap: 5px; padding: 6px 16px 0;
  flex-wrap: nowrap; overflow-x: auto; flex-shrink: 0;
}
.fruit-filter-row::-webkit-scrollbar { display: none; }


.history-toolbar {
  display: flex; flex-direction: column; gap: 0; padding: 0;
  border-bottom: 1px solid var(--card-border); flex-shrink: 0;
}
.hist-bottom-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 16px;
}
.filter-tabs { display: flex; gap: 4px; }
.ftab {
  padding: 5px 14px; border-radius: 99px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);         
  font-family: var(--font); font-size: 12px;
  cursor: pointer; transition: all 0.2s;
}
.ftab:hover { border-color: var(--accent); color: var(--accent); }
.ftab.active {
  background: rgba(0,255,204,0.15); border-color: var(--accent);
  color: var(--accent); font-weight: 700;
}
[data-theme="light"] .ftab.active { color: #000; }



.btn-danger-sm {
  display: flex; align-items: center; gap: 4px;
  background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.3);
  color: var(--grade-c); padding: 5px 12px; border-radius: 99px;
  font-family: var(--font); font-size: 12px; cursor: pointer; transition: all 0.2s;
}
.btn-danger-sm:hover { background: rgba(248,113,113,0.2); }
.btn-danger-sm i[data-lucide] svg {
  width: 10px; height: 10;
  stroke: var(--grade-c);
}


.btn-icon-sm {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text-muted); transition: all 0.2s;
}
.btn-icon-sm:hover { color: var(--accent); border-color: var(--accent); }
.btn-icon-sm i[data-lucide] svg { width: 16px; height: 16px; stroke: currentColor; }


.history-list {
  flex: 1; overflow-y: auto; padding: 10px 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-thumb { background: var(--card-border); border-radius: 99px; }


.history-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; color: var(--text-muted);
}
.history-empty i[data-lucide] svg { width: 36px; height: 36px; stroke: var(--text-muted); opacity: 0.4; }
.history-empty p { font-size: 13px; }


.history-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 10px 14px;
  cursor: pointer; transition: all 0.2s; animation: slideIn 0.25s ease;
}
@keyframes slideIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }
.history-item:hover { border-color: var(--accent); transform: translateX(3px); }


.hi-grade {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 900; font-family: var(--mono); flex-shrink: 0;
}
.hi-grade-a { background: rgba(0,255,204,0.12); color: var(--grade-a); border: 1.5px solid rgba(0,255,204,0.3); }
.hi-grade-b { background: rgba(251,191,36,0.12); color: var(--grade-b); border: 1.5px solid rgba(251,191,36,0.3); }
.hi-grade-c { background: rgba(248,113,113,0.12); color: var(--grade-c); border: 1.5px solid rgba(248,113,113,0.3); }
[data-theme="light"] .hi-grade-a { background: rgba(0,142,107,0.12); border-color: rgba(0,142,107,0.3); }


.hi-info { flex: 1; min-width: 0; }
.hi-top { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.hi-fruit { font-size: 14px; }
.hi-mode { font-size: 9px; padding: 2px 6px; border-radius: 99px; font-weight: 700; letter-spacing: 0.5px; background: rgba(0,255,204,0.1); color: var(--accent); }
.hi-mode.deep { background: rgba(167,139,250,0.12); color: var(--accent-deep); }
.hi-time { font-size: 10px; color: var(--text-muted); font-family: var(--mono); }
.hi-metrics { display: flex; gap: 10px; }
.hi-met { font-size: 11px; color: var(--text-muted); }
.hi-met span { color: var(--text); font-weight: 600; font-family: var(--mono); }
.hi-score { text-align: right; flex-shrink: 0; }
.hi-score-val { font-size: 18px; font-weight: 800; font-family: var(--mono); color: var(--metric-val); }
.hi-score-label { font-size: 9px; color: var(--text-muted); }


/* =========================================
   DASHBOARD SCREEN
   ========================================= */
.dash-fruit-bar {
  display: flex; gap: 6px; padding: 6px 20px 4px;
  border-bottom: 1px solid var(--card-border);
  flex-wrap: nowrap; overflow-x: auto; flex-shrink: 0;
  background: var(--header-bg);
}
.dash-fruit-bar::-webkit-scrollbar { display: none; }


.ffruit {
  padding: 4px 12px; border-radius: 99px;
  border: 1px solid var(--card-border); background: var(--card);
  font-size: 13px; cursor: pointer; transition: all 0.2s;
  color: var(--text-sub); font-family: var(--font);
  white-space: nowrap; flex-shrink: 0;
}
.ffruit:hover { border-color: var(--accent); color: var(--accent); }
.ffruit.active {
  background: rgba(0,255,204,0.15); border-color: var(--accent);
  color: var(--accent); font-weight: 700;
}
[data-theme="light"] .ffruit.active { background: rgba(0,158,127,0.15); }


.dash-body { flex: 1; display: flex; gap: 14px; padding: 14px 20px; overflow: hidden; min-height: 0; }
.dash-left { width: 200px; flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow-y: auto; padding-bottom: 2px; }
.dash-left::-webkit-scrollbar { display: none; }
.dash-right { flex: 1; display: flex; flex-direction: column; gap: 10px; overflow: hidden; min-height: 0; }


.dash-card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 14px 16px;
  box-shadow: var(--shadow-card); text-align: center;
  flex-shrink: 0;
  min-width: 0;
  overflow: hidden;
}
.dash-card-label { font-size: 10px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.dash-card-val { font-size: 36px; font-weight: 900; font-family: var(--mono); color: var(--text); line-height: 1; margin: 4px 0; }
.dash-card-val.accent { color: var(--accent); }
.dash-card-sub { font-size: 11px; color: var(--text-muted); }


.dash-grade-row { display: flex; gap: 6px; flex-shrink: 0; }
.dash-last-card {
  text-align: left !important;
  padding: 11px 14px;
}
.dash-last-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.dash-last-grade {
  font-size: 26px;
  font-weight: 900;
  font-family: var(--mono);
  color: var(--grade-a);
  line-height: 1;
  margin: 4px 0 0;
  flex: 0 0 auto;
  min-width: 32px;
}
.dash-last-copy {
  min-width: 0;
  flex: 1;
  padding-top: 2px;
}
.dash-last-meta {
  font-size: 11px;
  color: var(--text-sub);
  font-family: var(--mono);
  line-height: 1.25;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-last-time {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.25;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-grade-item {
  flex: 1; background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 8px; text-align: center;
  box-shadow: var(--shadow-card);
}
.dgi-grade { font-size: 14px; font-weight: 900; font-family: var(--mono); }
.dgi-count { font-size: 18px; font-weight: 800; font-family: var(--mono); margin-top: 2px; }
.ga { border-color: rgba(0,255,204,0.25); }
.ga .dgi-grade { color: var(--grade-a); }
.ga .dgi-count { color: var(--grade-a); }
.gb { border-color: rgba(251,191,36,0.25); }
.gb .dgi-grade { color: var(--grade-b); }
.gb .dgi-count { color: var(--grade-b); }
.gc { border-color: rgba(248,113,113,0.25); }
.gc .dgi-grade { color: var(--grade-c); }
.gc .dgi-count { color: var(--grade-c); }
[data-theme="light"] .ga { border-color: rgba(0,142,107,0.25); }


.dash-chart-card {
  flex: 1; min-height: 0; overflow: hidden;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow-card); display: flex; flex-direction: column;
}
.dash-chart-title {
  display: inline-block;
  align-self: flex-start;
  width: fit-content;
  max-width: 100%;
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
}
.dash-trend-wrap {
  position: relative;
  height: 80px;
  min-height: 80px;
  max-height: 80px;
  width: 100%;
  overflow: hidden;
  contain: layout paint size;
}
.dash-trend-wrap > div,
.dash-trend-svg {
  display: block;
  width: 100%;
  height: 80px;
}
.dash-trend-svg {
  overflow: visible;
}
.dash-trend-axis {
  font-family: var(--mono);
  font-size: 8px;
  fill: var(--text-muted);
  opacity: 0.62;
}
.dash-donut-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  gap: 6px;
}
.dash-chart-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;    /* ← เพิ่ม */
  height: 100%;          /* ← เปลี่ยนจาก height: 0 */
}
.dash-donut-wrap {
  overflow: visible;
}
.dash-donut-legend {
  width: 78px;
  flex: 0 0 78px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 9px;
}
.ddl-item {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-sub);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.ddl-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex: 0 0 10px;
}
.grade-a-dot { background: var(--grade-a); }
.grade-b-dot { background: var(--grade-b); }
.grade-c-dot { background: var(--grade-c); }
.dash-chart-wrap canvas,
.dash-chart-wrap > div {
  position: absolute;    /* ← เพิ่ม */
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;  /* ← ลบ max-height เดิมออก */
}




.dash-metrics-row { display: flex; gap: 8px; flex-shrink: 0; }
.dash-met {
  flex: 1; background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 10px; text-align: center;
  box-shadow: var(--shadow-card);
}
.dm-label { font-size: 10px; color: var(--text-muted); margin-bottom: 4px; }
.dm-val { font-size: 16px; font-weight: 700; font-family: var(--mono); color: var(--metric-val); }


/* =========================================
   AI MODAL
   ========================================= */


.modal-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.7);
  display: none; align-items: center; justify-content: center;
  z-index: 250; backdrop-filter: blur(6px);
}
.modal-overlay.open { display: flex; }
.modal-box {
  width: 480px; max-height: 400px;
  background: var(--surface); border: 1px solid var(--card-border);
  border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  display: flex; flex-direction: column; animation: modalIn 0.25s ease;
}
[data-theme="light"] .modal-box { background: #fff; }
@keyframes modalIn { from { opacity:0; transform:scale(0.95) translateY(10px); } to { opacity:1; transform:scale(1) translateY(0); } }


.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--card-border); flex-shrink: 0;
}
.modal-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; color: var(--accent-deep); }
.modal-title i[data-lucide] svg { width: 18px; height: 18px; stroke: var(--accent-deep); }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); display: flex; align-items: center; padding: 4px; border-radius: var(--radius-sm); transition: color 0.2s; }
.modal-close:hover { color: var(--text); }
.modal-close i[data-lucide] svg { width: 18px; height: 18px; stroke: currentColor; }


.modal-body { flex: 1; overflow-y: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; }
.ai-result-label { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--accent-deep); font-weight: 700; margin-bottom: 6px; }
.ai-result-label i[data-lucide] svg { width: 13px; height: 13px; stroke: var(--accent-deep); }
.ai-result-text { font-size: 12px; color: var(--text); line-height: 1.7; white-space: pre-wrap; }
@keyframes spin { to { transform: rotate(360deg); } }
.modal-footer { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--card-border); flex-shrink: 0; }


/* =========================================
   ONBOARDING OVERLAY
   ========================================= */
.onboard-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.75);
  display: none;           /* ← ต้องมี */
  align-items: center;
  justify-content: center;
  z-index: 300;            /* ← ต้องสูงกว่า screen ที่ z-index: 10 */
  backdrop-filter: blur(8px);
}
.onboard-overlay.open { display: flex; }
.onboard-box {
  width: 380px; background: var(--surface);
  border: 1px solid var(--card-border); border-radius: var(--radius);
  padding: 28px 28px 22px; text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
  animation: modalIn 0.3s ease;
}
.onboard-step { font-size: 10px; color: var(--text-muted); font-family: var(--mono); letter-spacing: 2px; margin-bottom: 16px; }
.onboard-icon { font-size: 48px; margin-bottom: 12px; }
.onboard-title { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.onboard-desc { font-size: 13px; color: var(--text-sub); line-height: 1.7; margin-bottom: 20px; }
.onboard-dots { display: flex; justify-content: center; gap: 6px; margin-bottom: 20px; }
.ob-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--card-border); transition: all 0.3s; }
.ob-dot.active { width: 20px; border-radius: 99px; background: var(--accent); }
.onboard-btns { display: flex; gap: 10px; }
.onboard-btns .btn { flex: 1; justify-content: center; }


/* =========================================
   BATCH MODE
   ========================================= */
.btn-batch {
  width: 100%;
  background: linear-gradient(135deg, rgba(0,255,204,0.08), rgba(0,200,160,0.05));
  border: 1px dashed rgba(0,255,204,0.4);
  color: var(--accent); position: relative; overflow: hidden;
}
.btn-batch::before {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, transparent, transparent 6px, rgba(0,255,204,0.03) 6px, rgba(0,255,204,0.03) 12px);
  pointer-events: none;
}
[data-theme="light"] .btn-batch { border-color: rgba(0,158,127,0.4); background: linear-gradient(135deg, rgba(0,158,127,0.06), transparent); }
.btn-batch .btn-desc { color: rgba(0,255,204,0.6); }
[data-theme="light"] .btn-batch .btn-desc { color: rgba(0,120,100,0.65); }
.btn-batch:hover { background: rgba(0,255,204,0.12); }


.batch-header {
  position: absolute; top: 0; left: 0; right: 0; height: 42px;
  background: rgba(0,255,204,0.08);
  border-bottom: 1px solid rgba(0,255,204,0.25);
  backdrop-filter: blur(12px);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  z-index: 80; animation: slideDown 0.3s ease;
}
@keyframes slideDown { from { transform: translateY(-42px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
[data-theme="light"] .batch-header { background: rgba(0,158,127,0.08); border-bottom-color: rgba(0,158,127,0.25); }


.bh-left { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.bh-badge {
  display: flex; align-items: center; gap: 4px;
  background: rgba(0,255,204,0.15); color: var(--accent);
  font-size: 10px; font-weight: 700; padding: 3px 10px; border-radius: 99px; letter-spacing: 1px;
}
.bh-badge i[data-lucide] svg { width: 11px; height: 11px; stroke: var(--accent); }
[data-theme="light"] .bh-badge { background: rgba(0,158,127,0.15); }
.bh-counter { font-size: 13px; font-weight: 700; font-family: var(--mono); color: var(--text); }


.bh-strip { flex: 1; display: flex; align-items: center; gap: 3px; overflow-x: auto; overflow-y: hidden; }
.bh-strip::-webkit-scrollbar { display: none; }


.bh-dot {
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 900; font-family: var(--mono);
  flex-shrink: 0; animation: popIn 0.25s cubic-bezier(.34,1.56,.64,1);
}
@keyframes popIn { from { transform: scale(0) rotate(-45deg); opacity: 0; } to { transform: scale(1) rotate(0deg); opacity: 1; } }
.bh-dot-a { background: rgba(0,255,204,0.2);   color: var(--grade-a); border: 1.5px solid var(--grade-a); }
.bh-dot-b { background: rgba(251,191,36,0.2);  color: var(--grade-b); border: 1.5px solid var(--grade-b); }
.bh-dot-c { background: rgba(248,113,113,0.2); color: var(--grade-c); border: 1.5px solid var(--grade-c); }


.bh-end {
  display: flex; align-items: center; gap: 5px;
  background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.35);
  color: var(--grade-c); padding: 5px 12px; border-radius: 99px;
  font-family: var(--font); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all 0.2s; flex-shrink: 0;
}
.bh-end:hover { background: rgba(248,113,113,0.2); }
.bh-end i[data-lucide] svg { width: 12px; height: 12px; stroke: var(--grade-c); }


.btn-batch-next {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  background: rgba(0,255,204,0.1); border: 1px solid rgba(0,255,204,0.35);
  color: var(--accent); padding: 11px 16px; border-radius: var(--radius);
  font-family: var(--font); font-size: 14px; font-weight: 700;
  cursor: pointer; transition: all 0.2s;
}
.btn-batch-next:hover { background: rgba(0,255,204,0.18); }
.btn-batch-next:active { transform: scale(0.97); }
.btn-batch-next i[data-lucide] svg { width: 18px; height: 18px; stroke: var(--accent); }
[data-theme="light"] .btn-batch-next { background: rgba(0,158,127,0.1); border-color: rgba(0,158,127,0.35); }


/* Batch Summary */
.batch-summary-body { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 12px 20px; overflow: hidden; }
.bs-stats { display: flex; gap: 8px; flex-shrink: 0; }
.bs-stat {
  flex: 1; background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 10px; text-align: center; box-shadow: var(--shadow-card);
}
.bs-val { font-size: 28px; font-weight: 900; font-family: var(--mono); color: var(--text); line-height: 1; }
.bs-label { font-size: 10px; color: var(--text-muted); margin-top: 4px; }
.grade-a-text { color: var(--grade-a); }
.grade-b-text { color: var(--grade-b); }
.grade-c-text { color: var(--grade-c); }


.bs-chart-row {
  display: flex;
  gap: 12px;
  flex: 1;
  min-height: 0;
  /* ลบ flex ที่ทำให้ canvas ขยายเต็ม */
}


.bs-chart-row canvas {
  width: 500px !important;
  height: 100% !important;
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 10px;
  box-shadow: var(--shadow-card);
}


.bs-grade-bar-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}


.bs-grade-bar-item {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}


.bs-gbi-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  gap: 4px;
}


.bs-gbi-label {
  font-size: 11px;
  font-weight: 900;
  font-family: var(--mono);
  white-space: nowrap;
}


.bs-gbi-count {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--text-muted);
  flex-shrink: 0;
}
.bs-bar { height: 5px; background: var(--score-bar-bg); border-radius: 99px; overflow: hidden; }
.bs-bar-fill { height: 100%; border-radius: 99px; transition: width 0.8s cubic-bezier(.4,0,.2,1); }
.bs-list { display: flex; gap: 5px; flex-wrap: wrap; overflow-y: auto; padding-bottom: 4px; }
.bs-list::-webkit-scrollbar { height: 3px; }
.bs-item {
  display: flex; align-items: center; gap: 6px;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 6px 10px;
  font-size: 11px; color: var(--text-sub); animation: popIn 0.2s ease;
}
.bs-item-grade {
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 900; font-family: var(--mono); flex-shrink: 0;
}
.bs-footer {
  display: flex; gap: 10px; padding: 12px 20px;
  border-top: 1px solid var(--card-border); background: var(--header-bg); flex-shrink: 0;
}
.bs-footer .btn { flex: 1; justify-content: center; }


/* Offset when batch header active */
body.batch-active .screen {
  top: 42px;
  height: calc(480px - 42px);
}
body.batch-active .theme-toggle { top: 52px; }


/* =========================================
   SPLASH VER LABEL
   ========================================= */
.splash-ver { font-size: 11px; color: var(--text-muted); font-family: var(--mono); margin-top: 6px; }


#screen-settings { display: flex; flex-direction: column; }


.settings-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 24px;
  overflow-y: hidden;
}
.settings-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.settings-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.settings-label i[data-lucide] svg {
  width: 18px; height: 18px;
  stroke: var(--accent);
}
.lang-toggle {
  display: flex;
  gap: 4px;
  background: var(--score-bar-bg);
  border-radius: 99px;
  padding: 3px;
}
.lang-btn {
  padding: 6px 16px;
  border-radius: 99px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active {
  background: var(--accent);
  color: #000;
  box-shadow: 0 2px 8px rgba(0,255,204,0.3);
}
.settings-info {
  margin-top: auto;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.settings-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-sub);
  font-weight: 600;
}
.settings-ver {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--card);
  border: 1px solid var(--card-border);
  padding: 2px 8px;
  border-radius: 99px;
}


#screen-deep-analyze .chart-card {
  display: flex;
  flex-direction: column;
}
#screen-deep-analyze .chart-card canvas {
  flex: 1;
  min-height: 0;
  width: 100% !important;
  height: 100% !important;
}


.result-right .metrics-grid {
  flex: 1;
  align-content: stretch;
  width: 100%;                   /* ← เพิ่ม */
}


.result-right .metrics-grid .metric-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
/* เพิ่ม spacer ระหว่าง metrics และ score bar */
.result-right .result-bar-section {
  margin-top: auto;    /* ← ยังคงดันลงล่าง */
  flex-shrink: 0;
}


/* ══ AI CHAT POPUP ══ */
.chat-fab {
  position: absolute;
  bottom: 20px; right: 20px;
  z-index: 200;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--accent);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 20px rgba(0,255,204,0.4);
  animation: fabPulse 2s ease-in-out infinite;
  transition: transform 0.2s;
}


.chat-fab i,
.chat-fab svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
}


.chat-fab:hover { transform: scale(1.1); }
@keyframes fabPulse {
  0%,100% { box-shadow: 0 4px 20px rgba(0,255,204,0.4); }
  50%      { box-shadow: 0 4px 32px rgba(0,255,204,0.7); }
}


.chat-popup {
  position: absolute;
  bottom: 76px; right: 16px;
  width: 340px; height: 320px;
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  z-index: 200;
  display: none; flex-direction: column;
  overflow: hidden;
  animation: chatPopupIn 0.16s ease-out;
  will-change: opacity, transform;
}
.chat-popup.open { display: flex; }
.chat-modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 250;
  display: none;
  background: transparent;
}
.chat-modal-backdrop.open { display: block; }
.chat-popup.lobby-modal {
  position: absolute;
  left: 50%;
  top: 50%;
  right: auto;
  bottom: auto;
  width: 360px;
  height: 330px;
  transform: translate(-50%, -50%);
  z-index: 260;
}

@keyframes chatPopupIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-popup.lobby-modal.open {
  animation-name: chatLobbyPopupIn;
}
@keyframes chatLobbyPopupIn {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 8px)); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}


.chat-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--card-border);
  background: var(--header-bg); flex-shrink: 0;
}
.chat-title { font-size: 13px; font-weight: 700; color: var(--accent); }
.chat-context-badge {
  flex: 1; font-size: 10px;
  color: var(--text-muted); font-family: var(--mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-close {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer; font-size: 14px;
  padding: 2px 6px; border-radius: 4px;
}
.chat-close:hover { color: var(--text); }


.chat-messages {
  flex: 1; overflow-y: auto; padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--card-border); border-radius: 99px; }


.chat-bubble {
  max-width: 85%; padding: 8px 12px;
  border-radius: 12px; font-size: 12px;
  line-height: 1.6; white-space: pre-wrap; word-break: break-word;
}
.chat-user {
  align-self: flex-end;
  background: var(--accent); color: #000; font-weight: 600;
  border-bottom-right-radius: 4px;
}
.chat-bot {
  align-self: flex-start;
  background: var(--card); color: var(--text);
  border: 1px solid var(--card-border);
  border-bottom-left-radius: 4px;
}
.chat-typing { opacity: 0.6; animation: blink 1s ease-in-out infinite; }


.chat-input-row {
  display: flex; gap: 6px; padding: 8px 10px;
  border-top: 1px solid var(--card-border);
  background: var(--header-bg); flex-shrink: 0;
}
.chat-input {
  flex: 1; background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: var(--font); font-size: 12px;
  padding: 7px 10px; outline: none;
  transition: border-color 0.2s;
}
.chat-input:focus { border-color: var(--accent); }
.chat-send {
  background: var(--accent); color: #000;
  border: none; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 12px; font-weight: 700;
  padding: 7px 14px; cursor: pointer; transition: filter 0.2s;
}
.chat-send:hover { filter: brightness(1.1); }


/* ── Quick Question Chips ── */
.chat-quick-wrap {
  padding: 4px 10px 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.quick-chip {
  background: rgba(0,255,204,0.08);
  border: 1px solid rgba(0,255,204,0.25);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 11px;
  color: var(--accent);
  cursor: pointer;
  font-family: 'Prompt', sans-serif;
  transition: all 0.15s;
  white-space: nowrap;
}
.quick-chip:hover,
.quick-chip:active {
  background: rgba(0,255,204,0.18);
  border-color: rgba(0,255,204,0.5);
}


/* ── Chat Header Avatar ── */
.chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0,255,204,0.15);
  border: 1px solid rgba(0,255,204,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-avatar svg {
  width: 14px;
  height: 14px;
  stroke: var(--accent);
}


/* ── Chat Header Info (title + badge) ── */
.chat-header-info {
  flex: 1;
  min-width: 0;
}


/* ── Chat Close Button ── */
.chat-close {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.chat-close:hover {
  background: rgba(255,255,255,0.12);
  color: var(--text);
}
.chat-close svg {
  width: 13px;
  height: 13px;
}

.emoji-img {
  /* ขนาดมาตรฐานที่ดูเหมือน Emoji */
  width: 1.6em; 
  height: 1.6em;
        
  /* จัดวางให้อยู่กึ่งกลางบรรทัดเดียวกับข้อความ */
  vertical-align: middle;
        
  /* ระยะห่างเล็กน้อยระหว่างรูปกับตัวอักษร */
  margin: 0 2px;
        
  /* ป้องกันรูปเบลอ (สำหรับไอคอนขนาดเล็ก) */
  image-rendering: -webkit-optimize-contrast;
}
