* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page-bg);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 12%, rgba(212, 168, 67, 0.06), transparent 28%),
    linear-gradient(180deg, #fbfdfc 0%, var(--page-bg) 58%, #f2f6f4 100%);
  font-family: "Cairo", Tahoma, Arial, sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

body.local-preview {
  padding-top: var(--preview-height);
}

button,
input {
  font: inherit;
}

button,
label,
input[type="file"] {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

svg {
  display: block;
  width: 1em;
  height: 1em;
  fill: currentColor;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 500;
  top: 10px;
  right: 12px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  color: #fff;
  background: var(--primary-dark);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid var(--gold-bright);
  outline-offset: 3px;
}

.mock-banner {
  position: fixed;
  z-index: 130;
  inset: 0 0 auto;
  min-height: var(--preview-height);
  padding: 7px max(14px, env(safe-area-inset-right)) 7px max(14px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: #4b3a10;
  background: #fff3c8;
  border-bottom: 1px solid #e6c45d;
  box-shadow: var(--shadow-sm);
  font-size: 0.82rem;
}

.mock-banner-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.mock-banner-text svg {
  flex: 0 0 19px;
  width: 19px;
  height: 19px;
  color: var(--primary);
}

.mock-toggle {
  min-height: 30px;
  padding: 4px 12px;
  border: 1px solid rgba(10, 92, 54, 0.22);
  border-radius: 999px;
  color: var(--primary-dark);
  background: rgba(255, 255, 255, 0.7);
  font-size: 0.74rem;
  font-weight: 700;
}

.site-header {
  position: sticky;
  z-index: 100;
  top: 0;
  min-height: var(--header-height);
  color: #fff;
  background: linear-gradient(135deg, #064023 0%, #0a5c36 55%, #0d7a47 100%);
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 5px 18px rgba(6, 64, 35, 0.18);
}

body.local-preview .site-header {
  top: var(--preview-height);
}

.header-inner {
  width: min(100% - 36px, var(--content-width));
  min-height: calc(var(--header-height) - 3px);
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand-lockup,
.header-actions,
.header-guest,
.header-student,
.header-student-name,
.header-login-label {
  display: flex;
  align-items: center;
}

.brand-lockup {
  min-width: 0;
  gap: 12px;
}

.brand-icon {
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  color: var(--gold-bright);
  background: rgba(255, 255, 255, 0.08);
}

.brand-icon svg {
  width: 26px;
  height: 26px;
}

.brand-copy {
  min-width: 0;
  display: grid;
  line-height: 1.35;
}

.brand-copy strong {
  overflow: hidden;
  color: #fff;
  font-size: clamp(0.88rem, 1.8vw, 1.14rem);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy small {
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.68rem;
}

.header-actions {
  flex: 0 0 auto;
  gap: 9px;
}

.header-guest,
.header-student {
  gap: 10px;
}

.header-login-label,
.header-student-name {
  gap: 6px;
  max-width: 260px;
  font-size: 0.8rem;
  font-weight: 700;
}

.header-login-label svg,
.header-student-name svg {
  width: 19px;
  height: 19px;
}

.header-student-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-status {
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}

.header-status.closed {
  color: #fff7e8;
  background: rgba(220, 53, 69, 0.38);
}

.logout-button,
.sound-toggle {
  min-height: 38px;
  border: 0;
  color: #fff;
}

.logout-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 9px;
  background: var(--danger);
  box-shadow: 0 5px 14px rgba(111, 18, 29, 0.24);
  font-size: 0.74rem;
  font-weight: 700;
}

.logout-button svg {
  width: 18px;
  height: 18px;
}

.sound-toggle {
  flex: 0 0 38px;
  width: 38px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.11);
  font-weight: 800;
}

.site-main {
  flex: 1 0 auto;
  width: 100%;
}

.connection-panel {
  width: min(100% - 32px, var(--content-width));
  margin: 18px auto 0;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  border: 1px solid #feb2b2;
  border-right: 5px solid var(--danger);
  border-radius: var(--radius-md);
  color: #8c2934;
  background: #fff5f5;
  box-shadow: var(--shadow-sm);
}

.alert-icon {
  color: var(--danger);
}

.alert-icon svg {
  width: 24px;
  height: 24px;
}

.connection-panel h2,
.connection-panel p {
  margin: 0;
}

.connection-panel h2 {
  font-size: 0.96rem;
}

.connection-panel p {
  color: #9b3e47;
  font-size: 0.78rem;
}
