:root {
  --paper: #e7dfd2;
  --paper-deep: #ddd3c3;
  --card: #fbf7f0;
  --ink: #1e1a16;
  --muted: #6f675e;
  --line: #d9cebf;
  --seal: #8f2d2a;
  --seal-soft: #f3e4dc;
  --prompter: #1c1814;
  --prompter-text: #f4ecdf;
  --prompter-dim: #cbbba6;
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "WenQuanYi Micro Hei", "Microsoft YaHei", sans-serif;
  --serif: "Songti SC", "Noto Serif CJK SC", "STSong", "SimSun", "PingFang SC", "WenQuanYi Micro Hei", serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  background:
    linear-gradient(180deg, rgba(255, 252, 247, 0.55), transparent 280px),
    var(--paper);
}

body::before {
  content: "";
  display: block;
  height: 6px;
  background: var(--seal);
}

button, input, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--seal);
  outline-offset: 2px;
}

.page {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.mast {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

.seal {
  flex: none;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  background: var(--seal);
  color: #f8efe4;
  font-family: var(--serif);
  font-size: 34px;
  line-height: 1;
  transform: rotate(-6deg);
  box-shadow: 0 10px 24px rgba(143, 45, 42, 0.22);
}

.mast-text { min-width: 0; }

.kicker {
  margin: 6px 0 0;
  color: var(--seal);
  font-size: 13px;
  letter-spacing: 0.14em;
}

h1 {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-size: 40px;
  font-weight: 650;
  letter-spacing: 0.04em;
  line-height: 1.15;
}

.lede {
  margin: 8px 0 0;
  max-width: 46em;
  color: var(--muted);
}

.mast-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex: none;
}

.btn {
  border: 1px solid var(--line);
  background: #fffdf9;
  border-radius: 999px;
  padding: 8px 14px;
}

.btn:hover { background: #fff; }

.btn.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #f6f1e7;
}

.btn.primary:hover { background: #322c26; }

.btn.tiny { padding: 5px 10px; font-size: 13px; }

.btn:disabled { opacity: 0.55; cursor: wait; }

.brief { margin-top: 22px; }

.range {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
}

.summary, .method, .quota, .list-note, .status {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.method { max-width: 68em; }

.quota { color: #8a5a32; }

.status:empty { display: none; }

.status {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--seal-soft);
  color: #6d2c24;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  margin-top: 16px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
}

.star-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.star-filter select {
  border: 1px solid var(--line);
  background: #fffdf9;
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--ink);
}

.source-badge {
  display: inline-block;
  margin: 8px 0 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: #efe6d8;
  color: var(--ink);
  font-size: 13px;
  letter-spacing: 0.04em;
}

.source-badge.is-trending {
  background: #e5efe6;
  color: #1e4d32;
}

.source-badge.is-search {
  background: #f8ead4;
  color: #7a4b12;
}

.view-switch { display: none; }

.chip {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 6px 12px;
}

.chip.is-on {
  background: var(--ink);
  border-color: var(--ink);
  color: #f6f1e7;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(340px, 0.88fr);
  gap: 22px;
  margin-top: 18px;
  align-items: start;
}

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
}

.toolbar-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.list-note { min-height: 1.4em; }

.card {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 12px;
  margin-top: 12px;
  padding: 14px 14px 14px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 28px rgba(70, 48, 24, 0.04);
}

.card.is-on { box-shadow: inset 3px 0 0 var(--seal), 0 10px 28px rgba(70, 48, 24, 0.05); }

.card input {
  margin-top: 6px;
  width: 16px;
  height: 16px;
  accent-color: var(--seal);
}

.card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.rank {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

.avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
}

.repo-link {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
}

.repo-link:hover { text-decoration: underline; }

.owner { color: var(--muted); }

.repo-name { font-weight: 650; }

.stars {
  margin-left: auto;
  flex: none;
  color: #8a4b12;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.meta, .topics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.lang { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); }

.swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.stamp {
  border: 1px dashed var(--seal);
  color: var(--seal);
  border-radius: 4px;
  padding: 0 6px;
  letter-spacing: 0.06em;
}

.pitch, .why, .origin {
  margin: 8px 0 0;
  font-size: 14.5px;
}

.origin { color: var(--muted); }

.label {
  display: inline-block;
  margin-right: 8px;
  color: var(--seal);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.topic {
  padding: 1px 7px;
  border-radius: 999px;
  background: #f0e7da;
  color: #5c5146;
}

.skeleton {
  height: 128px;
  margin-top: 12px;
  border-radius: 16px;
  background: linear-gradient(90deg, #efe6d8, #f7f1e7, #efe6d8);
  background-size: 200% 100%;
  animation: shine 1.2s ease-in-out infinite;
}

@keyframes shine {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.message {
  margin-top: 12px;
  padding: 22px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--line);
}

.message h3 { margin: 0 0 8px; }

.message p { margin: 0 0 14px; color: var(--muted); }

.prompter {
  position: sticky;
  top: 12px;
  height: calc(100vh - 24px);
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  padding: 14px 14px 12px;
  border-radius: 18px;
  background: var(--prompter);
  color: var(--prompter-text);
  box-shadow: 0 18px 40px rgba(28, 24, 20, 0.18);
}

.prompter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tabs { display: flex; gap: 4px; }

.tab {
  border: 0;
  background: transparent;
  color: var(--prompter-dim);
  padding: 6px 10px;
  border-radius: 999px;
}

.tab.is-on {
  background: rgba(244, 236, 223, 0.1);
  color: var(--prompter-text);
}

.tally {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e23b32;
  box-shadow: 0 0 0 4px rgba(226, 59, 50, 0.16);
}

.draft-meta, .dirty {
  margin: 8px 2px 0;
  color: var(--prompter-dim);
  font-size: 13px;
}

.dirty { color: #f0d2a4; }

.text-btn {
  border: 0;
  background: transparent;
  color: #f4ecdf;
  text-decoration: underline;
  padding: 0 0 0 6px;
}

.prompter textarea {
  flex: 1;
  width: 100%;
  min-height: 0;
  margin-top: 8px;
  border: 0;
  resize: none;
  background: transparent;
  color: inherit;
  line-height: 1.75;
  padding: 4px 2px 8px;
}

.prompter textarea:focus { outline: none; }

.prompter textarea:focus-visible {
  outline: 1px solid rgba(244, 236, 223, 0.4);
  outline-offset: 2px;
}

.prompter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 8px;
}

.btn.light {
  background: transparent;
  color: var(--prompter-text);
  border-color: rgba(244, 236, 223, 0.28);
}

.btn.light:hover { background: rgba(255, 255, 255, 0.06); }

dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(30, 20, 10, 0.28);
}

dialog::backdrop { background: rgba(30, 26, 22, 0.48); }

dialog form { padding: 22px; }

dialog h3 { margin: 0 0 8px; font-family: var(--serif); font-size: 26px; }

dialog p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }

dialog label {
  display: block;
  margin: 12px 0 6px;
  font-size: 14px;
}

dialog input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}

dialog code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.92em;
}

.hint { font-size: 13px; }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.jump-script { display: none; }

@media (max-width: 960px) {
  .page { width: min(100% - 28px, 1180px); padding-bottom: 28px; }
  .mast { flex-wrap: wrap; }
  .mast-actions { margin-left: 0; }
  h1 { font-size: 32px; }
  .view-switch {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 6;
    gap: 8px;
    padding: 8px 0;
    background: rgba(231, 223, 210, 0.94);
  }
  .view-switch button {
    flex: 1;
    border: 1px solid var(--line);
    background: #fffdf9;
    border-radius: 999px;
    padding: 8px 12px;
  }
  .view-switch button.is-on {
    background: var(--ink);
    color: #f6f1e7;
    border-color: var(--ink);
  }
  body[data-mobile-view="script"] .list-pane { display: none; }
  body[data-mobile-view="list"] .prompter { display: none; }
  .layout { grid-template-columns: 1fr; }
  .card-top { flex-wrap: wrap; align-items: flex-start; }
  .repo-link {
    flex: 1 1 140px;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
  .prompter {
    position: static;
    height: auto;
    min-height: calc(100vh - 220px);
  }
  .prompter textarea { min-height: 48vh; }
  .prompter-actions { position: sticky; bottom: 0; background: var(--prompter); padding-bottom: 4px; }
  .jump-script {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--ink);
    color: #f6f1e7;
    text-decoration: none;
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}
