@font-face {
  font-family: "PromptVaultW7";
  src: url("./w7.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: light;
  --ui-font: "PromptVaultW7", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --content-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #ffffff;
  --panel: #ffffff;
  --surface: #f7f7f5;
  --text: #37352f;
  --muted: #787774;
  --line: #e9e9e7;
  --ink: #37352f;
  --accent: #2383e2;
  --accent-2: #0b6fcb;
  --accent-soft: #eaf3ff;
  --quiet: #9b9a97;
  --quiet-soft: #f1f1ef;
  --shadow: 0 8px 24px rgba(15, 15, 15, .06);
  --button-text: #ffffff;
  --secondary-hover: #e9e9e7;
  --accent-hover-soft: #f4f9ff;
  --accent-border-soft: #cfe3f8;
  --neutral-hover: #f1f1ef;
  --neutral-border-hover: #d8d8d4;
  --pin-bg: #fff4d6;
  --pin-text: #8a5a00;
  --pin-border: #f1d48a;
  --pin-card-bg: #fffdf7;
  --focus-ring: rgba(35, 131, 226, .18);
  --image-bg: #ededeb;
  --lightbox-bg: rgba(18, 18, 16, .82);
  --badge-border: rgba(255, 255, 255, .78);
  --badge-shadow: rgba(29, 29, 27, .18);
  --linked-ring: rgba(35, 131, 226, .18);
  --linked-ring-strong: rgba(35, 131, 226, .24);
  --linked-glow: rgba(35, 131, 226, .10);
  --linked-glow-strong: rgba(35, 131, 226, .20);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151512;
  --panel: #1d1d19;
  --surface: #22221e;
  --text: #e8e6df;
  --muted: #a9a69d;
  --line: #34342e;
  --ink: #e8e6df;
  --accent: #5aa7f2;
  --accent-2: #7bbcff;
  --accent-soft: #18324a;
  --quiet: #858177;
  --quiet-soft: #2a2a25;
  --shadow: 0 12px 32px rgba(0, 0, 0, .32);
  --button-text: #10151a;
  --secondary-hover: #26384a;
  --accent-hover-soft: #202a32;
  --accent-border-soft: #3d5f7c;
  --neutral-hover: #2a2a25;
  --neutral-border-hover: #3a3a33;
  --pin-bg: rgba(244, 199, 107, .12);
  --pin-text: #f4c76b;
  --pin-border: rgba(244, 199, 107, .28);
  --pin-card-bg: #20201c;
  --focus-ring: rgba(90, 167, 242, .24);
  --image-bg: #2b2b26;
  --lightbox-bg: rgba(8, 8, 7, .88);
  --badge-border: rgba(232, 230, 223, .45);
  --badge-shadow: rgba(0, 0, 0, .38);
  --linked-ring: rgba(90, 167, 242, .24);
  --linked-ring-strong: rgba(90, 167, 242, .34);
  --linked-glow: rgba(90, 167, 242, .12);
  --linked-glow-strong: rgba(90, 167, 242, .22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui-font);
  font-size: 14px;
}

button,
input,
textarea {
  font: inherit;
}

button,
.file-button {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 10px;
  background: var(--accent);
  color: var(--button-text);
  font-weight: 750;
  cursor: pointer;
}

button.secondary,
.file-button.secondary {
  border: 1px solid var(--line);
  background: var(--accent-soft);
  color: var(--accent);
}

button:hover,
.file-button:hover {
  background: var(--accent-2);
}

button.secondary:hover {
  background: var(--secondary-hover);
}

button.secondary:hover,
.icon-button.subtle:hover,
.action-menu button:hover,
.menu-file-button:hover,
.file-button.secondary:hover {
  filter: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: .48;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: grid;
  grid-template-rows: auto auto auto auto 1fr;
  gap: 12px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 16px;
}

.brand {
  display: grid;
  grid-template-columns: 1fr 36px 38px;
  gap: 8px;
  align-items: center;
}

.brand h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.brand p.ready-paste {
  color: var(--accent);
  font-weight: 700;
}

.brand p.needs-permission {
  color: var(--quiet);
  font-weight: 700;
}

.brand button {
  padding: 0;
  font-size: 17px;
}

.brand .theme-toggle {
  font-size: 18px;
}

.search-box input,
.title-input,
.meta-row input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.search-box input,
.title-input,
.meta-row input {
  min-height: 38px;
  padding: 0 10px;
}

.list-toolbar {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 32px;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  border-color: transparent;
  padding: 0 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.sort-button::after {
  content: "⌄";
  color: var(--quiet);
  font-size: 14px;
}

.sort-button:hover,
.sort-button.active {
  background: var(--quiet-soft);
  color: var(--text);
}

.sort-menu {
  top: calc(100% + 4px);
  left: 0;
  right: auto;
  min-width: 126px;
}

.action-menu button.active {
  background: var(--quiet-soft);
  color: var(--accent);
}

.sidebar-actions {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 36px;
  gap: 6px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  min-height: 34px;
  padding: 0;
}

.icon-button.subtle {
  border-color: var(--line);
  background: transparent;
  color: var(--quiet);
  font-size: 22px;
  font-weight: 700;
}

.icon-button.subtle:hover,
.icon-button.subtle.active {
  background: var(--quiet-soft);
  color: var(--text);
}

.action-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 12;
  display: grid;
  min-width: 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.action-menu[hidden] {
  display: none;
}

.action-menu button,
.menu-file-button {
  display: flex;
  align-items: center;
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  padding: 0 10px;
  background: transparent;
  color: var(--text);
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}

.action-menu button:hover,
.menu-file-button:hover {
  background: var(--quiet-soft);
  filter: none;
}

.menu-file-button input {
  display: none;
}

.group-list {
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
}

.group-button {
  display: grid;
  gap: 3px;
  min-height: 62px;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: grab;
  text-align: left;
}

.group-button[draggable="false"] {
  cursor: pointer;
}

.group-button:hover,
.version-card:hover {
  border-color: var(--neutral-border-hover);
  background: var(--neutral-hover);
  filter: none;
}

.group-button:active,
.version-card:active {
  cursor: grabbing;
}

.group-button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.group-button.pinned {
  border-color: var(--pin-border);
  background: var(--pin-card-bg);
}

.group-button.pinned.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.group-button.active:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.group-button.dragging,
.version-card.dragging {
  opacity: .45;
}

.group-button.drag-over,
.version-card.drag-over {
  border-color: var(--accent);
  background: var(--accent-hover-soft);
}

.group-button span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.pin-badge {
  display: inline-grid;
  place-items: center;
  min-height: 18px;
  border: 1px solid var(--pin-border);
  border-radius: 999px;
  padding: 0 6px;
  background: var(--pin-bg);
  color: var(--pin-text);
  font-size: 11px;
  font-weight: 750;
  vertical-align: 1px;
}

.group-button em {
  color: var(--quiet);
  font-style: normal;
  font-weight: 650;
}

.workspace {
  min-width: 0;
  padding: 18px;
}

.empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: calc(100vh - 36px);
  text-align: center;
}

.empty-state h2 {
  margin: 0;
}

.empty-state p {
  max-width: 30em;
  color: var(--muted);
  line-height: 1.55;
}

.workspace-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.title-input {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 28px;
  font-weight: 850;
}

.save-state {
  color: var(--muted);
  font-size: 13px;
}

.status-stack {
  display: grid;
  justify-items: end;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-align: right;
}

.cloud-sync-state {
  color: var(--quiet);
  font-size: 12px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(460px, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: none;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 52px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.prompt-actions,
.edit-actions,
.image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.more-wrap {
  position: relative;
}

.action-menu.compact {
  min-width: 126px;
}

.file-button {
  display: grid;
  place-items: center;
}

.file-button input {
  display: none;
}

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

.image-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color .16s ease, box-shadow .16s ease;
}

.image-card:hover {
  border-color: var(--accent-border-soft);
}

.image-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.image-card.linked {
  border-color: var(--accent);
  outline: 3px solid var(--linked-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--linked-glow);
}

.image-card.linked.selected {
  border-color: var(--accent-2);
  outline-color: var(--linked-ring-strong);
  box-shadow:
    0 0 0 3px var(--linked-glow-strong),
    0 0 0 7px var(--linked-glow);
}

.image-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--image-bg);
}

.image-card b {
  position: absolute;
  top: 8px;
  left: 8px;
  display: none;
  max-width: calc(100% - 16px);
  border: 1px solid var(--badge-border);
  border-radius: 6px;
  padding: 4px 8px;
  background: var(--accent);
  color: var(--button-text);
  font-size: 12px;
  font-weight: 850;
  box-shadow: 0 6px 18px var(--badge-shadow);
}

.image-card.has-badge b {
  display: block;
}

.image-card-actions {
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 7px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.image-card.selected .image-card-actions {
  display: grid;
}

.image-card-actions button {
  display: grid;
  place-items: center;
  min-height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--accent-soft);
  color: var(--accent);
}

.image-card-actions button[data-action="delete"] {
  border-color: var(--line);
  background: var(--quiet-soft);
  color: var(--quiet);
}

.image-card-actions svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--lightbox-bg);
}

.lightbox[hidden] {
  display: none;
}

.lightbox > button {
  justify-self: end;
  margin: 14px;
  background: var(--panel);
  color: var(--text);
}

.lightbox-scroll {
  overflow: auto;
  padding: 0 24px 24px;
  text-align: center;
}

.lightbox img {
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  background: var(--panel);
}

.settings-dialog {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--lightbox-bg);
}

.settings-dialog[hidden] {
  display: none;
}

.settings-card {
  width: min(520px, 100%);
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.settings-head,
.settings-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.settings-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.settings-status {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.settings-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.image-card small {
  display: block;
  padding: 8px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-note {
  margin: 0;
  padding: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.side-stack {
  display: grid;
  gap: 16px;
}

.prompt-document {
  min-height: calc(100vh - 126px);
  display: grid;
  grid-template-rows: auto 1fr;
}

.prompt-view {
  min-height: 520px;
  padding: 22px;
  background: var(--panel);
  font-family: var(--content-font);
  line-height: 1.65;
  font-size: 15px;
}

.note-block {
  margin-bottom: 18px;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 12px;
  background: var(--accent-soft);
}

.note-block strong,
.prompt-block strong {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.note-block p,
.prompt-block p {
  margin: 0;
  white-space: pre-wrap;
}

.prompt-view.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.prompt-editor {
  padding: 12px;
}

textarea {
  resize: vertical;
  min-height: 260px;
  margin: 0 0 10px;
  width: 100%;
  padding: 10px;
  font-family: var(--content-font);
  font-size: 15px;
  line-height: 1.55;
}

.note-input {
  min-height: 62px;
  background: var(--accent-soft);
}

#negativeInput {
  min-height: 58px;
}

#promptInput {
  min-height: 260px;
}

.meta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.version-list {
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: auto;
  max-height: 380px;
  padding: 12px;
}

.version-card {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  color: var(--text);
  cursor: grab;
  text-align: left;
}

.version-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.version-card.active:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.version-card p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.45;
}

.version-card .prompt-text {
  display: -webkit-box;
  max-height: 4.35em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.version-card.has-note .prompt-text {
  color: var(--accent);
  font-weight: 700;
}

.negative-text {
  margin-top: 8px !important;
  color: var(--muted);
}

.version-meta {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .group-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(180px, 68vw);
    overflow-x: auto;
  }

  .workspace {
    padding: 12px;
  }

  .workspace-head,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .status-stack {
    justify-items: start;
    text-align: left;
  }

  .prompt-document {
    min-height: auto;
  }

  .prompt-view {
    min-height: 300px;
  }

  .image-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .title-input {
    font-size: 23px;
  }
}
