:root {
  --bg: #0f172a;
  --bg-2: #111827;
  --panel: #0b1221;
  --muted: #9ba9c9;
  --text: #e7ecf7;
  --accent: #f97316;
  --accent-2: #22d3ee;
  --header-height: 72px;
  --border: rgba(255, 255, 255, 0.08);
  --radius: 14px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;
  --transition-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --glow-accent: rgba(249, 115, 22, 0.4);
  --glow-accent-2: rgba(34, 211, 238, 0.4);
}

/* Smooth scroll pro celý dokument */
* {
  scroll-behavior: smooth;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

table {
  width: 100%;
  overflow-x: auto;
  display: block;
}

body {
  margin: 0;
  font-family: 'Space Grotesk', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 20% 20%, rgba(34, 211, 238, 0.06), transparent 25%),
    radial-gradient(circle at 80% 10%, rgba(249, 115, 22, 0.08), transparent 32%),
    linear-gradient(135deg, var(--bg), var(--bg-2));
  color: var(--text);
  min-height: 100vh;
  padding: clamp(8px, 2vw, 24px);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

.page {
  width: min(1100px, 100%);
  animation: fadeIn 0.4s ease;
}

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

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

.panel {
  background: linear-gradient(135deg, rgba(17, 24, 39, 0.92), rgba(15, 23, 42, 0.94));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(16px, 3vw, 32px);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
  transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
  max-width: 100%;
}

.panel:hover {
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(34, 211, 238, 0.15);
  border-color: rgba(34, 211, 238, 0.2);
}

.panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 80%, rgba(34, 211, 238, 0.08), transparent 40%),
    radial-gradient(circle at 80% 50%, rgba(249, 115, 22, 0.05), transparent 38%);
  pointer-events: none;
  opacity: 1;
  transition: opacity var(--transition-slow);
}

.panel:hover::before {
  opacity: 0.7;
}

.panel__header {
  margin-bottom: 28px;
  position: relative;
  z-index: 1;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.4px;
  transition: all var(--transition-fast);
  animation: slideDown 0.3s ease;
}

.eyebrow:hover {
  border-color: rgba(34, 211, 238, 0.4);
  background: rgba(255, 255, 255, 0.05);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

h1 {
  margin: 10px 0 6px;
  font-size: clamp(22px, 4.5vw, 34px);
  animation: slideDown 0.4s ease 0.1s both;
  line-height: 1.2;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  max-width: 720px;
  animation: slideDown 0.4s ease 0.15s both;
  line-height: 1.6;
  font-size: clamp(13px, 2vw, 15px);
}

.form {
  display: grid;
  gap: 18px;
  position: relative;
  z-index: 1;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

label {
  font-weight: 600;
  color: #dbeafe;
}

input,
select,
button {
  font-family: inherit;
}

input,
select {
  padding: clamp(10px, 2vw, 12px) clamp(12px, 2.5vw, 14px);
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  outline: none;
  transition: all var(--transition-fast);
  font-size: clamp(14px, 2vw, 16px);
  min-height: 44px;
  width: 100%;
  position: relative;
}

select option {
  background: #1e293b;
  color: #e7ecf7;
  padding: 8px;
}

select option:hover,
select option:focus,
select option:checked {
  background: #334155;
  color: #ffffff;
}

input:hover,
select:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
}

input:focus,
select:focus {
  border-color: rgba(34, 211, 238, 0.6);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15), 0 4px 12px rgba(34, 211, 238, 0.1);
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-1px);
}

input:focus::placeholder {
  opacity: 0.5;
  transform: translateX(4px);
  transition: all var(--transition-fast);
}

select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button[type='submit'] {
  padding: clamp(12px, 2.5vw, 13px) clamp(14px, 3vw, 16px);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0b1120;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.35), 0 0 0 0 var(--glow-accent);
  position: relative;
  overflow: hidden;
  min-height: 48px;
  width: 100%;
  font-size: clamp(14px, 2vw, 16px);
}

button[type='submit']::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2), transparent);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

button[type='submit']::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,0.8), transparent 70%);
  opacity: 0;
  transform: scale(0);
  transition: all 0.6s ease;
}

button[type='submit']:hover::before {
  opacity: 1;
}

button[type='submit']:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45), 0 0 30px var(--glow-accent);
}

button[type='submit']:active {
  transform: translateY(0);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}

button[type='submit']:active::after {
  opacity: 1;
  transform: scale(4);
  transition: all 0s;
}

button[type='submit']:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: clamp(9px, 2vw, 10px) clamp(11px, 2.5vw, 12px);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
  min-height: 44px;
  font-size: clamp(13px, 1.8vw, 15px);
}

.ghost::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.1), transparent);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.ghost::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(34, 211, 238, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.4s ease, height 0.4s ease;
}

.ghost:hover::before {
  opacity: 1;
}

.ghost:hover::after {
  width: 300px;
  height: 300px;
  opacity: 0;
}

.ghost:hover,
.ghost:focus-visible {
  border-color: rgba(34, 211, 238, 0.6);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2), 0 0 20px rgba(34, 211, 238, 0.2);
}

.ghost:active {
  transform: translateY(0);
}

.select-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.hint {
  color: var(--muted);
  margin: 0;
}

.form__footer {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.status {
  min-height: 20px;
  color: var(--muted);
  font-weight: 500;
  padding: 8px 0;
  transition: all var(--transition-base);
  animation: slideDown 0.3s ease;
  font-size: clamp(13px, 1.8vw, 14px);
  word-break: break-word;
  line-height: 1.5;
}

.status--error {
  color: #fca5a5;
  animation: shake 0.4s ease;
}

.status--success {
  color: #86efac;
  animation: slideDown 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.info {
  margin-top: 26px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
  position: relative;
  z-index: 1;
}

.info h2 {
  margin: 0 0 8px;
}

.info p {
  margin: 6px 0;
  color: var(--muted);
}

code {
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 14px;
}

.noscript {
  margin: 16px;
  padding: 14px;
  border-radius: 8px;
  background: #fee2e2;
  color: #7f1d1d;
  text-align: center;
}

/* ============================================ */
/* RESPONSIVE DESIGN - Mobile & Tablet Support */
/* ============================================ */

/* Small tablets & mobile landscape (768px and below) */
@media (max-width: 768px) {
  body {
    padding: 12px;
    align-items: flex-start;
  }

  .page {
    width: 100%;
  }

  .panel {
    padding: 20px;
  }

  .panel__header {
    margin-bottom: 20px;
  }

  h1 {
    font-size: clamp(24px, 5vw, 28px);
  }

  .subtitle {
    font-size: 14px;
  }

  .select-row {
    grid-template-columns: 1fr;
  }

  button.ghost {
    width: 100%;
  }

  .form__footer {
    flex-direction: column;
    align-items: flex-start;
  }

  button[type='submit'] {
    width: 100%;
  }

  .info {
    padding: 14px;
    font-size: 14px;
  }

  .info h2 {
    font-size: 16px;
  }
}

/* Mobile portrait (640px and below) */
@media (max-width: 640px) {
  body {
    padding: 8px;
    font-size: 15px;
  }

  .panel {
    padding: 16px;
    border-radius: 12px;
  }

  .panel__header {
    margin-bottom: 16px;
  }

  h1 {
    font-size: 22px;
    margin: 8px 0 4px;
  }

  .subtitle {
    font-size: 13px;
    line-height: 1.5;
  }

  .eyebrow {
    font-size: 12px;
    padding: 5px 8px;
  }

  .form {
    gap: 14px;
  }

  .field-group {
    gap: 6px;
  }

  label {
    font-size: 14px;
  }

  input,
  select {
    padding: 11px 12px;
    font-size: 15px;
  }

  button[type='submit'] {
    padding: 12px 14px;
    font-size: 15px;
  }

  .ghost {
    padding: 9px 11px;
    font-size: 14px;
  }

  .hint {
    font-size: 12px;
  }

  .info {
    padding: 12px;
    font-size: 13px;
    margin-top: 20px;
  }

  code {
    font-size: 12px;
  }
}

/* Extra small mobile (480px and below) */
@media (max-width: 480px) {
  body {
    padding: 6px;
    font-size: 14px;
  }

  .panel {
    padding: 14px;
    border-radius: 10px;
  }

  h1 {
    font-size: 20px;
  }

  input,
  select,
  button[type='submit'] {
    font-size: 14px;
  }
}

/* Header & footer for dashboard */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--header-height);
  z-index: 60;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  backdrop-filter: blur(12px);
  transition: all var(--transition-base);
}

.site-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 50%, rgba(34, 211, 238, 0.03), transparent 50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-slow);
}

.site-header:hover::before {
  opacity: 1;
}
.site-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.site-title .brand {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: inline-grid;
  place-items: center;
  color: #071226;
  font-weight: 700;
}
.site-nav {
  display: flex;
  gap: 12px;
  align-items: center;
  flex: 1;
}
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
}
.site-nav a.active {
  color: var(--text);
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
}
.site-nav .user-badge {
  margin-left: auto;
}

.burger-menu {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: background 0.15s ease;
}
.burger-menu:hover {
  background: rgba(255,255,255,0.08);
}
.burger-menu span {
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.burger-menu.active span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.burger-menu.active span:nth-child(2) {
  opacity: 0;
}
.burger-menu.active span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}
.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  position: relative;
}
.user-avatar-btn {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
}
.user-avatar-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15);
  border-radius: 999px;
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.2), rgba(34, 211, 238, 0.2));
  display: inline-grid;
  place-items: center;
  color: var(--text);
  font-weight: 700;
  border: 2px solid rgba(255, 255, 255, 0.1);
  transition: all var(--transition-base);
  cursor: pointer;
}

.user-avatar:hover {
  transform: scale(1.05);
  border-color: rgba(34, 211, 238, 0.5);
  box-shadow: 0 0 20px rgba(34, 211, 238, 0.3);
}

.user-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(380px, 92vw);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(17, 24, 39, 0.98), rgba(15, 23, 42, 0.98));
  backdrop-filter: blur(20px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  padding: 12px;
  z-index: 100;
  opacity: 0;
  transform: translateY(-10px);
  transition: all var(--transition-base);
  pointer-events: none;
}

.user-menu.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.user-menu[hidden] {
  display: none;
}
.user-menu__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.user-menu__title {
  font-weight: 700;
}
.user-menu__body {
  padding: 10px 0;
}
.user-menu__footer {
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.user-kv {
  display: grid;
  gap: 10px;
}
.user-kv__row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
}
.user-kv__k {
  color: var(--muted);
  font-weight: 600;
}
.user-kv__v {
  color: var(--text);
  font-weight: 600;
}
.site-footer {
  margin-top: 28px;
  padding: 14px 18px;
  text-align: center;
  color: var(--muted);
  border-top: 1px solid rgba(255,255,255,0.03);
  font-size: 14px;
  border-radius: 0 0 12px 12px;
}

@media (max-width: 720px) {
  body.with-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 0;
  }

  .with-header .page {
    padding-top: 0;
  }

  .site-header { 
    flex-wrap: wrap;
    height: auto; 
    position: relative;
    margin-bottom: 12px;
  }

  .site-title {
    order: 0;
  }
  .burger-menu {
    order: 1;
  }
  
  .burger-menu {
    display: flex;
  }
  
  .site-nav { 
    display: none;
    width: 100%;
    flex: 0 0 100%;
    order: 2;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding-top: 10px;
  }
  
  .site-nav.open {
    display: flex;
  }
  
  .site-nav a {
    width: 100%;
    text-align: left;
  }
  
  .site-nav .user-badge {
    margin-left: 0;
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
  }

  .user-menu {
    position: static;
    width: 100%;
    margin-top: 10px;
  }

  .user-kv__row {
    grid-template-columns: 1fr;
  }

  .site-footer {
    padding: 12px 16px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .site-header {
    padding: 12px 14px;
  }

  .site-title .brand {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }

  .site-title h2 {
    font-size: 16px;
  }

  .site-nav a {
    padding: 7px 10px;
    font-size: 14px;
  }

  .user-avatar {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .user-menu {
    width: calc(100vw - 16px);
  }
}

.with-header .page {
  padding-top: calc(var(--header-height) + 18px);
}

@media (max-width: 720px) {
  .with-header .page {
    padding-top: 12px;
  }
}

/* Badges (generic) */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  transition: all var(--transition-fast);
  animation: scaleIn 0.3s ease;
  position: relative;
  overflow: hidden;
}

.badge::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.badge:hover::before {
  transform: translateX(100%);
}

.badge:hover {
  transform: scale(1.05);
  background: rgba(255,255,255,0.08);
  border-color: rgba(34, 211, 238, 0.4);
  box-shadow: 0 2px 8px rgba(34, 211, 238, 0.15);
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.badge--muted {
  color: var(--muted);
  background: rgba(255,255,255,0.03);
}

/* Themes page */
.themes-list {
  margin-top: 14px;
  position: relative;
  z-index: 1;
}
.themes-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
}
.themes-header__title {
  font-weight: 800;
}
.themes-header__meta {
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
}
.themes-items {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.theme-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  padding: 12px 14px;
  transition: all var(--transition-base);
  cursor: pointer;
  animation: slideUp 0.3s ease backwards;
}

/* Responsive: Themes */
@media (max-width: 768px) {
  .themes-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .theme-item {
    padding: 10px 12px;
  }

  .theme-item__top {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .theme-item__badges {
    justify-content: flex-start;
  }
}

@media (max-width: 480px) {
  .themes-header {
    padding: 10px 12px;
  }

  .themes-header__title {
    font-size: 15px;
  }

  .theme-item__title {
    font-size: 15px;
  }

  .theme-item__note {
    font-size: 13px;
  }
}

.theme-item:nth-child(1) { animation-delay: 0.05s; }
.theme-item:nth-child(2) { animation-delay: 0.1s; }
.theme-item:nth-child(3) { animation-delay: 0.15s; }
.theme-item:nth-child(4) { animation-delay: 0.2s; }
.theme-item:nth-child(5) { animation-delay: 0.25s; }

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

.theme-item {
  position: relative;
  overflow: hidden;
}

.theme-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(249, 115, 22, 0.06), transparent);
  transition: left 0.6s ease;
  pointer-events: none;
}

.theme-item:hover::before {
  left: 100%;
}

.theme-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(34, 211, 238, 0.2);
  border-color: rgba(34, 211, 238, 0.3);
  background: rgba(255, 255, 255, 0.04);
}

.theme-item:active {
  transform: translateY(0);
  transition: all 0.1s ease;
}
.theme-item__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.theme-item__date {
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}
.theme-item__badges {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.theme-item__title {
  font-weight: 800;
}
.theme-item__note {
  margin-top: 6px;
  color: var(--muted);
  font-weight: 600;
}

/* Marks page */
.marks-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
  position: relative;
  z-index: 1;
}

.simulator {
  margin-top: 22px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  position: relative;
  z-index: 1;
  animation: slideUp 0.35s ease;
}

.simulator__header h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.simulator__controls {
  margin-top: 12px;
}

.simulator__row {
  display: grid;
  grid-template-columns: 1.6fr 0.9fr 0.7fr auto auto;
  gap: 10px;
  align-items: end;
}

.simulator__summary {
  margin-top: 12px;
}

.simulator__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.avg-badge--delta {
  background: rgba(255, 255, 255, 0.03);
}

.avg-badge--delta-good {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.30);
}

.avg-badge--delta-bad {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.30);
}

.avg-badge--delta-neutral {
  background: rgba(34, 211, 238, 0.10);
  border-color: rgba(34, 211, 238, 0.26);
}

.simulator__list {
  margin-top: 12px;
}

.sim-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sim-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  font-weight: 700;
  font-size: 13px;
}

.sim-chip__text {
  color: var(--text);
}

.sim-chip__remove {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  padding: 0;
  transition: all var(--transition-fast);
}

.sim-chip__remove:hover,
.sim-chip__remove:focus-visible {
  border-color: rgba(239, 68, 68, 0.5);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
  transform: translateY(-1px);
}

/* Final marks (Vysvědčení) */
.final-list {
  display: grid;
  gap: 14px;
  margin-top: 10px;
}

.final-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
  padding: 14px;
  animation: slideUp 0.35s ease backwards;
  box-shadow: 0 10px 28px rgba(0,0,0,0.25);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.final-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(168, 85, 247, 0.06), transparent);
  transition: left 0.6s ease;
}

.final-card:hover::before {
  left: 100%;
}

.final-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 36px rgba(0,0,0,0.35), 0 0 0 1px rgba(168, 85, 247, 0.2);
  border-color: rgba(168, 85, 247, 0.3);
}

.final-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.final-card__title {
  margin: 6px 0 0;
}

.final-badges {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.final-badges .badge.avg {
  background: rgba(168, 85, 247, 0.12);
  border-color: rgba(168, 85, 247, 0.28);
}

.final-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-weight: 600;
}

.final-marks-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

/* Responsive: Final marks */
@media (max-width: 900px) {
  .final-marks-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
  }

  .final-card {
    padding: 12px;
  }
}

@media (max-width: 640px) {
  .final-marks-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .final-card__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .final-badges {
    justify-content: flex-start;
  }

  .final-meta {
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .final-marks-grid {
    grid-template-columns: 1fr;
  }

  .final-mark {
    padding: 8px;
  }
}

.final-mark {
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
  padding: 10px;
  display: grid;
  gap: 4px;
}

.final-mark__subject {
  font-weight: 700;
}

.final-mark__value {
  font-weight: 900;
  font-size: 18px;
}

.section-divider {
  margin: 18px 0 10px;
  border-top: 1px solid var(--border);
  opacity: 0.8;
}

.measures-list {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.measure-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  padding: 12px;
  animation: slideUp 0.3s ease backwards;
}

.measure-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.measure-card__title {
  margin: 6px 0 0;
}

.measure-badges {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.measure-card__text {
  margin: 8px 0 0;
  color: var(--text);
  font-weight: 600;
}

.subject-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  padding: 14px;
  transition: all var(--transition-base);
  cursor: pointer;
  animation: slideUp 0.4s ease backwards;
  position: relative;
  overflow: hidden;
}

.subject-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(34, 211, 238, 0.08), transparent);
  transition: left 0.5s ease;
}

.subject-card:hover::before {
  left: 100%;
}

.subject-card:nth-child(odd) { animation-delay: 0.05s; }
.subject-card:nth-child(even) { animation-delay: 0.1s; }

.subject-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(249, 115, 22, 0.3);
  border-color: rgba(249, 115, 22, 0.4);
  background: rgba(255, 255, 255, 0.04);
}

.subject-card:active {
  transform: translateY(-2px) scale(1.01);
  transition: all 0.1s ease;
}

.subject-card__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.subject-card__title {
  font-weight: 700;
}

.subject-card__teacher {
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  margin-top: 2px;
}

.avg-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
  font-weight: 700;
  font-size: 13px;
}

.avg-badge--secondary {
  background: rgba(168, 85, 247, 0.10);
  border-color: rgba(168, 85, 247, 0.30);
}

.avg-stack {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.subject-card__marks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mark-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  color: inherit;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.mark-pill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,0.2), transparent 70%);
  opacity: 0;
  transform: scale(0);
  transition: all 0.4s ease;
}

.mark-pill:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.mark-pill:active::after {
  opacity: 1;
  transform: scale(4);
  transition: all 0s;
}

.mark-pill--good { background: rgba(34, 197, 94, 0.12); border-color: rgba(34, 197, 94, 0.28); }
.mark-pill--good:hover { box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3); border-color: rgba(34, 197, 94, 0.5); }

.mark-pill--ok { background: rgba(34, 211, 238, 0.10); border-color: rgba(34, 211, 238, 0.28); }
.mark-pill--ok:hover { box-shadow: 0 4px 12px rgba(34, 211, 238, 0.3); border-color: rgba(34, 211, 238, 0.5); }

.mark-pill--warn { background: rgba(249, 115, 22, 0.12); border-color: rgba(249, 115, 22, 0.30); }
.mark-pill--warn:hover { box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3); border-color: rgba(249, 115, 22, 0.5); }

.mark-pill--bad { background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.30); }
.mark-pill--bad:hover { box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3); border-color: rgba(239, 68, 68, 0.5); }

.mark-pill--points { background: rgba(168, 85, 247, 0.12); border-color: rgba(168, 85, 247, 0.30); }
.mark-pill--points:hover { box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3); border-color: rgba(168, 85, 247, 0.5); }

/* Responsive: Marks & Simulator */
@media (max-width: 1100px) {
  .marks-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

@media (max-width: 900px) {
  .marks-grid { grid-template-columns: 1fr; }

  .simulator {
    padding: 14px;
  }

  .simulator__row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .simulator__row button {
    width: 100%;
  }

  .subject-card {
    padding: 12px;
  }

  .subject-card__marks {
    gap: 6px;
  }

  .mark-pill {
    padding: 5px 8px;
    font-size: 12px;
  }
}

@media (max-width: 640px) {
  .simulator__row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .simulator__row .field-group {
    width: 100%;
  }

  .avg-stack {
    justify-content: flex-start;
  }

  .subject-card__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

@media (max-width: 560px) {
  .simulator__row {
    grid-template-columns: 1fr;
  }

  .simulator__badges {
    flex-direction: column;
    align-items: stretch;
  }

  .badge {
    text-align: center;
  }
}

/* Substitutions page */
.subs-controls {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

.subs-list {
  margin-top: 14px;
  display: grid;
  gap: 14px;
  position: relative;
  z-index: 1;
}

.subs-day {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  padding: 14px;
  animation: slideUp 0.35s ease backwards;
}

.subs-day__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.subs-day__title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.subs-day__count {
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
}

.subs-day__list {
  display: grid;
  gap: 10px;
}

.subs-item {
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  padding: 12px;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.subs-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(34, 211, 238, 0.05), transparent);
  transition: left 0.5s ease;
}

.subs-item:hover::before {
  left: 100%;
}

.subs-item:hover {
  transform: translateY(-2px);
  border-color: rgba(34, 211, 238, 0.25);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 10px 26px rgba(0,0,0,0.28), 0 0 0 1px rgba(34, 211, 238, 0.15);
}

.subs-item:active {
  transform: translateY(0);
  transition: all 0.1s ease;
}

.subs-item__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.subs-item__hours {
  font-weight: 900;
}

.subs-item__meta {
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  margin-top: 2px;
}

.subs-item__badges {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.subs-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  font-weight: 800;
  font-size: 12px;
}

.subs-badge--good { background: rgba(34, 197, 94, 0.12); border-color: rgba(34, 197, 94, 0.28); }
.subs-badge--warn { background: rgba(249, 115, 22, 0.12); border-color: rgba(249, 115, 22, 0.30); }
.subs-badge--bad { background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.30); }
.subs-badge--neutral { background: rgba(255,255,255,0.03); }

.subs-item__subject {
  margin-top: 8px;
  font-weight: 800;
}

.subs-item__desc {
  margin-top: 6px;
  font-weight: 700;
}

.subs-item__desc--muted {
  color: var(--muted);
}

/* Responsive: Substitutions */
@media (max-width: 900px) {
  .subs-controls {
    flex-wrap: wrap;
  }

  .subs-controls .field-group {
    flex: 1 1 200px;
  }
}

@media (max-width: 720px) {
  .subs-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .subs-controls button.ghost {
    width: 100%;
  }

  .subs-day {
    padding: 12px;
  }

  .subs-item {
    padding: 10px;
  }

  .subs-item__top {
    flex-direction: column;
    align-items: flex-start;
  }

  .subs-item__badges {
    justify-content: flex-start;
  }
}

@media (max-width: 480px) {
  .subs-day__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .subs-badge {
    font-size: 11px;
    padding: 3px 7px;
  }
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 80;
}

.modal--visible {
  display: flex;
  animation: fadeIn 0.25s ease;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.25s ease;
}

.modal__dialog {
  position: relative;
  z-index: 1;
  background: linear-gradient(145deg, rgba(17, 24, 39, 0.97), rgba(11, 17, 32, 0.97));
  backdrop-filter: blur(20px);
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 18px 18px 12px;
  width: min(640px, 92vw);
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 70px rgba(0,0,0,0.6);
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.modal__body {
  display: grid;
  gap: 6px;
}

.detail-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  transition: all var(--transition-fast);
  animation: slideDown 0.3s ease backwards;
}

/* Responsive: Modal & Details */
@media (max-width: 640px) {
  .modal__dialog {
    width: calc(100vw - 16px);
    max-height: 90vh;
    padding: 14px;
  }

  .modal__header {
    margin-bottom: 8px;
  }

  .detail-row {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 8px;
  }

  .detail-row strong {
    text-align: left;
  }
}

@media (max-width: 480px) {
  .modal__dialog {
    padding: 12px;
    border-radius: 12px;
  }
}

.detail-row:nth-child(1) { animation-delay: 0.05s; }
.detail-row:nth-child(2) { animation-delay: 0.1s; }
.detail-row:nth-child(3) { animation-delay: 0.15s; }
.detail-row:nth-child(4) { animation-delay: 0.2s; }
.detail-row:nth-child(5) { animation-delay: 0.25s; }

.detail-row:hover {
  background: rgba(255,255,255,0.04);
  border-color: rgba(34, 211, 238, 0.3);
  transform: translateX(2px);
}

.detail-row span {
  color: var(--muted);
}

.detail-row strong {
  text-align: right;
  white-space: pre-wrap;
}

/* Timetable */
.filter-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.pill-group {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill-group .ghost.active {
  background: rgba(34, 211, 238, 0.12);
  border-color: rgba(34, 211, 238, 0.5);
  color: var(--text);
}

.date-picker label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: #dbeafe;
}

.date-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.date-inline input[type='date'] {
  min-width: 160px;
}

/* Timetable matrix wrapper (horizontal scroll) */
.timetable-grid {
  margin-top: 10px;
  overflow: auto;
  padding-bottom: 6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.timetable-grid::-webkit-scrollbar {
  height: 8px;
}

.timetable-grid::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.02);
  border-radius: 4px;
}

.timetable-grid::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
}

.timetable-grid::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.3);
}

.tt-matrix {
  display: grid;
  grid-template-columns: 140px repeat(var(--tt-hours, 10), minmax(110px, 1fr));
  gap: 10px;
  min-width: 820px;
}

.tt-corner {
  height: 64px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.tt-hour {
  height: 64px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.tt-hour__cap {
  font-weight: 800;
  color: var(--text);
}

.tt-hour__time {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.tt-day {
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  padding: 10px;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.tt-day__dow {
  color: var(--muted);
  font-weight: 800;
  text-transform: lowercase;
}

.tt-day__date {
  font-weight: 800;
  color: var(--text);
}

.tt-day__type,
.tt-day__desc {
  color: var(--muted);
  font-size: 12px;
}

.tt-cell {
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.05);
  background: rgba(0,0,0,0.18);
  min-height: 92px;
  padding: 8px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.tt-empty {
  height: 100%;
  min-height: 76px;
  border-radius: 12px;
  border: 1px dashed rgba(255,255,255,0.06);
  display: grid;
  place-items: center;
  color: rgba(255,255,255,0.20);
  font-weight: 800;
}

.tt-event {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(34, 211, 238, 0.14);
  background: rgba(255,255,255,0.02);
  padding: 10px;
  cursor: pointer;
  color: inherit;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.25);
}

.tt-event:hover,
.tt-event:focus-visible {
  border-color: rgba(34, 211, 238, 0.42);
  outline: none;
}

/* Better touch feedback on mobile */
@media (hover: none) and (pointer: coarse) {
  .tt-event:active {
    transform: scale(0.98);
    border-color: rgba(34, 211, 238, 0.52);
  }
}

.tt-event--changed {
  border-color: rgba(249, 115, 22, 0.40);
  box-shadow: 0 12px 30px rgba(249, 115, 22, 0.10);
}

.tt-event__badges {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tt-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(34, 211, 238, 0.22);
  background: rgba(34, 211, 238, 0.08);
  font-weight: 800;
  font-size: 12px;
  color: var(--text);
}

.tt-badge--alt {
  border-color: rgba(34, 197, 94, 0.26);
  background: rgba(34, 197, 94, 0.10);
}

.tt-event__subject {
  font-weight: 900;
  font-size: 22px;
  line-height: 1.05;
  letter-spacing: 0.4px;
  color: var(--text);
}

.tt-event__subject--has-theme {
  color: rgba(34, 197, 94, 0.95);
}

.tt-event__meta {
  color: var(--muted);
  font-weight: 800;
}

/* Responsive optimizations */

/* Large tablets and small desktops */
@media (max-width: 1200px) {
  .tt-matrix {
    grid-template-columns: 120px repeat(var(--tt-hours, 10), minmax(100px, 1fr));
    gap: 8px;
  }

  .tt-event__subject {
    font-size: 20px;
  }
}

/* Tablets */
@media (max-width: 900px) {
  .tt-matrix {
    grid-template-columns: 100px repeat(var(--tt-hours, 10), minmax(90px, 1fr));
    min-width: 680px;
    gap: 6px;
  }

  .tt-hour,
  .tt-corner {
    height: 56px;
    padding: 8px;
  }

  .tt-day {
    min-height: 80px;
    padding: 8px;
  }

  .tt-cell {
    min-height: 80px;
    padding: 6px;
    gap: 6px;
  }

  .tt-event {
    padding: 8px;
    gap: 5px;
  }

  .tt-event__subject {
    font-size: 18px;
  }

  .tt-badge {
    padding: 3px 6px;
    font-size: 11px;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .date-picker {
    width: 100%;
  }

  .date-inline {
    justify-content: flex-start;
  }
}

/* Mobile landscape and small tablets */
@media (max-width: 768px) {
  .panel {
    padding: 20px;
  }

  .tt-matrix {
    grid-template-columns: 90px repeat(var(--tt-hours, 10), minmax(85px, 1fr));
    min-width: 620px;
  }

  .tt-hour__time {
    font-size: 11px;
  }

  .tt-day__dow,
  .tt-day__date {
    font-size: 14px;
  }

  .tt-day__type,
  .tt-day__desc {
    font-size: 11px;
  }

  .tt-event__subject {
    font-size: 16px;
  }

  .tt-event__meta {
    font-size: 12px;
  }

  .tt-popover__panel {
    width: min(380px, calc(100vw - 20px));
    max-height: min(75vh, 480px);
  }
}

/* Mobile portrait */
@media (max-width: 640px) {
  .page {
    width: 100%;
    padding: 12px;
  }

  .panel {
    padding: 16px;
  }

  .panel__header {
    margin-bottom: 18px;
  }

  h1 {
    font-size: 24px;
  }

  .subtitle {
    font-size: 14px;
  }

  .timetable-grid {
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
  }

  .tt-matrix {
    grid-template-columns: 80px repeat(var(--tt-hours, 10), minmax(80px, 1fr));
    min-width: 560px;
    gap: 5px;
  }

  .tt-hour,
  .tt-corner {
    height: 52px;
    padding: 6px;
    border-radius: 10px;
  }

  .tt-hour__cap {
    font-size: 14px;
  }

  .tt-hour__time {
    font-size: 10px;
  }

  .tt-day {
    min-height: 72px;
    padding: 6px;
    border-radius: 10px;
  }

  .tt-day__dow,
  .tt-day__date {
    font-size: 13px;
  }

  .tt-day__type,
  .tt-day__desc {
    font-size: 10px;
  }

  .tt-cell {
    min-height: 72px;
    padding: 5px;
    gap: 5px;
    border-radius: 10px;
  }

  .tt-empty {
    min-height: 62px;
    font-size: 12px;
  }

  .tt-event {
    padding: 7px;
    gap: 4px;
    border-radius: 10px;
    /* Touch-friendly minimum size */
    min-height: 62px;
  }

  .tt-event__subject {
    font-size: 15px;
  }

  .tt-event__meta {
    font-size: 11px;
  }

  .tt-badge {
    padding: 2px 5px;
    font-size: 10px;
  }

  .tt-popover__panel {
    width: calc(100vw - 16px);
    max-height: min(80vh, 440px);
    padding: 12px;
    border-radius: 12px;
  }

  .tt-popover__row {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 8px;
  }

  .tt-popover__row strong {
    text-align: left;
  }

  .filter-bar {
    gap: 10px;
  }

  .pill-group .ghost {
    padding: 8px 10px;
    font-size: 13px;
  }

  .date-inline input[type='date'] {
    min-width: 140px;
    padding: 10px 12px;
  }

  .ghost {
    padding: 8px 10px;
    font-size: 13px;
  }
}

/* Extra small mobile */
@media (max-width: 480px) {
  .panel {
    padding: 12px;
  }

  .tt-matrix {
    grid-template-columns: 70px repeat(var(--tt-hours, 10), minmax(75px, 1fr));
    min-width: 520px;
  }

  .tt-hour__cap {
    font-size: 13px;
  }

  .tt-hour__time {
    font-size: 9px;
  }

  .tt-event__subject {
    font-size: 14px;
  }

  .tt-badge {
    font-size: 9px;
  }
}

/* Large displays - optimize for better use of space */
@media (min-width: 1400px) {
  .page {
    width: min(1400px, 100%);
  }

  .tt-matrix {
    grid-template-columns: 160px repeat(var(--tt-hours, 10), minmax(120px, 1fr));
    gap: 12px;
  }

  .tt-hour,
  .tt-corner {
    height: 68px;
  }

  .tt-day {
    min-height: 100px;
  }

  .tt-cell {
    min-height: 100px;
    padding: 10px;
  }

  .tt-event {
    padding: 12px;
  }

  .tt-event__subject {
    font-size: 24px;
  }

  .tt-popover__panel {
    width: min(480px, calc(100vw - 24px));
  }
}

/* High DPI displays - sharper rendering */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .tt-event,
  .tt-cell,
  .tt-hour,
  .tt-day {
    border-width: 0.5px;
  }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.day-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  padding: 14px;
}

.day-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.day-card__date {
  font-weight: 700;
  font-size: 18px;
}

.day-card__desc {
  color: var(--muted);
  font-size: 14px;
}

.day-card__lessons {
  display: grid;
  gap: 10px;
}

.lesson {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
}

.lesson--empty {
  grid-template-columns: 1fr;
  text-align: center;
  color: var(--muted);
}

.lesson__time {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-weight: 700;
}

.lesson__hour {
  font-size: 14px;
}

.lesson__range {
  font-size: 13px;
}

.lesson__body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lesson__title {
  font-weight: 700;
  font-size: 15px;
}

.lesson__meta {
  color: var(--muted);
  font-size: 13px;
}

.lesson__theme {
  color: var(--text);
  font-size: 13px;
}

.lesson__change {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.lesson__change-text {
  color: var(--muted);
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}

.pill--change {
  background: rgba(249, 115, 22, 0.14);
  border-color: rgba(249, 115, 22, 0.4);
}

.pill--daytype {
  background: rgba(34, 211, 238, 0.10);
  border-color: rgba(34, 211, 238, 0.30);
}

/* Responsive: Day cards & Lessons */
@media (max-width: 768px) {
  .day-card {
    padding: 12px;
  }

  .day-card__date {
    font-size: 16px;
  }

  .day-card__desc {
    font-size: 13px;
  }

  .lesson {
    grid-template-columns: 100px 1fr;
    gap: 10px;
    padding: 8px;
  }
}

@media (max-width: 640px) {
  .day-card {
    padding: 10px;
  }

  .lesson {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .lesson__time {
    flex-direction: row;
    gap: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
  }

  .lesson__hour {
    font-size: 13px;
  }

  .lesson__range {
    font-size: 12px;
  }

  .lesson__title {
    font-size: 14px;
  }

  .lesson__meta,
  .lesson__theme {
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .lesson {
    padding: 8px;
  }

  .pill {
    font-size: 11px;
    padding: 3px 6px;
  }
}

/* Timetable popover */
.tt-popover {
  position: fixed;
  inset: 0 auto auto 0;
  z-index: 90;
}

.tt-popover[hidden] {
  display: none;
}

.tt-popover__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
}

.tt-popover__panel {
  position: fixed;
  width: min(420px, calc(100vw - 24px));
  max-height: min(70vh, 520px);
  overflow: auto;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(145deg, rgba(17, 24, 39, 0.97), rgba(11, 17, 32, 0.97));
  box-shadow: 0 20px 70px rgba(0,0,0,0.55);
  padding: 14px;
}

.tt-popover__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.tt-popover__title {
  font-weight: 800;
}

.tt-popover__content {
  display: grid;
  gap: 6px;
}

.tt-popover__row {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
}

.tt-popover__row span {
  color: var(--muted);
}

.tt-popover__row strong {
  text-align: right;
  white-space: pre-wrap;
}

.tt-popover__sep {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 6px 0;
  border-radius: 999px;
}

/* Loading Spinner */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner--large {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

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

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.03) 0%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.03) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 8px;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 1em;
  margin: 4px 0;
}

.skeleton-card {
  height: 120px;
  border-radius: 14px;
}

/* Empty State */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  animation: fadeIn 0.5s ease;
}

.empty-state__icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state__title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.empty-state__text {
  font-size: 14px;
  opacity: 0.8;
}

/* Utility Classes */
.fade-in {
  animation: fadeIn 0.4s ease;
}

.slide-up {
  animation: slideUp 0.4s ease;
}

.pulse {
  animation: pulse 2s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Smooth transitions for dynamic content */
.transition-opacity {
  transition: opacity var(--transition-base);
}

.transition-transform {
  transition: transform var(--transition-base);
}

.transition-all {
  transition: all var(--transition-base);
}

/* Focus improvements */
*:focus-visible {
  outline: 2px solid rgba(34, 211, 238, 0.6);
  outline-offset: 2px;
}

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

/* ============================================ */
/* ADDITIONAL RESPONSIVE ENHANCEMENTS */
/* ============================================ */

/* Extra small devices (portrait phones, less than 375px) */
@media (max-width: 374px) {
  body {
    padding: 4px;
    font-size: 13px;
  }

  .panel {
    padding: 12px;
    border-radius: 8px;
  }

  h1 {
    font-size: 18px;
  }

  .eyebrow {
    font-size: 11px;
    padding: 4px 6px;
  }

  input,
  select,
  button[type='submit'],
  .ghost {
    font-size: 13px;
    padding: 10px;
  }

  .badge {
    font-size: 11px;
    padding: 3px 8px;
  }
}

/* Small tablets (portrait, 768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
  .marks-grid,
  .simulator__grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }

  .final-marks-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .tt-matrix {
    grid-template-columns: 120px repeat(var(--tt-hours, 10), minmax(100px, 1fr));
  }
}

/* Landscape orientation optimizations */
@media (orientation: landscape) and (max-height: 600px) {
  body {
    padding: 8px;
    align-items: flex-start;
  }

  .panel {
    margin: 0;
  }

  .site-header {
    position: relative;
    height: auto;
  }

  .with-header .page {
    padding-top: 8px;
  }

  h1 {
    font-size: 20px;
    margin: 4px 0;
  }

  .panel__header {
    margin-bottom: 12px;
  }
}

/* Large screens (desktops, 1400px and up) */
@media (min-width: 1400px) {
  .page {
    width: min(1280px, 100%);
  }

  .marks-grid {
    grid-template-columns: 1fr;
  }

  .final-marks-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }

  .tt-matrix {
    grid-template-columns: 160px repeat(var(--tt-hours, 10), minmax(130px, 1fr));
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Larger hit areas for touch */
  button,
  a,
  .ghost,
  .badge,
  .tab-btn {
    min-height: 44px;
    min-width: 44px;
  }

  /* Remove hover effects on touch devices */
  .panel:hover,
  .ghost:hover,
  .subject-card:hover,
  .theme-item:hover {
    transform: none;
    box-shadow: var(--shadow);
  }

  /* Larger select dropdowns */
  select {
    font-size: 16px; /* Prevents zoom on iOS */
  }

  /* Better spacing for touch */
  .site-nav a {
    padding: 12px 16px;
  }

  .mark-pill,
  .badge {
    padding: 8px 12px;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  body {
    -webkit-font-smoothing: subpixel-antialiased;
  }

  .panel,
  .ghost,
  button {
    border-width: 0.5px;
  }
}

/* Print styles */
@media print {
  body {
    background: white;
    color: black;
    padding: 0;
  }

  .panel {
    box-shadow: none;
    border: 1px solid #ccc;
    page-break-inside: avoid;
  }

  .site-header,
  .site-footer,
  .burger-menu,
  .ghost,
  button[type='submit'],
  .simulator {
    display: none;
  }

  .panel__header {
    margin-bottom: 16px;
  }

  h1, h2, h3 {
    color: black;
  }

  .timetable-grid {
    overflow: visible;
  }

  .tt-matrix {
    min-width: auto;
  }
}

/* ============================================ */
/* UTILITY CLASSES & ANIMATIONS                */
/* ============================================ */

/* Loading Spinner */
.spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner--small {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.spinner--large {
  width: 60px;
  height: 60px;
  border-width: 4px;
}

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

/* Pulse animation for loading states */
.pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Skeleton loaders */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.03) 25%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.03) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 8px;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton--text {
  height: 16px;
  margin: 8px 0;
}

.skeleton--title {
  height: 24px;
  width: 60%;
}

.skeleton--card {
  height: 120px;
  border-radius: 14px;
}

/* Glow effects */
.glow {
  box-shadow: 0 0 20px var(--glow-accent-2);
}

.glow--accent {
  box-shadow: 0 0 20px var(--glow-accent);
}

/* Shake animation for errors */
@keyframes shake-error {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
  20%, 40%, 60%, 80% { transform: translateX(8px); }
}

.shake {
  animation: shake-error 0.5s ease;
}

/* Bounce animation */
@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.bounce {
  animation: bounce 0.6s ease infinite;
}

/* Fade animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.5s ease;
}

@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.fade-in-left {
  animation: fadeInLeft 0.5s ease;
}

/* Slide animations */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.slide-in-right {
  animation: slideInRight 0.4s ease;
}

/* Rotate animations */
@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.rotate {
  animation: rotate 2s linear infinite;
}

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width 0.3s ease;
  position: relative;
  overflow: hidden;
}

.progress-bar__fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: progress-shimmer 1.5s ease infinite;
}

@keyframes progress-shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* Tooltip */
.tooltip {
  position: relative;
  cursor: help;
}

.tooltip::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: 6px 10px;
  background: rgba(17, 24, 39, 0.97);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-fast);
  z-index: 100;
}

.tooltip::after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(17, 24, 39, 0.97);
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-fast);
}

.tooltip:hover::before,
.tooltip:hover::after {
  opacity: 1;
}

/* Utility classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.hidden { display: none !important; }
.visible { display: block !important; }

.opacity-0 { opacity: 0; }
.opacity-50 { opacity: 0.5; }
.opacity-100 { opacity: 1; }

/* Focus visible improvements */
*:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  transition: background var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Selection styling */
::selection {
  background: rgba(34, 211, 238, 0.3);
  color: var(--text);
}

::-moz-selection {
  background: rgba(34, 211, 238, 0.3);
  color: var(--text);
}
