:root {
  color-scheme: light;
  --bg: #f4f7f3;
  --panel: #ffffff;
  --panel-soft: #eef5ef;
  --text: #17231b;
  --muted: #66756a;
  --line: #dce6dd;
  --accent: #237a4b;
  --accent-dark: #155d36;
  --accent-soft: #dff0e6;
  --danger: #b42318;
  --shadow: 0 12px 32px rgba(31, 54, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px clamp(18px, 5vw, 56px);
  background: rgba(244, 247, 243, 0.9);
  border-bottom: 1px solid rgba(220, 230, 221, 0.9);
  backdrop-filter: blur(14px);
}

.brand,
.topbar nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  font-size: 13px;
  letter-spacing: 0;
}

.topbar nav a {
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--muted);
}

.topbar nav a:hover {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 28px auto 56px;
}

.search-band {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(360px, 1.2fr);
  gap: 28px;
  align-items: end;
  padding: 30px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.08;
  letter-spacing: 0;
}

.search-form,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--text);
  outline: none;
}

input {
  height: 44px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 11px 12px;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(35, 122, 75, 0.14);
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.primary-button {
  align-self: end;
  padding: 0 20px;
  background: var(--accent);
  color: white;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  padding: 0 18px;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.ghost-button,
.pager button {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 22px 0 14px;
}

.result-head span {
  margin-left: 8px;
  color: var(--muted);
}

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.state-box {
  padding: 22px;
  border: 1px dashed #bfd4c4;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.65);
  color: var(--muted);
}

.state-box.error {
  border-color: rgba(180, 35, 24, 0.35);
  color: var(--danger);
  background: #fff6f5;
}

.state-box.hidden,
.hidden {
  display: none;
}

.results {
  display: grid;
  gap: 12px;
}

.book-card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 18px rgba(31, 54, 39, 0.045);
}

.book-cover {
  width: 96px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 6px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.book-main {
  min-width: 0;
}

.book-title {
  margin: 0 0 8px;
  font-size: 18px;
  line-height: 1.35;
}

.book-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 14px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.tag {
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--panel-soft);
  color: #365140;
  font-size: 12px;
  font-weight: 800;
}

.tag.success {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.tag.warn {
  background: #fff5d9;
  color: #8a6100;
}

.book-actions {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 132px;
}

.book-actions button {
  width: 100%;
}

.panel {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.admin-shell {
  width: min(900px, calc(100vw - 32px));
}

.stack-form {
  display: grid;
  gap: 14px;
  max-width: 360px;
  margin-top: 22px;
}

.hint,
.status-strip,
.test-result {
  color: var(--muted);
  font-size: 14px;
}

code {
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--panel-soft);
}

.panel-title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.status-strip {
  display: grid;
  gap: 6px;
  margin: 16px 0 20px;
  padding: 14px;
  border-radius: 8px;
  background: var(--panel-soft);
}

.help-panel {
  display: grid;
  gap: 14px;
  margin: 0 0 22px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.help-title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.help-title-row h2 {
  margin: 0 0 6px;
  font-size: 18px;
  letter-spacing: 0;
}

.help-title-row p,
.help-steps {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.help-steps {
  padding-left: 20px;
}

.code-textarea {
  min-height: 220px;
  color: #26352a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre;
}

.paste-box {
  margin-top: 2px;
}

.settings-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.wide {
  grid-column: 1 / -1;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.test-result {
  margin-top: 16px;
  padding: 14px;
  border-radius: 8px;
  background: var(--panel-soft);
}

.test-result:empty {
  display: none;
}

@media (max-width: 780px) {
  .search-band,
  .search-form,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .result-head,
  .panel-title-row,
  .help-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .book-card {
    grid-template-columns: 78px minmax(0, 1fr);
  }

  .book-cover {
    width: 78px;
  }

  .book-actions {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* SS-style public page */
body {
  background: #f2f2f2;
}

.topbar {
  position: relative;
  min-height: 50px;
  padding: 0 calc((100vw - min(1140px, calc(100vw - 24px))) / 2);
  background: #009688;
  border-bottom: 0;
  color: white;
  backdrop-filter: none;
}

.brand {
  height: 50px;
  padding: 0 6px;
  color: white;
  font-size: 20px;
  font-weight: 500;
}

.brand-mark {
  display: none;
}

.topbar nav a,
.topbar nav a:hover,
.topbar nav a.active {
  display: flex;
  align-items: center;
  height: 50px;
  padding: 0 18px;
  border-radius: 0;
  background: rgba(0, 0, 0, 0.08);
  color: white;
}

.shell {
  width: min(1140px, calc(100vw - 24px));
  min-height: 800px;
  margin: 15px auto 48px;
}

.notice-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  padding: 14px 15px;
  border-left: 5px solid #009688;
  background: white;
  color: #333;
  line-height: 1.7;
}

.poem {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 150px;
  color: #111;
}

.search-band {
  display: block;
  margin-bottom: 12px;
  padding: 18px;
  border: 0;
  border-radius: 2px;
  background: white;
  box-shadow: none;
  text-align: center;
}

.search-form {
  display: inline-grid;
  grid-template-columns: 380px auto;
  gap: 8px 12px;
  align-items: center;
  width: auto;
}

.search-form label {
  display: block;
  grid-column: 1;
}

.search-form input {
  height: 38px;
  border: 1px solid green;
  border-radius: 0;
  font-size: 14px;
}

.search-form .primary-button {
  grid-column: 2;
  grid-row: 1 / span 2;
  min-width: 92px;
  height: 82px;
  border-radius: 2px;
  background: #009688;
}

.search-form small {
  grid-column: 1 / -1;
  color: #333;
  font-size: 10px;
  font-weight: 700;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
}

.result-head {
  align-items: center;
  margin: 12px 0 10px;
  color: #333;
  font-size: 13px;
}

.result-head span {
  color: #333;
}

.sort-line {
  display: inline-block;
  padding-left: 18px;
}

.pager button {
  min-height: 34px;
  border-radius: 2px;
}

.state-box {
  border: 1px solid #ddd;
  border-radius: 2px;
  background: white;
}

.results {
  gap: 12px;
}

.book-card {
  display: block;
  padding: 10px 0 0;
  border: 1px solid #222;
  border-radius: 18px;
  background: white;
  box-shadow: none;
}

.book-action-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 0 14px;
}

.result-index {
  color: #009688;
  font-size: 12px;
  font-weight: 700;
}

.copy-ss-button,
.query-ss-button {
  width: 200px;
  min-height: 30px;
  border-radius: 4px;
  color: white;
  font-size: 13px;
}

.copy-ss-button {
  background: #009688;
}

.query-ss-button {
  background: #7e53e7;
}

.book-table {
  width: calc(100% - 30px);
  margin: 8px 15px 14px;
  border-collapse: collapse;
  color: #333;
  font-size: 14px;
}

.book-table td {
  border: 1px solid #e6e6e6;
  padding: 9px 12px;
  vertical-align: middle;
  line-height: 1.6;
}

.cover-col {
  width: 100px;
}

.cover-cell {
  width: 100px;
  text-align: center;
}

.book-cover {
  width: 86px;
  max-height: 126px;
  border: 0;
  border-radius: 0;
  object-fit: contain;
  background: #f6f6f6;
}

.book-title-cell p {
  margin: 8px 0 0;
}

.sstext {
  color: #009688;
  font-weight: 700;
}

.sstext.muted {
  color: #777;
}

.catalog-link {
  color: #333;
  font-size: 13px;
  text-decoration: underline;
}

@media (max-width: 780px) {
  .topbar {
    padding: 0 12px;
  }

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

  .poem {
    align-items: flex-start;
  }

  .search-form {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .search-form .primary-button,
  .search-form label,
  .search-form small {
    grid-column: 1;
    grid-row: auto;
  }

  .search-form .primary-button {
    height: 40px;
  }

  .result-head,
  .pager {
    align-items: flex-start;
    flex-direction: column;
  }

  .sort-line {
    display: block;
    margin-top: 8px;
    padding-left: 0;
  }

  .book-table,
  .book-table tbody,
  .book-table tr,
  .book-table td {
    display: block;
    width: auto;
  }

  .cover-cell {
    width: auto;
    text-align: left;
  }
}

/* Modern public page polish */
body {
  background: #f6f8f6;
}

.topbar {
  position: sticky;
  min-height: 58px;
  padding: 0 clamp(18px, 5vw, 64px);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid #dfe8e1;
  color: var(--text);
  backdrop-filter: blur(14px);
}

.brand {
  height: 58px;
  padding: 0;
  color: #124d32;
  font-size: 18px;
  font-weight: 800;
}

.topbar nav a,
.topbar nav a:hover,
.topbar nav a.active {
  height: 58px;
  padding: 0;
  border-bottom: 2px solid #237a4b;
  background: transparent;
  color: #237a4b;
  font-weight: 700;
}

.shell {
  width: min(1040px, calc(100vw - 28px));
  min-height: 760px;
  margin: 28px auto 56px;
}

.notice-card,
.poem {
  display: none;
}

.search-band {
  display: grid;
  grid-template-columns: minmax(180px, 0.42fr) minmax(420px, 1fr);
  gap: 24px;
  align-items: center;
  margin-bottom: 18px;
  padding: 24px;
  border: 1px solid #dfe8e1;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdfb 100%);
  box-shadow: 0 14px 34px rgba(20, 64, 38, 0.08);
  text-align: left;
}

.search-title h1 {
  margin: 0;
  color: #14251a;
  font-size: 28px;
  line-height: 1.15;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 0.7fr) 110px;
  gap: 10px;
  align-items: center;
  width: 100%;
}

.search-form label {
  display: block;
  grid-column: auto;
}

.search-form input {
  height: 42px;
  border: 1px solid #cddbd0;
  border-radius: 6px;
  background: white;
  font-size: 14px;
}

.search-form input:focus {
  border-color: #237a4b;
}

.search-form .primary-button {
  grid-column: auto;
  grid-row: auto;
  min-width: 0;
  height: 42px;
  border-radius: 6px;
  background: #237a4b;
}

.result-head {
  align-items: center;
  margin: 18px 0 12px;
  color: #18261d;
  font-size: 14px;
}

.result-head span,
.sort-line {
  color: #647268;
}

.sort-line b {
  color: #1f3b2b;
}

.pager {
  flex-direction: row;
}

.pager button {
  min-height: 34px;
  border: 1px solid #dce6dd;
  border-radius: 6px;
  background: white;
}

.state-box {
  border: 1px dashed #bfcfc3;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.results {
  gap: 14px;
}

.book-card {
  display: block;
  overflow: hidden;
  padding: 0;
  border: 1px solid #dce6dd;
  border-radius: 8px;
  background: white;
  box-shadow: 0 10px 24px rgba(30, 52, 38, 0.06);
}

.book-action-line {
  min-height: 44px;
  padding: 8px 14px;
  border-bottom: 1px solid #eef3ef;
  background: #fbfdfb;
}

.result-index {
  width: 24px;
  color: #237a4b;
  font-size: 13px;
  text-align: center;
}

.copy-ss-button,
.query-ss-button {
  width: auto;
  min-width: 150px;
  min-height: 32px;
  border-radius: 6px;
  font-size: 13px;
}

.copy-ss-button {
  background: #237a4b;
}

.query-ss-button {
  background: #7052d8;
}

.book-table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  color: #26342b;
  font-size: 14px;
}

.book-table td {
  border-color: #edf2ee;
  padding: 10px 14px;
}

.cover-col,
.cover-cell {
  width: 118px;
}

.cover-cell {
  background: #fbfdfb;
  text-align: center;
}

.book-cover {
  width: 82px;
  max-height: 122px;
  border-radius: 4px;
  object-fit: contain;
}

.book-title-cell {
  font-weight: 700;
}

.sstext {
  color: #237a4b;
}

.sstext.muted {
  color: #6a756d;
}

@media (max-width: 780px) {
  .topbar {
    padding: 0 16px;
  }

  .search-band,
  .search-form {
    grid-template-columns: 1fr;
  }

  .search-title h1 {
    font-size: 24px;
  }

  .search-form .primary-button,
  .search-form label {
    grid-column: 1;
    grid-row: auto;
  }

  .result-head,
  .pager {
    align-items: flex-start;
    flex-direction: column;
  }

  .cover-col,
  .cover-cell {
    width: auto;
  }
}
