/* ==========================================================================
   Qahwa AI — Base styles (every page via templates/root.html)
   Formerly static/root.v45.css. Colors come from css/tokens.css.
   ========================================================================== */

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

/* Font Definition
   Beiruti is a variable font (weights 200–900). Declaring the full range gives
   real bold glyphs instead of browser-synthesised "faux bold", and the Latin
   subset keeps usernames, numbers and "Pro"/"AI" in the same family instead of
   falling back to another font. Files: Google Fonts v5, display=swap. */
@font-face {
  font-family: 'Beiruti';
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/beiruti/v5/JTUXjIU69Cmr9FGcSA1t4FZA.woff2) format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF,
                 U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC,
                 U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC4, U+10EFC-10EFF, U+1EE00-1EE03,
                 U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37,
                 U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52,
                 U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64,
                 U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89,
                 U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}

@font-face {
  font-family: 'Beiruti';
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/beiruti/v5/JTUXjIU69Cmr9FGcSAht4A.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
                 U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Base Body Styles */
html {
  background-color: var(--q-surface-0);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background-color: var(--background-color);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--font-family);
  color: var(--text-color-primary); /* Default text color for body */
  /* Natural (start) alignment: justified Arabic in narrow phone columns opens wide gaps */
  text-align: start;
  line-height: 1.7;
  word-break: break-word;
  /* Beiruti's space glyph is narrow (~0.1em at bold weights); real variable
     weights expose it, so add a touch of word spacing for readable Arabic. */
  word-spacing: 0.08em;
  /* Crisper light-on-black text on macOS/iOS */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  margin-top: 100px;
}

header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 5px;
  padding-top: max(10px, var(--q-safe-top));
  border-bottom: 0.5px solid var(--q-border-subtle);
  z-index: 999;

  /* Black glass bar */
  background: var(--q-header-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow:
    inset 0 -1px 0 rgb(var(--q-fg-rgb) / 0.04),
    0 4px 24px rgb(var(--q-shade-rgb) / calc(0.3 * var(--q-shadow-k)));
}

.head-left {
  display: flex;
  align-items: center;
}

.head-left img {
  height: 75px;
}

header .header-title {
  color: var(--color-primary);
}

header .upmenu {
  display: flex;
  justify-content: space-between;
  width: 50%;
  word-break: normal
}

header .upmenu li {
  list-style: none;
  margin: 0 10px;
}

header a {
  text-decoration: none;
  color: var(--text-color-primary);
  font-weight: 900;
  font-size: 15px;
}

header a:hover {
  color: var(--text-color-primary);
  text-shadow: 0 0 15px var(--color-secondary);
}

.head-right {
  display: flex;
  align-items: center;
}

.navq {
  position: relative;
  margin-right: 25px;
  border-radius: var(--button-radius);
  background-size: 200%;

}

.head-right button {
  inset: 3px 3px 3px 3px;
  border: none;
  background: transparent;
  color: var(--text-color-primary);
  cursor: pointer;
  border-radius: var(--button-radius);

  transition: 0.3s ease-in-out;
  font-size: large;
  font-weight: 700;

}

.head-right button:hover {
  color: var(--text-color-primary);
  background: transparent;
  font-weight: 900;
  font-size: larger;
  box-shadow: 0 0 15px var(--color-primary);
}

.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90%;
  height: 100vh;
  overflow: hidden;
}

.hero h1 {
  display: flex;
  margin-top: 7%;
  font-size: 50px;
  max-width: 1000px;
  text-align: center;
  color: var(--color-primary);
  line-height: 2;

}

.hero h3 {
  top: 15%;
  font-size: 20px;
  max-width: 700px;
  text-align: center;
  color: var(--color-primary);
}

.d3button {
  /* Basic button styling */
  margin-top: 5%;
  display: inline-block;
  width: 220px;
  height: 70px;
  line-height: 70px;
  font-weight: 700;
  font-size: 30px;
  padding: 0 20px;
  border-radius: 16px; /* Rounded edges for 3D look */
  color: var(--q-on-accent);
  background-color: var(--color-primary);
  text-align: center;
  border: none;
  text-decoration: none;
  cursor: pointer;
  position: fixed;
  bottom: 10px;
  overflow: hidden;
  direction: rtl; /* Right-to-left for Arabic text */
  z-index: 100;
  user-select: none;

  touch-action: manipulation; /* Improves mobile touch responsiveness */
  -webkit-tap-highlight-color: transparent; /* Removes default tap highlight */

  /* Inner shadow and gradient for bulging effect */
  background-image: radial-gradient(
    circle at 30% 30%, /* Light source for bulge */
    rgba(255, 255, 255, 0.4) 0%, /* Highlight */
    rgba(255, 255, 255, 0.1) 50%,
    transparent 70%
  );
  box-shadow:
    inset 0 -2px 4px rgb(var(--q-shade-rgb) / calc(0.2 * var(--q-shadow-k))), /* Inner shadow for depth */
    inset 0 2px 4px rgba(255, 255, 255, 0.3), /* Inner highlight */
    0 4px 8px rgb(var(--q-shade-rgb) / calc(0.2 * var(--q-shadow-k))); /* Subtle outer shadow for lift */

  /* Smooth transition for interactions */
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;

  color: var(--q-on-accent);
  background: linear-gradient(45deg, #301a76, #e50e37);

}

/* Hover effect: enhance bulge and lift (desktop) */
.d3button:hover {
  transform: translateY(-3px); /* Slight lift */
  box-shadow:
    inset 0 -3px 6px rgb(var(--q-shade-rgb) / calc(0.2 * var(--q-shadow-k))),
    inset 0 3px 6px rgba(255, 255, 255, 0.3),
    0 8px 16px rgb(var(--q-shade-rgb) / calc(0.3 * var(--q-shadow-k))); /* Stronger outer shadow */
}

/* Focus effect: similar to hover for accessibility */
.d3button:focus {
  outline: none; /* Removes default focus outline */
  transform: translateY(-3px); /* Same lift as hover */
  box-shadow:
    inset 0 -3px 6px rgb(var(--q-shade-rgb) / calc(0.2 * var(--q-shadow-k))),
    inset 0 3px 6px rgba(255, 255, 255, 0.3),
    0 8px 16px rgb(var(--q-shade-rgb) / calc(0.3 * var(--q-shadow-k))); /* Same shadow as hover */
}

/* Active effect: press down, reduce bulge (mobile tap and click) */
.d3button:active {
  transform: translateY(2px); /* Push down */
  box-shadow:
    inset 0 3px 6px rgb(var(--q-shade-rgb) / calc(0.3 * var(--q-shadow-k))), /* Deeper inner shadow */
    inset 0 -3px 6px rgba(255, 255, 255, 0.2),
    0 3px 6px rgb(var(--q-shade-rgb) / calc(0.1 * var(--q-shadow-k))); /* Reduced outer shadow */
}

main {
  flex-grow: 1;
}

header, footer {
  flex-shrink: 0;
}

/* Utility Class for Loading Transition */
body.loading-transition {
  opacity: 0.7;
  pointer-events: none; /* Prevent further clicks during transition */
}

.navq > a { /* Direct child 'a' (logo link) */
  display: flex; /* Helps with vertical alignment of image if needed */
  align-items: center;
}

.navq img { /* Logo image */
  height: auto; /* Allow image to scale based on width, if style attribute for height is removed */

}

/* ================== General Page Title & Buttons ================== */

.g_title {
  font-size: clamp(24px, 5vw, 32px); /* Responsive font size */
  color: var(--text-color-light);
  text-align: center;
  padding: 15px;
  background: linear-gradient(45deg, #000, #301a76);
  border-radius: 40px;
  margin: 10px 20px;
  box-shadow: 0.3em 0.3em 1em rgba(126, 120, 108, 0.527);

  align-self: center;

}

.g_text {
  font-size: 28px;

  text-align: center;
  padding: 10px;
  border-radius: 10px;
  display: inline-block;
  text-decoration: none;
  border: none;
  background: linear-gradient(45deg, var(--color-primary), var(--color-secondary));
  -webkit-background-clip: text;
  background-clip: text;

  text-shadow: 0 2px 4px rgb(var(--q-shade-rgb) / calc(0.3 * var(--q-shadow-k)));
}

.q_title {

  font-size: 28px;
  color: var(--primary-color);
  text-align: center;
  text-decoration: none;
  border: none;
  background: linear-gradient(45deg, var(--color-primary), var(--color-secondary));
  -webkit-background-clip: text;
  background-clip: text;

  text-shadow: 0 2px 4px rgb(var(--q-shade-rgb) / calc(0.3 * var(--q-shadow-k)));
  line-height: 1;
}

.q_button, .g_button {
  display: inline-flex; /* For aligning icon and text */
  align-items: center;
  justify-content: center;
  gap: 8px; /* Space between icon and text */
  font-size: 20px;
  text-align: center;
  padding: 10px 15px;
  border-radius: 10px;
  text-decoration: none;
  border: none; /* If it's a button element */
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.q_button {
  color: var(--q-on-accent);
  background: linear-gradient(45deg, #301a76, #e50e37);
  box-shadow: 0.1em 0.1em 0.5em rgba(200, 0, 0, 0.2);
  margin-bottom: 10px; /* Default margin */
}
.q_button:hover, .q_button:focus {
  transform: scale(1.05);
  box-shadow: 0.2em 0.2em 0.7em rgba(200, 0, 0, 0.3);
  outline: none;
}

.g_button {
  color: var(--text-color-dark); /* Default, overridden by inline style sometimes */
  background-color: var(--background-color-light); /* Default */
  box-shadow: 0.1em 0.1em 0.5em rgb(var(--q-shade-rgb) / calc(0.6 * var(--q-shadow-k)));
  margin: 10px;
}
.g_button:hover, .g_button:focus {
  transform: scale(1.05);
  box-shadow: 0.1em 0.1em 0.7em rgba(0, 93, 200, 0.6);
  outline: none;
}

/* Google Button Specific Colors */
.g-blue{ color:#4285F4; }
.o-red{ color:#DB4437; }
.o-yellow{ color:#F4B400; }
.l-green{ color:#0F9D58; }
.e-red { display:inline-block;transform:rotate(-20deg); }

/* ================== Gallery & Cards Styles ================== */
.gallery {
  display: flex;
  justify-content: center;

  margin-bottom: 30px;
}

.gallery .images {
  gap: 20px; /* Increased gap */
  width: 90%; /* Use width for better control than max-width */
  max-width: 1400px; /* Max width for large screens */

  display: flex;
  flex-wrap: wrap;
  justify-content: center; /* Center cards if they don't fill the row */
  align-items: stretch; /* Make cards in a row same height if needed */
}

.images .icard {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  border-radius: 10px;
  list-style: none;

  background-color: rgba(0,0,0,0.3); /* Base background for card */
  width: clamp(280px, 100%, 320px); /* Responsive width */
  min-height: 450px; /* Keep consistent height */
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.images .icard:hover, .images .icard:focus-within {
  transform: scale(1.01);
  box-shadow: 0em 0em 1em rgba(82, 55, 255, 0.8);
  z-index: 5; /* Bring to front on hover */
}

.icard img {
  width: 100%;
  height: 200px; /* Fixed height for image part */
  object-fit: cover;
  object-position: center 25%;
  display: block;
}

.icard img[src=""], .icard img:not([src]) { /* Broken image placeholder */
  background: #ccc;
  height: 200px; /* Match image height */
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  content: "Image not available"; /* Pseudo-content, might not work directly on img */
}

.icard .details {
  flex-grow: 1; /* Take remaining space */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px;
  background: linear-gradient(to top, rgba(0,0,0,0.8), rgba(0,0,0,0.4));
}

.generative {
  color: var(--text-color-light);
  padding-right: 5px; /* Adjust from 10px */
  margin-bottom: 10px;
}
.details .generative span { /* Bot name */
  font-size: 1.4rem; /* Reduced from 1.5rem */
  font-weight: bold;
  display: block; /* Ensure it takes full width */
  margin-bottom: 5px;
  text-align: center;
}
.details .generative .desc {

  font-weight: normal;
  line-height: 1.4;
  margin-left: 0; /* Align with name */
  /* Ellipsis for long descriptions */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: calc(0.95rem * 1.4 * 3); /* Approximate height for 3 lines */
}

.additional-info {
  padding-top: 10px; /* Space above meta/tags */
  font-weight: normal;
  font-size: 0.9rem;
}

.meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-color-light);
  margin-bottom: 10px;
  padding: 0 5px; /* Slight horizontal padding */
}

.meta .creator span { /* For the username part */
  color: var(--primary-color);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px; /* Reduced gap */
  margin-bottom: 5px;
  padding: 0 5px; /* Slight horizontal padding */
}
.tag {

  background: linear-gradient(45deg, #000, #14024b);
  color: var(--q-text-primary);
  padding: 3px 8px; /* Slightly more padding */
  border-radius: 5px; /* More rounded */
  font-size: 0.8rem;
}
.tag.dialect-tag {
  background-color: #550011; /* Specific color for dialect */
  margin-top: 5px;
}

.icard2 {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  align-items: center;
  padding: 10px 30px;
  filter: hue-rotate(4deg) brightness(0.9);
}

.icard2 img {
  height: 200px; /* Fixed height for image part */
  object-fit: cover;
  object-position: center 25%;
  display: block;

  filter: drop-shadow(2px 4px 6px black);
}

.tag2 {

  background: linear-gradient(45deg, #000, #14024b);
  color: var(--q-text-primary);
  padding: 3px 8px; /* Slightly more padding */
  border-radius: 5px; /* More rounded */
  font-size: 0.8rem;
}

/* Container for all buttons */
.char-buttons {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 10;
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

/* ===== Shared button styles ===== */
.char-buttons button {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 3px solid rgba(0, 0, 0, 0.25);;
  cursor: pointer;
  font-size: 20px;
  background-color: rgb(var(--q-fg-rgb) / 0.95);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

/* ===== Icon styling ===== */
.char-buttons ion-icon {
  font-size: 38px;
}

/* ===== Shared button styles ===== */

/* ===== Icon styling ===== */

/* ===== Call & Chat: Always visible ===== */

.card-edit-btn, .card-delete-btn {
  width: 38px;
  height: 38px;
  box-shadow: 0 0 10px rgb(var(--q-shade-rgb) / calc(0.3 * var(--q-shadow-k)));

}

.card-call-btn, .card-chat-btn {
  width: 65px;
  height: 65px;
}

.card-call-btn {
  color: rgb(45, 179, 18);
  box-shadow: 0 0 10px rgb(45, 179, 18);
}

.card-chat-btn {
  color: rgb(0, 132, 255);
  box-shadow: 0 0 10px rgb(0, 132, 255);
}

.card-call-btn:hover,
.card-call-btn:focus {

  color: var(--q-text-primary);
  transform: scale(1.15);
  box-shadow: 0 0 15px rgb(45, 179, 18);
}

.card-chat-btn:hover,
.card-chat-btn:focus {
  color: var(--q-text-primary);
  transform: scale(1.15);
  box-shadow: 0 0 15px #0084ff;
}

/* Style for SVG icons used in cards */
.card-call-btn img,
.card-chat-btn img {
    width: 28px; /* or your desired size */
    height: 28px;
    filter: none; /* If you want them to be white on a dark button */
}

/* ===== Edit & Delete: Hidden until hover/focus ===== */
.card-edit-btn,
.card-delete-btn {
  display: none;
  color: var(--text-color-dark);
}
.icard:hover .card-edit-btn,
.icard:hover .card-delete-btn,
.icard:focus-within .card-edit-btn,
.icard:focus-within .card-delete-btn {
  display: flex;
}
.card-edit-btn:hover,
.card-delete-btn:hover {
  background-color: white;
  transform: scale(1.1);
  box-shadow: 0 4px 10px rgb(var(--q-shade-rgb) / calc(0.3 * var(--q-shadow-k)));
}

/* ================== Lightbox (Modal) Styles ================== */
.overlay {
  width: 100%;
  height: 100%;
  display: none; /* Hidden by default, shown by JS by adding .show */
  background: rgba(0,0,0,0.75); /* Darker backdrop */
  z-index: 1000;
  position: fixed;
  top: 0;
  left: 0;
  overflow: hidden;

}
.overlay.show {
  display: block; /* Show overlay */
  -webkit-pointer-events: auto;
  pointer-events: auto;

}

.lightbox {
  width: 100%;
  height: 100%;
  display: none; /* Hidden by default, shown by JS by adding .show */
  background: rgba(0,0,0,0.65); /* Darker backdrop */
  z-index: 1000;
  position: fixed;
  top: 0;
  left: 0;
  overflow-y: auto; /* Allow scrolling if content is too tall */
}
.lightbox.show {
  display: flex; /* Use flex to center wrapper */
  align-items: center;
  justify-content: center;
}
.lightbox .wrapper {
  /* position, top, left, transform are not needed if lightbox is flex container */
  width: 90%;
  max-width: 500px; /* Reduced from 600px for better fit */
  padding: 25px; /* Increased padding */
  background: var(--background-color-light);
  color: var(--text-color-dark); /* Text inside lightbox */
  border-radius: 8px; /* Softer radius */
  box-shadow: 0 5px 15px rgb(var(--q-shade-rgb) / calc(0.3 * var(--q-shadow-k)));
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.lightbox .wrapper .g_text { /* g_text inside lightbox */
  color: var(--primary-color); /* Ensure consistent color */
}

/* ================== Form Input Styles (Animated Label) ================== */
.inputBox {
  position:relative;
  width: 250px;
  margin: 15px 0; /* Add some margin */
}
.inputBox input {
  width: 100%;
  padding: 10px; /* Consistent padding */
  border: 2px solid rgba(0, 0, 0, 0.25);
  background: white;
  border-radius: 5px;
  outline: none;
  font-size: 1.1em; /* Adjusted */
  transition: border-color 0.3s ease;
  color: var(--text-color-dark);
}
.inputBox span { /* Floating label */
  position: absolute;
  right: 12px; /* Position from right */
  top: 10px;   /* Align with input padding */
  padding: 0 5px; /* Padding for background */
  pointer-events: none;
  font-size: 1.1em;
  color: rgba(0, 0, 0, 0.5);
  background-color: white; /* To cover the input border when floated */
  transition: transform 0.3s ease, font-size 0.3s ease, color 0.3s ease;
}
.inputBox input:focus ~ span,
.inputBox input:valid ~ span {
  transform: translateY(-22px) translateX(0); /* Adjust Y based on font and padding */
  font-size: 0.9em; /* Smaller font when floated */
  color: var(--primary-color);
  font-weight: bold;
}
.inputBox input:focus {
  border-color: var(--primary-color);
}

/* ================== Character Creation Form Styles ================== */
.form-container {
    max-width: 600px;
    margin: 30px auto;
    margin-top: 100px;
    padding: 25px;
    background-color: #bababa;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgb(var(--q-shade-rgb) / calc(0.1 * var(--q-shadow-k)));
    direction: rtl; /* Right-to-left for Arabic */
    text-align: right;
}
.character-form {
  background: #ffe4e4; /* Keep specific form background */
  padding: 2rem;
  border-radius: 10px;
  box-shadow: 0 0 20px rgb(var(--q-shade-rgb) / calc(0.1 * var(--q-shadow-k)));
  width: 100%;
  max-width: 500px;
  color: var(--text-color-dark);
}
.character-form h2 {
  text-align: center;
  color: var(--primary-color);
  margin-bottom: 2rem;
}
.form-group {
  margin-bottom: 1.5rem;
}
.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: #555;
  font-weight: bold;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.8rem;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 1rem;
  font-family: var(--font-family-base);
  background-color: white;
  color: var(--text-color-dark);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgb(var(--q-accent-rgb) / 0.2);
  outline: none;
}
.form-group textarea {
  min-height: 100px;
  resize: vertical;
}
.form-group input[type="file"] {
  padding: 0.5rem; /* Give file input some padding too */
  background-color: transparent; /* Remove default browser styling */
  border: 1px dashed #ddd; /* Dashed border for file input */
}
.character-form button[type="submit"] { /* Submit button within this specific form */
  width: 100%;
  padding: 0.75rem; /* Increased padding */
  background-color: var(--primary-color);
  color: var(--q-on-accent);
  border: none;
  border-radius: 10px;
  font-size: 1.2rem; /* Adjusted */
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.3s, transform 0.2s;
}
.character-form button[type="submit"]:hover,
.character-form button[type="submit"]:focus {
  background-color: #e02850; /* Darker shade of primary */
  transform: translateY(-2px);
  outline: none;
}
.character-form button[type="submit"]:active {
  transform: translateY(0);
}

/* Custom Select Arrow */
.form-group select {
  appearance: none;
  -webkit-appearance: none;
  -moz-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='%23333' stroke-width='2' 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: left 1rem center; /* Changed to left for RTL */
  background-size: 1em;
  padding-right: 1rem; /* Default padding */
  padding-left: 2.5rem; /* Space for arrow on the left */
}

/* Switch (Toggle) Styles */
.switch-container {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-start; /* Default for LTR, works for RTL due to overall form direction */
}
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 25px;
}
.switch input { display: none; } /* Hide checkbox */
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc;
  transition: 0.3;
  border-radius: 25px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px; width: 18px;
  left: 4px; bottom: 3.5px; /* Centered */
  background-color: white;
  transition: 0.3;
  border-radius: 50%;
}

input:checked + .slider:before { transform: translateX(24px); }
#visibilityLabel { /* Label for the switch */
  font-size: 1rem; /* Matched to form input text */
  font-weight: normal; /* Normal weight like other labels */
  color: #555;
}

input:checked + .slider { background-color: var(--slider-bg-checked); }

/* =================================================================
   Modern Qahwa AI Footer (.q-footer)
   ================================================================= */

/* --- Brand Column --- */

/* Google Play Box & Badge */

/* --- Column Titles & Lists --- */

/* Email link */

/* --- Community Column --- */

/* --- Footer Bottom Bar --- */

@keyframes q-heart-beat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

/* Responsive Breakpoints */

/* ================== Fixed Bottom Action Bar ================== */
.navbarb {
  width:100%;
  display: flex;
  align-items: center;
  justify-content: center; /* Center the button */
  padding: 8px 4px; /* More vertical padding */
  position: fixed;
  bottom: 0;
  left: 0; /* Align to left edge for full width */
  z-index: 550;
  /* Glass gradient instead of flat dark gradient */
  background: linear-gradient(
    to top,
    rgb(var(--q-panel-rgb) / 0.92) 0%,
    rgb(var(--q-panel-rgb) / 0.6) 60%,
    transparent 100%
  );
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.3s ease, opacity 0.3s ease;
}
/* .bbottom class seems redundant if .navbarb is styled directly, keeping for compatibility */
.navbarb .q_button { /* Style the button within this bar */
  margin-bottom: 0; /* Override default q_button margin */
  width: auto; /* Allow button to size to content */
  max-width: 300px; /* Max width for the button */
}

/* ================== Offers & Ads Section (Front Page) ================== */
.importantnews {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 20px; /* Add gap between offer boxes */
  margin: 30px auto; /* Centered with auto margin */
  padding: 0 15px; /* Padding on sides */
  max-width: 900px; /* Max width for this section */
  color: #1a73e8 !important;
}
.importantwords {
  padding: 20px;

  min-height: 150px; /* Minimum height */
  background: radial-gradient(circle at 50% 50%, #dcedff, #301a76);
  font-size: 1.1rem; /* Adjusted */
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-color-dark); /* Text inside offer */
  border-radius: 10px;
  position: relative;
  box-shadow: 0 4px 10px rgb(var(--q-shade-rgb) / calc(0.15 * var(--q-shadow-k)));
}
.g_button { /* Button inside offer */
  font-size: 18px; /* Slightly smaller */
  width: auto; padding: 8px 15px;

  background: white;
  color: rgb(0, 0, 0) !important;
}

/* Add to your root.css */

/* Styles for Edit Space Page */
.image-preview-container {
    text-align: center;
    margin-bottom: 15px;
}

.space-cover-preview {
    max-width: 100%;
    height: auto;
    max-height: 300px;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 4px 8px rgb(var(--q-shade-rgb) / calc(0.1 * var(--q-shadow-k)));
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ================== Responsive Adjustments ================== */

@media (max-width: 480px) {
  .gallery .images { width: 95%; gap: 15px; }
  .images .icard { max-width: 320px; /* Full width on very small screens */ }
  .inputBox { width: 100%; max-width: 250px; margin-left: auto; margin-right: auto;}
  .character-form { padding: 1.5rem; }
  .form-group select { background-position: left 0.8rem center; padding-left: 2.2rem; }
  .importantnews { padding: 0px 10px; }
  .importantwords { width: 100%; }
}

/* Fallback for @property --angle if not supported (though widely supported now) */
@supports not (animation: spin 3s linear infinite) {
  .importantwords::before {
    border: 3px solid var(--primary-color); /* Static border as fallback */
    background-image: none;
    animation: none;
  }
}

.home_header {

  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Commented out original search styles - kept for reference if feature is re-added */

@media screen and (max-width: 768px) {
header .upmenu {
  display: none;
}

.hero h1 {
  display: flex;
  margin-top: 31%;
  font-size: 30px;
  color: var(--text-color-primary);
  line-height: 1.3;

}

.hero h3 {
  top: 22%;
  font-size: 25px;
  max-width: 700px;
  text-align: center;
}

.d3button {
  margin-top: 10%;

  height: 60px;
  line-height: 60px;
  position: fixed;
  bottom: 10px;
}

.head-right .navq {
  display: block;

}

}

/* =================================================================
   Gallery — My Spaces Cards
   ================================================================= */

.gal-space-card {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: rgb(var(--q-panel-rgb) / 0.9);
  border: 1px solid rgb(var(--q-fg-rgb) / 0.12);
  box-shadow: 0 4px 20px rgb(var(--q-shade-rgb) / calc(0.2 * var(--q-shadow-k)));
  transition: transform 0.3s cubic-bezier(.4, 0, .2, 1), box-shadow 0.3s;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  opacity: 0;
  transform: translateY(24px) scale(0.97);
  animation: gal-card-in 0.45s cubic-bezier(.22, 1, .36, 1) forwards;
}

.gal-space-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 0 30px rgba(139, 92, 246, 0.45), 0 4px 24px rgb(var(--q-shade-rgb) / calc(0.4 * var(--q-shadow-k)));
}

.gal-space-card-img-wrap {
  position: relative;
  width: 100%;
  height: 260px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--q-surface-3), var(--q-surface-3));
}

.gal-space-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 0.4s;
}

.gal-space-card:hover .gal-space-card-img {
  transform: scale(1.06);
}

.gal-space-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgb(var(--q-panel-rgb) / 0.92) 0%, rgb(var(--q-panel-rgb) / 0.3) 40%, transparent 65%);
  pointer-events: none;
}

.gal-space-card-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 12px;
  border-radius: 50px;
  font-size: 11px;
  font-weight: 600;
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: 4px;
}

.gal-space-card-badge.public {
  background: rgba(59, 130, 246, 0.45);
  color: #a5d0ff;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.gal-space-card-badge.private {
  background: rgba(139, 92, 246, 0.45);
  color: #d4bfff;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.gal-space-card-story-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 10px;
  border-radius: 50px;
  background: rgb(var(--q-accent-rgb) / 0.5);
  color: #ffc0cb;
  font-size: 11px;
  font-weight: 600;
  backdrop-filter: blur(8px);
  border: 1px solid rgb(var(--q-accent-rgb) / 0.3);
}

.gal-space-card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  direction: rtl;
  flex-grow: 1;
}

.gal-space-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--q-text-primary);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gal-space-card-desc {
  font-size: 0.83rem;
  color: rgb(var(--q-fg-rgb) / 0.69);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-align: right;
  min-height: 2.4em;
}

.gal-space-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  gap: 8px;
}

.gal-space-card-time {
  font-size: 0.75rem;
  color: rgb(var(--q-fg-rgb) / 0.41);
}

.gal-space-card-enter {
  padding: 5px 16px;
  border-radius: 50px;
  border: 1px solid rgba(139, 92, 246, 0.4);
  background: rgba(139, 92, 246, 0.15);
  color: #c4b5fd;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.gal-space-card-enter:hover {
  background: rgba(139, 92, 246, 0.35);
  border-color: rgba(139, 92, 246, 0.6);
  color: var(--q-text-primary);
  box-shadow: 0 0 14px rgba(139, 92, 246, 0.35);
}

.gal-space-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 72px;
  background: linear-gradient(135deg, var(--q-surface-3) 0%, #2d1b4e 50%, var(--q-surface-3) 100%);
  color: rgba(139, 92, 246, 0.3);
  user-select: none;
}

.gal-space-card-delete {
  position: absolute;
  bottom: 10px;
  left: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.25);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #f87171;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10;
  padding: 0;
}

.gal-space-card-delete:hover {
  background: rgba(239, 68, 68, 0.85);
  border-color: rgba(239, 68, 68, 1);
  color: var(--q-on-accent);
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.6);
  transform: scale(1.1);
}

.gal-space-card-delete svg {
  width: 16px;
  height: 16px;
  transition: transform 0.2s;
}

.gal-space-card-chars {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  direction: rtl;
}

.gal-space-card-char-pill {
  padding: 3px 10px;
  border-radius: 50px;
  background: rgb(var(--q-fg-rgb) / 0.06);
  border: 1px solid rgb(var(--q-fg-rgb) / 0.1);
  color: rgb(var(--q-fg-rgb) / 0.76);
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
}

.gal-space-card-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  direction: rtl;
}

.gal-space-card-msg-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--q-accent);
  background: rgb(var(--q-accent-rgb) / 0.1);
  border: 1px solid rgb(var(--q-accent-rgb) / 0.2);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

/* Spaces Stats Banner */

/* ===== Mobile polish pass (small screens) ===== */
@media (max-width: 480px) {
  body {
    overflow-x: hidden; /* guard against accidental horizontal scroll */
  }

  /* 16px minimum prevents iOS Safari zoom-on-focus */
  input, select, textarea {
    font-size: 16px;
  }

  .gallery .images {
    width: 100%;
    padding: 0 12px;
    box-sizing: border-box;
    gap: 12px;
  }

}

/* ===== Keyboard focus visibility (a11y) ===== */
header a:focus-visible,
.q_button:focus-visible,
.g_button:focus-visible,
.d3button:focus-visible {
  outline: 2px solid var(--primary-accent-color);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ==========================================================================
   Header navigation, user menu, mobile drawer, Google button
   (moved from inline <style> in templates/root.html)
   ========================================================================== */
.google-btn {
    display: flex;
    align-items: center;
    background-color: #1a73e8;
    color: var(--q-on-accent);
    border: none;
    border-radius: 4px;
    padding: 2px 2px 2px 0px;
    height: 44px;
    font-family: 'Roboto', 'Inter', Arial, sans-serif;
    font-size: 18px;
    font-weight: 500;
    letter-spacing: 0.25px;
    text-decoration: none;
    transition: background-color 0.2s, box-shadow 0.2s;
    width: 100%;
    max-width: 260px;
    margin: 0 auto;
    box-sizing: border-box;
    direction: ltr;
    box-shadow: 0 1px 2px 0 rgb(var(--q-panel-rgb) / 0.3), 0 1px 3px 1px rgb(var(--q-panel-rgb) / 0.15);
}
.google-btn:hover {
    background-color: #1b66c9;
    box-shadow: 0 1px 3px 0 rgb(var(--q-panel-rgb) / 0.3), 0 4px 8px 3px rgb(var(--q-panel-rgb) / 0.15);
}
.google-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #fff;
    border-radius: 2px;
    height: 40px;
    width: 40px;
    flex-shrink: 0;
    margin-left: 2px;
}
.google-btn-icon svg {
    width: 20px;
    height: 20px;
}
.google-btn-text {
    flex-grow: 1;
    text-align: center;
}

/* ===== Modern Tuned Header Navigation & User Profile Dropdown ===== */
header {
    padding: 8px 18px;
    padding-top: max(8px, var(--q-safe-top));
    gap: 12px;
}
header .upmenu {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: auto !important;
    flex: 1;
    max-width: fit-content;
    margin: 0 auto;
    direction: rtl;
    padding: 0;
    list-style: none;
}
header .upmenu li {
    list-style: none;
    margin: 0;
    display: flex;
    align-items: center;
}
.nav-link-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    border-radius: 20px;
    font-size: 14.5px;
    font-weight: 700;
    color: rgb(var(--q-fg-rgb) / 0.82) !important;
    text-decoration: none !important;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
    border: 1px solid transparent;
}
.nav-link-pill:hover {
    background: rgb(var(--q-fg-rgb) / 0.08);
    color: var(--q-text-primary) !important;
    border-color: rgb(var(--q-fg-rgb) / 0.12);
    transform: translateY(-1px);
    text-shadow: none !important;
}
.nav-link-pill.collab-link {
    color: var(--q-accent-soft) !important;
}
.nav-link-pill.collab-link:hover {
    background: rgba(255, 143, 163, 0.12);
    border-color: rgba(255, 143, 163, 0.35);
}
.nav-link-pill.sub-pro-link {
    color: var(--q-gold-ink) !important;
    font-weight: 800;
    background: rgb(var(--q-gold-rgb) / 0.08);
    border-color: rgb(var(--q-gold-rgb) / 0.25);
}
.nav-link-pill.sub-pro-link:hover {
    background: rgb(var(--q-gold-rgb) / 0.18);
    border-color: rgb(var(--q-gold-rgb) / 0.5);
    box-shadow: 0 0 12px rgb(var(--q-gold-rgb) / 0.3);
}
.nav-login-btn {
    display: inline-flex;
    align-items: center;
    padding: 7px 18px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--q-accent) 0%, var(--q-purple) 100%);
    color: var(--q-on-accent) !important;
    font-weight: 700;
    font-size: 14.5px;
    text-decoration: none !important;
    box-shadow: 0 4px 15px rgb(var(--q-accent-rgb) / 0.35);
    transition: all 0.2s ease;
    white-space: nowrap;
}
.nav-login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgb(var(--q-accent-rgb) / 0.5);
    color: var(--q-on-accent) !important;
}

/* User Profile Dropdown Pill */
.user-menu-item {
    position: relative;
}
.user-dropdown-container {
    position: relative;
}
.user-pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 12px 4px 6px;
    background: rgb(var(--q-fg-rgb) / 0.06);
    border: 1px solid rgb(var(--q-fg-rgb) / 0.12);
    border-radius: 24px;
    color: var(--q-text-primary);
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    transition: all 0.2s ease;
    outline: none;
    box-shadow: 0 2px 8px rgb(var(--q-shade-rgb) / calc(0.25 * var(--q-shadow-k)));
    direction: rtl;
}
.user-pill-btn:hover, .user-pill-btn.active {
    background: rgb(var(--q-accent-rgb) / 0.14);
    border-color: rgb(var(--q-accent-rgb) / 0.4);
    box-shadow: 0 4px 16px rgb(var(--q-accent-rgb) / 0.25);
}
.user-avatar-mini {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--q-accent), var(--q-tertiary));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
    color: var(--q-on-accent);
    flex-shrink: 0;
}
.user-avatar-mini.pro {
    border: 1.5px solid var(--q-gold);
    box-shadow: 0 0 8px rgb(var(--q-gold-rgb) / 0.5);
}
.user-pill-name {
    max-width: 105px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--q-text-primary);
}
.user-crown-badge {
    font-size: 13px;
    line-height: 1;
}
.user-caret-icon {
    transition: transform 0.2s ease;
    fill: rgb(var(--q-fg-rgb) / 0.7);
    flex-shrink: 0;
}
.user-pill-btn.active .user-caret-icon {
    transform: rotate(180deg);
}

/* Dropdown Menu Box */
.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    min-width: 250px;
    background: rgb(var(--q-panel-rgb) / 0.96);
    border: 1px solid rgb(var(--q-fg-rgb) / 0.12);
    border-radius: 16px;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: 0 16px 45px rgb(var(--q-shade-rgb) / calc(0.7 * var(--q-shadow-k))), 0 0 0 1px rgb(var(--q-fg-rgb) / 0.05);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px) scale(0.97);
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1005;
    padding: 8px;
    direction: rtl;
    text-align: right;
}
.user-dropdown-menu.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}
.user-dropdown-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px 10px 10px;
}
.udh-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--q-accent), var(--q-tertiary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 800;
    color: var(--q-on-accent);
    flex-shrink: 0;
}
.udh-avatar.pro {
    border: 2px solid var(--q-gold);
    box-shadow: 0 0 10px rgb(var(--q-gold-rgb) / 0.4);
}
.udh-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow: hidden;
}
.udh-name {
    font-size: 14.5px;
    font-weight: 800;
    color: var(--q-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.udh-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 50px;
    width: fit-content;
}
.udh-badge.pro {
    background: rgb(var(--q-gold-rgb) / 0.15);
    color: var(--q-gold-ink);
    border: 1px solid rgb(var(--q-gold-rgb) / 0.3);
}
.udh-badge.free {
    background: rgb(var(--q-fg-rgb) / 0.08);
    color: var(--q-text-secondary);
    border: 1px solid rgb(var(--q-fg-rgb) / 0.12);
}
.user-dropdown-divider {
    height: 1px;
    background: rgb(var(--q-fg-rgb) / 0.08);
    margin: 5px 0;
}
.user-dropdown-links {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.dropdown-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    color: rgb(var(--q-fg-rgb) / 0.82) !important;
    text-decoration: none !important;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.15s ease;
}
.dropdown-link:hover {
    background: rgb(var(--q-fg-rgb) / 0.07);
    color: var(--q-text-primary) !important;
    transform: translateX(-3px);
    text-shadow: none !important;
}
.dropdown-link.admin-link {
    color: #c4b5fd !important;
}
.dropdown-link.admin-link:hover {
    background: rgba(167, 139, 250, 0.12);
}
.dropdown-link.logout-link {
    color: #f87171 !important;
}
.dropdown-link.logout-link:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5 !important;
}
.dd-icon {
    font-size: 15px;
    line-height: 1;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

@media screen and (max-width: 820px) {
    header .upmenu {
        display: none !important;
    }
}

/* Redirect overlay spinner */
.overlay.show {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

/* Redirect overlay (root.html) */
.spinner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.spinner-container .spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgb(var(--q-fg-rgb) / 0.15);
  border-top-color: var(--q-accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

.spinner-container .loading-msg {
  color: var(--q-text-primary);
  font-size: 1.2rem;
  font-family: inherit;
  margin: 0;
  text-align: center;
}

/* Accessible focus ring for keyboard users (all pages) */
:where(a, button, [role="button"], input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--q-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Mobile drawer (hamburger menu) — templates/root.html
   One solid sheet on a dimmed page: no see-through layers, so the menu reads
   as a separate surface. The scrim lives OUTSIDE <header> on purpose: the
   header's backdrop-filter makes it the containing block for fixed children,
   so a scrim inside it would only cover the header bar.
   ========================================================================== */

/* Hamburger / close button */
.navq .menu_icon_box {
  position: relative;
  z-index: 27; /* stays above the open drawer so it can close it */
  width: var(--q-tap-min);
  height: var(--q-tap-min);
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 12px;
  border: 1px solid rgb(var(--q-accent-rgb) / 0.45);
  background: rgb(var(--q-fg-rgb) / 0.05);
  box-shadow: 0 0 14px rgb(var(--q-accent-rgb) / 0.25);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.navq .menu_icon_box:hover {
  font-size: inherit;
  background: rgb(var(--q-accent-rgb) / 0.12);
  box-shadow: 0 0 18px rgb(var(--q-accent-rgb) / 0.35);
}

.navq .menu_icon_box.active {
  background: var(--q-surface-3);
  border-color: var(--q-border-strong);
  box-shadow: none;
}

.menu_icon_box .line1,
.menu_icon_box .line2,
.menu_icon_box .line3 {
  display: block;
  width: 22px;
  height: 2.5px;
  margin: 0;
  border-radius: 3px;
  background-color: var(--q-accent);
  transition: transform 0.25s var(--q-ease-out), opacity 0.2s ease;
}

.menu_icon_box.active .line1 { transform: translateY(7.5px) rotate(45deg); }
.menu_icon_box.active .line2 { opacity: 0; }
.menu_icon_box.active .line3 { transform: translateY(-7.5px) rotate(-45deg); }

/* Page scrim */
.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 998; /* above page content and floating bars, below <header> (999) */
  background: var(--q-scrim);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.drawer-scrim.is-open { opacity: 1; }
.drawer-scrim[hidden] { display: none; }

body.drawer-open { overflow: hidden; }

/* The sheet */
.dropsidemenu {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 26;
  width: min(320px, 86vw);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  direction: rtl;
  text-align: right;
  background: var(--q-surface-1);
  border-left: 1px solid var(--q-border-default);
  box-shadow: -16px 0 48px rgb(var(--q-shade-rgb) / 0.55);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.3s var(--q-ease-out), visibility 0s linear 0.3s;
}

.dropsidemenu.active {
  transform: none;
  visibility: visible;
  transition: transform 0.3s var(--q-ease-out), visibility 0s;
}

.drawer-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  /* clear the header row where the close button sits */
  padding: calc(var(--q-safe-top) + 76px) 14px 12px;
}

/* Account card */
.dropside-user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  background: var(--q-surface-2);
  border: 1px solid var(--q-border-default);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.dropside-user-card:active {
  background: var(--q-surface-3);
  border-color: rgb(var(--q-accent-rgb) / 0.35);
}

.dropside-user-card .udh-avatar {
  width: 42px;
  height: 42px;
  font-size: 17px;
}

.dropside-user-card .udh-info { flex: 1; min-width: 0; }
.dropside-user-card .udh-name { font-size: 15.5px; }

.drawer-card-chevron {
  color: var(--q-text-tertiary);
  font-size: 22px;
  line-height: 1;
}

/* Guest sign-in block */
.drawer-login {
  padding: 14px;
  border-radius: 16px;
  background: var(--q-surface-2);
  border: 1px solid var(--q-border-default);
}

.drawer-login p {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--q-text-secondary);
  text-align: right;
}

.nav-login-btn.nav-login-btn--block {
  width: 100%;
  min-height: var(--q-tap-min);
  justify-content: center;
}

/* Groups */
.nav-group-title {
  margin: 20px 12px 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--q-text-tertiary);
}

.drawer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.drawer-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--q-text-primary);
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
  transition: background 0.15s ease;
}

.drawer-link:active { background: rgb(var(--q-fg-rgb) / 0.1); }

.drawer-link[aria-current="page"] {
  background: rgb(var(--q-accent-rgb) / 0.12);
}

.drawer-link[aria-current="page"]::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 11px;
  bottom: 11px;
  width: 3px;
  border-radius: 3px;
  background: var(--q-accent);
}

.drawer-ico {
  width: 24px;
  flex-shrink: 0;
  text-align: center;
  font-size: 18px;
  line-height: 1;
}

.drawer-link--accent { color: var(--q-accent-soft); }
.drawer-link--pro { color: var(--q-gold-ink); }
.drawer-link--admin { color: #c4b5fd; }
.drawer-link--danger { color: var(--q-danger-ink); }

.drawer-link--cta {
  margin-bottom: 2px;
  background: rgb(var(--q-accent-rgb) / 0.08);
  border: 1px dashed rgb(var(--q-accent-rgb) / 0.4);
}

/* Pinned footer (sign out) */
.drawer-footer {
  flex-shrink: 0;
  padding: 8px 14px calc(8px + var(--q-safe-bottom));
  border-top: 1px solid var(--q-border-subtle);
  background: var(--q-surface-1);
}

/* Hover feedback only for real pointers (no sticky hover after a tap) */
@media (hover: hover) {
  .drawer-link:not([aria-current="page"]):hover { background: rgb(var(--q-fg-rgb) / 0.06); }
  .drawer-link.drawer-link--cta:hover { background: rgb(var(--q-accent-rgb) / 0.14); }
  .dropside-user-card:hover {
    background: var(--q-surface-3);
    border-color: rgb(var(--q-accent-rgb) / 0.35);
  }
}

/* Keep attention on the sheet: fade the header bar's other content while it's open */
header .head-left,
header .upmenu {
  transition: opacity 0.25s ease;
}

body.drawer-open header .head-left,
body.drawer-open header .upmenu {
  opacity: 0.3;
}

/* ==========================================================================
   Phones: slimmer header (92px → ~64px) so more of the screen is content
   ========================================================================== */
@media (max-width: 600px) {
  header {
    padding: 6px 12px;
    padding-top: max(6px, var(--q-safe-top));
  }

  .head-left img {
    height: 52px;
    width: auto;
  }

  .navq {
    margin-right: 2px;
  }

  .container {
    margin-top: 72px;
  }

  .drawer-scroll {
    padding-top: calc(var(--q-safe-top) + 70px);
  }
}

/* ==========================================================================
   Footer (templates/footer.html) — moved from its inline <style> block,
   which used to ship with every page and override an older copy here.
   ========================================================================== */
/* =================================================================
Modern Centered 3-Column Footer (.q-footer)
 ================================================================= */
.q-footer {
  width: 100%;
  box-sizing: border-box;
  background: linear-gradient(180deg, rgb(var(--q-panel-rgb) / 0.96) 0%, rgb(var(--q-panel-rgb) / 0.99) 100%);
  border-top: 1px solid rgb(var(--q-fg-rgb) / 0.08);
  box-shadow: 0 -4px 30px rgb(var(--q-shade-rgb) / calc(0.35 * var(--q-shadow-k)));
  color: var(--q-text-primary);
  padding: 3rem 1.5rem 1.8rem 1.5rem;
  margin-top: 40px;
  direction: rtl;
  font-family: var(--font-family-base, 'Cairo', sans-serif);
}

.q-footer__container {
  max-width: 1140px;
  margin: 0 auto;
  width: 100%;
  padding: 0 1rem;
  box-sizing: border-box;
}

.q-footer__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2.5rem;
  align-items: start;
  justify-items: center;
  text-align: center;
}

/* Column General */
.q-footer__col {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  max-width: 340px;
}

/* Brand Column */
.q-footer__col--brand {
  gap: 0.85rem;
}

.q-footer__logo-link {
  display: inline-block;
  transition: opacity 0.2s ease;
}

.q-footer__logo-link:hover {
  opacity: 0.88;
}

.q-footer__logo {
  max-width: 140px;
  height: auto;
  display: block;
  margin: 0 auto;
}

.q-footer__tagline {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #9d99ab;
  margin: 0;
  text-align: center;
}

/* Google Play Badge */
.q-footer__app-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.q-footer__app-label {
  font-size: 0.82rem;
  color: #8b8799;
  font-weight: 500;
}

.q-footer__play-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgb(var(--q-fg-rgb) / 0.04);
  border: 1px solid rgb(var(--q-fg-rgb) / 0.12);
  border-radius: 12px;
  padding: 8px 18px;
  text-decoration: none;
  box-shadow: 0 4px 15px rgb(var(--q-shade-rgb) / calc(0.2 * var(--q-shadow-k)));
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
  background 0.2s ease,
  border-color 0.2s ease,
  box-shadow 0.2s ease;
  direction: ltr;
}

.q-footer__play-badge:hover {
  transform: translateY(-2px);
  background: rgb(var(--q-fg-rgb) / 0.08);
  border-color: rgba(0, 195, 255, 0.45);
  box-shadow: 0 8px 25px rgba(0, 195, 255, 0.2);
}

.q-footer__play-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.q-footer__play-text {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.15;
}

.q-footer__play-sub {
  font-size: 0.68rem;
  color: #9d99ab;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.q-footer__play-main {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--q-text-primary);
  letter-spacing: 0.02em;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Column Titles */
.q-footer__col-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--q-text-primary);
  margin-bottom: 1.25rem;
  position: relative;
  display: inline-block;
  text-align: center;
}

.q-footer__col-title::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 2px;
  background: var(--primary-accent-color, var(--q-accent));
  border-radius: 2px;
}

/* Links */
.q-footer__links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.q-footer__links li a {
  color: var(--q-text-secondary);
  text-decoration: none;
  font-size: 0.94rem;
  display: inline-block;
  transition: color 0.2s ease, transform 0.2s ease;
}

.q-footer__links li a:hover {
  color: var(--q-text-primary);
  transform: translateY(-2px);
}

.q-footer__links--support {
  margin-top: 1rem;
}

/* Email link */
.q-footer__email-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  direction: ltr;
}

.q-footer__email-link svg {
  flex-shrink: 0;
  stroke: var(--primary-accent-color, var(--q-accent));
}

/* Discord Button */
.q-footer__social-box {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-bottom: 0.5rem;
}

.q-footer__discord-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(88, 101, 242, 0.12);
  border: 1px solid rgba(88, 101, 242, 0.35);
  color: var(--q-text-primary);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 12px;
  text-decoration: none;
  box-shadow: 0 4px 15px rgba(88, 101, 242, 0.15);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
  background 0.2s ease,
  box-shadow 0.2s ease;
}

.q-footer__discord-btn svg {
  fill: #5865f2;
  transition: fill 0.2s ease;
}

.q-footer__discord-btn:hover {
  transform: translateY(-2px);
  background: #5865f2;
  color: var(--q-on-accent);
  box-shadow: 0 8px 25px rgba(88, 101, 242, 0.35);
}

.q-footer__discord-btn:hover svg {
  fill: var(--q-text-primary);
}

/* Bottom Bar */
.q-footer__bottom {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgb(var(--q-fg-rgb) / 0.07);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.88rem;
  color: var(--q-text-tertiary);
  text-align: center;
}

.q-footer__copyright,
.q-footer__heart {
  margin: 0;
}

.q-footer__heart-icon {
  display: inline-block;
  animation: q-heart-beat 1.8s infinite ease-in-out;
  margin: 0 2px;
}

@keyframes q-heart-beat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

/* Responsive */
@media (max-width: 860px) {
  .q-footer__grid {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }
  .q-footer__bottom {
    flex-direction: column;
    justify-content: center;
    gap: 0.6rem;
  }
}

@media (max-width: 600px) {
  .q-footer {
    padding-top: 2.5rem;
    padding-bottom: calc(75px + env(safe-area-inset-bottom, 0px));
  }
}

/* ── Theme switch (templates/partials/theme_switch.html) ─────────────────── */
.theme-switch {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--q-text-primary);
  font: inherit;
  font-size: 15.5px;
  font-weight: 600;
  text-align: start;
  cursor: pointer;
}
.theme-switch-ico::before { content: "🌙"; }
.theme-switch[aria-checked="true"] .theme-switch-ico::before { content: "☀️"; }
.theme-switch-label { flex: 1; }
.theme-switch-track {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 26px;
  border-radius: var(--q-radius-full);
  background: rgb(var(--q-fg-rgb) / 0.18);
  transition: background var(--q-duration-normal) var(--q-ease-out);
}
.theme-switch-thumb {
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff; /* thumb is white on both tracks */
  box-shadow: 0 1px 3px rgb(var(--q-shade-rgb) / calc(0.25 * var(--q-shadow-k)));
  transition: inset-inline-start var(--q-duration-normal) var(--q-ease-spring);
}
.theme-switch[aria-checked="true"] .theme-switch-track { background: var(--q-gradient-brand); }
.theme-switch[aria-checked="true"] .theme-switch-thumb { inset-inline-start: 21px; }
.theme-switch:focus-visible { outline: 2px solid var(--q-accent); outline-offset: 2px; }
.theme-switch:active { background: rgb(var(--q-fg-rgb) / 0.08); }
@media (hover: hover) { .theme-switch:hover { background: rgb(var(--q-fg-rgb) / 0.06); } }
.drawer-footer { display: grid; gap: 2px; }

/* Cross-fade colours for a moment when the user flips the theme (class set by root.html) */
html.theme-fade, html.theme-fade *, html.theme-fade *::before, html.theme-fade *::after {
  transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease, fill 0.4s ease !important;
}

/* ── Light theme ("crema") overrides for pieces tuned for black ──────────── */
:root[data-theme="light"] .q-footer__tagline,
:root[data-theme="light"] .q-footer__app-label,
:root[data-theme="light"] .q-footer__play-sub { color: var(--q-text-secondary); }
:root[data-theme="light"] .drawer-link--admin { color: var(--q-purple-ink); }
:root[data-theme="light"] .gal-space-card-enter,
:root[data-theme="light"] .dropdown-link.admin-link { color: var(--q-purple-ink) !important; }
:root[data-theme="light"] .gal-space-card-delete,
:root[data-theme="light"] .dropdown-link.logout-link,
:root[data-theme="light"] .dropdown-link.logout-link:hover { color: var(--q-danger-ink) !important; }
:root[data-theme="light"] .gal-space-card-placeholder {
  background: linear-gradient(135deg, var(--q-surface-2) 0%, rgb(var(--q-violet-rgb) / 0.16) 50%, var(--q-surface-2) 100%);
}
