* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

:root {
  color-scheme: light dark;
  --background: #fff;
  --text: #171717;
  --muted: #666;
  --rule: #ddd;
  --soft-rule: #ececec;
  --control: #aaa;
  --surface: #f7f7f7;
  --surface-hover: #f1f1f1;
  --opposite: #171717;
  --opposite-text: #fff;
  --blue: #4169e1;
  --blue-soft: rgb(65 105 225 / 11%);
  --green: #287a44;
  --red: #bc3f32;
}

html {
  min-width: 0;
  overflow-x: clip;
}

body {
  background: var(--background);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  min-width: 0;
  overflow-x: clip;
}

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

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

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

a {
  color: inherit;
}

.site-header {
  align-items: center;
  display: flex;
  height: 72px;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1680px;
  padding: 0 28px;
  width: 100%;
}

.logo {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.login-link {
  color: var(--muted);
  text-decoration-color: var(--rule);
  text-underline-offset: 3px;
}

.profile-dot {
  background: var(--opposite);
  border: 1px solid var(--opposite);
  border-radius: 50%;
  display: block;
  height: 18px;
  position: relative;
  width: 18px;
}

.profile-dot::after {
  border: 1px solid var(--background);
  border-radius: 50%;
  content: "";
  inset: 3px;
  opacity: .38;
  position: absolute;
}

h1,
h2 {
  font-weight: 600;
  letter-spacing: -0.025em;
}

h1 {
  font-size: clamp(23px, 3vw, 32px);
  line-height: 1.12;
  margin: 0;
}

h2 {
  font-size: 19px;
  line-height: 1.2;
  margin: 0;
}

p {
  margin: 0;
}

.muted {
  color: var(--muted);
}

.sr-only {
  border: 0 !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  height: 1px !important;
  margin: -1px !important;
  overflow: hidden !important;
  padding: 0 !important;
  position: absolute !important;
  white-space: nowrap !important;
  width: 1px !important;
}

.skip-link {
  background: var(--opposite);
  color: var(--opposite-text);
  left: 12px;
  padding: 8px 10px;
  position: fixed;
  top: -80px;
  z-index: 1000;
}

.skip-link:focus {
  top: 12px;
}

.primary-button,
.secondary-button,
.text-button,
.add-button,
.danger-button,
.icon-button {
  align-items: center;
  border-radius: 5px;
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  text-decoration: none;
}

.primary-button,
.secondary-button,
.danger-button {
  border: 1px solid var(--control);
  min-height: 38px;
  padding: 8px 12px;
}

.primary-button {
  background: var(--opposite);
  border-color: var(--opposite);
  color: var(--opposite-text);
}

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

.secondary-button.following {
  color: var(--muted);
}

.text-button,
.icon-button {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 5px 0;
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 3px;
}

.danger-button {
  background: transparent;
  border-color: color-mix(in srgb, var(--red) 55%, var(--rule));
  color: var(--red);
}

button:disabled,
label:has(+ input:disabled) {
  cursor: wait;
  opacity: .55;
}

.home-page {
  margin: 0 auto;
  max-width: 1180px;
  padding: 0 24px 100px;
}

.composer-section {
  align-items: center;
  display: flex;
  min-height: min(680px, calc(100svh - 72px));
  padding-bottom: clamp(50px, 10vh, 110px);
}

.composer {
  border-bottom: 1px solid var(--rule);
  margin: 0 auto;
  max-width: 940px;
  width: 100%;
}

.composer-input {
  background: transparent;
  border: 0;
  display: block;
  font-size: clamp(25px, 3.4vw, 44px);
  font-weight: 440;
  letter-spacing: -0.037em;
  line-height: 1.16;
  max-height: 360px;
  min-height: 132px;
  outline: none;
  overflow-y: auto;
  padding: 0 0 32px;
  resize: none;
  width: 100%;
}

.composer-input::placeholder {
  color: color-mix(in srgb, var(--text) 35%, transparent);
  opacity: 1;
}

.composer-input:focus-visible {
  outline: none;
}

.composer:focus-within {
  border-bottom-color: var(--text);
}

.attachments {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding-bottom: 14px;
}

.attachments:empty {
  display: none;
}

.draft-image {
  height: 52px;
  margin: 0;
  position: relative;
  width: 52px;
}

.draft-image img {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  display: block;
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.remove-chip {
  align-items: center;
  background: var(--opposite);
  border: 1px solid var(--background);
  border-radius: 50%;
  color: var(--opposite-text);
  cursor: pointer;
  display: flex;
  font-size: 15px;
  height: 20px;
  justify-content: center;
  line-height: 1;
  padding: 0 0 2px;
  position: absolute;
  right: -6px;
  top: -6px;
  width: 20px;
}

.url-chip {
  align-items: center;
  background: var(--blue-soft);
  border-radius: 999px;
  color: var(--blue);
  display: inline-flex;
  font-size: 13px;
  gap: 5px;
  max-width: min(300px, 80vw);
  padding: 4px 7px 4px 10px;
}

.url-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.url-remove {
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
}

.composer-footer {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: auto 1fr auto;
  min-height: 68px;
  padding: 12px 0;
}

.add-button {
  border: 1px solid var(--control);
  border-radius: 50%;
  font-size: 23px;
  font-weight: 300;
  height: 38px;
  line-height: 1;
  padding-bottom: 3px;
  width: 38px;
}

.composer-status {
  color: var(--muted);
  font-size: 13px;
  min-width: 0;
}

.community-section {
  border-top: 1px solid var(--rule);
  padding-top: 34px;
}

.section-heading {
  align-items: baseline;
  display: flex;
  justify-content: space-between;
  margin-bottom: 26px;
}

.section-heading h1 {
  font-size: 20px;
}

.community-grid {
  display: grid;
  gap: 46px 24px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.board-card {
  min-width: 0;
}

.board-card-link {
  display: block;
  text-decoration: none;
}

.board-card-link:hover .board-card-name {
  text-decoration: underline;
  text-decoration-color: var(--control);
  text-underline-offset: 3px;
}

.board-card .board-preview {
  border: 1px solid var(--soft-rule);
  border-radius: 5px;
}

.board-card-meta {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding-top: 10px;
}

.board-card-name {
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-card-count {
  color: var(--muted);
  flex: none;
  font-size: 13px;
}

.scroll-sentinel {
  color: var(--muted);
  min-height: 90px;
  padding: 30px 0;
  text-align: center;
}

.scroll-sentinel.loading::after {
  animation: spin .8s linear infinite;
  border: 1px solid var(--rule);
  border-radius: 50%;
  border-top-color: var(--text);
  content: "";
  display: inline-block;
  height: 18px;
  width: 18px;
}

.board-page {
  margin: 22px auto 100px;
  max-width: 1680px;
  padding: 0 28px;
}

.board-shell {
  min-width: 0;
  transition: outline-color 120ms;
}

.board-shell.drop-active {
  outline: 1px dashed var(--blue);
  outline-offset: 10px;
}

.board-mast {
  align-items: flex-end;
  border-bottom: 1px solid var(--rule);
  display: flex;
  gap: 28px;
  justify-content: space-between;
  padding-bottom: 18px;
}

.board-identity h1 {
  margin-bottom: 8px;
}

.board-byline,
.board-social {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 7px 12px;
}

.board-byline > * + * {
  position: relative;
}

.board-person {
  font-weight: 550;
}

.profile-link {
  color: var(--muted);
  font-size: 13px;
  text-decoration-color: var(--rule);
  text-underline-offset: 3px;
}

.follow-count {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.board-notice {
  border-bottom: 1px solid var(--rule);
  padding: 13px 0;
}

.owner-controls {
  align-items: center;
  display: flex;
  gap: 14px;
  padding: 14px 0 0;
}

.keyboard-help {
  font-size: 12px;
}

.job-status {
  align-items: center;
  border-bottom: 1px solid var(--rule);
  color: var(--muted);
  display: flex;
  font-size: 13px;
  gap: 14px;
  min-height: 42px;
  padding: 9px 0;
}

.job-status.active::before {
  animation: spin .8s linear infinite;
  border: 1px solid var(--rule);
  border-radius: 50%;
  border-top-color: var(--text);
  content: "";
  flex: 0 0 auto;
  height: 14px;
  width: 14px;
}

.job-status.complete {
  color: var(--green);
}

.job-status.error {
  color: var(--red);
}

.board-canvas {
  aspect-ratio: 9 / var(--board-rows, 9);
  min-height: 1px;
  overflow: visible;
  position: relative;
  width: 100%;
}

.board-preview {
  aspect-ratio: 1;
  background: var(--surface);
  overflow: hidden;
}

.board-item {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text);
  cursor: pointer;
  display: block;
  left: var(--item-left);
  margin: 0;
  padding: 0;
  position: absolute;
  top: var(--item-top);
  touch-action: manipulation;
  transform: rotate(var(--item-rotation, 0deg));
  transform-origin: center;
  width: var(--item-width);
  z-index: 1;
}

.board-preview .board-item {
  cursor: inherit;
  pointer-events: none;
}

.board-owner .board-item {
  touch-action: none;
}

.board-item img {
  display: block;
  filter: drop-shadow(3px 8px 6px rgb(0 0 0 / 19%));
  height: auto;
  pointer-events: none;
  user-select: none;
  width: 100%;
}

.board-preview .board-item img {
  filter: drop-shadow(2px 5px 4px rgb(0 0 0 / 16%));
}

.board-item:hover,
.board-item:focus-visible {
  z-index: 5;
}

.board-item:not(.dragging):hover img,
.board-item:focus-visible img {
  transform: scale(1.025);
}

.board-item:focus-visible {
  border-radius: 3px;
  outline: 1px solid var(--text);
  outline-offset: 5px;
}

.board-item.dragging {
  cursor: grabbing;
  opacity: .82;
  z-index: 10;
}

.item-placeholder {
  align-items: center;
  aspect-ratio: 1 / var(--item-ratio, 1);
  background: var(--surface);
  border: 1px solid var(--rule);
  color: var(--muted);
  display: flex;
  font-size: clamp(8px, .9vw, 13px);
  justify-content: center;
  line-height: 1.25;
  overflow: hidden;
  padding: 8px;
  text-align: center;
  width: 100%;
}

.board-preview .item-placeholder {
  padding: 3px;
}

.item-state {
  align-items: center;
  background: var(--background);
  border: 1px solid var(--rule);
  border-radius: 50%;
  bottom: -4px;
  color: var(--red);
  display: flex;
  height: 18px;
  justify-content: center;
  position: absolute;
  right: -4px;
  width: 18px;
}

.board-item[data-status="pending"] .item-state::after {
  animation: spin .8s linear infinite;
  border: 1px solid var(--rule);
  border-radius: 50%;
  border-top-color: var(--text);
  content: "";
  height: 10px;
  width: 10px;
}

.image-failed img {
  opacity: .15;
}

.item-dialog {
  background: var(--background);
  border: 1px solid var(--rule);
  border-radius: 7px;
  color: var(--text);
  max-height: min(800px, calc(100dvh - 36px));
  max-width: min(570px, calc(100vw - 28px));
  overflow-y: auto;
  padding: 0;
  width: 100%;
}

.item-dialog::backdrop {
  background: rgb(0 0 0 / 48%);
}

.dialog-top {
  align-items: center;
  border-bottom: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  padding: 18px 20px;
  position: sticky;
  top: 0;
  z-index: 2;
}

.dialog-top,
.item-form {
  background: var(--background);
}

.dialog-top h2 {
  overflow: hidden;
  padding-right: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-top .icon-button {
  flex: none;
  font-size: 13px;
}

.dialog-visual {
  align-items: center;
  background: var(--surface);
  display: flex;
  height: min(38vh, 330px);
  justify-content: center;
  padding: 25px;
}

.dialog-visual img {
  filter: drop-shadow(3px 9px 7px rgb(0 0 0 / 20%));
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
}

.item-form {
  display: grid;
  gap: 15px;
  padding: 20px;
}

.field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.field > span:first-child {
  color: var(--muted);
  font-size: 13px;
}

.field input,
.field textarea {
  background: var(--background);
  border: 1px solid var(--control);
  border-radius: 5px;
  min-width: 0;
  padding: 9px 10px;
  width: 100%;
}

.field textarea {
  min-height: 86px;
  resize: vertical;
}

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

.save-status {
  font-size: 12px;
  min-height: 18px;
}

.dialog-actions {
  border-top: 1px solid var(--rule);
  margin-top: 2px;
  padding-top: 17px;
}

.item-description,
.item-details,
.source-link,
.item-dialog > .muted,
.item-dialog > .error-text {
  margin: 20px;
}

.item-description {
  white-space: pre-wrap;
}

.item-details {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
}

.item-details dt,
.item-details dd {
  border-top: 1px solid var(--rule);
  margin: 0;
  padding: 10px 0;
}

.item-details dt {
  color: var(--muted);
}

.source-link {
  display: inline-block;
  text-underline-offset: 3px;
}

.profile-page,
.error-page {
  padding: 0 18px;
}

.narrow-page {
  margin: clamp(55px, 10vh, 110px) auto;
  max-width: 560px;
}

.narrow-page > h1 + .intro,
.narrow-page > h1 + p {
  margin-top: 9px;
}

.narrow-page > .primary-button,
.narrow-page > .secondary-button {
  margin-top: 24px;
}

.profile-form {
  display: grid;
  gap: 18px;
}

.profile-form .intro {
  margin-bottom: 13px;
}

.profile-field {
  position: relative;
}

.field-status {
  align-items: center;
  bottom: 10px;
  display: flex;
  font-size: 12px !important;
  min-height: 18px;
  position: absolute;
  right: 10px;
}

.field-status.checking::after {
  animation: spin .8s linear infinite;
  border: 1px solid var(--rule);
  border-radius: 50%;
  border-top-color: var(--text);
  content: "";
  height: 13px;
  width: 13px;
}

.field-status.available,
.success-text {
  color: var(--green) !important;
}

.field-status.invalid,
.error-text {
  color: var(--red) !important;
}

.profile-save {
  font-size: 13px;
  min-height: 20px;
}

.profile-actions {
  align-items: center;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 9px;
  padding-top: 20px;
}

.profile-actions .text-button {
  margin-left: auto;
}

.page-loading {
  color: var(--muted);
  margin: 20vh auto;
  text-align: center;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #000;
    --text: #f1f1ee;
    --muted: #9b9b97;
    --rule: #333;
    --soft-rule: #272727;
    --control: #666;
    --surface: #111;
    --surface-hover: #171717;
    --opposite: #fff;
    --opposite-text: #000;
    --blue: #7d9cff;
    --blue-soft: rgb(125 156 255 / 16%);
    --green: #69b77e;
    --red: #e1786d;
  }

  .profile-dot {
    background: #fff;
    border-color: #fff;
  }

  .profile-dot::after {
    border-color: #000;
  }

  .board-item img,
  .dialog-visual img {
    filter: drop-shadow(3px 8px 7px rgb(0 0 0 / 75%));
  }
}

@media (max-width: 700px) {
  .site-header {
    height: 58px;
    padding: 0 16px;
  }

  .home-page {
    padding: 0 16px 70px;
  }

  .composer-section {
    min-height: min(560px, calc(100svh - 58px));
    padding-bottom: 48px;
  }

  .composer-input {
    font-size: clamp(24px, 7.4vw, 34px);
    min-height: 150px;
    padding-bottom: 22px;
  }

  .composer-footer {
    gap: 9px;
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .composer-status {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .primary-button {
    padding-left: 10px;
    padding-right: 10px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .community-grid {
    gap: 38px;
    grid-template-columns: minmax(0, 1fr);
  }

  .board-page {
    margin-top: 10px;
    padding: 0 16px;
  }

  .board-mast {
    align-items: flex-start;
    flex-direction: column;
    gap: 16px;
  }

  .board-social {
    width: 100%;
  }

  .board-social .primary-button,
  .board-social .secondary-button {
    margin-left: auto;
  }

  .owner-controls {
    align-items: flex-start;
    flex-direction: column;
  }

  .keyboard-help {
    display: none;
  }

  .board-canvas:not(.board-preview) {
    margin-left: -4px;
    width: calc(100% + 8px);
  }

  .item-dialog {
    max-height: calc(100dvh - 12px);
    max-width: calc(100vw - 12px);
  }

  .dialog-top {
    padding: 15px 16px;
  }

  .item-form {
    padding: 16px;
  }

  .dialog-visual {
    height: 30vh;
  }

  .profile-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .profile-actions .text-button {
    margin-left: 0;
    margin-top: 8px;
  }
}

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