:root {
  --ink: #171714;
  --muted: #6f7069;
  --paper: #f4f3ee;
  --surface: #fff;
  --line: #deddd5;
  --accent: #e65d3f;
  --accent-dark: #b83d25;
  --moss: #60735a;
  --focus: #1f5fa8;
  --shadow: 0 18px 50px rgba(34, 32, 27, .12);
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: Iowan Old Style, Baskerville, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); line-height: 1.5; }
button, input, textarea, select { font: inherit; }
button, a { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(31, 95, 168, .35); outline-offset: 2px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.site-header { height: 72px; padding: 0 clamp(20px, 4vw, 64px); display: flex; align-items: center; justify-content: space-between; gap: 28px; position: sticky; top: 0; z-index: 20; background: rgba(244, 243, 238, .92); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-family: var(--serif); font-size: 22px; font-weight: 700; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; background: var(--ink); color: white; border-radius: 4px; font-family: var(--serif); font-size: 20px; }
.desktop-nav { display: flex; align-items: center; gap: 4px; }
.nav-link { min-height: 44px; padding: 0 15px; border: 0; background: transparent; color: var(--muted); transition: color .2s, background .2s; }
.nav-link:hover { color: var(--ink); background: rgba(23, 23, 20, .05); }
.nav-link.active { color: var(--ink); font-weight: 650; position: relative; }
.nav-link.active::after { content: ""; position: absolute; left: 15px; right: 15px; bottom: 4px; height: 2px; background: var(--accent); }
.header-actions, .admin-actions { display: flex; align-items: center; gap: 10px; }
.login-button, .primary-button, .secondary-button, .copy-button { min-height: 44px; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 650; transition: background .2s, color .2s, border-color .2s; }
.login-button { padding: 0 16px; border: 1px solid var(--line); background: white; color: var(--ink); }
.login-button:hover, .secondary-button:hover { border-color: #aeadA5; background: #f9f9f6; }
.primary-button { padding: 0 18px; border: 1px solid var(--ink); background: var(--ink); color: white; }
.primary-button:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.secondary-button { padding: 0 18px; border: 1px solid var(--line); background: white; color: var(--ink); }
.icon-button, .avatar-button { width: 44px; height: 44px; display: inline-grid; place-items: center; border: 1px solid var(--line); background: white; color: var(--ink); border-radius: 4px; }
.avatar-button { border-radius: 50%; background: var(--moss); border-color: var(--moss); color: white; font-weight: 700; }
.admin-profile { position: relative; }
.admin-profile::after { content: ""; position: absolute; top: 100%; right: 0; width: 100%; height: 10px; }
.profile-menu { position: absolute; z-index: 30; top: calc(100% + 8px); right: 0; width: 190px; padding: 8px; visibility: hidden; opacity: 0; pointer-events: none; background: white; border: 1px solid var(--line); border-radius: 5px; box-shadow: 0 14px 36px rgba(34, 32, 27, .14); transition: opacity .18s, visibility .18s; }
.admin-profile:hover .profile-menu, .admin-profile:focus-within .profile-menu, .admin-profile.open .profile-menu { visibility: visible; opacity: 1; pointer-events: auto; }
.profile-identity { padding: 8px 10px 11px; display: grid; border-bottom: 1px solid var(--line); }
.profile-identity strong { font-size: 13px; }
.profile-identity span { color: var(--muted); font-size: 12px; }
.profile-logout-button { width: 100%; min-height: 44px; margin-top: 5px; padding: 0 10px; display: flex; align-items: center; gap: 9px; border: 0; border-radius: 4px; background: transparent; color: #9b3025; text-align: left; font-size: 13px; font-weight: 650; }
.profile-logout-button:hover { background: #fff3f1; }
.mobile-menu-button { display: none; }
.lucide { width: 18px; height: 18px; stroke-width: 1.8; }

main { width: min(1400px, calc(100% - 48px)); min-height: calc(100vh - 200px); margin: 0 auto; padding-top: 24px; }
.eyebrow { margin: 0 0 12px; color: var(--accent-dark); font-size: 12px; font-weight: 750; letter-spacing: .12em; }
.search-box { height: 44px; padding: 0 12px; display: flex; align-items: center; gap: 8px; background: white; border: 1px solid var(--line); border-radius: 4px; }
.header-search { width: clamp(220px, 20vw, 300px); flex: none; }
.search-box:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(31, 95, 168, .12); }
.search-box input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; }
.search-box input::placeholder { color: #92938d; }
kbd { padding: 2px 7px; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); background: var(--paper); font-size: 11px; }

.prompt-grid { --masonry-columns: 5; display: grid; grid-template-columns: repeat(var(--active-columns, var(--masonry-columns)), minmax(0, 1fr)); align-items: start; gap: 16px; padding-bottom: 88px; }
.prompt-column { min-width: 0; display: grid; align-content: start; gap: 16px; }
.prompt-card { display: block; width: 100%; margin: 0; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 0 0 1px transparent, 0 0 0 rgba(34, 32, 27, 0); transform: none; translate: none; scale: none; transition: box-shadow .2s, border-color .2s; }
.prompt-card:hover, .prompt-card:focus-within { border-color: #c3c1b7; box-shadow: 0 0 0 1px rgba(34, 32, 27, .03), 0 0 18px rgba(34, 32, 27, .1); transform: none; translate: none; scale: none; }
.card-media { position: relative; overflow: hidden; background: #deddd5; cursor: pointer; }
.card-media img, .card-media video { display: block; width: 100%; height: auto; object-fit: contain; }
.video-badge { position: absolute; left: 14px; bottom: 14px; display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; color: white; background: rgba(23, 23, 20, .82); border-radius: 3px; font-size: 12px; }
.card-body { padding: 17px 18px 18px; }
.card-meta { min-height: 44px; display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: -4px -4px 9px 0; }
.category-label { color: var(--accent-dark); font-size: 11px; font-weight: 750; letter-spacing: .08em; }
.card-meta-tools { display: flex; align-items: center; gap: 4px; }
.card-title-button { width: 100%; padding: 0; border: 0; background: transparent; color: var(--ink); text-align: left; }
.card-title { margin: 0; font-family: var(--serif); font-size: 20px; font-weight: 600; line-height: 1.25; }
.card-description { margin: 11px 0 0; color: var(--muted); font-size: 14px; line-height: 1.65; }
.card-prompt-preview { margin: 16px 0 0; display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 3; color: #494a45; font-size: 13px; line-height: 1.65; white-space: pre-line; }
.card-tool-button { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--muted); transition: color .2s, border-color .2s, background .2s; }
.card-tool-button:hover { border-color: var(--line); background: var(--paper); color: var(--ink); }
.text-card { min-height: 220px; }
.text-card .card-body { padding: 20px; }
.text-card.writing { border-top: 3px solid var(--moss); }
.text-card.other { border-top: 3px solid #bc8a3c; }
.empty-state { padding: 110px 20px; text-align: center; color: var(--muted); }
.empty-state .lucide { width: 36px; height: 36px; }
.empty-state h2 { margin: 18px 0 6px; color: var(--ink); font-family: var(--serif); font-size: 28px; }
.empty-state p { margin: 0; }

footer { min-height: 140px; padding: 32px clamp(24px, 4vw, 64px); display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); }
footer p { color: var(--muted); font-size: 14px; }
.footer-brand { font-size: 18px; }
.footer-brand .brand-mark { width: 28px; height: 28px; font-size: 16px; }

.modal { width: min(680px, calc(100% - 32px)); max-height: min(88vh, 900px); padding: 0; overflow: auto; overscroll-behavior: contain; border: 0; border-radius: 7px; background: white; color: var(--ink); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(20, 20, 18, .62); backdrop-filter: blur(3px); }
html.modal-open, body.modal-open { overflow: hidden; overscroll-behavior: none; }
.modal-close { position: sticky; z-index: 3; top: 14px; float: right; margin: 14px 14px -58px 0; box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.detail-modal { width: min(880px, calc(100% - 32px)); }
.detail-media { background: #e7e6e0; }
.detail-media img, .detail-media video { display: block; width: 100%; max-height: 65vh; object-fit: contain; }
.detail-body { padding: clamp(28px, 5vw, 52px); }
.detail-body h2 { max-width: 650px; margin: 8px 0 0; font-family: var(--serif); font-size: clamp(32px, 5vw, 48px); font-weight: 550; line-height: 1.08; }
.detail-description { max-width: 680px; margin: 18px 0 0; color: var(--muted); font-size: 16px; }
.prompt-block { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--line); }
.prompt-block-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.prompt-block-header h3 { margin: 0; font-size: 13px; letter-spacing: .08em; }
.copy-button { padding: 0 14px; border: 1px solid var(--line); background: white; color: var(--ink); }
.copy-button:hover { border-color: var(--ink); }
.prompt-text { margin: 0; padding: 20px; overflow-wrap: anywhere; white-space: pre-wrap; background: var(--paper); border-left: 3px solid var(--accent); font-family: var(--sans); font-size: 15px; line-height: 1.8; }
.detail-admin-actions { margin-top: 32px; padding-top: 24px; display: flex; justify-content: flex-end; border-top: 1px solid var(--line); }
.danger-button { min-height: 44px; padding: 0 16px; display: inline-flex; align-items: center; gap: 8px; border: 1px solid #d7a09a; border-radius: 4px; background: white; color: #a72d20; font-weight: 650; }
.danger-button:hover { border-color: #a72d20; background: #fff4f2; }
.auth-modal { width: min(460px, calc(100% - 32px)); padding: 38px; }
.modal-heading { text-align: center; }
.modal-heading .brand-mark { margin: 0 auto 22px; }
.modal-heading h2, .editor-header h2 { margin: 0; font-family: var(--serif); font-size: 34px; font-weight: 600; }
.modal-heading > p:last-child { margin: 10px auto 28px; color: var(--muted); font-size: 14px; }
form { display: grid; gap: 18px; }
form label { display: grid; gap: 7px; font-size: 13px; font-weight: 650; }
form input, form textarea, form select { width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 4px; background: white; color: var(--ink); outline: none; resize: vertical; }
form input, form select { height: 46px; }
form input:focus, form textarea:focus, form select:focus { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(31, 95, 168, .12); }
.full-button { width: 100%; }
.demo-hint { margin: -6px 0 0; padding: 10px; background: var(--paper); color: var(--muted); text-align: center; font-size: 12px; }
.form-error { margin: -6px 0; color: #b42318; font-size: 13px; }
.editor-modal { width: min(640px, calc(100% - 32px)); padding: 38px; }
.editor-header { margin-bottom: 28px; }
.field-help { color: var(--muted); font-size: 12px; font-weight: 400; }
.required-mark { color: var(--accent-dark); font-size: 11px; font-weight: 750; letter-spacing: .04em; }
input[type="file"] { height: auto; padding: 9px 12px; cursor: pointer; }
input[type="file"]::file-selector-button { min-height: 30px; margin-right: 10px; padding: 0 10px; border: 0; border-radius: 3px; background: var(--paper); color: var(--ink); font-weight: 650; cursor: pointer; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 8px; }
.confirm-modal { width: min(430px, calc(100% - 32px)); padding: 36px; text-align: center; }
.confirm-icon { width: 48px; height: 48px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 50%; background: #f1efe8; color: var(--ink); }
.confirm-icon .lucide { width: 22px; height: 22px; }
.confirm-modal h2 { margin: 0; font-family: var(--serif); font-size: 30px; font-weight: 600; }
.confirm-modal > p { margin: 10px 0 26px; color: var(--muted); font-size: 14px; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 28px; min-height: 46px; padding: 0 18px; display: flex; align-items: center; gap: 9px; background: var(--ink); color: white; border-radius: 4px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translate(-50%, 16px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1180px) {
  .prompt-grid { --masonry-columns: 4; }
}

@media (max-width: 960px) {
  .desktop-nav { display: none; }
  .mobile-menu-button { display: inline-grid; }
  .mobile-nav { position: fixed; z-index: 19; top: 72px; left: 0; right: 0; padding: 10px 20px 16px; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--paper); border-bottom: 1px solid var(--line); box-shadow: 0 10px 20px rgba(0,0,0,.06); }
  .prompt-grid { --masonry-columns: 3; }
}

@media (max-width: 760px) {
  .prompt-grid { --masonry-columns: 2; }
}

@media (max-width: 640px) {
  .site-header { padding: 0 16px; }
  .site-header { gap: 16px; }
  .site-header > .brand > span:last-child { display: none; }
  .login-button span, .primary-button span { display: none; }
  .login-button, .primary-button { padding: 0 13px; }
  .header-actions { min-width: 0; gap: 6px; }
  .header-search { width: clamp(122px, 39vw, 180px); padding-inline: 10px; }
  .mobile-nav { grid-template-columns: repeat(5, minmax(0, 1fr)); padding-inline: 8px; }
  .mobile-nav .nav-link { padding: 0 5px; font-size: 13px; }
  main { width: min(100% - 28px, 1400px); }
  main { padding-top: 18px; }
  kbd { display: none; }
  .prompt-grid { --masonry-columns: 1; }
  footer { align-items: start; flex-direction: column; gap: 20px; }
  .auth-modal, .editor-modal { padding: 28px 20px; }
  .confirm-modal { padding: 32px 20px 24px; }
  form input, form textarea, form select { font-size: 16px; }
  .editor-modal .modal-close, .auth-modal .modal-close { margin-right: -6px; }
  .detail-body { padding: 30px 20px; }
  .prompt-block-header { align-items: start; flex-direction: column; }
  .copy-button { width: 100%; }
}

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