:root {
  --paper: #f3f1ea;
  --paper-deep: #e9e5db;
  --ink: #162826;
  --ink-soft: #5f6b67;
  --line: rgba(22, 40, 38, 0.14);
  --accent: #e95f38;
  --accent-deep: #c64221;
  --teal: #174d47;
  --cream: #fffdf8;
  --shadow: 0 20px 60px rgba(30, 45, 40, 0.09);
  --sans: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    sans-serif;
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 83% 8%, rgba(233, 95, 56, 0.09), transparent 23rem),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

.paper-grain {
  position: fixed;
  z-index: 20;
  inset: 0;
  pointer-events: none;
  opacity: 0.28;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.08'/%3E%3C/svg%3E");
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1400px, calc(100% - 80px));
  margin: 0 auto;
  padding: 30px 0;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: var(--ink);
}

.brand-mark span {
  position: absolute;
  width: 24px;
  height: 7px;
  border: 1.3px solid var(--paper);
  border-radius: 50%;
  transform: rotate(-20deg);
}

.brand-mark span:nth-child(2) {
  transform: rotate(40deg);
}

.brand-mark span:nth-child(3) {
  transform: rotate(100deg);
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy strong {
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: 0.08em;
}

.brand-copy small {
  color: var(--ink-soft);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.25em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 19px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition:
    transform 180ms ease,
    background-color 180ms ease,
    color 180ms ease,
    border-color 180ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

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

.button:focus-visible,
.icon-button:focus-visible,
.image-trigger:focus-visible,
.card-copy [contenteditable]:focus-visible {
  outline: 3px solid rgba(233, 95, 56, 0.24);
  outline-offset: 3px;
}

.button-primary {
  color: #fffdf8;
  background: var(--teal);
}

.button-primary:hover {
  background: #0f3c37;
}

.button-primary svg {
  width: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.button-ghost {
  border-color: var(--line);
  background: rgba(255, 253, 248, 0.45);
}

.button-ghost:hover {
  border-color: rgba(22, 40, 38, 0.28);
  background: var(--cream);
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 23px;
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.22em;
}

.eyebrow span {
  display: inline-block;
  width: 25px;
  height: 1px;
  background: var(--accent);
}

.library {
  width: min(1400px, calc(100% - 80px));
  margin: 0 auto;
  padding-top: 28px;
}

.library-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
  padding-bottom: 26px;
}

.page-title {
  flex: 0 0 auto;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(24px, 2.4vw, 34px);
  font-weight: 600;
  letter-spacing: -0.035em;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(22px, 3vw, 46px);
  min-width: 0;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: min(340px, 38vw);
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.6);
  transition:
    border-color 180ms ease,
    background-color 180ms ease,
    box-shadow 180ms ease;
}

.search-box:focus-within {
  border-color: rgba(23, 77, 71, 0.38);
  background: var(--cream);
  box-shadow: 0 0 0 3px rgba(23, 77, 71, 0.06);
}

.search-box svg {
  width: 20px;
  fill: none;
  stroke: var(--ink);
  stroke-linecap: round;
  stroke-width: 1.5;
}

.search-box input {
  width: 100%;
  padding: 11px 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 13px;
}

.search-box input::placeholder {
  color: #8a928e;
}

.search-box kbd {
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: #7a837f;
  background: rgba(255, 253, 248, 0.55);
  font-family: var(--sans);
  font-size: 9px;
}

.result-summary {
  display: flex;
  align-items: center;
  gap: 15px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.1em;
}

.summary-rule {
  width: 45px;
  height: 1px;
  background: var(--line);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
  padding-bottom: 100px;
}

.prompt-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(22, 40, 38, 0.09);
  border-radius: 24px;
  background: var(--cream);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
  animation: card-in 500ms both cubic-bezier(0.22, 0.8, 0.26, 1);
  transition:
    transform 280ms cubic-bezier(0.22, 0.8, 0.26, 1),
    box-shadow 280ms ease,
    border-color 280ms ease;
}

.prompt-card:hover {
  border-color: rgba(22, 40, 38, 0.16);
  box-shadow: var(--shadow);
  transform: translateY(-6px);
}

.prompt-card:nth-child(2) {
  animation-delay: 60ms;
}

.prompt-card:nth-child(3) {
  animation-delay: 120ms;
}

.prompt-card:nth-child(4) {
  animation-delay: 180ms;
}

.prompt-card:nth-child(5) {
  animation-delay: 240ms;
}

.prompt-card:nth-child(6) {
  animation-delay: 300ms;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--paper-deep);
}

.image-trigger {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: var(--paper-deep);
  cursor: pointer;
}

.image-trigger img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 650ms cubic-bezier(0.22, 0.8, 0.26, 1);
}

.prompt-card:hover .image-trigger img {
  transform: scale(1.035);
}

.image-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: white;
  background: rgba(12, 31, 28, 0.37);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.04em;
  opacity: 0;
  transition: opacity 220ms ease;
}

.image-overlay svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.image-trigger:hover .image-overlay,
.image-trigger:focus-visible .image-overlay {
  opacity: 1;
}

.card-tools {
  position: absolute;
  z-index: 2;
  top: 13px;
  right: 13px;
  display: flex;
  gap: 7px;
  opacity: 0;
  transform: translateY(-4px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.prompt-card:hover .card-tools,
.prompt-card:focus-within .card-tools {
  opacity: 1;
  transform: translateY(0);
}

.icon-button {
  display: grid;
  width: 35px;
  height: 35px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(15, 38, 34, 0.72);
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition:
    background-color 160ms ease,
    transform 160ms ease;
}

.icon-button:hover {
  background: rgba(15, 38, 34, 0.92);
  transform: scale(1.05);
}

.icon-button svg {
  width: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.delete-button:hover {
  background: var(--accent-deep);
}

.card-copy {
  min-height: 196px;
  padding: 25px 25px 27px;
}

.card-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.card-description {
  height: 200px;
  margin: 13px 0 0;
  padding-right: 8px;
  overflow-y: auto;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.82;
  overscroll-behavior: contain;
  scrollbar-color: rgba(23, 77, 71, 0.28) transparent;
  scrollbar-width: thin;
  white-space: pre-line;
}

.card-description::-webkit-scrollbar {
  width: 5px;
}

.card-description::-webkit-scrollbar-track {
  background: transparent;
}

.card-description::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(23, 77, 71, 0.22);
}

.card-description:hover::-webkit-scrollbar-thumb {
  background: rgba(23, 77, 71, 0.38);
}

.card-copy [contenteditable] {
  border-radius: 5px;
  outline: transparent;
  cursor: text;
  transition:
    background-color 160ms ease,
    box-shadow 160ms ease;
}

.card-copy [contenteditable]:hover {
  background: rgba(23, 77, 71, 0.045);
  box-shadow: -6px 0 0 rgba(23, 77, 71, 0.045), 6px 0 0 rgba(23, 77, 71, 0.045);
}

.card-copy [contenteditable]:focus {
  background: rgba(23, 77, 71, 0.06);
  box-shadow: -7px 0 0 rgba(23, 77, 71, 0.06), 7px 0 0 rgba(23, 77, 71, 0.06);
}

.card-description:empty::before {
  color: #a0a7a3;
  content: attr(data-placeholder);
}

.empty-state {
  padding: 80px 20px 120px;
  text-align: center;
}

.empty-symbol {
  display: grid;
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent);
  font-family: var(--serif);
  font-size: 36px;
}

.empty-state h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 500;
}

.empty-state p {
  margin: 10px 0 24px;
  color: var(--ink-soft);
  font-size: 13px;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1400px, calc(100% - 80px));
  margin: 0 auto;
  padding: 23px 0 30px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.editor-dialog {
  width: min(620px, calc(100% - 32px));
  max-height: calc(100vh - 40px);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 26px;
  color: var(--ink);
  background: var(--cream);
  box-shadow: 0 30px 100px rgba(9, 26, 23, 0.26);
}

.editor-dialog[open] {
  animation: dialog-in 260ms both cubic-bezier(0.22, 0.8, 0.26, 1);
}

.editor-dialog::backdrop {
  background: rgba(12, 27, 25, 0.48);
  backdrop-filter: blur(6px);
  animation: backdrop-in 220ms both ease;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.985);
  }
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }
}

.editor-form {
  display: flex;
  max-height: calc(100vh - 40px);
  flex-direction: column;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 29px 31px 20px;
}

.dialog-heading .eyebrow {
  margin-bottom: 9px;
}

.dialog-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 31px;
  font-weight: 500;
  letter-spacing: -0.03em;
}

.dialog-close {
  width: 38px;
  height: 38px;
  color: var(--ink);
  background: var(--paper-deep);
}

.dialog-close:hover {
  background: #ddd8cc;
}

.form-body {
  padding: 0 31px;
  overflow-y: auto;
}

.upload-zone {
  position: relative;
  display: grid;
  min-height: 200px;
  margin-bottom: 8px;
  padding: 20px;
  place-items: center;
  overflow: hidden;
  border: 1.5px dashed rgba(22, 40, 38, 0.23);
  border-radius: 17px;
  background:
    linear-gradient(rgba(255, 253, 248, 0.72), rgba(255, 253, 248, 0.72)),
    repeating-linear-gradient(
      -45deg,
      rgba(23, 77, 71, 0.08),
      rgba(23, 77, 71, 0.08) 1px,
      transparent 1px,
      transparent 10px
    );
  outline: none;
  cursor: pointer;
  transition:
    border-color 180ms ease,
    background-color 180ms ease;
}

.upload-zone:hover,
.upload-zone:focus-visible,
.upload-zone.is-dragging {
  border-color: var(--accent);
}

.upload-zone.is-dragging {
  background: rgba(233, 95, 56, 0.06);
}

.upload-zone > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-placeholder {
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
}

.upload-placeholder strong {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 650;
}

.upload-placeholder > span:last-child {
  color: var(--ink-soft);
  font-size: 10px;
}

.upload-icon {
  display: grid;
  width: 47px;
  height: 47px;
  place-items: center;
  border-radius: 50%;
  color: var(--teal);
  background: #e5ebe3;
}

.upload-icon svg {
  width: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.remove-preview {
  position: absolute;
  right: 13px;
  bottom: 13px;
  padding: 8px 12px;
  border: 0;
  border-radius: 999px;
  color: white;
  background: rgba(12, 28, 25, 0.72);
  backdrop-filter: blur(8px);
  font-size: 10px;
  cursor: pointer;
}

.upload-error {
  min-height: 18px;
  margin-bottom: 3px;
  color: var(--accent-deep);
  font-size: 11px;
}

.field {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.field-label span:last-child {
  color: #919995;
  font-size: 9px;
  font-weight: 500;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: 0;
  color: var(--ink);
  background: #faf8f2;
  font-size: 13px;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    background-color 180ms ease;
}

.field input {
  height: 48px;
  padding: 0 14px;
}

.field textarea {
  min-height: 118px;
  padding: 13px 14px;
  line-height: 1.7;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  border-color: rgba(23, 77, 71, 0.62);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(23, 77, 71, 0.07);
}

.field input::placeholder,
.field textarea::placeholder {
  color: #9aa19d;
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 24px;
  padding: 19px 31px 25px;
  border-top: 1px solid var(--line);
}

.dialog-actions > span {
  color: #909894;
  font-size: 9px;
}

.dialog-actions > div {
  display: flex;
  gap: 8px;
}

.toast {
  position: fixed;
  z-index: 100;
  bottom: 28px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  color: white;
  background: rgba(16, 38, 34, 0.94);
  box-shadow: 0 12px 40px rgba(10, 25, 22, 0.22);
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.toast-mark {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #83c8ac;
}

.toast button {
  margin-left: 3px;
  padding: 4px 8px;
  border: 0;
  border-radius: 999px;
  color: #ffd6c9;
  background: rgba(255, 255, 255, 0.11);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

@media (max-width: 1050px) {
  .site-header,
  .library,
  .site-footer {
    width: min(100% - 48px, 950px);
  }

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

  .library-heading {
    gap: 25px;
  }

  .search-box {
    min-width: min(300px, 34vw);
  }
}

@media (max-width: 680px) {
  .site-header,
  .library,
  .site-footer {
    width: calc(100% - 32px);
  }

  .site-header {
    padding: 19px 0;
  }

  .brand-copy small {
    display: none;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .reset-button {
    display: none;
  }

  .header-actions .button-primary {
    min-height: 40px;
    padding: 0 14px;
  }

  .header-actions .button-primary svg {
    display: none;
  }

  .library {
    padding-top: 23px;
  }

  .library-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 17px;
    padding-bottom: 20px;
  }

  .page-title {
    font-size: 27px;
  }

  .toolbar {
    align-items: center;
    justify-content: space-between;
    gap: 16px;
  }

  .search-box {
    min-width: 0;
    flex: 1;
  }

  .search-box input {
    width: 100%;
  }

  .search-box kbd,
  .summary-rule {
    display: none;
  }

  .result-summary {
    padding-top: 9px;
    white-space: nowrap;
  }

  .card-grid {
    grid-template-columns: 1fr;
    gap: 20px;
    padding-bottom: 70px;
  }

  .card-media {
    aspect-ratio: 1.25 / 1;
  }

  .card-copy {
    min-height: 0;
    padding: 22px;
  }

  .card-tools {
    opacity: 1;
    transform: none;
  }

  .site-footer {
    align-items: flex-start;
    gap: 15px;
    padding-bottom: 90px;
    line-height: 1.5;
  }

  .site-footer p:last-child {
    text-align: right;
  }

  .editor-dialog {
    width: calc(100% - 18px);
    max-height: calc(100dvh - 18px);
    margin-bottom: 9px;
    border-radius: 22px 22px 16px 16px;
  }

  .editor-form {
    max-height: calc(100dvh - 18px);
  }

  .dialog-heading {
    padding: 24px 20px 16px;
  }

  .dialog-heading h2 {
    font-size: 27px;
  }

  .form-body {
    padding: 0 20px;
  }

  .upload-zone {
    min-height: 170px;
  }

  .dialog-actions {
    align-items: flex-end;
    padding: 16px 20px 20px;
  }

  .dialog-actions > span {
    display: none;
  }

  .dialog-actions > div {
    width: 100%;
    justify-content: flex-end;
  }

  .toast {
    bottom: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
