:root {
  --bg: #fff7df;
  --bg-accent: #ffe6b7;
  --surface: #fffdf8;
  --surface-strong: #fff3d0;
  --text: #5a3a12;
  --text-soft: #8a6233;
  --primary: #f3a847;
  --primary-strong: #ea8b22;
  --border: #e6c18d;
  --shadow: rgba(153, 97, 24, 0.14);
  --max-width: 1120px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg) 0%, #fffaf0 100%);
}

button,
a {
  font: inherit;
}

.page-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: min(calc(100% - 24px), var(--max-width));
  margin: 0 auto;
  padding: 4px 0 6px;
}


.page-header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 2px 0 6px;
  background: linear-gradient(180deg, rgba(255, 247, 223, 0.96) 0%, rgba(255, 247, 223, 0.9) 80%, rgba(255, 247, 223, 0) 100%);
  backdrop-filter: blur(8px);
}

main {
  display: flex;
  flex-direction: column;
}

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

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

.page-title {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  line-height: 1.1;
  letter-spacing: 0.02em;
  font-weight: 400;
}

.page-title-main {
  font-size: clamp(1.08rem, 0.9vw + 0.78rem, 1.52rem);
  font-weight: 700;
  flex: 0 1 auto;
}

.page-title-note {
  color: var(--text-soft);
  font-size: 0.58rem;
  font-weight: 400;
  line-height: 1.2;
}

.title-break {
  display: none;
}

.doubao-link {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: #fff;
  text-decoration: none;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
  box-shadow: 0 8px 18px rgba(234, 139, 34, 0.2);
}

.doubao-link:hover,
.doubao-link:focus-visible {
  transform: translateY(-1px);
}

.tab-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

@media (min-width: 901px) {
  .page-shell {
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 100vh;
  }

  .page-header {
    display: grid;
    grid-template-rows: auto auto;
    row-gap: 8px;
    padding-bottom: 0;
  }

  .tab-list {
    margin-top: 0;
  }

  main {
    min-height: 0;
    display: grid;
    grid-template-rows: 1fr auto;
    row-gap: 10px;
  }

  .card-grid {
    height: 100%;
    margin-top: 0;
    align-content: stretch;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(2, auto);
    row-gap: 10px;
    column-gap: 10px;
  }

  .prompt-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
  }

  .card-image-wrap {
    aspect-ratio: auto;
    flex: 1 1 auto;
    min-height: 0;
  }

  .card-body {
    display: flex;
    flex: 0 0 auto;
    min-height: 0;
    flex-direction: column;
    justify-content: flex-end;
  }

  .prompt-box {
    flex: 0 0 auto;
    min-height: auto;
  }

  .prompt-text {
    min-height: 0;
  }

  .prompt-box.is-collapsed .prompt-text {
    -webkit-line-clamp: 2;
  }

  .bottom-bar {
    margin-top: 0;
  }
}

.tab-button {
  min-height: 36px;
  padding: 6px 5px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.tab-button:hover,
.tab-button:focus-visible {
  border-color: var(--primary-strong);
  transform: translateY(-1px);
}

.tab-button.is-active {
  border-color: #d88b2b;
  background: linear-gradient(135deg, #ffe6b6 0%, #ffd08a 100%);
  box-shadow: 0 8px 20px var(--shadow);
}

.status-panel {
  display: none;
  margin: 20px 0;
  padding: 18px 20px;
  border: 1px dashed var(--border);
  border-radius: 16px;
  color: var(--text-soft);
  background: rgba(255, 253, 248, 0.95);
}

.status-panel.is-visible {
  display: block;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.prompt-card {
  overflow: hidden;
  min-width: 0;
  border: 1px solid rgba(230, 193, 141, 0.75);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 6px 16px var(--shadow);
}

.card-image-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  background: linear-gradient(135deg, #ffefcb 0%, #f8d79c 100%);
}


.card-image,
.image-fallback {
  width: 100%;
  height: 100%;
}

.card-image {
  display: block;
  object-fit: cover;
}

.image-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  text-align: center;
  color: var(--text-soft);
  font-size: 0.88rem;
}

.image-fallback[hidden] {
  display: none;
}

.card-body {
  padding: 8px;
}

.card-title {
  margin: 0 0 8px;
  font-size: 0.86rem;
  line-height: 1.3;
  word-break: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.prompt-box {
  position: relative;
  border-radius: 12px;
  background: var(--surface-strong);
}

.prompt-box.is-collapsed::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 28px;
  border-radius: 0 0 12px 12px;
  background: linear-gradient(180deg, rgba(255, 243, 208, 0) 0%, rgba(255, 243, 208, 0.96) 100%);
  pointer-events: none;
}

.prompt-text {
  margin: 0;
  padding: 8px;
  color: var(--text-soft);
  font-size: 0.74rem;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.prompt-box.is-collapsed .prompt-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.toggle-button {
  margin-top: 4px;
  min-height: 24px;
  padding: 0;
  border: 0;
  color: var(--primary-strong);
  font-size: 0.72rem;
  background: transparent;
  cursor: pointer;
}

.bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 0;
}

.pagination-button,
.pagination-number,
.pagination-ellipsis {
  min-width: 36px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 10px;
}

.pagination-button,
.pagination-number {
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}

.pagination-button[disabled],
.pagination-number[disabled] {
  cursor: not-allowed;
  opacity: 0.5;
}

.pagination-number.is-active {
  border-color: #d88b2b;
  color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
}

.pagination-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-soft);
}

.page-footer {
  flex: 0 0 auto;
  margin-top: 0;
  text-align: left;
  color: var(--text-soft);
  font-size: 0.72rem;
  line-height: 1.2;
}

@media (max-width: 900px) {
  .bottom-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .page-footer {
    text-align: center;
  }

  .pagination {
    justify-content: center;
  }

  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
}

@media (max-width: 640px) {
  body {
    overflow-x: hidden;
  }

  .page-shell {
    width: min(calc(100% - 16px), var(--max-width));
    padding-top: 14px;
    padding-bottom: 10px;
  }

  .page-header {
    padding: 8px 0 8px;
  }

  .header-row {
    gap: 8px;
    align-items: flex-start;
  }

  .title-group {
    min-width: 0;
  }

  .page-title {
    display: block;
    min-width: 0;
    line-height: 1.1;
  }

  .page-title-main {
    display: inline;
    font-size: 0.94rem;
    font-weight: 700;
  }

  .title-break {
    display: block;
    height: 0;
  }

  .page-title-note {
    display: inline;
    font-size: 0.48rem;
    line-height: 1.12;
  }

  .doubao-link {
    min-height: 34px;
    padding: 0 10px;
    font-size: 0.78rem;
  }

  .tab-list {
    gap: 4px;
    margin-top: 10px;
  }

  .tab-button {
    min-height: 42px;
    padding: 6px 4px;
    font-size: 0.68rem;
    line-height: 1.15;
  }

  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 8px;
  }

  .prompt-card {
    border-radius: 14px;
  }

  .card-image-wrap {
    aspect-ratio: 1 / 1;
  }

  .card-body {
    padding: 10px;
  }

  .card-title {
    margin-bottom: 8px;
    font-size: 0.82rem;
  }

  .prompt-text {
    padding: 10px;
    font-size: 0.74rem;
    line-height: 1.45;
  }

  .prompt-box.is-collapsed .prompt-text {
    -webkit-line-clamp: 2;
  }

  .toggle-button {
    margin-top: 6px;
    min-height: 28px;
    font-size: 0.74rem;
  }

  .bottom-bar {
    margin-top: 12px;
    gap: 8px;
  }

  .pagination {
    gap: 6px;
    margin-top: 0;
  }

  .pagination-button,
  .pagination-number,
  .pagination-ellipsis {
    min-width: 34px;
    min-height: 34px;
    padding: 0 8px;
    font-size: 0.82rem;
  }
}
