:root {
  --bg: #14100c;
  --bg-elevated: #1f1812;
  --surface: #2a2219;
  --text: #f5efe6;
  --text-muted: #b5a090;
  --accent: #c47b3a;
  --accent-soft: rgba(196, 123, 58, 0.2);
  --border: rgba(245, 239, 230, 0.1);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.25rem clamp(1.25rem, 4vw, 3rem);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(20, 16, 12, 0.92);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.logo:hover {
  text-decoration: none;
}

.logo-mark {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #e8c9a0, var(--accent) 55%, #6b3d1f);
  color: #14100c;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1rem;
  box-shadow: 0 0 24px var(--accent-soft);
}

.site-nav {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.site-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.site-nav a:hover {
  color: var(--text);
  text-decoration: none;
}

main {
  padding-bottom: 4rem;
}

.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 2.5rem;
  align-items: center;
  padding: clamp(2.5rem, 6vw, 5rem) clamp(1.25rem, 4vw, 3rem);
  max-width: 1200px;
  margin: 0 auto;
}

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

.eyebrow {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.75rem;
}

.hero h1 {
  font-size: clamp(2rem, 4.5vw, 3.25rem);
  line-height: 1.15;
  margin: 0 0 1rem;
  font-weight: 700;
}

.lead {
  color: var(--text-muted);
  font-size: 1.1rem;
  max-width: 38ch;
  margin: 0 0 1.75rem;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.7rem 1.25rem;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #14100c;
}

.btn-primary:hover {
  filter: brightness(1.08);
  text-decoration: none;
}

.btn-ghost {
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  background: var(--surface);
  text-decoration: none;
}

.hero-visual {
  margin: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45), 0 0 80px var(--accent-soft);
}

.hero-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: 4 / 5;
}

.services,
.code-section,
.gallery-section,
.contact {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem clamp(1.25rem, 4vw, 3rem);
}

.services h2,
.code-section h2,
.gallery-section h2,
.contact h2 {
  font-size: 1.75rem;
  margin: 0 0 1.5rem;
}

.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

.service-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.service-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.service-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.section-head p {
  color: var(--text-muted);
  margin: -0.75rem 0 1.5rem;
  max-width: 60ch;
}

.code-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.code-card:hover {
  text-decoration: none;
  border-color: rgba(196, 123, 58, 0.45);
  background: var(--surface);
}

.code-card h3 {
  margin: 0 0 0.5rem;
  font-family: var(--mono);
  font-size: 1.1rem;
  color: var(--accent);
}

.code-card p {
  margin: 0;
  color: var(--text-muted);
  max-width: 50ch;
  font-size: 0.95rem;
}

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

.gallery-item {
  position: relative;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: var(--surface);
  aspect-ratio: 1;
}

.gallery-item img,
.gallery-placeholder {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s ease;
}

.gallery-placeholder {
  display: block;
  background: var(--surface);
}

.gallery-media-icon {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 4px;
  background: rgba(20, 16, 12, 0.8);
  color: var(--text);
  pointer-events: none;
}

.gallery-media-icon svg {
  width: 1rem;
  height: 1rem;
}

.gallery-item:hover img {
  transform: scale(1.04);
}

.gallery-album,
.gallery-date {
  position: absolute;
  left: 0.5rem;
  font-size: 0.7rem;
  font-family: var(--mono);
  background: rgba(20, 16, 12, 0.8);
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  max-width: calc(100% - 1rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-album {
  top: 0.5rem;
}

.gallery-date {
  bottom: 0.5rem;
}

.gallery-loading,
.gallery-empty {
  color: var(--text-muted);
  grid-column: 1 / -1;
}

.contact-intro,
.contact-unavailable {
  color: var(--text-muted);
  max-width: 50ch;
}

.contact-form {
  max-width: 32rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.contact-form .form-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
}

.contact-form .form-row label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
}

.contact-form .form-row input,
.contact-form .form-row textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}

.contact-form .form-row input:focus,
.contact-form .form-row textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: rgba(196, 123, 58, 0.45);
}

.contact-form .form-row textarea {
  resize: vertical;
  min-height: 8rem;
}

.contact-form .btn {
  align-self: flex-start;
}

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

.contact-result {
  margin-top: 1rem;
  max-width: 32rem;
}

.alert {
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.alert p {
  margin: 0;
}

.alert ul {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}

.alert-success {
  background: rgba(196, 123, 58, 0.12);
  border-color: rgba(196, 123, 58, 0.35);
}

.alert-error {
  background: rgba(120, 40, 40, 0.25);
  border-color: rgba(180, 80, 80, 0.35);
}

.alert a {
  color: var(--accent);
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem clamp(1.25rem, 4vw, 3rem);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.site-footer p {
  margin: 0;
  max-width: 1200px;
  margin-inline: auto;
}

.site-footer a {
  margin-left: 0.75rem;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  display: grid;
  place-items: center;
  padding: 1.5rem;
  z-index: 100;
}

.modal {
  position: relative;
  max-width: min(960px, 100%);
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow: hidden;
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.modal-figure {
  margin: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}

.modal-figure > img {
  display: block;
  width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 8px;
  background: #000;
}

.modal-video-stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

.modal-video-stack video {
  display: block;
  width: 100%;
  max-height: 75vh;
  min-height: 3.5rem;
  object-fit: contain;
  border-radius: 8px;
  background: #000;
}

.modal-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
}

.modal-nav-btn {
  font: inherit;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.modal-nav-btn:hover {
  background: var(--accent-soft);
}

.htmx-request.gallery-grid {
  opacity: 0.6;
}

/* --- Mobile --- */
@media (max-width: 768px) {
  .site-header {
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
  }

  .logo-text {
    font-size: 0.95rem;
  }

  .site-nav {
    width: 100%;
    gap: 0.5rem 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.15rem;
  }

  .site-nav::-webkit-scrollbar {
    display: none;
  }

  .site-nav a {
    font-size: 0.9rem;
    white-space: nowrap;
    padding: 0.35rem 0;
  }

  .hero {
    gap: 1.5rem;
    padding: 1.75rem 1rem 2rem;
  }

  .hero h1 {
    font-size: clamp(1.65rem, 8vw, 2.25rem);
  }

  .lead {
    font-size: 1rem;
    max-width: none;
  }

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

  .hero-actions .btn {
    justify-content: center;
    min-height: 2.75rem;
  }

  .services,
  .code-section,
  .gallery-section,
  .contact {
    padding: 2rem 1rem;
  }

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

  .code-card {
    flex-direction: column;
    align-items: stretch;
    padding: 1.25rem;
  }

  .code-card .btn {
    justify-content: center;
    width: 100%;
    min-height: 2.75rem;
    pointer-events: none;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .contact-form {
    max-width: none;
  }

  .contact-form .btn {
    width: 100%;
    justify-content: center;
    min-height: 2.75rem;
  }

  .site-footer {
    padding: 1.25rem 1rem;
    font-size: 0.85rem;
  }

  .site-footer p {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
  }

  .site-footer a {
    margin-left: 0;
  }

  .modal-backdrop {
    padding: 0;
    align-items: stretch;
  }

  .modal {
    display: flex;
    flex-direction: column;
    max-width: none;
    width: 100%;
    min-height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    padding: max(0.75rem, env(safe-area-inset-top))
      max(0.75rem, env(safe-area-inset-right))
      max(0.75rem, env(safe-area-inset-bottom))
      max(0.75rem, env(safe-area-inset-left));
  }

  .modal-close {
    top: max(0.5rem, env(safe-area-inset-top));
    right: max(0.5rem, env(safe-area-inset-right));
    width: 2.75rem;
    height: 2.75rem;
  }

  .modal-figure {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .modal-figure > img {
    flex: 1;
    min-height: 0;
    max-height: none;
    object-fit: contain;
  }

  .modal-video-stack {
    flex: 1;
    min-height: 0;
    justify-content: center;
  }

  .modal-video-stack video {
    flex: 1;
    min-height: 0;
    max-height: none;
  }

  .modal-nav {
    flex-shrink: 0;
    gap: 0.5rem;
  }

  .modal-nav-btn {
    flex: 1;
    min-height: 2.75rem;
    text-align: center;
  }
}

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

@media (hover: hover) {
  .gallery-item:hover img {
    transform: scale(1.04);
  }
}

@media (hover: none) {
  .gallery-item:active img {
    transform: scale(1.02);
  }
}

/* --- Admin --- */
.admin-body {
  min-height: 100vh;
}

.admin-login {
  max-width: 24rem;
  margin: 4rem auto;
  padding: 0 1rem;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 2rem);
  border-bottom: 1px solid var(--border);
}

.admin-header h1 {
  margin: 0;
  font-size: 1.25rem;
}

.admin-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem clamp(1rem, 4vw, 2rem) 3rem;
}

.admin-panel {
  margin-bottom: 2rem;
  padding: 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.admin-panel h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
}

.admin-back {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.admin-table code {
  font-family: var(--mono);
  font-size: 0.8rem;
  word-break: break-all;
}

.admin-thumb {
  width: 4rem;
}

.admin-thumb img {
  width: 4rem;
  height: 4rem;
  object-fit: cover;
  border-radius: 6px;
}

.admin-delete {
  color: #e8a090;
}

.admin-delete:hover {
  background: rgba(120, 40, 40, 0.25);
}

#admin-flash:empty {
  display: none;
}

.contact-form select {
  display: block;
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
}

.contact-form input[type="file"] {
  font-size: 0.9rem;
  color: var(--text-muted);
}
