:root {
  --dark-brown: #5a3a22;
  --light-brown: #c98f5a;
  --soft-brown: #f2e4d6;
  --black: #1d1d1d;
  --white: #ffffff;
  --line: #d9c2ab;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: #f7f3ee;
  color: var(--black);
  font-family: "Meiryo UI", Meiryo, "Yu Gothic UI", "Yu Gothic", sans-serif;
}
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: var(--dark-brown);
  color: var(--white);
  border-bottom: 4px solid var(--light-brown);
}
.title-wrap h1 {
  margin: 0;
  font-size: 1.1rem;
}
.title-wrap p {
  margin: 4px 0 0;
  font-size: 0.9rem;
  opacity: 0.9;
}
.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.controls button,
.nav {
  border: none;
  background: var(--light-brown);
  color: var(--white);
  cursor: pointer;
  border-radius: 10px;
  transition: transform 0.1s ease, opacity 0.2s ease;
}
.controls button {
  padding: 9px 14px;
  font-size: 1rem;
}
.controls button:hover,
.nav:hover {
  opacity: 0.92;
}
.controls button:active,
.nav:active {
  transform: scale(0.98);
}
#counter {
  min-width: 72px;
  text-align: center;
  font-weight: 700;
}
.viewer {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 54px;
  align-items: center;
  gap: 8px;
  flex: 1;
  padding: 14px 10px;
}
.slide-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 0;
}
.slide-stage img {
  width: min(100%, 1400px);
  height: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  border: 1px solid var(--line);
  background: var(--white);
}
.nav.side {
  width: 44px;
  height: 84px;
  font-size: 1.8rem;
}
.thumbbar {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 12px;
  background: var(--soft-brown);
  border-top: 1px solid var(--line);
}
.thumbbar::-webkit-scrollbar { height: 10px; }
.thumbbar::-webkit-scrollbar-thumb { background: #c4a388; border-radius: 999px; }
.thumb {
  flex: 0 0 auto;
  width: 120px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 0;
  cursor: pointer;
}
.thumb img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--line);
}
.thumb.active {
  border-color: var(--dark-brown);
}
@media (max-width: 900px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .controls {
    width: 100%;
    justify-content: flex-end;
  }
}
@media (max-width: 680px) {
  .viewer {
    grid-template-columns: 1fr;
  }
  .nav.side {
    display: none;
  }
  .thumb {
    width: 92px;
  }
}
