:root {
  --bg: #ede6dc;
  --ink: #1e1e1e;
  --red: #ff2d2d;
  --rose-mid: #f88080;
  --rose-light: #ffc8c8;
  --white: #ffffff;
  --muted: rgba(30, 30, 30, 0.65);
  --soft: rgba(30, 30, 30, 0.42);
  --line: rgba(30, 30, 30, 0.18);
  --panel: #f4ece1;
  --panel-strong: #fbf2e8;
  --radius: 4px;
  --column-width: 304px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Outfit", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.52;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.skip-link,
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.skip-link:focus {
  z-index: 20;
  width: auto;
  height: auto;
  clip: auto;
  top: 12px;
  left: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  padding: 8px 12px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto minmax(280px, 430px) 1fr;
  align-items: center;
  gap: 24px;
  min-height: 72px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.tools-topbar {
  grid-template-columns: 1fr;
}

.tools-page {
  min-height: 100vh;
}

.tools-shell {
  display: grid;
  min-height: calc(100vh - 72px);
  padding: 42px 22px 64px;
}

.tools-auth-panel,
.tools-overview {
  width: min(980px, 100%);
  margin: 0 auto;
}

.tools-auth-panel {
  align-self: center;
  display: grid;
  gap: 18px;
  border-top: 3px solid var(--red);
  border-bottom: 1px solid var(--line);
  padding: 28px 0 32px;
}

.tools-auth-panel h1,
.tools-intro h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(36px, 6vw, 68px);
  font-weight: 700;
  line-height: 0.98;
}

.tools-auth-panel p,
.tools-intro p,
.tool-card p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
}

.tools-auth-form {
  justify-content: flex-start;
}

.tools-status {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.tools-overview {
  display: grid;
  gap: 30px;
}

.tools-intro {
  display: grid;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 28px;
}

.tools-userbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-weight: 600;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.tool-card {
  display: grid;
  gap: 9px;
  min-height: 188px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--red);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  padding: 20px;
  text-decoration: none;
}

.tool-card:hover,
.tool-card:focus-visible {
  border-color: var(--red);
}

.tool-card span {
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
}

.tool-card strong {
  font-size: 24px;
  line-height: 1.05;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 14px;
  min-width: 214px;
  white-space: nowrap;
}

.logo {
  color: var(--ink);
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
  text-decoration: none;
}

.logo::first-letter {
  color: var(--red);
}

.brand span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
}

.global-search {
  width: 100%;
}

.global-search input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  outline: none;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 500;
}

.global-search input::placeholder {
  color: var(--soft);
}

.global-search input:focus,
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  border-color: var(--red);
}

.header-actions {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.sync-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: #f4ece1;
}

.sync-status {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.sync-status strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.sync-status span {
  color: var(--muted);
  font-size: 13px;
}

.auth-form {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.auth-form input {
  width: 190px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbf2e8;
  color: var(--ink);
  outline: none;
  padding: 8px 11px;
}

.auth-form input:focus {
  border-color: var(--red);
}

.io-menu {
  position: relative;
  display: flex;
}

.io-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 11;
  display: grid;
  min-width: 158px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.io-popover[hidden] {
  display: none;
}

.io-popover button {
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
}

.io-popover button:last-child {
  border-bottom: 0;
}

.io-popover button:hover {
  color: var(--red);
}

.button,
.pill,
.reset-button,
.icon-button,
.add-column-button,
.star-button,
.card-open {
  border: 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: var(--radius);
  padding: 8px 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.button.compact {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
}

.button.primary {
  background: var(--red);
  color: var(--white);
}

.button.primary:hover,
.button.ghost:hover,
.button.secondary:hover {
  opacity: 0.78;
}

.button.ghost,
.button.secondary {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

.button.danger {
  border: 1px solid var(--red);
  background: transparent;
  color: var(--red);
}

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

.filters {
  position: sticky;
  top: 72px;
  z-index: 9;
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 34px;
}

.filter-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.filter-group span {
  color: var(--red);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  padding: 3px 10px;
  font-size: 13px;
  font-weight: 500;
}

.language-pill.active,
.tag-pill.active,
.tags-menu.active {
  border-color: var(--red);
  background: var(--red);
  color: var(--white);
}

.tags-menu {
  gap: 6px;
  min-height: 32px;
  padding-inline: 12px;
  font-weight: 600;
}

.reset-button {
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 0 0 0 16px;
  font-size: 13px;
  font-weight: 500;
}

.reset-button:hover {
  color: var(--red);
}

.result-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.tag-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: none;
  overflow: visible;
  padding-top: 12px;
}

.tag-strip.collapsed {
  display: none;
}

.board-shell {
  overflow-x: auto;
  min-height: calc(100vh - 178px);
  padding: 36px 22px 56px;
}

.columns {
  display: grid;
  grid-auto-columns: var(--column-width);
  grid-auto-flow: column;
  gap: 18px;
  align-items: start;
  min-width: max-content;
}

.column {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.column.drag-over {
  border-color: var(--red);
}

.column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 52px;
  border-top: 3px solid var(--red);
  border-bottom: 1px solid var(--line);
  background: #f8efe4;
  padding: 12px 13px;
}

.column-header div {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.column h2 {
  overflow: hidden;
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.2;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.column-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.column-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 8px;
}

.add-column-button,
.delete-column-button,
.icon-button,
.star-button {
  display: inline-grid;
  place-items: center;
  background: transparent;
}

.add-column-button,
.delete-column-button {
  width: 25px;
  height: 25px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 19px;
  font-weight: 500;
  line-height: 1;
}

.delete-column-button {
  font-size: 17px;
  font-weight: 600;
}

.add-column-button:hover,
.delete-column-button:hover,
.add-column-button:focus-visible,
.delete-column-button:focus-visible {
  border-color: var(--red);
  color: var(--red);
}

@media (hover: hover) and (pointer: fine) {
  .delete-column-button {
    opacity: 0;
    pointer-events: none;
  }

  .column:hover .delete-column-button,
  .delete-column-button:focus-visible {
    opacity: 1;
    pointer-events: auto;
  }
}

.card-stack {
  display: grid;
  gap: 8px;
  min-height: 78px;
  padding: 9px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 66px;
  color: var(--muted);
  font-size: 13px;
}

.prompt-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
}

.prompt-card.filtered-favorite {
  border-color: var(--red);
}

.prompt-card.dragging {
  opacity: 0.5;
}

.card-open {
  display: block;
  width: 100%;
  background: transparent;
  padding: 14px 14px 6px;
  color: inherit;
  text-align: left;
}

.prompt-card:hover {
  border-color: rgba(30, 30, 30, 0.36);
}

.prompt-card h3 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.18;
}

.prompt-card p {
  display: -webkit-box;
  overflow: hidden;
  min-height: 42px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.prompt-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 10px 12px 14px;
}

.card-tags,
.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag-chip {
  max-width: 128px;
  overflow: hidden;
  border: 1px solid rgba(255, 45, 45, 0.2);
  border-radius: var(--radius);
  background: rgba(255, 200, 200, 0.42);
  color: var(--ink);
  padding: 1px 7px 2px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.language-badge {
  border-radius: 3px;
  background: var(--ink);
  color: var(--bg);
  padding: 1px 6px 2px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.4;
}

.star-button {
  width: 24px;
  height: 24px;
  color: var(--soft);
  font-size: 22px;
  font-weight: 300;
  line-height: 1;
}

.star-button.active {
  color: var(--red);
}

.prompt-dialog {
  width: min(1040px, calc(100% - 28px));
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  background: transparent;
}

#detailDialog {
  width: min(1180px, calc(100% - 28px));
}

.prompt-dialog::backdrop {
  background: rgba(30, 30, 30, 0.38);
}

.dialog-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  padding: 22px 24px;
}

.dialog-eyebrow {
  margin: 0 0 6px;
  color: var(--red);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
}

.dialog-header h2 {
  margin: 0;
  color: var(--ink);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.1;
}

.icon-button {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  color: var(--ink);
  font-size: 26px;
  font-weight: 300;
  line-height: 1;
}

.icon-button:hover {
  color: var(--red);
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(170px, 0.9fr) 92px;
  gap: 16px;
  padding: 24px;
}

.form-grid label,
.summary-field > .summary-label-row > label {
  display: grid;
  gap: 8px;
  color: var(--red);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
}

.form-grid label.full,
.form-grid .full {
  grid-column: 1 / -1;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbf2e8;
  color: var(--ink);
  outline: none;
  padding: 10px 11px;
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.summary-field {
  display: grid;
  gap: 8px;
}

.summary-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.form-grid textarea {
  resize: vertical;
}

#promptBody {
  min-height: 48vh;
}

.library-editor {
  display: grid;
  gap: 10px;
  padding: 24px;
}

.library-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.library-row input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbf2e8;
  color: var(--ink);
  outline: none;
  padding: 10px 11px;
  font-size: 15px;
}

.library-row input:focus {
  border-color: var(--red);
}

.library-row input[readonly] {
  color: var(--muted);
}

.dialog-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  margin: 0;
  border-top: 1px solid var(--line);
  padding: 16px 24px 20px;
}

.detail-panel {
  padding-bottom: 20px;
}

.detail-summary {
  margin: 20px 24px 14px;
  color: var(--muted);
  font-weight: 500;
}

.detail-tags {
  margin: 0 24px 18px;
}

.prompt-preview {
  overflow: auto;
  max-height: 68vh;
  margin: 0 24px;
  border: 0;
  border-radius: var(--radius);
  background: rgba(30, 30, 30, 0.92);
  color: #f0e8de;
  padding: 18px 20px;
  font-family: "SF Mono", Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.detail-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  padding: 18px 24px 0;
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 10px;
    min-height: auto;
  }

  .brand {
    min-width: 0;
  }

  .header-actions {
    justify-content: stretch;
  }

  .header-actions .button {
    flex: 1;
  }

  .io-menu {
    flex: 1;
  }

  .io-menu .button {
    width: 100%;
  }

  .filters {
    position: static;
  }

  .sync-panel {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .auth-form {
    justify-content: stretch;
  }

  .auth-form input,
  .auth-form .button,
  #signOutButton {
    flex: 1 1 180px;
  }

  .filter-row {
    flex-wrap: wrap;
  }

  .result-count {
    flex-basis: 100%;
    margin-left: 0;
  }

  .board-shell {
    min-height: calc(100vh - 230px);
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .summary-label-row {
    align-items: stretch;
    flex-direction: column;
  }

  #promptBody {
    min-height: 52vh;
  }
}

@media (max-width: 560px) {
  :root {
    --column-width: min(86vw, 326px);
  }

  body {
    font-size: 14px;
  }

  .topbar,
  .filters,
  .board-shell {
    padding-inline: 16px;
  }

  .dialog-actions {
    grid-template-columns: 1fr;
  }

  .library-row {
    grid-template-columns: 1fr;
  }

  .dialog-actions span {
    display: none;
  }

  .detail-actions {
    grid-template-columns: 1fr;
  }

  .detail-actions span {
    display: none;
  }
}
