:root {
  color-scheme: light;
  --bg: #f3f2f5;
  --surface: #ffffff;
  --surface-2: #f8f7fa;
  --surface-3: #eceaf0;
  --ink: #222126;
  --muted: #6e6975;
  --line: #d8d3de;
  --accent: #6f2378;
  --accent-strong: #53195b;
  --accent-soft: #f0e2f2;
  --danger: #a9343d;
  --shadow: 0 12px 35px rgba(30, 20, 35, .12);
  --radius: 14px;
  --sidebar: 258px;
  --stunt: #b53b3b;
  --spell: #2f6fb0;
  --sleight: #7745a2;
  --ritual: #267c67;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17151a;
  --surface: #211e25;
  --surface-2: #29252e;
  --surface-3: #35303b;
  --ink: #f3eff5;
  --muted: #b8afbd;
  --line: #433c49;
  --accent: #c275cf;
  --accent-strong: #dda1e6;
  --accent-soft: #3a273e;
  --danger: #e36c75;
  --shadow: 0 14px 40px rgba(0, 0, 0, .36);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 78px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 240px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  aspect-ratio: 1;
  border-radius: 13px;
  color: white;
  font-family: Georgia, serif;
  font-size: 29px;
  font-weight: 700;
  background: linear-gradient(145deg, #8b3296, #4c1855);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.2);
}
.brand h1 { margin: 0; font-size: 19px; line-height: 1.15; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.button, .icon-button, .text-button, .type-chip {
  border: 0;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, border-color .15s ease, color .15s ease;
}
.button:active, .icon-button:active, .text-button:active, .type-chip:active { transform: translateY(1px); }
.button {
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 10px;
  font-weight: 700;
}
.button.primary { background: var(--accent); color: white; }
.button.primary:hover { background: var(--accent-strong); }
.button.subtle { background: var(--surface-2); border: 1px solid var(--line); }
.button.subtle:hover { background: var(--surface-3); }
.button.danger { background: var(--danger); color: white; }
.button.danger-quiet { background: transparent; color: var(--danger); }
.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 18px;
}
.icon-button:hover, .icon-button.selected { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.text-button { padding: 5px 2px; color: var(--accent-strong); background: transparent; font-weight: 700; }
.text-button:hover { text-decoration: underline; }

.app-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: calc(100vh - 78px); }
.filters {
  position: sticky;
  top: 78px;
  align-self: start;
  height: calc(100vh - 78px);
  overflow: auto;
  padding: 20px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.filter-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.filter-heading h2 { margin: 0; font-size: 17px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span, fieldset legend { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: 0;
  padding: 10px 11px;
  color: var(--ink);
  background: var(--surface-2);
}
.field textarea { resize: vertical; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field small { color: var(--muted); }
.type-filter { display: grid; gap: 6px; margin: 0 0 16px; padding: 0; border: 0; }
.type-filter legend { margin-bottom: 7px; }
.type-chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 37px;
  padding: 8px 10px;
  border-radius: 9px;
  background: transparent;
  font-weight: 700;
  text-align: left;
}
.type-chip:hover { background: var(--surface-2); }
.type-chip.active { color: var(--accent-strong); background: var(--accent-soft); }
.type-chip span { min-width: 27px; padding: 2px 7px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 11px; text-align: center; }
.storage-note { display: grid; gap: 4px; margin-top: 24px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); font-size: 11px; line-height: 1.45; background: var(--surface-2); }
.storage-note strong { color: var(--ink); }

.content { min-width: 0; padding: 24px; }
.content-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.content-toolbar h2 { margin: 0; font-size: 24px; }
.content-toolbar p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.view-actions { display: flex; gap: 6px; }
.entry-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 17px; }
.entry-grid.list-mode { grid-template-columns: 1fr; }
.entry-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 5px 18px rgba(20, 15, 25, .06);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.entry-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: var(--shadow); }
.card-open { display: block; width: 100%; padding: 0; border: 0; color: inherit; background: transparent; text-align: left; cursor: pointer; }
.card-image { position: relative; height: 260px; overflow: hidden; background: linear-gradient(145deg, var(--surface-3), var(--surface-2)); }
.card-image img { width: 100%; height: 100%; object-fit: contain; display: block; }
.card-fallback { display: grid; place-items: center; height: 100%; padding: 8px; background: linear-gradient(145deg, #343434, #1f1f1f); }
.type-badge { position: absolute; top: 10px; left: 10px; padding: 5px 8px; border-radius: 999px; color: white; font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.type-badge[data-type="Stunt"] { background: var(--stunt); }
.type-badge[data-type="Spell"] { background: var(--spell); }
.type-badge[data-type="Sleight"] { background: var(--sleight); }
.type-badge[data-type="Ritual"] { background: var(--ritual); }
.card-copy { padding: 14px 15px 12px; }
.card-title-row { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.card-title-row h3 { margin: 0; overflow-wrap: anywhere; font-size: 18px; }
.card-cost { min-width: 28px; padding: 3px 6px; border-radius: 7px; background: var(--surface-3); color: var(--muted); font-size: 11px; font-weight: 900; text-align: center; }
.card-cost:empty { display: none; }
.card-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.card-effect { display: -webkit-box; overflow: hidden; min-height: 48px; margin: 11px 0 0; line-height: 1.42; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.card-tags, .tag-row { display: flex; flex-wrap: wrap; gap: 5px; }
.card-tags { margin-top: 12px; }
.tag { padding: 3px 7px; border-radius: 999px; color: var(--muted); background: var(--surface-3); font-size: 10px; font-weight: 700; }
.card-actions { display: flex; justify-content: flex-end; gap: 12px; padding: 0 15px 11px; }
.entry-grid.list-mode .entry-card { display: grid; grid-template-columns: minmax(170px, 215px) 1fr; }
.entry-grid.list-mode .card-open { display: grid; grid-template-columns: minmax(170px, 215px) 1fr; grid-column: 1 / -1; }
.entry-grid.list-mode .card-image { height: 180px; }
.entry-grid.list-mode .card-copy { align-self: stretch; padding: 18px; }
.entry-grid.list-mode .card-effect { -webkit-line-clamp: 4; }
.entry-grid.list-mode .card-actions { grid-column: 2; align-self: end; margin-top: -42px; }
.empty-state { display: grid; place-items: center; min-height: 440px; padding: 30px; text-align: center; }
.empty-symbol { font-size: 44px; color: var(--accent); }
.empty-state h3 { margin: 8px 0 4px; }
.empty-state p { margin: 0 0 16px; color: var(--muted); }

::backdrop { background: rgba(15, 10, 18, .68); backdrop-filter: blur(4px); }
dialog { color: var(--ink); }
.entry-dialog, .detail-dialog {
  width: min(1040px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.entry-dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.dialog-header, .dialog-footer { display: flex; align-items: center; gap: 12px; padding: 15px 18px; background: var(--surface); }
.dialog-header { justify-content: space-between; border-bottom: 1px solid var(--line); }
.dialog-footer { border-top: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-size: 22px; }
.eyebrow { margin: 0 0 3px; color: var(--accent-strong); font-size: 10px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.dialog-body { overflow: auto; }
.form-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; padding: 20px; }
.image-editor { min-width: 0; }
.preview-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.preview-heading strong { font-size: 13px; }
.preview-heading span { color: var(--muted); font-size: 10px; text-align: right; }
.image-dropzone {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 410px;
  overflow: hidden;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  outline: 0;
  background: linear-gradient(145deg, var(--surface-3), var(--surface-2));
  cursor: pointer;
}
.image-dropzone:hover, .image-dropzone:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.image-dropzone img { width: 100%; max-height: 410px; object-fit: contain; }
.image-upload-hint {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: calc(100% - 20px);
  padding: 7px 10px;
  border: 1px solid rgba(255,255,255,.4);
  border-radius: 999px;
  color: white;
  background: rgba(25, 22, 28, .86);
  box-shadow: 0 5px 15px rgba(0,0,0,.22);
  pointer-events: none;
}
.image-upload-hint span:last-child { display: grid; line-height: 1.15; }
.image-upload-hint small { color: rgba(255,255,255,.72); font-size: 8px; }
.upload-symbol { color: white; font-size: 18px; font-weight: 900; }
.image-actions { display: flex; gap: 8px; margin-top: 10px; }
.help { color: var(--muted); font-size: 11px; line-height: 1.45; }
.fields-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.span-2 { grid-column: span 2; }
.footer-spacer { flex: 1; }

.detail-dialog { width: min(980px, calc(100vw - 32px)); }
.detail-body { display: grid; grid-template-columns: minmax(260px, 370px) minmax(0, 1fr); gap: 26px; max-height: calc(100vh - 170px); overflow: auto; padding: 22px; }
.detail-image-wrap { display: grid; place-items: start center; min-height: 420px; }
.detail-image-wrap img { width: 100%; max-height: 620px; object-fit: contain; border-radius: 10px; box-shadow: var(--shadow); }
.detail-copy { min-width: 0; }
.detail-copy section { margin-top: 22px; }
.detail-copy h3 { margin: 0 0 7px; font-size: 14px; }
.detail-copy p { margin: 0; white-space: pre-wrap; line-height: 1.55; }
.effect-copy { font-size: 19px; }
.detail-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.meta-item { padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); }
.meta-item span { display: block; margin-bottom: 3px; color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.meta-item strong { overflow-wrap: anywhere; font-size: 13px; }
.tag-row { margin-top: 22px; }
.generated-card {
  --card-accent: var(--spell);
  display: flex;
  flex-direction: column;
  width: min(100%, 360px);
  aspect-ratio: 5 / 7;
  overflow: hidden;
  border: 7px solid #202124;
  border-radius: 8px;
  background: #bfc1c3;
  color: #151515;
  box-shadow: var(--shadow);
  container-type: inline-size;
}
.generated-card[data-type="Stunt"] { --card-accent: var(--stunt); }
.generated-card[data-type="Spell"] { --card-accent: var(--spell); }
.generated-card[data-type="Sleight"] { --card-accent: var(--sleight); }
.generated-card[data-type="Ritual"] { --card-accent: var(--ritual); }
.generated-card .g-header {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  min-height: 58px;
  color: white;
  background: linear-gradient(#555, #272727);
  border-bottom: 1px solid #111;
}
.generated-card .g-mark { display: grid; place-items: center; background: var(--card-accent); font-size: 22px; font-weight: 900; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.generated-card .g-name { align-self: center; overflow: hidden; padding: 5px 8px; font-family: Georgia, serif; font-size: clamp(18px, 9cqw, 30px); font-variant: small-caps; font-weight: 800; line-height: 1; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.generated-card .g-cost { display: grid; place-items: center; color: #111; background: color-mix(in srgb, var(--card-accent) 38%, white); font-size: clamp(18px, 9cqw, 30px); font-weight: 900; }
.generated-card .g-cost.is-empty { color: #666; }
.generated-card .g-action { padding: 4px 8px 3px; border-bottom: 1px solid #777; background: linear-gradient(#f8f8f8, #d4d4d4); font-size: clamp(11px, 5.5cqw, 17px); font-weight: 750; line-height: 1.05; text-align: center; }
.generated-card .g-tier { min-height: 22px; padding: 3px 8px 4px; border-bottom: 1px solid #6d6d6d; background: linear-gradient(#eeeeee, #cfcfcf); font-size: clamp(9px, 4.6cqw, 14px); font-style: italic; line-height: 1.05; text-align: center; }
.generated-card .g-body { display: flex; flex: 1; flex-direction: column; min-height: 0; margin: 8px; overflow: hidden; padding: 8px 8px 5px; border: 2px solid #333; border-radius: 6px 6px 45% 45% / 6px 6px 5% 5%; background: linear-gradient(135deg, #f9f9f9, #d7d7d7); text-align: center; }
.generated-card .g-heading { flex: 0 0 auto; margin-bottom: 8px; padding: 5px 7px; border-radius: 5px; color: white; background: linear-gradient(#555, #303030); font-size: clamp(12px, 7cqw, 21px); font-weight: 850; line-height: 1.05; }
.generated-card .g-effect { display: -webkit-box; flex: 1; overflow: hidden; font-size: clamp(11px, 6.4cqw, 20px); line-height: 1.18; white-space: pre-wrap; -webkit-box-orient: vertical; -webkit-line-clamp: 10; }
.generated-card .g-details { flex: 0 0 auto; overflow: hidden; margin: 7px 5px 0; padding-top: 6px; border-top: 1px solid #aaa; font-size: clamp(7px, 3.8cqw, 11px); font-weight: 700; line-height: 1.15; text-overflow: ellipsis; white-space: nowrap; }
.generated-card .g-footer { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; color: #555; font-size: clamp(7px, 3.6cqw, 10px); font-weight: 900; letter-spacing: .07em; text-transform: uppercase; }
.generated-card .g-sigil { color: var(--card-accent); font-size: 13px; }
.generated-card--editor { width: min(100%, 278px); box-shadow: 0 8px 26px rgba(0,0,0,.2); }
.generated-card--compact { width: auto; height: 100%; border-width: 4px; border-radius: 5px; box-shadow: none; }
.generated-card--compact .g-header { grid-template-columns: 34px minmax(0, 1fr) 34px; min-height: 38px; }
.generated-card--compact .g-mark { font-size: 14px; }
.generated-card--compact .g-body { margin: 5px; padding: 5px 5px 3px; border-width: 1px; }
.generated-card--compact .g-heading { margin-bottom: 5px; padding: 3px 4px; }
.generated-card--compact .g-details { margin-top: 4px; padding-top: 3px; }

.toast { position: fixed; right: 18px; bottom: 18px; z-index: 50; max-width: 320px; padding: 11px 14px; border-radius: 10px; color: white; background: #222; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) {
  .app-header { align-items: flex-start; }
  .header-actions { max-width: 430px; }
  .app-shell { grid-template-columns: 220px minmax(0, 1fr); }
  .filters { padding: 16px; }
  .content { padding: 18px; }
  .entry-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
  .form-layout { grid-template-columns: 240px minmax(0, 1fr); }
}

@media (max-width: 720px) {
  .app-header { position: static; flex-direction: column; padding: 12px 15px; }
  .header-actions { width: 100%; max-width: none; justify-content: flex-start; }
  .header-actions .button { flex: 1 1 auto; }
  .app-shell { display: block; }
  .filters { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .type-filter { grid-template-columns: repeat(5, minmax(72px, 1fr)); overflow-x: auto; }
  .type-chip { justify-content: center; gap: 7px; }
  .storage-note { display: none; }
  .form-layout, .detail-body { grid-template-columns: 1fr; }
  .image-dropzone { min-height: 390px; }
  .image-dropzone img { max-height: 390px; }
  .detail-image-wrap { min-height: 0; }
}

@media (max-width: 500px) {
  .content { padding: 14px; }
  .content-toolbar h2 { font-size: 21px; }
  .entry-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card-image { height: 210px; }
  .card-copy { padding: 11px; }
  .card-effect, .card-tags { display: none; }
  .card-actions { padding: 0 11px 9px; }
  .entry-grid.list-mode { grid-template-columns: 1fr; }
  .entry-grid.list-mode .entry-card, .entry-grid.list-mode .card-open { display: block; }
  .entry-grid.list-mode .card-actions { margin: 0; }
  .fields-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .dialog-footer { flex-wrap: wrap; }
  .dialog-footer .footer-spacer { display: none; }
  .dialog-footer .button { flex: 1; }
  .detail-meta { grid-template-columns: 1fr; }
}


/* Branded, double-sided card previews */
.brand { min-width: 300px; }
.brand-logo { width: 138px; height: 60px; object-fit: contain; object-position: left center; }
.brand-copy { padding-left: 2px; }
.brand-copy h1 { font-size: 20px; }
.empty-logo { width: 78px; height: 78px; object-fit: contain; filter: drop-shadow(0 8px 16px rgba(0,0,0,.18)); }

.entry-card { position: relative; }
.card-preview-stage { position: relative; width: min(100%, 360px); aspect-ratio: 5 / 7; perspective: 1200px; }
.card-preview-stage--editor { width: min(100%, 278px); }
.card-preview-stage--detail { width: min(100%, 360px); }
.card-preview-stage--compact { width: 100%; height: 100%; aspect-ratio: auto; }
.card-image .card-preview-stage { width: 100%; height: 100%; }

.flip-card, .flip-card-inner, .card-face { width: 100%; height: 100%; }
.flip-card { position: relative; }
.flip-card-inner { position: relative; transform-style: preserve-3d; transition: transform .55s cubic-bezier(.2,.72,.2,1); }
.flip-card.is-flipped .flip-card-inner { transform: rotateY(180deg); }
.card-face { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.card-face--back { transform: rotateY(180deg); }
.card-face > .generated-card { width: 100%; height: 100%; }
.card-face > img { display: block; width: 100%; height: 100%; object-fit: contain; background: #222; }
.card-preview-stage--compact .card-face > img { object-fit: contain; }

.card-flip-toggle {
  position: absolute;
  top: 220px;
  right: 10px;
  z-index: 4;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 999px;
  color: #fff;
  background: rgba(22,20,25,.82);
  box-shadow: 0 4px 12px rgba(0,0,0,.26);
  font-size: 10px;
  font-weight: 850;
  cursor: pointer;
}
.card-flip-toggle:hover { background: rgba(22,20,25,.96); }
.entry-grid.list-mode .card-flip-toggle { top: 142px; left: 152px; right: auto; }
.flip-button::before { content: "↻"; margin-right: 6px; }
.flip-hint { margin: 10px 0 0; color: var(--muted); font-size: 11px; text-align: center; }
.card-preview-stage--detail.is-clickable { cursor: pointer; }

.generated-card--back { position: relative; background: #bfc1c3; }
.generated-card--back .g-back-body {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  margin: 9px;
  overflow: hidden;
  padding: 13px 12px 28px;
  border: 2px solid #333;
  border-radius: 7px 7px 45% 45% / 7px 7px 5% 5%;
  background:
    radial-gradient(circle at 50% 42%, rgba(255,255,255,.96), rgba(231,231,231,.94) 62%, rgba(205,205,205,.96)),
    linear-gradient(135deg,#fafafa,#d2d2d2);
  color: #171717;
  text-align: center;
}
.generated-card--back .g-back-title { position: relative; z-index: 2; font-family: Georgia, serif; font-size: clamp(17px,8cqw,27px); font-variant: small-caps; font-weight: 800; line-height: 1.05; }
.generated-card--back .g-back-rule { position: relative; z-index: 2; display: flex; align-items: center; gap: 8px; margin: 7px 3px 12px; }
.generated-card--back .g-back-rule::before, .generated-card--back .g-back-rule::after { content: ""; height: 1px; flex: 1; background: #555; }
.generated-card--back .g-back-rule span { font-size: clamp(11px,5cqw,17px); }
.generated-card--back .g-description { position: relative; z-index: 2; display: -webkit-box; flex: 1; overflow: hidden; font-size: clamp(12px,6.2cqw,20px); line-height: 1.24; white-space: pre-wrap; -webkit-box-orient: vertical; -webkit-line-clamp: 13; }
.generated-card--back .g-back-watermark { position: absolute; inset: 23% 20% auto; z-index: 1; width: 60%; opacity: .055; pointer-events: none; }
.generated-card--back .g-back-footer { position: relative; z-index: 2; display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: auto; color: #565656; font-size: clamp(7px,3.7cqw,11px); font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.generated-card--back .g-back-footer img { width: clamp(18px,9cqw,32px); height: auto; }
.generated-card--compact.generated-card--back .g-back-body { margin: 5px; padding: 8px 7px 18px; border-width: 1px; }
.generated-card--compact.generated-card--back .g-back-rule { margin: 4px 2px 7px; }

.image-dropzone { min-height: 430px; }
.image-dropzone .card-preview-stage { z-index: 1; }
.image-upload-hint { z-index: 3; }
.image-actions { flex-wrap: wrap; }
.detail-image-wrap { align-content: start; }
.detail-card-stage { filter: drop-shadow(0 10px 24px rgba(0,0,0,.22)); }

@media (max-width: 720px) {
  .brand { min-width: 0; }
  .brand-logo { width: 124px; height: 54px; }
  .brand-copy h1 { font-size: 18px; }
}

@media (max-width: 500px) {
  .brand-logo { width: 112px; height: 48px; }
  .card-flip-toggle { top: 172px; right: 6px; }
}

@media print {
  @page { size: letter portrait; margin: .35in; }
  body { background: white; }
  .app-header, .filters, .content-toolbar, .card-actions, .card-flip-toggle, dialog, .toast { display: none !important; }
  .app-shell, .content { display: block; padding: 0; }
  .entry-grid, .entry-grid.list-mode { display: grid !important; grid-template-columns: repeat(3, 2.5in); gap: .15in; justify-content: center; }
  .entry-card, .entry-grid.list-mode .entry-card { display: block; width: 2.5in; height: 3.5in; break-inside: avoid; border: 0; border-radius: 0; box-shadow: none; }
  .card-open, .entry-grid.list-mode .card-open { display: block; height: 100%; }
  .card-image, .entry-grid.list-mode .card-image { height: 100%; }
  .card-image img { object-fit: contain; }
  .card-copy, .type-badge { display: none; }
  .card-preview-stage, .flip-card, .flip-card-inner, .card-face { width: 100%; height: 100%; }
  .generated-card--compact { width: 100%; height: 100%; border-width: 6px; border-radius: 0; }
}

.home-logo-link{display:inline-flex;color:inherit;text-decoration:none}
.home-logo-link:focus-visible{outline:2px solid currentColor;outline-offset:4px;border-radius:4px}

/* Account-backed journal catalog */
.prebuild-panel {
  display: grid;
  gap: 10px;
  margin-top: 22px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
}
.prebuild-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.prebuild-heading strong { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
.prebuild-panel .field { margin: 0; }
.prebuild-apply { width: 100%; }
.prebuild-summary { display: grid; gap: 3px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.prebuild-summary strong { color: var(--ink); font-size: 11px; }
.prebuild-summary span { color: var(--accent-strong); font-weight: 800; }
.prebuild-summary small { font-size: 9px; line-height: 1.45; }
.source-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  padding: 5px 8px;
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 999px;
  color: white;
  background: rgba(24,22,28,.82);
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.source-badge[data-scope="custom"] { background: color-mix(in srgb, var(--accent) 82%, #17151a); }
.entry-card.is-allocated { border-color: color-mix(in srgb, var(--accent) 34%, var(--line)); }
.entry-card.is-allocated .source-badge::after { content: " · Journal"; }
.card-actions { flex-wrap: wrap; }
.allocate-card { margin-right: auto; }
.button:disabled, .text-button:disabled { cursor: not-allowed; opacity: .5; transform: none; }

@media (max-width: 720px) {
  .prebuild-panel { margin-top: 14px; }
}

@media print {
  .source-badge { display: none !important; }
}

/* Journal sharing and public Explore */
.card-author {
  margin: 5px 0 0;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 750;
}
.source-badge[data-scope="public"] { background: color-mix(in srgb, var(--ritual) 82%, #17151a); }
.source-badge[data-scope="unlisted"] { background: color-mix(in srgb, var(--sleight) 82%, #17151a); }
.source-badge[data-scope="private"] { background: rgba(38, 36, 42, .88); }
.field select:disabled, .field input:disabled, .field textarea:disabled {
  cursor: not-allowed;
  opacity: .68;
}
#visibilityField small { line-height: 1.45; }
.detail-dialog .dialog-footer { row-gap: 8px; }
.entry-grid.list-mode .card-author { margin-top: 3px; }

@media (max-width: 500px) {
  .card-author { display: none; }
}
