:root {
  --paper: #f2ede3;
  --paper-deep: #e5ded1;
  --ink: #171713;
  --muted: #6d685f;
  --line: #c9c0b2;
  --accent: #9b412f;
  --night: #11110f;
  --night-text: #f7f2e8;
  --danger: #8e2d24;
  --serif: "Iowan Old Style", "Baskerville", "Songti SC", "STSong",
    "Noto Serif CJK SC", serif;
  --sans: "Helvetica Neue", "PingFang SC", "Microsoft YaHei",
    "Noto Sans CJK SC", sans-serif;
}

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

html {
  background: var(--paper);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body.is-busy {
  cursor: wait;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  border: 0;
}

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

[hidden] {
  display: none !important;
}

::selection {
  background: var(--accent);
  color: var(--paper);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

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

.eyebrow,
.login-brand > span,
.status-strip,
.header-actions,
.sidebar-count span,
.preview-meta,
.photo-index,
.photo-info p,
.photo-actions,
.backup-grid > article > span {
  font-size: 10px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-weight: 700;
}

.eyebrow-light {
  color: #ce816d;
}

.loading-view {
  display: grid;
  min-height: 100svh;
  place-content: center;
  text-align: center;
}

.loading-mark {
  font-family: var(--serif);
  font-size: 44px;
  letter-spacing: 0.12em;
}

.loading-view p {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.12em;
}

.login-view {
  display: grid;
  min-height: 100svh;
  grid-template-columns: minmax(0, 1.15fr) minmax(440px, 0.85fr);
}

.login-brand {
  display: flex;
  min-height: 100svh;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(28px, 5vw, 78px);
  background:
    linear-gradient(rgb(17 17 15 / 36%), rgb(17 17 15 / 70%)),
    url("photos/ink-mountains.webp") center / cover,
    var(--night);
  color: var(--night-text);
}

.back-link {
  align-self: flex-start;
  font-size: 12px;
  letter-spacing: 0.08em;
}

.login-mark {
  margin-top: 24px;
  font-family: var(--serif);
  font-size: clamp(100px, 14vw, 230px);
  letter-spacing: -0.1em;
  line-height: 0.84;
}

.brand-line {
  max-width: 440px;
  margin: 42px 0 0;
  font-family: var(--serif);
  font-size: 22px;
}

.login-panel {
  display: grid;
  place-items: center;
  padding: clamp(40px, 6vw, 96px);
}

.login-form {
  width: min(100%, 420px);
}

.login-form h1 {
  margin: 25px 0 12px;
  font-family: var(--serif);
  font-size: clamp(52px, 5vw, 74px);
  font-weight: 400;
  letter-spacing: -0.055em;
  line-height: 0.95;
}

.form-intro {
  margin: 0 0 48px;
  color: var(--muted);
}

.login-form label,
.metadata-fields label {
  display: block;
  margin-bottom: 23px;
}

.login-form label > span,
.metadata-fields label > span:not(.check-field span) {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.login-form input,
.metadata-fields input:not([type="checkbox"]),
.metadata-fields select,
.metadata-fields textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  outline: 0;
  background: transparent;
  transition: border-color 160ms ease;
}

.metadata-fields textarea {
  min-height: 110px;
  resize: vertical;
}

.login-form input:focus,
.metadata-fields input:focus,
.metadata-fields select:focus,
.metadata-fields textarea:focus {
  border-color: var(--accent);
}

.form-error {
  margin: -5px 0 19px;
  color: var(--danger);
  font-size: 12px;
}

.primary-button {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  transition: background 160ms ease;
}

.primary-button:hover:not(:disabled) {
  background: var(--accent);
}

.primary-button:disabled,
.outline-button:disabled,
button:disabled {
  cursor: wait;
  opacity: 0.52;
}

.login-button {
  width: 100%;
  margin-top: 34px;
}

.login-form small {
  display: block;
  margin-top: 16px;
  color: var(--muted);
  font-size: 10px;
}

.dashboard {
  min-height: 100vh;
}

.admin-header {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
}

.admin-wordmark {
  display: flex;
  align-items: baseline;
  gap: 18px;
}

.admin-wordmark strong {
  font-family: var(--serif);
  font-size: 26px;
  letter-spacing: 0.1em;
}

.admin-wordmark span {
  color: var(--muted);
  font-size: 11px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 26px;
}

.header-actions button {
  padding: 10px 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  letter-spacing: inherit;
}

.header-actions a:hover,
.header-actions button:hover {
  color: var(--accent);
}

.status-strip {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 4fr;
  gap: 28px;
  margin: 24px clamp(20px, 4vw, 64px) 0;
  padding: 17px 20px;
  border-left: 3px solid var(--accent);
  background: #e8dfd0;
}

.status-strip strong {
  color: var(--accent);
}

.status-strip p {
  margin: 0;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: none;
}

.admin-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: clamp(34px, 5vw, 86px);
  padding: clamp(50px, 7vw, 100px) clamp(20px, 4vw, 64px) 130px;
}

.admin-sidebar {
  position: sticky;
  top: 34px;
  display: flex;
  height: fit-content;
  flex-direction: column;
  align-items: flex-start;
  gap: 17px;
  color: var(--muted);
}

.admin-sidebar .eyebrow {
  margin-bottom: 16px;
}

.admin-sidebar > a {
  position: relative;
  padding-left: 16px;
  font-size: 12px;
}

.admin-sidebar > a::before {
  position: absolute;
  left: 0;
  color: var(--accent);
  content: "—";
}

.sidebar-count {
  display: flex;
  width: 100%;
  flex-direction: column;
  margin-top: 44px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.sidebar-count strong {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 58px;
  font-weight: 400;
  letter-spacing: -0.07em;
  line-height: 1;
}

.admin-main {
  min-width: 0;
  max-width: 1280px;
}

.admin-section + .admin-section {
  margin-top: clamp(110px, 13vw, 200px);
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--line);
}

.section-heading h1,
.section-heading h2 {
  margin: 18px 0 0;
  font-family: var(--serif);
  font-size: clamp(48px, 5.6vw, 82px);
  font-weight: 400;
  letter-spacing: -0.06em;
  line-height: 0.95;
}

.section-heading > p {
  max-width: 310px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.upload-editor {
  display: grid;
  grid-template-columns: minmax(300px, 1.05fr) minmax(320px, 0.95fr);
  gap: clamp(30px, 5vw, 74px);
  padding-top: 40px;
}

.upload-dropzone {
  position: relative;
  display: grid;
  min-height: 570px;
  border: 1px dashed #a99f90;
  background: rgb(229 222 209 / 34%);
  overflow: hidden;
  transition: background 160ms ease, border-color 160ms ease;
}

.upload-dropzone.is-dragging {
  border-color: var(--accent);
  background: #e9ded0;
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px;
  text-align: center;
}

.upload-plus {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  margin-bottom: 28px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent);
  font-family: var(--serif);
  font-size: 38px;
}

.upload-placeholder strong {
  font-family: var(--serif);
  font-size: 29px;
  font-weight: 400;
}

.upload-placeholder > span:not(.upload-plus) {
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}

.outline-button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--ink);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  transition: background 160ms ease, color 160ms ease;
}

.outline-button:hover:not(:disabled) {
  background: var(--ink);
  color: var(--paper);
}

.upload-placeholder .outline-button {
  margin-top: 28px;
}

.upload-preview {
  position: absolute;
  inset: 0;
}

.upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-meta {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  justify-content: space-between;
  padding: 54px 18px 16px;
  background: linear-gradient(transparent, rgb(17 17 15 / 82%));
  color: #fff;
}

.change-photo {
  position: absolute;
  top: 14px;
  right: 14px;
  min-height: 38px;
  padding: 0 14px;
  background: rgb(242 237 227 / 94%);
  cursor: pointer;
  font-size: 11px;
}

.upload-form-side {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.check-field {
  display: flex !important;
  min-height: 44px;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 12px;
}

.check-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.photo-list {
  border-bottom: 1px solid var(--line);
}

.list-loading,
.photo-empty {
  display: grid;
  min-height: 320px;
  margin: 0;
  place-items: center;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 22px;
  text-align: center;
}

.photo-row {
  display: grid;
  grid-template-columns: 38px 160px minmax(200px, 1fr) auto;
  gap: 24px;
  align-items: center;
  padding: 20px 0;
  border-top: 1px solid var(--line);
}

.photo-list .photo-row:first-child {
  border-top: 0;
}

.photo-index {
  color: var(--muted);
}

.photo-thumb {
  width: 160px;
  height: 108px;
  background: var(--paper-deep);
  object-fit: cover;
}

.photo-title-line {
  display: flex;
  align-items: center;
  gap: 12px;
}

.photo-title-line strong {
  overflow: hidden;
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cover-badge {
  flex: 0 0 auto;
  padding: 3px 7px;
  background: #dfd1c3;
  color: var(--accent);
  font-size: 9px;
  letter-spacing: 0.08em;
}

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

.photo-actions {
  display: flex;
  gap: 18px;
  justify-content: flex-end;
}

.photo-actions button {
  padding: 9px 0;
  background: transparent;
  cursor: pointer;
  letter-spacing: 0.04em;
}

.photo-actions button:hover {
  color: var(--accent);
}

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

.backup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.backup-grid article {
  padding: 46px 44px 52px;
  border-bottom: 1px solid var(--line);
}

.backup-grid article:first-child {
  border-right: 1px solid var(--line);
}

.backup-grid article > span {
  color: var(--accent);
}

.backup-grid h3 {
  margin: 23px 0 12px;
  font-family: var(--serif);
  font-size: 29px;
  font-weight: 400;
}

.backup-grid p {
  max-width: 430px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.backup-grid .outline-button {
  margin-top: 28px;
}

.toast {
  position: fixed;
  z-index: 150;
  right: 24px;
  bottom: 24px;
  display: flex;
  max-width: min(460px, calc(100vw - 48px));
  align-items: flex-start;
  gap: 22px;
  padding: 16px 18px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 16px 54px rgb(0 0 0 / 23%);
  font-size: 12px;
  animation: toast-in 180ms ease both;
}

.toast button {
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}

.edit-dialog {
  width: min(640px, 100vw);
  height: 100svh;
  max-height: none;
  margin: 0 0 0 auto;
  padding: 34px clamp(24px, 4vw, 56px) 50px;
  border: 0;
  background: var(--paper);
  color: var(--ink);
  overflow-y: auto;
  box-shadow: -18px 0 60px rgb(0 0 0 / 22%);
  animation: dialog-in 220ms ease both;
}

.edit-dialog::backdrop {
  background: rgb(17 17 15 / 64%);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
}

.dialog-head h2 {
  margin: 11px 0 0;
  font-family: var(--serif);
  font-size: 40px;
  font-weight: 400;
  letter-spacing: -0.04em;
}

.dialog-head button,
.dialog-actions > button:first-child {
  padding: 10px 0;
  background: transparent;
  cursor: pointer;
  font-size: 11px;
}

.edit-image {
  width: 100%;
  height: 270px;
  margin-bottom: 32px;
  background: var(--paper-deep);
  object-fit: cover;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  margin-top: 32px;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
}

@media (max-width: 980px) {
  .login-view {
    grid-template-columns: 1fr 1fr;
  }

  .admin-layout {
    grid-template-columns: 145px minmax(0, 1fr);
    gap: 34px;
  }

  .upload-editor {
    grid-template-columns: 1fr;
  }

  .upload-form-side .primary-button {
    margin-top: 24px;
  }

  .photo-row {
    grid-template-columns: 32px 110px minmax(160px, 1fr);
  }

  .photo-thumb {
    width: 110px;
    height: 82px;
  }

  .photo-actions {
    grid-column: 3;
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .login-view {
    grid-template-columns: 1fr;
  }

  .login-brand {
    min-height: 38svh;
    padding: 24px 20px;
  }

  .login-brand > div {
    margin-top: 45px;
  }

  .login-mark {
    font-size: 86px;
  }

  .brand-line {
    margin-top: 25px;
    font-size: 17px;
  }

  .login-brand > span {
    display: none;
  }

  .login-panel {
    min-height: 62svh;
    padding: 54px 20px;
  }

  .login-form h1 {
    font-size: 50px;
  }

  .admin-header {
    min-height: 68px;
    padding-inline: 20px;
  }

  .admin-wordmark span,
  .header-actions a {
    display: none;
  }

  .status-strip {
    grid-template-columns: 1fr;
    gap: 5px;
    margin: 18px 20px 0;
  }

  .admin-layout {
    grid-template-columns: 1fr;
    padding: 48px 20px 92px;
  }

  .admin-sidebar {
    position: static;
    flex-flow: row wrap;
    gap: 8px 18px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--line);
  }

  .admin-sidebar .eyebrow,
  .sidebar-count {
    width: 100%;
  }

  .sidebar-count {
    display: none;
  }

  .section-heading {
    display: block;
  }

  .section-heading h1,
  .section-heading h2 {
    font-size: 52px;
  }

  .section-heading > p {
    margin-top: 18px;
    text-align: left;
  }

  .upload-dropzone {
    min-height: 430px;
  }

  .field-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .photo-row {
    grid-template-columns: 28px 92px minmax(0, 1fr);
    gap: 12px;
  }

  .photo-thumb {
    width: 92px;
    height: 72px;
  }

  .photo-title-line strong {
    font-size: 17px;
  }

  .cover-badge {
    display: none;
  }

  .photo-actions {
    grid-column: 2 / -1;
    flex-wrap: wrap;
  }

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

  .backup-grid article {
    padding: 36px 0 42px;
  }

  .backup-grid article:first-child {
    border-right: 0;
  }

  .edit-dialog {
    padding-inline: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
