@font-face {
  font-family: "Catwall Masthead";
  src: url("type/masthead.woff2") format("woff2");
  font-style: normal;
  font-weight: 800;
  font-display: swap;
}
@font-face {
  font-family: "Catwall Display";
  src: url("type/display.ttf?v=rotate1") format("truetype");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}
:root {
  --paper: #f7f9fa;
  --surface: #fff;
  --ink: #17283d;
  --soft: #536779;
  --line: #cbd5dd;
  --accent: #244d85;
  --tint: #e4edf3;
  --amber: #ffcc68;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --masthead: "Catwall Masthead", var(--sans);
  --serif: "Catwall Display", "Songti SC", "Noto Serif CJK SC", SimSun, serif;
  --gutter: clamp(22px, 3.5vw, 66px);
  --nav-height: 60px;
  --wall-height: clamp(416px, calc(100svh - 221px), 840px);
  color: var(--ink);
  background: var(--paper);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { border: 0; cursor: pointer; background: transparent; }
a { color: inherit; text-decoration: none; }
button:disabled { opacity: .52; cursor: wait; }
:where(button, a, input, textarea, canvas):focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; flex: none; }
.top-inner, main { max-width: 1700px; padding-inline: var(--gutter); margin-inline: auto; }
.top { background: var(--ink); color: white; }
.top-inner { height: var(--nav-height); display: flex; align-items: center; gap: clamp(28px, 4vw, 72px); }
.brand { display: inline-flex; align-items: center; flex: none; gap: 9px; font: 800 20px/1 var(--masthead); letter-spacing: -.065em; }
.brand img { width: 33px; height: 33px; }
.top nav { align-self: stretch; display: flex; align-items: stretch; gap: clamp(20px, 2.35vw, 38px); }
.top nav a { display: flex; align-items: center; position: relative; font-size: 14px; color: #c5d1dc; }
.top nav a:hover, .top nav a[aria-current="page"] { color: white; }
.top nav a[aria-current="page"]::after { content: ""; position: absolute; inset: auto 0 0; height: 3px; background: var(--amber); }
.top :where(a, button):focus-visible { outline-color: var(--amber); outline-offset: 2px; }
#account { margin-left: auto; max-width: 150px; min-height: 34px; padding: 0 11px; color: white; border: 1px solid #536476; }
#account:hover { background: #2a4057; }
#account .ico { width: 16px; height: 16px; }
#account span, #indexName { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quiet, .primary, .icon { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 6px; min-height: 42px; padding: 0 14px; font-size: 14px; font-weight: 560; }
.primary { color: white; background: var(--accent); padding-inline: 20px; }
.primary:hover { background: var(--ink); }
.quiet:hover, .icon:hover { background: var(--tint); }
.icon { width: 38px; min-height: 38px; padding: 0; }
.wall-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: clamp(22px, 2.3vw, 40px) 0 clamp(18px, 1.9vw, 32px); }
.wall-heading h1, .reading h1 { margin: 0; font-family: var(--masthead); font-weight: 800; letter-spacing: -.075em; font-size: clamp(47px, 5.15vw, 85px); line-height: 1.08; }
#upload { gap: 9px; border-radius: 5px; min-height: 44px; padding-inline: 14px 19px; background: var(--accent); }
#upload:hover { background: var(--ink); }
#upload .ico { width: 19px; height: 19px; stroke-width: 2; }
.gallery { display: grid; grid-template-columns: minmax(0, 1fr) clamp(234px, 21vw, 335px); gap: clamp(18px, 1.7vw, 30px); align-items: start; padding-bottom: 24px; }
.count, small { color: var(--soft); font-size: 13px; }
.count { font-variant-numeric: tabular-nums; }
#board {
  position: relative; isolation: isolate; overflow: hidden; min-width: 0;
  height: var(--wall-height); border: 1px solid #8ba9c1; border-radius: 6px;
  background: #a9c4d9;
}
#board::before {
  content: ""; position: absolute; z-index: -1; inset: 0; pointer-events: none;
  background-image: url("grid.svg?v=print1");
  background-position: var(--grid-x, 0) var(--grid-y, 0);
  background-size: var(--grid-step, 32px) var(--grid-step, 32px);
}
#canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; outline-offset: -3px; }
#rotateHandle {
  position: absolute; width: 44px; height: 44px; padding: 0; border: 0;
  transform: translate(-50%, -50%); background: transparent; color: var(--accent);
  display: grid; place-items: center; isolation: isolate;
  font: 24px/1 system-ui,sans-serif; touch-action: none; user-select: none; cursor: grab;
}
#rotateHandle::before { content: ""; position: absolute; z-index: -1; inset: 6px; border-radius: 50%; background: white; border: 1px solid #7291af; box-shadow: 0 1px 5px #17283d25; }
#rotateHandle:active { cursor: grabbing; }
#rotateHandle:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; border-radius: 50%; }
.board-tools { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; padding: 3px; background: var(--surface); border: 1px solid #9aafc0; border-radius: 8px; box-shadow: 0 2px 5px #17283d17; }
.tool-group { display: flex; align-items: center; }
.tool-group + .tool-group { border-left: 1px solid var(--line); margin-left: 4px; padding-left: 4px; }
.tool-group button { width: 36px; height: 34px; display: grid; place-items: center; border-radius: 4px; }
.tool-group button .ico { width: 17px; height: 17px; }
.tool-group button[aria-pressed="true"] { color: white; background: var(--ink); }
.tool-group button:hover:not([aria-pressed="true"]) { background: var(--tint); }
.tool-group output { text-align: center; min-width: 42px; font: 12px/1 ui-monospace, "SFMono-Regular", Consolas, monospace; }
.tool-group #fit { margin-left: 3px; }
#dropVeil { position: absolute; inset: 6px; border: 2px dashed var(--accent); border-radius: 5px; background: #edf4f9eb; color: var(--accent); display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 20px; pointer-events: none; }
.sr-list { position: absolute; top: 12px; left: 12px; }
.sr-list button:not(:focus-visible) { width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); position: absolute; }
.sr-list button:focus-visible { background: var(--paper); padding: 8px; border-radius: 4px; }
.photo-index { display: flex; flex-direction: column; min-width: 0; max-height: var(--wall-height); border-top: 3px solid var(--ink); }
.index-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 7px; padding: 11px 0 12px; }
.index-heading h2 { margin: 0; flex: none; font: 800 clamp(17px, 1.35vw, 22px)/1.25 var(--masthead); letter-spacing: -.055em; }
.index-heading .count { font-size: clamp(10px, .8vw, 12px); text-align: right; }
.index-portrait { display: flex; flex-direction: column; flex: none; position: relative; width: 100%; padding: 0; overflow: hidden; text-align: left; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.index-portrait img { display: block; width: 100%; aspect-ratio: 1.7; object-fit: cover; background: #dce7ef; }
.index-portrait[data-cutout] img { object-fit: contain; padding: 8px 12px; }
.portrait-caption { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 8px 11px; border-top: 1px solid var(--line); }
#indexName { font-weight: 700; font-size: 16px; }
.portrait-caption .ico { width: 17px; height: 17px; }
.index-portrait:hover .portrait-caption { background: var(--tint); }
.index-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 14px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); overflow-y: auto; align-content: start; scrollbar-width: thin; scrollbar-color: #8ba0b1 transparent; }
.index-item { display: flex; flex-direction: column; position: relative; gap: 3px; align-items: center; justify-content: center; min-width: 0; padding: 6px 4px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--paper); color: var(--soft); font-size: 12px; line-height: 1.35; }
.index-item .thumb { display: block; width: 88%; height: clamp(32px, 3.4vw, 56px); object-fit: contain; }
.index-item .name { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.index-item .ico { display: none; }
.index-item[aria-pressed="true"] { background: #dce8f2; color: var(--accent); font-weight: 700; box-shadow: inset 0 -2px var(--accent); }
.index-item:hover { background: var(--tint); }
.index-item:focus-visible { z-index: 1; outline-offset: -2px; }
.photo-index:has(.index-list:empty) { display: none; }
.gallery:has(.index-list:empty) { grid-template-columns: 1fr; }
.modal-head, .actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
dialog { color: var(--ink); width: min(424px, calc(100vw - 28px)); max-height: 90dvh; overflow: auto; border: 1px solid #afbeca; border-radius: 10px; padding: clamp(20px, 2.5vw, 30px); background: var(--surface); box-shadow: 0 14px 80px #14283d33; }
dialog::backdrop { background: #17283d75; }
dialog h2 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -.045em; overflow-wrap: anywhere; }
.modal-head { margin-bottom: 18px; }
.photo-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.photo-actions .quiet { padding-inline: 9px; }
form label { display: block; font-size: 14px; font-weight: 550; margin: 15px 0; }
label small { font-size: 12px; font-weight: 400; }
input:not([hidden]), textarea { width: 100%; display: block; margin-top: 6px; padding: 10px 12px; background: white; border: 1px solid #bfccd6; border-radius: 5px; }
textarea { resize: vertical; }
.actions { margin-top: 19px; }
.error { color: #a13334; font-size: 13px; }
.error:empty, #detailStory:empty { display: none; }
#fileZone, .portrait { width: 100%; border-radius: 5px; background: #e5eef5; height: 155px; display: grid; place-items: center; overflow: hidden; }
#fileZone { border: 1px dashed #90a8bb; }
#fileZone img, .portrait img { max-width: 100%; max-height: 145px; object-fit: contain; }
#pickPrompt { display: grid; justify-items: center; gap: 10px; color: var(--accent); }
#pickPrompt .ico { width: 27px; height: 27px; }
.portrait { height: 225px; }
.portrait img { max-height: 200px; }
#detailStory { font-size: 15px; line-height: 1.7; overflow-wrap: anywhere; }
#petDialog .detail-links { justify-content: flex-start; gap: 5px 13px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
#petDialog .detail-links #author { flex: 1 0 100%; min-width: 0; overflow-wrap: anywhere; }
#petDialog .detail-links .quiet { min-height: 33px; padding: 0; color: var(--accent); font-size: 13px; }
#petDialog #detailDownload { margin-left: auto; padding-inline: 11px; color: white; background: var(--accent); }
#notice { position: fixed; z-index: 10; bottom: 24px; left: 50%; transform: translateX(-50%); max-width: 90vw; padding: 10px 17px; background: var(--ink); color: white; border-radius: 6px; font-size: 14px; }
@media (max-width: 900px) {
  :root { --gutter: clamp(18px, 3vw, 28px); --wall-height: clamp(390px, calc(100svh - 206px), 720px); }
  .gallery { grid-template-columns: minmax(0,1fr) 200px; gap: 16px; }
}
@media (max-width: 690px) {
  :root { --gutter: 15px; --nav-height: 54px; --wall-height: clamp(310px, min(105vw, 54svh), 470px); }
  .top-inner { gap: clamp(10px, 4vw, 24px); }
  .brand { gap: 5px; font-size: 17px; }
  .brand img { width: 27px; height: 27px; }
  .top nav { margin-left: auto; gap: clamp(10px, 3.6vw, 20px); }
  .top nav a { font-size: 12px; }
  #account { flex: none; margin-left: 0; width: 29px; min-height: 29px; padding: 0; border-radius: 4px; }
  #account span { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); }
  .wall-heading { padding: 23px 0 18px; gap: 8px; }
  .wall-heading h1, .reading h1 { font-size: clamp(37px, 9.8vw, 54px); line-height: 1.1; }
  #upload { min-height: 36px; padding: 0 11px; gap: 4px; font-size: 13px; }
  #upload .ico { width: 16px; height: 16px; }
  .gallery { display: flex; flex-direction: column; align-items: stretch; gap: 18px; }
  #board { border-radius: 5px; }
  .board-tools { bottom: 9px; padding: 2px; }
  .tool-group button { width: 33px; height: 33px; }
  .tool-group output { min-width: 33px; font-size: 11px; }
  .photo-index { display: grid; grid-template-columns: 39% minmax(0, 1fr); column-gap: 12px; align-items: start; max-height: none; }
  .index-heading { grid-column: 1 / -1; padding: 9px 0 10px; }
  .index-heading h2 { font-size: 19px; }
  .index-heading .count { font-size: 11px; }
  .index-portrait img { aspect-ratio: 1.1; }
  .portrait-caption { padding: 6px 8px; }
  #indexName { font-size: 14px; }
  .portrait-caption .ico { width: 15px; height: 15px; }
  .index-list { margin: 0; max-height: clamp(166px, 49vw, 240px); }
  .index-item { font-size: 11px; gap: 2px; padding: 4px 2px; }
  .index-item .thumb { height: clamp(26px, 8vw, 40px); }
}
@media (max-width: 359px) {
  :root { --gutter: 11px; }
  .top-inner { gap: 8px; }
  .brand { font-size: 15px; }
  .brand img { width: 24px; height: 24px; }
  .top nav { gap: 9px; }
  .tool-group button { width: 30px; }
}
@media (prefers-reduced-motion: no-preference) {
  .primary, .quiet, .index-item, .index-portrait .portrait-caption, .tool-group button { transition: color .14s ease, background-color .14s ease; }
}
