:root {
  --background: #ffffff;
  --surface: #ffffff;
  --surface-muted: #f7f8f7;
  --text: #111513;
  --muted: #5e6762;
  --border: #d8ddda;
  --accent: #0f8f68;
  --accent-strong: #087452;
  --danger: #d92d2d;
  --shadow: 0 12px 32px rgba(17, 21, 19, 0.08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--background);
  color: var(--text);
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--background);
  color: var(--text);
}

button,
input {
  font: inherit;
}

svg {
  display: block;
}

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

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  min-height: 72px;
  padding: max(10px, env(safe-area-inset-top)) 18px 10px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

.header-spacer {
  grid-column: 1;
}

.header-title {
  grid-column: 2;
  min-width: 0;
  text-align: center;
}

.app-header h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
  font-weight: 760;
}

.header-title span {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.1;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-header form {
  grid-column: 3;
  margin: 0;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: var(--radius);
}

.icon-button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-main {
  width: min(100%, 820px);
  margin: 0 auto;
  padding: 22px 18px calc(34px + env(safe-area-inset-bottom));
}

.capture-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.capture-heading {
  padding: 18px 20px 0;
}

.capture-heading h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 780;
}

.upload-form {
  display: grid;
  gap: 16px;
  padding: 24px 20px 18px;
}

[data-photo-input] {
  position: absolute;
  pointer-events: none;
  opacity: 0;
}

.capture-button {
  display: grid;
  justify-items: center;
  gap: 14px;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  font-weight: 650;
  cursor: pointer;
}

.camera-circle {
  display: grid;
  place-items: center;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  color: white;
  background: var(--accent);
  box-shadow: 0 12px 24px rgba(15, 143, 104, 0.25);
}

.camera-circle svg {
  width: 52px;
  height: 52px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.secondary-button,
.login-form button {
  min-height: 48px;
  border: 0;
  border-radius: var(--radius);
  color: #fff;
  background: var(--accent);
  font-size: 16px;
  line-height: 1;
  font-weight: 700;
}

.secondary-button:disabled {
  color: var(--muted);
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

.import-form {
  display: grid;
  gap: 12px;
  padding: 0 20px 20px;
}

.import-button {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 14px;
  color: var(--accent-strong);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1;
  font-weight: 760;
  cursor: pointer;
}

.import-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.upload-status {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.check-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: white;
  background: var(--accent);
}

.check-icon svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#upload-status-text {
  color: var(--accent-strong);
  font-size: 17px;
  font-weight: 700;
}

.progress-line {
  grid-column: 2;
  display: block;
  width: 100%;
  height: 6px;
  margin-top: -6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(15, 143, 104, 0.16);
}

.progress-line::after {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform-origin: left center;
}

@keyframes progress {
  from {
    transform: scaleX(0.35);
  }
  to {
    transform: scaleX(0.95);
  }
}

body:has(.is-uploading) .progress-line::after {
  animation: progress 1.1s ease-in-out infinite alternate;
}

.gallery-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 22px;
  padding: 4px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.gallery-tabs a {
  display: grid;
  place-items: center;
  min-height: 42px;
  color: var(--muted);
  border-radius: 6px;
  text-decoration: none;
  font-size: 14px;
  line-height: 1;
  font-weight: 760;
}

.gallery-tabs a.is-active {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(17, 21, 19, 0.08);
}

.gallery-section {
  margin-top: 24px;
}

.gallery-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.gallery-heading h2 {
  margin: 0;
  font-size: 30px;
  line-height: 1.05;
  font-weight: 780;
}

.gallery-heading span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 12px;
}

.photo-card {
  min-width: 0;
}

.photo-link {
  display: block;
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.photo-link img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-meta {
  min-height: 20px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  font-weight: 700;
}

.photo-meta span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 7px;
}

.photo-actions form {
  margin: 0;
}

.action-button {
  display: grid;
  grid-template-columns: 18px minmax(0, auto);
  justify-content: center;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 40px;
  padding: 0 8px;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 12px;
  line-height: 1;
  font-weight: 720;
}

.action-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.action-button.danger {
  color: var(--danger);
}

.photo-actions form:last-child:nth-child(3),
.photo-actions .action-button:first-child:nth-last-child(3) {
  grid-column: auto;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 180px;
  color: var(--muted);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.empty-state svg {
  width: 46px;
  height: 46px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-state p {
  margin: 0;
  font-weight: 650;
}

.auth-page {
  background: var(--surface-muted);
}

.login-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-panel {
  width: min(100%, 380px);
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin-bottom: 18px;
  color: white;
  background: var(--accent);
  border-radius: 50%;
}

.brand-mark svg {
  width: 31px;
  height: 31px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.login-panel h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.05;
  font-weight: 780;
}

.login-panel p {
  margin: 10px 0 22px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.login-form {
  display: grid;
  gap: 10px;
}

.login-form label {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
}

.form-error {
  color: var(--danger) !important;
  font-weight: 700;
}

.text-link {
  color: var(--accent-strong);
  font-weight: 700;
}

@media (min-width: 640px) {
  .photo-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
  }

  .action-button {
    min-height: 44px;
    font-size: 13px;
  }
}

@media (min-width: 860px) {
  .app-main {
    padding-top: 28px;
  }

  .capture-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: end;
  }

  .capture-heading {
    grid-column: 1 / -1;
  }

  .upload-form,
  .import-form {
    padding-bottom: 22px;
  }

  .photo-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 360px) {
  .app-main {
    padding-inline: 14px;
  }

  .action-button span {
    display: none;
  }
}
