:root {
  color-scheme: light;
  --wall: #d7d4cc;
  --wall-deep: #c9c5bc;
  --paper: #f3f0e8;
  --ink: #1c1a16;
  --ink-soft: #3f3b34;
  --line: #b7b2a8;
  --line-strong: #5c574e;
  --walnut: #6a4630;
  --mat: #efece4;
  --cinnabar: #8f2c24;
  --danger: #8a241e;
  --danger-ink: #6e1c18;
  --danger-bg: #f6e4e1;
  --font-ui: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --font-display: "Nanum Myeongjo", "Iowan Old Style", "Songti SC", serif;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --focus: 2px solid var(--ink);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--wall);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}

img { max-width: 100%; height: auto; }

p, h1, h2, h3, figure { margin: 0; }

button, input, textarea { font: inherit; font-size: max(1rem, 1em); }

a, button { touch-action: manipulation; }

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

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

.skip {
  display: inline-block;
  position: fixed;
  z-index: 3;
  inset-inline-start: 1rem;
  inset-block-start: 1rem;
  background: var(--ink);
  color: var(--paper);
  padding: 0.65rem 1rem;
  text-decoration: none;
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
  overflow: hidden;
  white-space: nowrap;
}

.skip:focus {
  clip-path: none;
  width: auto;
  height: auto;
  overflow: visible;
}

:focus-visible {
  outline: var(--focus);
  outline-offset: 3px;
}

.wrap {
  width: min(calc(100% - 2rem), 68rem);
  margin-inline: auto;
}

.offline {
  margin: 0;
  padding: 0.75rem 1rem;
  background: var(--ink);
  color: var(--paper);
  text-align: center;
}

.site-head { padding-top: 1rem; }

.head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3rem;
  color: inherit;
  text-decoration: none;
}

.brand-text { display: flex; flex-direction: column; }

.brand-name {
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.brand-meta { color: var(--ink-soft); font-size: 0.875rem; line-height: 1.4; }

.seal {
  width: 2.25rem;
  height: 2.25rem;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--cinnabar);
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 1.15rem;
}

nav { display: flex; gap: 0.25rem; }

nav a {
  color: inherit;
  text-decoration: none;
  min-height: 3rem;
  display: inline-flex;
  align-items: center;
  padding-inline: 0.75rem;
}

nav a[aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: 0.35em;
  text-decoration-thickness: 2px;
}

.head-sub { padding-bottom: 0.5rem; }

.period { color: var(--ink-soft); }

.statement summary {
  min-height: 3rem;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.statement p {
  max-width: 38rem;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding-bottom: 1rem;
}

.page { padding-block: 1.5rem 3rem; }

.page-title,
.room-status,
#work-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.5rem, 5vw, 3.25rem);
  line-height: 1.25;
  letter-spacing: -0.02em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.room-message {
  padding-block: 2rem 3rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
}

.room-status { max-width: 12em; }

#room-catalog-link { color: inherit; }

.hang { padding-block: 1.25rem 0.5rem; }

.hang figure {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.frame {
  background: var(--walnut);
  padding: 0.65rem;
  max-width: 100%;
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.28),
    0 16px 36px rgb(36 28 20 / 0.16);
}

.mat {
  background: var(--mat);
  padding: 0.75rem 0.75rem 1.35rem;
}

.work-photo {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(68dvh, 42rem);
  background: var(--mat);
}

.broken { padding: 1.5rem 0.5rem; }

.label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.meta { color: var(--ink-soft); }

.writing {
  margin-top: 0.85rem;
  max-width: 34rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.75;
}

.walk {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-block: 1.25rem 0.5rem;
}

.count { font-variant-numeric: tabular-nums; }

.filmstrip {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding: 0.4rem 0.15rem 1.5rem;
  scroll-behavior: smooth;
}

.thumb {
  display: block;
  flex: none;
  padding: 0.25rem;
  border: 1px solid transparent;
  background: var(--mat);
  color: inherit;
}

.thumb img {
  width: 4.5rem;
  height: 3.4rem;
  object-fit: contain;
  display: block;
  background: var(--mat);
}

.thumb[aria-current="true"] { border-color: var(--cinnabar); }

.checklist {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.checklist a {
  display: grid;
  grid-template-columns: 2rem 4.5rem minmax(0, 1fr);
  grid-template-areas: "num thumb title" "num thumb spec";
  column-gap: 0.75rem;
  row-gap: 0.1rem;
  align-items: center;
  color: inherit;
  text-decoration: none;
  min-height: 3rem;
  padding-block: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.checklist .num {
  grid-area: num;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

.checklist img {
  grid-area: thumb;
  width: 4.5rem;
  height: 3.4rem;
  object-fit: contain;
  background: var(--mat);
}

.checklist .title {
  grid-area: title;
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1.35;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.checklist .spec {
  grid-area: spec;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

.lede { max-width: 28rem; margin-bottom: 1.25rem; }

.admin-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 1.5rem;
}

.hint-banner,
.form-alert {
  background: var(--paper);
  padding: 0.75rem 1rem;
  border-radius: 2px;
}

.hint-banner { margin-block: 0.5rem 0; }

.form-alert {
  background: var(--danger-bg);
  color: var(--danger-ink);
}

.status { min-height: 1.5rem; margin-block: 0.75rem; }

.admin-works {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding-block: 1rem 0.5rem;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.sheet {
  background: var(--paper);
  border-radius: 6px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.admin-block { margin-block: 0 1.5rem; }

.field {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}

.field label { font-weight: 500; }

.hint { color: var(--ink-soft); font-size: 0.875rem; }

input,
textarea {
  width: 100%;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  padding: 0.65rem 0.75rem;
  min-height: 3rem;
}

textarea {
  min-height: 8rem;
  resize: vertical;
  line-height: 1.6;
}

input[type="file"] { padding: 0.55rem; }

input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  min-height: 0;
  accent-color: var(--ink);
}

.check {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3rem;
}

input:-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  caret-color: var(--ink);
  box-shadow: 0 0 0 1000px var(--paper) inset;
}

.error-msg { display: none; color: var(--danger-ink); }

.field:has(:is(:user-invalid, .user-invalid-fallback)) :is(input, textarea) {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.field:has(:is(:user-invalid, .user-invalid-fallback)) .error-msg { display: block; }

.preview img {
  display: block;
  max-height: 12rem;
  width: auto;
  background: var(--mat);
  margin-top: 0.25rem;
}

.btn {
  font-size: 1rem;
  min-height: 3rem;
  padding: 0.65rem 1.1rem;
  border-radius: 2px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--paper);
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.text-btn {
  min-height: 3rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.ledger {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.ledger li {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
  min-width: 0;
}

.ledger img {
  width: 4.5rem;
  height: 3.4rem;
  object-fit: contain;
  background: var(--mat);
}

.ledger-copy {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.quiet { color: var(--ink-soft); }

.ledger li[aria-current="true"] h3 { text-decoration: underline; text-underline-offset: 0.2em; }

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

html:has(dialog:modal) { overflow: hidden; }

dialog:modal { overscroll-behavior: contain; }

dialog[open] {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  padding: 1.25rem;
  width: min(26rem, calc(100vw - 2rem));
  max-height: min(90dvh, 32rem);
  overflow: auto;
  border-radius: 6px;
  box-shadow: 0 18px 50px rgb(28 26 22 / 0.2);
}

dialog::backdrop {
  background: rgb(28 26 22 / 0.45);
  overflow: hidden;
  overscroll-behavior: contain;
}

dialog h2 { margin-bottom: 0.5rem; }

dialog form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

dialog .btn { flex: 1 1 8rem; }

#view-room:not([hidden]) .work-photo { view-transition-name: hanging; }

#view-room:not([hidden]) #work-title {
  view-transition-name: wall-title;
  width: fit-content;
  max-width: 100%;
}

::view-transition-old(hanging),
::view-transition-new(hanging) {
  height: 100%;
  object-fit: contain;
}

@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: var(--ink-soft); border-color: var(--ink-soft); }
  .btn-ghost:hover { background: var(--wall-deep); color: var(--ink); }
  .btn-danger:hover { background: var(--danger-ink); border-color: var(--danger-ink); }
  nav a:hover { text-decoration: underline; text-underline-offset: 0.35em; }
  .thumb:hover { border-color: var(--ink); }
  .checklist a:hover { background: var(--paper); }
}

@media (prefers-reduced-motion: no-preference) {
  .btn:active:not(:disabled) { transform: translateY(1px); }
}

@media (min-width: 860px) {
  .hang { padding-top: 2.5rem; }
  .hang figure {
    display: grid;
    grid-template-columns: minmax(0, auto) minmax(16rem, 22rem);
    gap: 3rem;
    align-items: center;
    justify-content: center;
  }
}

@media (min-width: 960px) {
  .admin-works {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(18rem, 26rem);
    align-items: start;
    gap: 2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .filmstrip { scroll-behavior: auto; }
  .btn { transition: none; }
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}

@media print {
  .site-head nav, .walk, .filmstrip, .skip, #view-admin { display: none; }
  body { background: #fff; }
  .frame { box-shadow: none; }
}
