:root {
  --bg: #eef1ee;
  --panel: #ffffff;
  --ink: #1d2328;
  --muted: #677178;
  --line: #d9dfdb;
  --line-strong: #bac5bf;
  --accent: #b43b2f;
  --accent-dark: #7d2b25;
  --teal: #1f6f6b;
  --gold: #b98624;
  --stage: #e4e8e4;
  --stage-bar: #d8ddd8;
  --shadow: 0 18px 45px rgba(31, 39, 44, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.shell {
  width: min(1520px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  padding: 0 0 20px;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.15;
}

.small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}

.small-button {
  min-width: 56px;
  padding: 0 12px;
  font-size: 13px;
}

.small-button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
  padding: 20px 0;
}

.search-box {
  display: flex;
  align-items: center;
  width: min(420px, 100%);
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel);
  overflow: hidden;
}

.search-box span {
  flex: 0 0 auto;
  padding: 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 10px 12px 10px 0;
  background: transparent;
  color: var(--ink);
}

.style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 340px));
  gap: 20px;
  align-items: start;
}

.style-card {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(31, 39, 44, 0.04);
  overflow: hidden;
}

.style-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.card-button {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.cover-wrap {
  position: relative;
  height: clamp(300px, 42vh, 380px);
  background: var(--stage);
  overflow: hidden;
}

.cover-wrap img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.card-body {
  padding: 14px;
}

.card-body h2 {
  margin: 0 0 8px;
  font-size: 17px;
  line-height: 1.35;
}

.card-body p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.chip {
  display: inline-flex;
  max-width: 100%;
  min-height: 24px;
  align-items: center;
  border: 1px solid #dce1df;
  border-radius: 4px;
  padding: 2px 8px;
  color: #384148;
  background: #f8faf9;
  font-size: 12px;
  line-height: 1.3;
}

.empty-state {
  grid-column: 1 / -1;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 32px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.52);
}

.style-dialog {
  width: min(1120px, calc(100vw - 32px));
  height: min(760px, calc(100vh - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: var(--panel);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.36);
  overflow: hidden;
}

.style-dialog::backdrop {
  background: rgba(24, 29, 31, 0.56);
}

.close-button {
  position: absolute;
  z-index: 4;
  top: 12px;
  right: 12px;
}

.dialog-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  height: 100%;
  min-height: 0;
}

.image-stage {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 76px;
  min-width: 0;
  min-height: 0;
  background: var(--stage);
}

.active-frame {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
  place-items: center;
  gap: 12px;
  margin: 0;
  padding: 22px 58px 10px;
  overflow: hidden;
}

.image-fit-box {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  border-radius: 4px;
  border: 1px solid rgba(31, 39, 44, 0.18);
  background: var(--stage);
  box-shadow: 0 18px 46px rgba(31, 39, 44, 0.22);
  overflow: hidden;
}

.image-fit-box img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.active-frame figcaption {
  display: flex;
  width: min(720px, 100%);
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #3b454b;
  font-size: 13px;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(31, 39, 44, 0.2);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  cursor: pointer;
}

.icon-button:hover {
  border-color: rgba(31, 39, 44, 0.36);
  background: #fff;
}

.nav-button {
  position: absolute;
  z-index: 2;
  top: 50%;
  transform: translateY(-50%);
  font-size: 30px;
  line-height: 1;
}

.prev-button {
  left: 14px;
}

.next-button {
  right: 14px;
}

.filmstrip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 10px 14px;
  border-top: 1px solid rgba(31, 39, 44, 0.12);
  background: var(--stage-bar);
  overflow-x: auto;
}

.thumb-button {
  flex: 0 0 auto;
  width: auto;
  height: 54px;
  aspect-ratio: var(--style-aspect, 3 / 4);
  border: 2px solid transparent;
  border-radius: 4px;
  padding: 0;
  background: transparent;
  overflow: hidden;
  cursor: pointer;
}

.thumb-button.is-active {
  border-color: var(--accent);
}

.thumb-button img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.detail-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  border-left: 1px solid var(--line);
  padding: 28px 20px 20px;
  overflow: auto;
}

.detail-panel h2 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.25;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0;
}

.section-title-row h3 {
  margin: 0;
  font-size: 15px;
}

.prompt-box {
  flex: 1;
  min-height: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #f8faf9;
  color: #273036;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow: auto;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  transform: translate(-50%, 16px);
  border-radius: 6px;
  padding: 10px 14px;
  background: rgba(17, 21, 25, 0.92);
  color: #fff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 860px) {
  .shell {
    width: min(100% - 22px, 720px);
    padding-top: 20px;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .style-dialog {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }

  .dialog-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 68vh) minmax(0, 1fr);
  }

  .detail-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 25px;
  }

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

  .cover-wrap {
    height: min(380px, 72vh);
  }

  .active-frame {
    padding: 24px 48px 10px;
  }

  .nav-button {
    width: 34px;
    height: 34px;
  }

  .prev-button {
    left: 8px;
  }

  .next-button {
    right: 8px;
  }

  .prompt-box {
    max-height: 240px;
  }
}
