:root {
  --bg: #f7f2ec;
  --panel: #fffdf9;
  --panel-alt: #f2ebe3;
  --border: #decfc4;
  --text: #211c18;
  --muted: #786d64;
  --accent: #2a231f;
  --accent-weak: #efe4dc;
  --catalog-shell-bg: var(--bg);
  --catalog-shell-panel: var(--panel);
  --catalog-shell-border: var(--border);
  --catalog-shell-text: var(--text);
  --catalog-shell-muted: var(--muted);
  --catalog-shell-accent: var(--accent);
  --catalog-shell-accent-weak: var(--accent-weak);
  --catalog-shell-display: "Noto Serif SC", "Songti SC", "SimSun", Georgia, serif;
  --catalog-shell-shadow: 0 18px 44px rgba(42, 35, 31, .09);
}

button {
  border: 1px solid var(--catalog-shell-border);
  background: var(--catalog-shell-panel);
  color: var(--catalog-shell-text);
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .2s ease;
}

button:hover {
  border-color: #b8967e;
  background: #faf7f2;
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: .48;
  cursor: not-allowed;
}

input,
select,
textarea {
  border-color: var(--catalog-shell-border);
  border-radius: 6px;
  background: #fffdf9;
  color: var(--catalog-shell-text);
}

button.primary {
  background: var(--catalog-shell-accent);
  color: #fffdf9;
  border-color: var(--catalog-shell-accent);
}

button.primary:hover {
  background: #17130f;
  border-color: #17130f;
}

button.active,
.tabs button.active {
  background: var(--catalog-shell-accent-weak);
  border-color: #b8967e;
  color: var(--catalog-shell-accent);
  font-weight: 720;
}

.result,
.case-row,
.law-row,
.detail-row,
.patent-result-row {
  border-radius: 6px;
  background: #fffdf9;
  transition: background-color .2s ease, border-color .2s ease, transform .2s ease;
}

.result:hover,
.result.selected,
.case-row:hover,
.case-row.selected,
.law-row:hover,
.law-row.selected,
.detail-row:hover,
.detail-row.selected,
.patent-result-row:hover,
.patent-result-row.selected {
  border-color: #b8967e;
  background: #f5eee7;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  position: relative;
  background:
    linear-gradient(180deg, rgba(250, 247, 242, .98), rgba(242, 235, 227, .96)),
    var(--catalog-shell-bg);
}

.shell > aside {
  height: 100vh;
  min-width: 0;
  border-right: 1px solid var(--catalog-shell-border);
  background:
    linear-gradient(180deg, rgba(255, 253, 249, .94), rgba(247, 242, 236, .92)),
    var(--catalog-shell-bg);
  display: flex;
  flex-direction: column;
}

.side-head {
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--catalog-shell-border);
  background: rgba(255, 253, 249, .84);
}

.side-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.side-title-row h1 {
  margin: 0;
}

.catalog-brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  color: var(--catalog-shell-text);
  font-family: var(--catalog-shell-display);
  font-size: 19px;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
}

.catalog-brand:hover {
  color: var(--catalog-shell-text);
}

.catalog-logo {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  background: url("/static/site-logo.svg?v=deep-search-32") center / contain no-repeat;
  filter: drop-shadow(0 8px 16px rgba(42, 35, 31, .12));
}

.side-head h1 {
  margin-top: 14px;
  color: var(--catalog-shell-text);
  font-family: var(--catalog-shell-display);
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 0;
}

.sidebar-toggle {
  width: 38px;
  height: 38px;
  display: none;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 0;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.side-collapse {
  font-size: 26px;
}

.open-sidebar {
  display: none;
}

main {
  height: 100vh;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--catalog-shell-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  background:
    linear-gradient(180deg, #b8967e 0 6px, rgba(255, 253, 249, .94) 6px),
    var(--catalog-shell-panel);
  box-shadow: var(--catalog-shell-shadow);
}

.topbar-left {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  flex: 1 1 auto;
  gap: 14px;
}

.topbar-brand {
  flex: 0 0 auto;
}

.topbar-title {
  min-width: 0;
  flex: 1 1 auto;
}

.title {
  color: var(--catalog-shell-text);
  font-family: var(--catalog-shell-display);
  font-size: 23px;
  line-height: 1.28;
  font-weight: 800;
}

.meta {
  margin-top: 7px;
  color: var(--catalog-shell-muted);
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.actions {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.actions > button {
  flex: 0 0 auto;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--catalog-shell-border);
  overflow-x: auto;
  background: rgba(255, 253, 249, .82);
}

.tabs > button {
  flex: 0 0 auto;
}

.status {
  margin-left: auto;
  min-width: 0;
  color: var(--catalog-shell-muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.copy-current {
  margin-left: 8px;
  flex: 0 0 auto;
}

.content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 20px 22px 30px;
  scroll-behavior: auto;
  background:
    linear-gradient(90deg, rgba(184, 150, 126, .055) 1px, transparent 1px),
    linear-gradient(rgba(184, 150, 126, .055) 1px, transparent 1px),
    #fffdf9;
  background-size: 54px 54px;
}

.empty {
  color: var(--catalog-shell-muted);
  padding: 36px 0;
}

.catalog-shell-backdrop {
  display: none;
}

@media (max-width: 900px) and (orientation: portrait) {
  body {
    overflow: hidden;
  }

  .shell {
    display: block;
    min-height: 100vh;
    overflow: hidden;
  }

  .shell > aside {
    position: fixed;
    z-index: 20;
    inset: 0 auto 0 0;
    width: min(88vw, 390px);
    max-width: 390px;
    height: 100vh;
    border-right: 1px solid var(--catalog-shell-border);
    border-bottom: 0;
    box-shadow: 8px 0 28px rgba(23, 35, 59, .16);
    transform: translateX(0);
    transition: transform .22s ease, box-shadow .22s ease;
  }

  .shell.sidebar-collapsed > aside {
    transform: translateX(calc(-100% - 16px));
    box-shadow: none;
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .open-sidebar {
    display: none;
  }

  .shell.sidebar-collapsed .open-sidebar {
    display: inline-flex;
  }

  main {
    width: 100%;
    height: 100vh;
  }

  .topbar {
    padding: 12px 12px 10px;
    gap: 10px;
    align-items: flex-start;
  }

  .topbar-left {
    gap: 12px;
  }

  .title {
    font-size: 20px;
  }

  .tabs {
    padding: 10px 12px;
  }

  .content {
    padding: 16px 12px 24px;
  }

  .catalog-shell-backdrop {
    position: fixed;
    z-index: 15;
    inset: 0 0 0 min(88vw, 390px);
    display: block;
    background: transparent;
    cursor: default;
  }

  .catalog-shell-backdrop[hidden],
  .shell.sidebar-collapsed .catalog-shell-backdrop {
    display: none;
  }

  .origin-shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 100vh;
    overflow: hidden;
  }

  .origin-shell > aside {
    position: relative;
    inset: auto;
    width: 100%;
    max-width: none;
    height: auto;
    max-height: 42vh;
    border-right: 0;
    border-bottom: 1px solid var(--catalog-shell-border);
    box-shadow: none;
    transform: none;
  }

  .origin-shell main {
    height: 58vh;
  }
}
