/* ====== CSS Variables ====== */
:root{
  --bg: #0f1115;
  --panel: #161a22;
  --panel-2: #1b2130;
  --text: #e6e9ef;
  --muted: #9aa3b2;
  --primary: #7c9cff;
  --primary-600: #567dff;
  --danger: #ff6b6b;
  --accent: #32d4a4;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}

*{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  margin: 0; font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica Neue, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: radial-gradient(1200px 800px at 10% -10%, #1c2230 0%, transparent 60%) no-repeat, var(--bg);
  color: var(--text);
}

[hidden] { display: none !important; }

/* ====== Header ====== */
.app-header{
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem;
  background: rgba(22,26,34,.9);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 6px 20px rgba(0,0,0,.35);
}
.app-header h1{
  margin: 0; font-size: 1.6rem; font-weight: 700; letter-spacing: .3px;
}
.app-header .header-right{
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.app-header .header-link{
  color: var(--text);
  background: #0f131b;
  border: 1px solid rgba(255,255,255,.08);
  padding: .45rem .7rem; border-radius: 10px;
  text-decoration: none;
}
.app-header .header-link:hover{ background: #151a2a; }

#auth-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#user-info {
  color: var(--text);
  font-size: 0.95rem;
}

/* ====== Authentication Forms ====== */
.auth-container {
  max-width: 900px;
  margin: 3rem auto;
  padding: 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
}

.auth-box {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-radius: 14px;
  padding: 2rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.06);
}

.auth-box-centered {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-radius: 14px;
  padding: 2.5rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.06);
  width: 100%;
  max-width: 400px;
}

.auth-box h2,
.auth-box-centered h2 {
  margin-top: 0;
  margin-bottom: 1.5rem;
  font-size: 1.75rem;
  color: var(--text);
  text-align: center;
}

.auth-switch {
  text-align: center;
  margin-top: 1.5rem;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.auth-switch a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.error-message {
  background: rgba(255, 107, 107, 0.15);
  border: 1px solid rgba(255, 107, 107, 0.3);
  color: #ff9999;
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  display: none;
}

.error-message:not(:empty) {
  display: block;
}

/* ====== Galleries List ====== */
.galleries-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.75rem;
}

.galleries-list li {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
}

.gallery-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  color: var(--text);
  text-decoration: none;
  transition: background 0.2s ease;
}

.gallery-link:hover {
  background: rgba(124, 156, 255, 0.1);
}

.gallery-name {
  font-size: 1.1rem;
  font-weight: 600;
}

.gallery-count {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ====== Breadcrumb ====== */
.breadcrumb {
  margin-bottom: 1rem;
}

/* ====== Layout ====== */
.container{ max-width: 1000px; margin: 0 auto; padding: 1rem; display: grid; gap: 1.5rem; }

/* ====== Panels ====== */
.panel{
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-radius: 14px; padding: 1rem; box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.06);
  margin-bottom: 1.5rem;
}
.panel-header{ display:flex; align-items:center; justify-content: space-between; gap:.5rem; }

.panel-header .header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.add-image-panel .panel-header{ justify-content: center; }

.add-image-panel .collapsible[hidden]{ display: block; height: 0; overflow: hidden; padding-top: 0; padding-bottom: 0; border: 0; }
.add-image-panel .collapsible{
  margin-top: .75rem; animation: drop .35s ease both;
}
@keyframes drop{ from{ opacity: 0; transform: translateY(-6px); } to{ opacity: 1; transform: translateY(0); } }

/* ====== Forms ====== */
.field{ display: grid; gap: .35rem; margin-block: .6rem; }
label{ color: var(--muted); font-size: .9rem; }
input, textarea{
  width: 100%; color: var(--text); background: #0f131b; border: 1px solid #283148; border-radius: 10px;
  padding: .7rem .8rem; outline: none; transition: border .15s ease, box-shadow .15s ease;
}
input:focus-visible, textarea:focus-visible{ border-color: var(--primary); box-shadow: 0 0 0 3px rgba(124,156,255,.15); }

.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrapper input {
  padding-right: 2.5rem;
}

.toggle-password {
  position: absolute;
  right: 0.5rem;
  background: transparent;
  border: none;
  padding: 0.4rem;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
  border-radius: 6px;
}

.toggle-password:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.toggle-password:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ====== Buttons ====== */
.actions{ display:flex; gap:.5rem; flex-wrap: wrap; }
.btn{
  appearance: none; border: 1px solid rgba(255,255,255,.08); background: #121622; color: var(--text);
  padding: .55rem .8rem; border-radius: 10px; cursor: pointer; transition: transform .06s ease, background .2s ease, color .2s ease, border-color .2s ease;
}
.btn:hover{ transform: translateY(-1px); background: #151a2a; }
.btn:active{ transform: translateY(0); }
.btn.primary{ background: linear-gradient(180deg, var(--primary), var(--primary-600)); border-color: rgba(0,0,0,.15); color: #081028; }
.btn.primary:hover{ filter: brightness(1.05); }
.btn.danger{ background: linear-gradient(180deg, #ff8181, var(--danger)); color: #2b0707; border-color: rgba(0,0,0,.15); }
.btn.subtle{ background: #0f131b; color: var(--muted); }
.btn[disabled]{ opacity: .6; cursor: not-allowed; }

/* ====== Image Viewer ====== */
.viewer{ background: transparent; margin-bottom: 1.5rem; }
.viewer-inner{ display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: .5rem; }
.stage{ margin: 0; background: linear-gradient(180deg, var(--panel), var(--panel-2)); border-radius: 16px; padding: .75rem; border: 1px solid rgba(255,255,255,.06); box-shadow: var(--shadow); display: grid; gap: .6rem; }
.stage img{ width: 100%; height: 55vh; object-fit: contain; background: #0c0f15; border-radius: 10px; animation: fadein .25s ease both; }
@keyframes fadein{ from{ opacity:0 } to{ opacity: 1 } }
.stage figcaption{ display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .95rem; flex-wrap: wrap; word-break: break-word; }
.stage .title{ color: var(--text); font-weight: 600; max-width: 100%; word-break: break-word; }
.stage .author{ max-width: 100%; word-break: break-word; }
.stage .sep{ opacity: .5; }

.nav-btn{ width: 48px; height: 48px; border-radius: 12px; border: 1px solid rgba(255,255,255,.08); background: #101521; color: var(--text); font-size: 26px; line-height: 1; display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow); }
.nav-btn:hover{ background: #151b2a; }
.nav-btn[disabled]{ opacity: 0; pointer-events: none; }

.viewer-actions{ margin-top: 1rem; display: flex; justify-content: flex-end; }

/* ====== Comments ====== */
.comment-list{ list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.comment-list li{ display: grid; gap: .35rem; padding: .75rem; background: linear-gradient(180deg, var(--panel), var(--panel-2)); border-radius: 12px; border: 1px solid rgba(255,255,255,.06); }
.comment-header{ display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; color: var(--muted); }
.comment-author{ font-weight: 600; color: var(--text); }
.comment-date{ font-size: .85rem; }
.comment-actions{ display:flex; gap:.5rem; }

.pager{ display:flex; gap:.5rem; }

/* Informational panel when there are no images */
.empty{ text-align: center; color: var(--muted); padding: 2rem; margin-bottom: 1.5rem; }

/* ====== Media Queries ====== */
@media (max-width: 720px){
  .viewer-inner{ grid-template-columns: 36px 1fr 36px; }
  .nav-btn{ width: 36px; height: 36px; font-size: 20px; }
}

.credits-page main{ max-width: 800px; margin: 0 auto; padding: 2rem 1rem; }
.credits-page h1{ margin-bottom: 1rem; }
.credits-page ul{ padding-left: 1.2rem; }
.credits-page .note{ color: var(--muted); font-size: .9rem; }
