:root {
  color-scheme: light;
  --ink: #252926;
  --muted: #828a84;
  --line: #e6e9e5;
  --paper: #fbfcf8;
  --panel: #ffffff;
  --panel-2: #f5f7f2;
  --accent: #efff28;
  --accent-ink: #22251f;
  --accent-2: #8ea59a;
  --danger: #c65353;
  --shadow: 0 18px 45px rgba(37, 41, 38, .08);
  --soft-shadow: 0 8px 22px rgba(37, 41, 38, .06);
  --display: "Instrument Serif", Georgia, serif;
  --ui: "Inter", "Zen Kaku Gothic New", -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  --jp: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", sans-serif;
  --mono: "SFMono-Regular", Menlo, Consolas, monospace;
  font-family: var(--ui);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--ui);
  font-feature-settings: "palt" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
  background:
    linear-gradient(180deg, rgba(239, 255, 40, .16), transparent 220px),
    var(--paper);
  display: grid;
  grid-template-columns: 248px 1fr;
}

.side {
  min-height: 100vh;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, .9);
  color: var(--ink);
  position: sticky;
  top: 0;
  backdrop-filter: blur(18px);
}

.brand {
  display: grid;
  gap: 4px;
  text-align: center;
  margin-bottom: 24px;
}
.brand > span {
  display: none;
}
.brand p, header p {
  margin: 0 0 2px;
  color: var(--muted);
  font-family: var(--ui);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .13em;
}
.brand h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 28px;
  font-weight: 400;
  letter-spacing: .01em;
  line-height: .95;
}
header h2 {
  margin: 0;
  font-family: var(--jp);
  font-size: 25px;
  font-weight: 500;
  letter-spacing: .01em;
  line-height: 1.25;
}

nav {
  display: grid;
  gap: 8px;
}
nav button, .link {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
nav button.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 6px 18px rgba(239, 255, 40, .42);
}
nav button:hover, .link:hover {
  background: var(--panel-2);
}
.meta {
  margin: 24px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
}
.meta strong {
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 700;
}
.meta span { color: var(--muted); font-size: 12px; line-height: 1.55; }

main {
  padding: 22px;
  min-width: 0;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 18px;
}
header p { color: var(--muted); }
.search {
  width: min(440px, 45vw);
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
input, select, button {
  font-family: var(--ui);
}
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
  font-size: 13px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.metrics div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  box-shadow: var(--soft-shadow);
}
.metrics span {
  color: var(--muted);
  font-family: var(--jp);
  font-size: 12px;
  font-weight: 500;
}
.metrics b {
  display: block;
  font-family: var(--ui);
  font-size: 24px;
  font-weight: 700;
  margin-top: 4px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr)) 170px 120px;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}
.controls label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-family: var(--jp);
  font-size: 12px;
  font-weight: 500;
}
.controls button, #exportBtn {
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}
.view-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 4px;
}
.view-toggle button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 7px 8px;
  cursor: pointer;
  font-size: 12px;
}
.view-toggle button.is-active {
  background: var(--accent);
  color: var(--accent-ink);
}
.notice {
  display: flex;
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(239, 255, 40, .85);
  background: rgba(239, 255, 40, .18);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  color: #535910;
  font-size: 13px;
  font-family: var(--jp);
  line-height: 1.5;
}
.notice strong {
  flex: 0 0 auto;
}

.showcase {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  margin-bottom: 14px;
  box-shadow: var(--soft-shadow);
  overflow: hidden;
}
.showcase-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.showcase-head p,
.showcase-head h3 {
  margin: 0;
}
.showcase-head p {
  color: var(--muted);
  font-family: var(--ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.showcase-head h3 {
  font-family: var(--jp);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .02em;
}
#favoriteHint {
  color: var(--muted);
  font-family: var(--jp);
  font-size: 12px;
}
.polaroid-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(132px, 158px);
  gap: 12px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  padding: 6px 4px 12px;
}
.polaroid-track::-webkit-scrollbar,
.list::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}
.polaroid-track::-webkit-scrollbar-thumb,
.list::-webkit-scrollbar-thumb {
  background: #d8ded7;
  border-radius: 999px;
}
.polaroid {
  scroll-snap-align: start;
  border: 0;
  border-radius: 3px;
  background: #fff;
  padding: 8px 8px 12px;
  color: var(--ink);
  box-shadow: 0 10px 24px rgba(37, 41, 38, .14);
  transform: rotate(var(--tilt));
  transition: transform .22s ease, box-shadow .22s ease;
  text-align: left;
}
.polaroid:hover {
  transform: translateY(-5px) rotate(0deg);
  box-shadow: 0 18px 34px rgba(37, 41, 38, .18);
}
.polaroid-photo {
  aspect-ratio: 1 / 1;
  background: var(--panel-2);
  overflow: hidden;
  margin-bottom: 8px;
}
.polaroid-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.polaroid strong,
.polaroid span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.polaroid strong {
  font-family: var(--jp);
  font-size: 12px;
  font-weight: 600;
}
.polaroid span {
  color: var(--muted);
  font-family: var(--ui);
  font-size: 11px;
  font-weight: 500;
  margin-top: 2px;
}
.rail-empty {
  grid-column: 1 / -1;
  border: 1px dashed #d7ddd6;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  font-family: var(--jp);
  padding: 18px;
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(320px, 380px);
  gap: 14px;
  align-items: start;
}
.list, .detail, .chat-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
}
.list {
  max-height: 66vh;
  overflow: auto;
}
.list.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(164px, 1fr));
  gap: 12px;
  padding: 12px;
  align-content: start;
}
.list.rows {
  display: block;
  padding: 0;
}
.row {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 12px;
  cursor: pointer;
}
.row:hover, .row.is-active { background: #eef7f6; }
.gallery-card {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 7px 7px 9px;
  overflow: hidden;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(37, 41, 38, .03);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.gallery-card:hover,
.gallery-card.is-active {
  transform: translateY(-3px);
  border-color: #d5df53;
  box-shadow: 0 14px 26px rgba(37, 41, 38, .1), 0 0 0 2px rgba(239, 255, 40, .42);
}
.gallery-image {
  aspect-ratio: 1 / 1;
  background: #e5e9ef;
  border-radius: 5px;
  overflow: hidden;
}
.gallery-image img,
.gallery-placeholder {
  width: 100%;
  height: 100%;
}
.gallery-image img {
  display: block;
  object-fit: cover;
}
.gallery-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-family: var(--ui);
  font-size: 12px;
}
.gallery-body {
  display: grid;
  gap: 6px;
  padding: 8px 2px 0;
}
.gallery-body h3 {
  margin: 0;
  font-family: var(--jp);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.gallery-body p {
  margin: 0;
  color: var(--muted);
  font-family: var(--jp);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.thumb {
  width: 92px;
  aspect-ratio: 3 / 2;
  border-radius: 8px;
  background: #e5e9ef;
  object-fit: cover;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-family: var(--ui);
  font-size: 12px;
}
.row h3 {
  margin: 0 0 6px;
  font-family: var(--jp);
  font-size: 15px;
  font-weight: 600;
}
.row p {
  margin: 0 0 8px;
  color: var(--muted);
  font-family: var(--jp);
  font-size: 13px;
  line-height: 1.45;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.chip {
  border-radius: 999px;
  padding: 2px 7px;
  background: var(--panel-2);
  color: #4e5650;
  font-family: var(--ui);
  font-size: 11px;
  font-weight: 600;
}
.chip.warn { background: rgba(239, 255, 40, .28); color: #606600; }
.chip.danger { background: #ffe4e2; color: var(--danger); }

.detail {
  padding: 14px;
  position: sticky;
  top: 16px;
  max-height: 86vh;
  overflow: auto;
}
.detail img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #eef1f5;
}
.detail h3 {
  margin: 12px 0 8px;
  font-family: var(--jp);
  font-size: 18px;
  font-weight: 600;
}
.kv {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 8px;
  font-family: var(--jp);
  font-size: 13px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 10px;
}
.kv span { color: var(--muted); }
.detail-actions {
  display: flex;
  gap: 8px;
  margin: 12px 0 4px;
}
.detail-actions button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  font-weight: 600;
}
.detail-actions button.is-on {
  background: var(--accent);
  border-color: var(--accent);
}
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #fafbf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font-family: var(--jp);
  font-size: 12px;
  line-height: 1.55;
}
.empty {
  color: var(--muted);
}

.chat-panel {
  margin-top: 14px;
  padding: 16px;
}
.chat-panel h3 {
  margin: 0 0 10px;
  font-family: var(--jp);
  font-size: 17px;
  font-weight: 600;
}
.chat {
  border-top: 1px solid var(--line);
  padding: 10px 0;
  display: grid;
  gap: 4px;
}
.chat a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}
.chat span {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 960px) {
  body { grid-template-columns: 1fr; }
  .side { position: static; min-height: auto; }
  header, .layout { grid-template-columns: 1fr; display: grid; }
  .search { width: 100%; }
  .metrics, .controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .notice { display: grid; }
  .detail { position: static; }
}
