:root {
  color-scheme: light dark;
  --bg: #0f172a;
  --bg-panel: rgba(15, 23, 42, 0.65);
  --bg-light: #f8fafc;
  --text: #0f172a;
  --text-light: #e2e8f0;
  --accent: #6366f1;
  --accent-dark: #4f46e5;
  --border: rgba(148, 163, 184, 0.3);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(160deg, #111827 0%, #1e293b 40%, #0f172a 100%);
  color: var(--text-light);
  display: flex;
  flex-direction: column;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.app-header,
.app-footer {
  padding: 1.5rem clamp(1rem, 5vw, 3rem);
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(6px);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.5);
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
}

.app-header p,
.app-footer p {
  margin: 0.5rem 0 0;
  max-width: 700px;
  line-height: 1.6;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  padding: clamp(1rem, 5vw, 3rem);
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.3);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel h2 {
  margin: 0;
  font-size: 1.4rem;
}

.settings-section {
  width: min(640px, 100%);
  align-self: center;
}

.camera-section {
  width: min(960px, 100%);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: clamp(1.25rem, 4vw, 2rem);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.35);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1.5rem;
}

.camera-section .status-message {
  text-align: center;
}


.camera-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 16px;
  overflow: hidden;
  background: #0f172a;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-controls {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.camera-controls button {
  min-width: 180px;
}

.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.preset-button {
  text-transform: capitalize;
  min-width: 130px;
  letter-spacing: 0.01em;
}

.preset-button--active {
  background: rgba(99, 102, 241, 0.18);
  border-color: var(--accent);
  color: var(--text-light);
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.35);
}

.preset-button--active:hover:not(:disabled) {
  background: rgba(99, 102, 241, 0.22);
}

.preset-button:hover:not(:disabled) {
  box-shadow: 0 10px 25px rgba(148, 163, 184, 0.18);
  transform: translateY(-1px);
}

video,
#photoPreview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#photoPreview {
  opacity: 0;
  transition: opacity 0.4s ease;
}

#photoPreview.is-visible {
  opacity: 1;
}

.countdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  color: #f8fafc;
  font-weight: 700;
  font-size: clamp(3rem, 12vw, 6rem);
  text-shadow: 0 12px 32px rgba(15, 23, 42, 0.7);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 2;
}

.countdown-overlay.is-visible {
  opacity: 1;
}

.countdown-overlay__text {
  display: inline-block;
  min-width: 2ch;
  text-align: center;
  transform-origin: center;
}

.countdown-overlay__text.is-animating {
  animation: countdown-pop 1s ease;
}

@keyframes countdown-pop {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }
  15% {
    opacity: 1;
  }
  40% {
    transform: scale(1.05);
  }
  70% {
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.9);
  }
}

.prompt-bar {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.prompt-field {
  flex: 1 1 280px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.prompt-field span {
  font-weight: 600;
}

#submitButton {
  flex: 0 0 auto;
  align-self: stretch;
}

.post-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.post-actions a,
.post-actions button {
  flex: 0 0 auto;
}

.remember-field {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.95rem;
}

button,
a.secondary {
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.4rem;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  text-decoration: none;
  text-align: center;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
  box-shadow: none;
}

button.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4);
}

button.primary:hover:not(:disabled) {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

button.secondary,
a.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-light);
}

button.secondary:hover:not(:disabled),
a.secondary:hover {
  background: rgba(148, 163, 184, 0.1);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field span {
  font-weight: 600;
}

textarea,
input[type="password"] {
  background: rgba(15, 23, 42, 0.65);
  color: var(--text-light);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  font-size: 1rem;
  resize: vertical;
}

textarea:focus,
input[type="password"]:focus {
  outline: 2px solid rgba(99, 102, 241, 0.4);
  outline-offset: 2px;
}

.hint {
  color: rgba(226, 232, 240, 0.7);
}

.status-message {
  min-height: 1.2rem;
  color: rgba(226, 232, 240, 0.85);
  font-size: 0.9rem;
}

.status-message.error {
  color: #fca5a5;
}

.status-message.success {
  color: #bbf7d0;
}

.gallery-section {
  width: min(960px, 100%);
  align-self: stretch;
}

.gallery-header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.gallery-header p {
  margin: 0;
  color: rgba(226, 232, 240, 0.75);
}

.gallery-tabs {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.55);
}

.gallery-tab {
  padding: 0.4rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-light);
  box-shadow: none;
  transform: none;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.gallery-tab[aria-selected="true"] {
  background: var(--accent);
  color: white;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
}

.gallery-tab:hover:not([aria-selected="true"]) {
  background: rgba(148, 163, 184, 0.15);
}

.gallery-tab:focus-visible {
  outline: 2px solid rgba(99, 102, 241, 0.6);
  outline-offset: 2px;
}

.gallery-content {
  width: 100%;
}

.gallery-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}


.gallery-item {
  margin: 0;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
}

.gallery-item__footer {
  margin: 0;
  padding: 0.75rem 0.9rem;
  background: rgba(15, 23, 42, 0.65);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.gallery-item__description {
  flex: 1 1 auto;
  font-size: 0.85rem;
  line-height: 1.4;
  color: rgba(226, 232, 240, 0.85);
}

.gallery-item__actions {
  display: flex;
  flex: 0 0 auto;
  gap: 0.5rem;
  align-items: center;
}

.gallery-item__download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.3rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-light);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.gallery-item__download:hover,
.gallery-item__download:focus-visible {
  background: rgba(99, 102, 241, 0.25);
  color: white;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

.gallery-item__delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(248, 113, 113, 0.5);
  background: rgba(239, 68, 68, 0.15);
  color: rgba(248, 250, 252, 0.9);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease,
    border-color 0.2s ease, opacity 0.2s ease;
}

.gallery-item__delete:hover,
.gallery-item__delete:focus-visible {
  background: rgba(239, 68, 68, 0.25);
  color: white;
  border-color: rgba(248, 113, 113, 0.7);
  box-shadow: 0 8px 20px rgba(239, 68, 68, 0.3);
}

.gallery-item__delete:disabled {
  opacity: 0.7;
  cursor: wait;
  box-shadow: none;
}

.gallery-item img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
}

.gallery-item figcaption {
  margin: 0;
}

.gallery-empty {
  margin: 0;
  padding: 1rem;
  border-radius: 12px;
  border: 1px dashed var(--border);
  text-align: center;
  color: rgba(226, 232, 240, 0.7);
  background: rgba(15, 23, 42, 0.35);
}

@media (max-width: 768px) {
  .app-header,
  .app-footer {
    text-align: center;
  }

  .camera-section {
    padding: 1.25rem;
  }

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

  #submitButton {
    width: 100%;
  }

  .gallery-tabs {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}
