:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --border: rgba(0, 0, 0, 0.06);
  --accent: #cb1b32;
  /* Brand medical red color from the logo */
  --accent-hover: #a81427;
  --accent-light: rgba(203, 27, 50, 0.1);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* =========================================================
   Base reset
   ========================================================= */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body.app {
  display: flex;
  flex-direction: column;
}

/* =========================================================
   Top bar
   ========================================================= */
.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: white;
  box-shadow: var(--shadow);
  z-index: 10;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.account-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: white;
  opacity: 0.95;
}

#btnLogout {
  background: white;
  color: var(--accent);
  padding: 0.4rem 1rem;
  font-size: 0.8rem;
  border-radius: 0.75rem;
  text-transform: none;
  font-weight: 700;
  border: 1.5px solid white;
}

#btnLogout:hover {
  background: var(--surface-alt);
  border-color: var(--surface-alt);
  color: var(--accent-hover);
  transform: translateY(-1px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  height: 60px;
  width: auto;
  transition: transform 0.2s ease;
  cursor: pointer;
}

.logo:hover {
  transform: scale(1.05);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.subtitle {
  font-size: 0.875rem;
  opacity: 0.9;
}

.aitg {
  height: 60px;
  width: auto;
  transition: transform 0.2s ease;
  cursor: pointer;
}

.aitg:hover {
  transform: scale(1.05);
}

/* =========================================================
   Main layout
   ========================================================= */
.newlayout {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 1rem;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
  overflow: hidden;
  /* Critical for inner scrolling */
}

/* =========================================================
   Avatar card
   ========================================================= */
.card.avatar {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1.25rem;
  align-items: center;
  background: var(--surface);
  border-radius: 1.25rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  min-height: 0;
  overflow: hidden;
  /* Ensure grid/flex containment */
}

@media (max-width: 1023px) {
  .avatar-content {
    display: contents;
    /* Only use display: contents on layouts where card.avatar is a grid */
  }

  .avatar-actions {
    grid-column: 1 / -1;
  }
}

.avatar-img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 1rem;
  border: 2px solid var(--accent-light);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.avatar-controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.avatar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  flex-shrink: 0;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.control-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.toggle-group {
  display: flex;
  background: var(--surface-alt);
  padding: 0.25rem;
  border-radius: 0.75rem;
  gap: 0.25rem;
}

.btn-toggle {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.4rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  color: var(--muted);
}

.btn-toggle.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
  font-weight: 800;
}

.btn-toggle img {
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.btn-toggle:hover:not(.active) {
  background: rgba(0, 0, 0, 0.03);
}

.styled-select {
  width: 100%;
  padding: 0.65rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background-color: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  background-size: 1.1em;
  padding-right: 2.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.styled-select:hover {
  border-color: rgba(0, 0, 0, 0.15);
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  transform: translateY(-1px);
}

.styled-select:focus {
  background-color: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-light), 0 2px 6px rgba(0,0,0,0.04);
  transform: translateY(0);
}

.styled-select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background-color: var(--surface-alt);
  transform: none;
  box-shadow: none;
}

.avatar-name {
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1.35;
}

.avatar-status {
  font-size: 0.875rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0px rgba(34, 197, 94, 0.7);
  }

  70% {
    box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
  }

  100% {
    box-shadow: 0 0 0 0px rgba(34, 197, 94, 0);
  }
}

/* =========================================================
   Chat Area (Field)
   ========================================================= */
.field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--surface);
  border-radius: 1.5rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 0;
  /* Allow the field to shrink to fit the screen */
}

.chat-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

/* =========================================================
   Chat feed
   ========================================================= */
.chat-feed {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.chat-feed::-webkit-scrollbar {
  width: 6px;
}

.chat-feed::-webkit-scrollbar-track {
  background: transparent;
}

.chat-feed::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 20px;
}

/* =========================================================
   Messages
   ========================================================= */
.msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg.bot {
  align-self: flex-start;
}

.msg.user {
  align-self: flex-end;
}

.msg-meta {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.25rem;
  margin-left: 0.5rem;
}

.msg.user .msg-meta {
  margin-left: 0;
  margin-right: 0.5rem;
  text-align: right;
}

.bubble {
  padding: 0.875rem 1.25rem;
  border-radius: 1.5rem;
  font-size: 1rem;
  line-height: 1.6;
  white-space: pre-wrap;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.msg.bot .bubble {
  background: var(--surface-alt);
  color: var(--text);
  border-bottom-left-radius: 0.25rem;
  border: 1px solid var(--border);
}

.msg.user .bubble {
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 0.25rem;
}

/* =========================================================
   Typing Indicator Animation
   ========================================================= */
.typing-dots {
  display: flex;
  gap: 3px;
  padding: 2px 0;
  align-items: center;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  background: var(--muted);
  border-radius: 50%;
  display: inline-block;
  animation: typing-bounce 1.4s infinite ease-in-out both;
  opacity: 0.6;
}

.msg.bot.typing .bubble {
  padding: 0.4rem 0.6rem !important;
  width: fit-content !important;
  max-width: 60px !important;
  min-height: 0 !important;
  line-height: 0 !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

.typing-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typing-bounce {

  0%,
  80%,
  100% {
    transform: scale(0);
  }

  40% {
    transform: scale(1.0);
  }
}

/* =========================================================
   Input Area
   ========================================================= */
.input-group {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  /* Align input and send button at the bottom */
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.input-container {
  flex: 1;
  position: relative;
}

input[type="text"] {
  width: 100%;
  padding: 0.875rem 1.25rem;
  border-radius: 2rem;
  border: 2px solid var(--surface-alt);
  background: var(--surface-alt);
  font-size: 0.95rem;
  line-height: 1.5;
  transition: all 0.2s ease;
  outline: none;
}

input[type="text"]:focus {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-light);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 2rem;
  cursor: pointer;
  font-weight: 700;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: white;
  padding: 0.75rem 1.75rem;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-primary:active {
  transform: translateY(0);
}

#btnRecord {
  padding: 0.65rem 1rem;
  font-size: 0.875rem;
  background: var(--accent);
  color: white;
  width: 100%;
  box-shadow: var(--shadow-sm);
  transition: background 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}

#btnRecord.recording {
  background: #f87171 !important;
  opacity: 1 !important;
}

@media (hover: hover) {
  #btnRecord:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
  }
}

.btn-evaluate {
  background: #f59e0b;
  color: white;
  padding: 0.65rem 1rem;
  font-size: 0.875rem;
  width: 100%;
  box-shadow: var(--shadow-sm);
  transition: background 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}

@media (hover: hover) {
  .btn-evaluate:hover:not(:disabled) {
    background: #d97706;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
  }
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
  /* Prevents interactions while disabled */
}

#btnSend {
  border-radius: 50%;
  width: 44px;
  height: 44px;
  padding: 0;
}

/* =========================================================
   Notes & Footer
   ========================================================= */
.footer-area {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.note-box {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
  text-align: center;
}

.note-box small {
  display: block;
}

.note-box a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.note-box a:hover {
  text-decoration: underline;
}

.site-footer {
  text-align: center;
  padding: 0.25rem;
  font-size: 0.7rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 640px) {
  .topbar {
    padding: 0.5rem 1rem;
  }

  .logo {
    height: 60px;
  }

  .title {
    font-size: 1.1rem;
  }

  .newlayout {
    padding: 1rem;
    /* Reduced from 2rem to give cards more space */
    gap: 1.5rem;
  }

  .card.avatar {
    padding: 0.85rem;
    grid-template-columns: auto 1fr;
    gap: 0.75rem;
  }

  .avatar-actions {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
  }

  .avatar-actions #btnRecord,
  .avatar-actions #btnEvaluate {
    width: 100%;
    padding: 0.65rem 1rem;
    font-size: 0.875rem;
  }

  .field {
    padding: 1rem;
    border-radius: 1rem;
  }

  .avatar-controls {
    grid-column: 1 / -1;
    flex-direction: row;
    gap: 0.75rem;
  }

  .control-group {
    flex: 1;
  }

  .control-label {
    font-size: 0.65rem;
  }

  .msg {
    max-width: 90%;
  }
}

/* =========================================================
   Tablet Layout
   ========================================================= */
@media (min-width: 641px) and (max-width: 1023px) {
  .avatar-actions {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: row;
    gap: 0.75rem;
    width: 100%;
  }

  .avatar-actions #btnRecord,
  .avatar-actions #btnEvaluate {
    flex: 1;
    width: auto;
    padding: 0.65rem 1rem;
    font-size: 0.875rem;
  }
}

/* =========================================================
   Desktop Layout (Split Screen)
   ========================================================= */
@media (min-width: 1024px) {
  .topbar {
    padding: 1rem 2rem;
  }

  .newlayout {
    max-width: none;
    margin: 0;
    padding: 1rem 2rem;
    display: grid;
    grid-template-columns: 380px 1fr;
    grid-template-rows: 1fr auto;
    grid-template-areas:
      "sidebar main"
      "footer footer";
    gap: 1.5rem;
    height: 100%;
    align-items: stretch;
  }

  .card.avatar {
    grid-area: sidebar;
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1.5rem;
    border-radius: 2.5rem;
    box-shadow: var(--shadow-lg);
    background: var(--surface);
    height: 100%;
    overflow: hidden;
  }

  .avatar-content {
    width: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    text-align: center;
    gap: 0.6rem;
    overflow-y: auto;
  }

  .avatar-content::-webkit-scrollbar {
    width: 4px;
  }

  .avatar-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 4px;
  }

  .avatar-img {
    width: clamp(100px, 16vh, 140px);
    height: clamp(100px, 16vh, 140px);
    border-radius: 2rem;
    border-width: 4px;
    margin-bottom: 0rem;
    flex-shrink: 0;
  }

  .avatar-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
  }

  .avatar-controls {
    width: 100%;
    flex-shrink: 0;
    margin-top: 0.5rem;
    gap: 0.65rem;
  }

  .avatar-name {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
  }

  .avatar-status {
    font-size: 0.875rem;
    background: var(--surface-alt);
    padding: 0.25rem 0.8rem;
    border-radius: 2rem;
  }

  .avatar-actions {
    width: 100%;
    margin-top: auto;
    padding-top: 0.65rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-shrink: 0;
  }

  #btnRecord,
  #btnEvaluate {
    width: 100%;
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    border-radius: 2rem;
    border: none;
  }

  .field {
    grid-area: main;
    border-radius: 2.5rem;
    padding: 1.5rem 2.5rem;
    /* Reduced top padding */
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    height: 100%;
  }

  .chat-feed {
    padding-right: 1.5rem;
  }

  #ui-input-label {
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--muted);
  }

  .input-group {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    background: var(--surface);
  }

  .msg {
    max-width: 75%;
  }

  .footer-area {
    grid-area: footer;
    margin-top: 0;
    padding: 0 1rem;
    opacity: 0.8;
  }

  .note-box {
    text-align: center;
    font-size: 0.85rem;
  }

  .site-footer {
    text-align: center;
    padding-left: 0;
    border-top: none;
    margin-top: 0.5rem;
  }
}

@media (min-width: 1024px) and (max-height: 800px) {
  .card.avatar {
    padding: 0.9rem 1.25rem;
  }
  .avatar-img {
    width: 100px;
    height: 100px;
    border-radius: 1.5rem;
    border-width: 3px;
  }
  .avatar-name {
    font-size: 1.05rem;
  }
  .avatar-status {
    font-size: 0.8rem;
    padding: 0.2rem 0.65rem;
  }
  .avatar-controls {
    margin-top: 0.35rem;
    gap: 0.4rem;
  }
  .control-group {
    gap: 0.2rem;
  }
  .control-label {
    font-size: 0.625rem;
  }
  .btn-toggle {
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
  }
  .styled-select {
    padding: 0.45rem 0.75rem;
    font-size: 0.8rem;
  }
  .avatar-actions {
    margin-top: auto;
    padding-top: 0.35rem;
    gap: 0.35rem;
  }
  #btnRecord,
  #btnEvaluate {
    padding: 0.55rem 1rem;
    font-size: 0.875rem;
  }
}

/* =========================================================
   Auth Overlay
   ========================================================= */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem 1rem;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.auth-overlay::-webkit-scrollbar {
  width: 6px;
}

.auth-overlay::-webkit-scrollbar-track {
  background: transparent;
}

.auth-overlay::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 9999px;
}

.auth-overlay::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

.auth-card {
  background: var(--surface);
  padding: 2.25rem 2.5rem;
  border-radius: 2rem;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border);
  text-align: center;
  animation: slideIn 0.4s ease-out;
  position: relative;
  margin: auto;
  flex-shrink: 0;
}


.auth-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  width: 100%;
}

.auth-logo {
  height: 48px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  margin-bottom: 0;
}

.auth-lang-toggle {
  display: flex;
  align-items: center;
}


.auth-card h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
}

.auth-card p {
  color: var(--muted);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-input-group {
  text-align: left;
}

.auth-input-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
  margin-left: 1rem;
}

.auth-input-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  padding: 0 1rem;
}

.auth-input-header label {
  margin: 0;
  display: inline-block;
}

.auth-forgot-link {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.2s;
}

.auth-forgot-link:hover {
  text-decoration: underline;
  opacity: 0.85;
}

.auth-form input {
  width: 100%;
  padding: 0.875rem 1.25rem;
  border-radius: 2rem;
  border: 2px solid var(--surface-alt);
  background: var(--surface-alt);
  font-size: 1rem;
  transition: all 0.2s ease;
  outline: none;
}

.auth-form input:focus {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-light);
}

.auth-btn {
  margin-top: 1rem;
  padding: 1rem;
  font-size: 1.1rem;
}

.auth-switch {
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--muted);
  user-select: none;
}

.auth-switch a,
.auth-switch .auth-switch-action {
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  margin-left: 0.35rem;
}

.auth-switch a:hover,
.auth-switch .auth-switch-action:hover {
  text-decoration: underline;
}

.auth-error {
  color: #ef4444;
  font-size: 0.85rem;
  margin-top: 0.5rem;
  min-height: 1.25rem;
  line-height: 1.4;
}

.auth-unverified-box {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 0.85rem;
  padding: 0.85rem 1rem;
  margin-top: 0.5rem;
  text-align: left;
}

.auth-unverified-msg {
  color: #ef4444;
  font-size: 0.85rem;
  line-height: 1.45;
  margin-bottom: 0.65rem;
}

.btn-resend-verify {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--accent);
  color: #ffffff;
  border: none;
  padding: 0.5rem 0.9rem;
  border-radius: 0.6rem;
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(203, 27, 50, 0.2);
}

.btn-resend-verify:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-resend-verify:active:not(:disabled) {
  transform: translateY(0);
}

.btn-resend-verify:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-notice {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #059669;
  padding: 0.85rem 1rem;
  border-radius: 0.85rem;
  font-size: 0.85rem;
  line-height: 1.45;
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
  text-align: left;
}

.auth-terms-group {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.35rem;
  margin-bottom: 0.25rem;
  text-align: left;
}

.auth-checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.825rem;
  line-height: 1.4;
  color: var(--text);
}

.auth-checkbox-group input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin: 2px 0 0 0;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.auth-checkbox-group label {
  font-size: 0.825rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  font-weight: 500;
  text-transform: none;
  margin: 0;
}

.auth-checkbox-group a {
  color: var(--accent);
  text-decoration: underline;
  font-weight: 700;
  cursor: pointer;
}

.auth-checkbox-group a:hover {
  color: var(--accent-hover);
}

.auth-checkbox-group input[type="checkbox"]:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.legal-link-disabled {
  pointer-events: none !important;
  opacity: 0.45 !important;
  cursor: not-allowed !important;
  text-decoration: underline dotted !important;
  color: var(--muted) !important;
}

.clarification-hint {
  font-size: 0.76rem;
  margin-top: -0.2rem;
  margin-bottom: 0.25rem;
  padding-left: 1.65rem;
  line-height: 1.35;
  transition: all 0.2s ease;
}

@media (max-width: 480px) {
  .auth-overlay {
    padding: 1rem 0.5rem;
  }
  .auth-card {
    padding: 1.5rem 1.25rem;
    border-radius: 1.5rem;
  }
}

/* Low-height screen adaptations for Login & Signup */
@media (max-height: 880px) {
  .auth-overlay {
    padding: 1rem 0.75rem;
  }
  .auth-card {
    padding: 1.5rem 1.75rem;
    border-radius: 1.5rem;
    max-width: 410px;
  }
  .auth-top-bar {
    margin-bottom: 0.85rem;
  }
  .auth-logo {
    height: 38px;
  }
  .auth-lang-toggle .btn-toggle {
    padding: 0.25rem 0.55rem;
    font-size: 0.78rem;
  }
  .auth-card h2 {
    font-size: 1.45rem;
    margin-bottom: 0.25rem;
  }
  .auth-card p {
    font-size: 0.875rem;
    margin-bottom: 1rem;
  }
  .auth-form {
    gap: 0.65rem;
  }
  .auth-input-group label {
    font-size: 0.72rem;
    margin-bottom: 0.25rem;
    margin-left: 0.75rem;
  }
  .auth-input-header {
    margin-bottom: 0.25rem;
    padding: 0 0.75rem;
  }
  .auth-forgot-link {
    font-size: 0.75rem;
  }
  .auth-form input {
    padding: 0.65rem 1.1rem;
    font-size: 0.92rem;
    border-radius: 1.5rem;
  }
  .auth-terms-group {
    gap: 0.45rem;
    margin-top: 0.2rem;
    margin-bottom: 0.15rem;
  }
  .auth-checkbox-group {
    gap: 0.5rem;
    font-size: 0.76rem;
    line-height: 1.35;
  }
  .auth-checkbox-group input[type=checkbox] {
    width: 15px;
    height: 15px;
    margin-top: 1px;
  }
  .auth-checkbox-group label {
    font-size: 0.76rem;
  }
  .clarification-hint {
    font-size: 0.72rem;
    padding-left: 1.45rem;
    margin-top: -0.15rem;
    margin-bottom: 0.15rem;
  }
  .auth-btn {
    margin-top: 0.65rem;
    padding: 0.75rem;
    font-size: 1rem;
    border-radius: 1.5rem;
  }
  .auth-switch {
    margin-top: 0.85rem;
    font-size: 0.825rem;
  }
  .auth-error {
    font-size: 0.8rem;
    margin-top: 0.35rem;
    min-height: 1rem;
  }
  .auth-notice {
    padding: 0.65rem 0.85rem;
    font-size: 0.8rem;
    margin-top: 0.5rem;
    margin-bottom: 0.35rem;
  }
  .auth-unverified-box {
    padding: 0.65rem 0.85rem;
    margin-top: 0.35rem;
  }
  .auth-unverified-msg {
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
  }
}

@media (max-height: 720px) {
  .auth-overlay {
    padding: 0.75rem 0.5rem;
  }
  .auth-card {
    padding: 1.15rem 1.4rem;
    border-radius: 1.25rem;
    max-width: 390px;
  }
  .auth-top-bar {
    margin-bottom: 0.6rem;
  }
  .auth-logo {
    height: 32px;
  }
  .auth-lang-toggle .btn-toggle {
    padding: 0.22rem 0.45rem;
    font-size: 0.74rem;
  }
  .auth-card h2 {
    font-size: 1.25rem;
    margin-bottom: 0.15rem;
  }
  .auth-card p {
    font-size: 0.8rem;
    margin-bottom: 0.7rem;
  }
  .auth-form {
    gap: 0.45rem;
  }
  .auth-input-group label {
    font-size: 0.68rem;
    margin-bottom: 0.2rem;
    margin-left: 0.5rem;
  }
  .auth-input-header {
    margin-bottom: 0.2rem;
    padding: 0 0.5rem;
  }
  .auth-forgot-link {
    font-size: 0.7rem;
  }
  .auth-form input {
    padding: 0.5rem 0.9rem;
    font-size: 0.85rem;
    border-radius: 1.25rem;
  }
  .auth-terms-group {
    gap: 0.35rem;
    margin-top: 0.15rem;
    margin-bottom: 0.1rem;
  }
  .auth-checkbox-group {
    gap: 0.45rem;
    font-size: 0.71rem;
    line-height: 1.26;
  }
  .auth-checkbox-group input[type=checkbox] {
    width: 14px;
    height: 14px;
    margin-top: 1px;
  }
  .auth-checkbox-group label {
    font-size: 0.71rem;
  }
  .clarification-hint {
    font-size: 0.68rem;
    padding-left: 1.35rem;
    margin-top: -0.1rem;
    margin-bottom: 0.1rem;
  }
  .auth-btn {
    margin-top: 0.5rem;
    padding: 0.6rem;
    font-size: 0.925rem;
    border-radius: 1.25rem;
  }
  .auth-switch {
    margin-top: 0.65rem;
    font-size: 0.78rem;
  }
}

@media (max-height: 600px) {
  .auth-overlay {
    padding: 0.5rem 0.4rem;
  }
  .auth-card {
    padding: 0.85rem 1.15rem;
    border-radius: 1rem;
    max-width: 370px;
  }
  .auth-top-bar {
    margin-bottom: 0.35rem;
  }
  .auth-logo {
    height: 26px;
  }
  .auth-lang-toggle .btn-toggle {
    padding: 0.18rem 0.38rem;
    font-size: 0.7rem;
  }
  .auth-card h2 {
    font-size: 1.1rem;
    margin-bottom: 0.1rem;
  }
  .auth-card p {
    font-size: 0.75rem;
    margin-bottom: 0.45rem;
  }
  .auth-form {
    gap: 0.35rem;
  }
  .auth-input-group label {
    font-size: 0.64rem;
    margin-bottom: 0.12rem;
    margin-left: 0.4rem;
  }
  .auth-input-header {
    margin-bottom: 0.12rem;
    padding: 0 0.4rem;
  }
  .auth-forgot-link {
    font-size: 0.66rem;
  }
  .auth-form input {
    padding: 0.38rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 1rem;
  }
  .auth-terms-group {
    gap: 0.25rem;
    margin-top: 0.1rem;
    margin-bottom: 0.05rem;
  }
  .auth-checkbox-group {
    gap: 0.35rem;
    font-size: 0.66rem;
    line-height: 1.2;
  }
  .auth-checkbox-group input[type=checkbox] {
    width: 13px;
    height: 13px;
    margin-top: 1px;
  }
  .auth-checkbox-group label {
    font-size: 0.66rem;
  }
  .clarification-hint {
    font-size: 0.64rem;
    padding-left: 1.2rem;
  }
  .auth-btn {
    margin-top: 0.4rem;
    padding: 0.5rem;
    font-size: 0.85rem;
    border-radius: 1rem;
  }
  .auth-switch {
    margin-top: 0.45rem;
    font-size: 0.72rem;
  }
}

/* =========================================================
   Credit Badge & Indicators
   ========================================================= */
.credit-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: white;
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.825rem;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  transition: all 0.25s ease;
  user-select: none;
}

.credit-badge:hover {
  background: rgba(255, 255, 255, 0.24);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-1px);
}

.credit-badge .credit-icon {
  width: 16px;
  height: 16px;
  color: #fbbf24; /* Warm gold */
  flex-shrink: 0;
}

.credit-badge .credit-label {
  font-size: 0.75rem;
  opacity: 0.9;
  letter-spacing: 0.02em;
}

.credit-badge .credit-amount {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}

.credit-badge.credit-warning {
  background: rgba(245, 158, 11, 0.25);
  border-color: rgba(245, 158, 11, 0.7);
  color: #fef3c7;
}

.credit-badge.credit-warning .credit-icon {
  color: #f59e0b;
}

.credit-badge.credit-danger {
  background: rgba(239, 68, 68, 0.3);
  border-color: rgba(239, 68, 68, 0.8);
  color: #fee2e2;
  animation: creditPulse 2s infinite ease-in-out;
}

.credit-badge.credit-danger .credit-icon {
  color: #ef4444;
}

@keyframes creditPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
  }
}

/* Helper Utilities */
.is-hidden {
  display: none !important;
}

/* =========================================================
   Cookie Consent Banner
   ========================================================= */
.cookie-banner {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(140%);
  max-width: 760px;
  width: calc(100% - 2rem);
  z-index: 10001;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 20px 35px -8px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.08);
  border-radius: 1rem;
  padding: 1.1rem 1.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
}

.cookie-banner.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.cookie-banner-content {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex: 1;
  min-width: 0;
}

.cookie-banner-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}

.cookie-banner-text {
  font-size: 0.85rem;
  line-height: 1.5;
  color: #e2e8f0;
}

.cookie-banner-text a {
  color: #fca5a5;
  text-decoration: underline;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s ease;
}

.cookie-banner-text a:hover {
  color: #ffffff;
}

.cookie-banner-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.btn-cookie-accept {
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.6rem 1.35rem;
  border-radius: 0.65rem;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(203, 27, 50, 0.35);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-cookie-accept:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(203, 27, 50, 0.45);
}

@media (max-width: 640px) {
  .cookie-banner {
    bottom: 1rem;
    width: calc(100% - 1.5rem);
    padding: 1rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }
  
  .cookie-banner-content {
    align-items: flex-start;
    gap: 0.75rem;
  }

  .cookie-banner-actions {
    width: 100%;
  }

  .btn-cookie-accept {
    width: 100%;
    text-align: center;
    padding: 0.75rem;
  }
}