:root {
  --ink: #293229;
  --muted: #697268;
  --paper: #fffdf6;
  --paper-soft: #f6f0dc;
  --line: #d8ceb2;
  --green: #4f7844;
  --green-dark: #304d2d;
  --gold: #b9812f;
  --red: #ad493d;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #e8efe1; }
body { min-height: 100vh; margin: 0; color: var(--ink); font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif; letter-spacing: 0; background: linear-gradient(180deg, #dceef3 0 180px, transparent 180px), var(--paper-soft); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }

.collection-header { color: #fffdf6; background: #355732; border-bottom: 1px solid #273e25; }
.collection-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 20px; width: min(1060px, calc(100% - 32px)); min-height: 66px; margin: 0 auto; }
.brand-link { display: flex; align-items: baseline; gap: 10px; color: inherit; text-decoration: none; }
.brand-link span { color: #e6c875; font-size: 11px; font-weight: 900; }
.brand-link strong { font-size: 20px; }
.collection-header nav { display: flex; gap: 8px; }
.collection-header nav a { padding: 8px 11px; color: inherit; font-size: 13px; font-weight: 800; text-decoration: none; border: 1px solid rgba(255,255,255,.34); border-radius: 4px; }
.collection-header nav a:hover { color: #2d422a; background: #f2d681; }

.collection-shell { width: min(1060px, calc(100% - 32px)); margin: 0 auto; padding: 30px 0 80px; }
.collection-message { min-height: 0; margin: 0 0 14px; color: var(--green-dark); font-size: 13px; font-weight: 800; }
.collection-message:not(:empty) { padding: 11px 13px; background: #edf5df; border: 1px solid #b7cb93; border-radius: 6px; }
.collection-message.is-error:not(:empty) { color: var(--red); background: #fff0ed; border-color: #dcb4ab; }
.page-heading, .detail-heading { padding: 24px 26px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.kicker { margin: 0 0 5px; color: var(--gold); font-size: 11px; font-weight: 900; }
.page-heading h1, .detail-heading h1 { margin: 0; color: var(--green-dark); font-size: 28px; line-height: 1.25; overflow-wrap: anywhere; }
.page-heading p:last-child, #detail-description { margin: 7px 0 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.primary-button, .collection-pager button, .detail-actions button, .favorite-picker button { min-height: 38px; padding: 7px 13px; color: #fffdf6; font-weight: 800; background: var(--green); border: 1px solid #365d34; border-radius: 4px; cursor: pointer; }
.primary-button:disabled, button:disabled { cursor: wait; opacity: .55; }

.collection-toolbar { display: flex; align-items: center; gap: 9px; min-height: 54px; margin-top: 16px; padding: 9px 14px; color: var(--muted); font-size: 13px; background: rgba(255,253,246,.72); border: 1px solid var(--line); border-radius: 6px; }
.collection-toolbar select { min-height: 34px; padding: 5px 30px 5px 9px; color: var(--ink); background: #fff; border: 1px solid #c9c0aa; border-radius: 4px; }
.collection-toolbar span { margin-left: auto; }
.collection-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.collection-card { display: grid; grid-template-rows: auto minmax(48px, auto) auto; gap: 10px; min-width: 0; min-height: 188px; padding: 17px; color: inherit; text-decoration: none; background: var(--paper); border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 4px 12px rgba(55,65,48,.06); }
.collection-card:hover { border-color: #91aa74; transform: translateY(-1px); }
.collection-card h2 { margin: 0; color: #30462d; font-size: 17px; line-height: 1.4; overflow-wrap: anywhere; }
.collection-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.collection-card-meta { display: flex; flex-wrap: wrap; gap: 7px 12px; padding-top: 10px; color: #596254; font-size: 11px; font-weight: 800; border-top: 1px solid #e6dfcc; }
.empty-state { grid-column: 1 / -1; min-height: 180px; display: grid; place-items: center; color: var(--muted); background: var(--paper); border: 1px solid var(--line); border-radius: 7px; }

.collection-pager { display: flex; align-items: center; justify-content: center; gap: 14px; min-height: 62px; margin-top: 14px; color: var(--muted); font-size: 13px; font-weight: 800; }
.collection-pager button { min-width: 82px; }
.back-button { display: inline-block; margin-bottom: 18px; color: #466c3e; font-size: 13px; font-weight: 800; text-decoration: none; }
.detail-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.detail-title-row > div:first-child { min-width: 0; }
.detail-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.detail-actions button { background: #fffaf0; color: #3d5937; border-color: #b8ad90; }
.detail-actions button.is-liked { color: #fff; background: #a9443b; border-color: #88362f; }
.detail-actions strong { margin-left: 3px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 17px; padding-top: 13px; color: var(--muted); font-size: 12px; border-top: 1px solid #e3dbc5; }

.mod-list { display: grid; margin-top: 16px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.mod-item { display: block; padding: 17px 19px; color: inherit; text-decoration: none; border-top: 1px solid #e5deca; transition: background-color .14s ease, border-color .14s ease; }
.mod-item:first-child { border-top: 0; }
.mod-item:hover, .mod-item:focus-visible { background: #f4f7e9; outline: 0; }
.mod-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.source-badge, .ai-badge { padding: 3px 6px; color: #fff; font-size: 10px; font-weight: 900; background: #57784d; border-radius: 3px; }
.source-badge.is-blog { background: #a9772d; }
.ai-badge { background: #386f84; }
.mod-item h2 { margin: 0; font-size: 16px; line-height: 1.45; overflow-wrap: anywhere; }
.mod-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; color: var(--muted); font-size: 12px; }
.collection-grid.is-loading, .mod-list.is-loading { opacity: .62; pointer-events: none; }
.collection-skeleton { display: grid; gap: 12px; min-height: 142px; padding: 18px; background: var(--paper); border: 1px solid var(--line); border-radius: 7px; }
.collection-skeleton span { display: block; height: 13px; background: #e7e2d3; border-radius: 3px; animation: collection-pulse 1.1s ease-in-out infinite alternate; }
.collection-skeleton span:first-child { width: 58%; height: 18px; }
.collection-skeleton span:last-child { width: 76%; }
.mod-list .collection-skeleton { min-height: 96px; border: 0; border-top: 1px solid #e5deca; border-radius: 0; }
@keyframes collection-pulse { from { opacity: .5; } to { opacity: 1; } }
.add-mod-button { position: fixed; right: max(22px, calc((100vw - 1060px) / 2)); bottom: 24px; min-height: 46px; padding: 9px 16px; color: #fffdf6; font-weight: 900; background: #355f36; border: 1px solid #274829; border-radius: 7px; box-shadow: 0 8px 24px rgba(37,59,35,.24); cursor: pointer; }
.add-mod-button span { margin-right: 4px; font-size: 20px; line-height: 1; }

.collection-dialog { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 18px; }
.collection-dialog[hidden] { display: none; }
.dialog-backdrop { position: absolute; inset: 0; background: rgba(31,41,31,.6); }
.dialog-panel { position: relative; width: min(520px, 100%); max-height: calc(100vh - 36px); padding: 23px; overflow-y: auto; background: var(--paper); border: 1px solid #b9ad8d; border-radius: 8px; box-shadow: 0 18px 54px rgba(31,41,31,.3); }
.dialog-panel h2 { margin: 0 36px 18px 0; color: var(--green-dark); font-size: 21px; }
.dialog-close { position: absolute; top: 9px; right: 9px; width: 34px; height: 34px; color: var(--muted); font-size: 24px; background: transparent; border: 0; cursor: pointer; }
.dialog-form { display: grid; gap: 13px; }
.dialog-form label { display: grid; gap: 6px; color: #465144; font-size: 13px; font-weight: 800; }
.dialog-form input, .dialog-form select, .dialog-form textarea { width: 100%; min-height: 40px; padding: 8px 10px; color: var(--ink); background: #fff; border: 1px solid #c9c0aa; border-radius: 4px; resize: vertical; }
.dialog-form input:focus, .dialog-form select:focus, .dialog-form textarea:focus { outline: 3px solid rgba(185,129,47,.2); border-color: var(--gold); }
.form-note { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.form-error { min-height: 18px; margin: 0; color: var(--red); font-size: 13px; font-weight: 800; }
.favorite-picker { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; padding: 11px; background: #f2efe4; border: 1px solid #ddd3bc; border-radius: 6px; }
.favorite-picker label { min-width: 0; }

@media (max-width: 820px) { .collection-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) {
  .collection-header-inner, .collection-shell { width: min(100% - 22px, 1060px); }
  .brand-link span { display: none; }
  .collection-header nav a { padding: 7px 8px; }
  .collection-shell { padding-top: 16px; }
  .page-heading, .detail-heading { padding: 19px 17px; }
  .page-heading, .detail-title-row { align-items: stretch; flex-direction: column; }
  .page-heading h1, .detail-heading h1 { font-size: 23px; }
  .primary-button { width: 100%; }
  .collection-grid { grid-template-columns: 1fr; }
  .collection-card { min-height: 164px; }
  .detail-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .mod-item { padding: 15px; }
  .add-mod-button { right: 13px; bottom: 13px; }
  .favorite-picker { grid-template-columns: 1fr; }
}
