:root {
  color-scheme: light;
  --ink: #4c4f69;
  --muted: #6c6f85;
  --line: #ccd0da;
  --paper: #eff1f5;
  --panel: #e6e9ef;
  --base: #ffffff;
  --green: #40a02b;
  --blue: #1e66f5;
  --red: #d20f39;
  --mauve: #8839ef;
  --teal: #179299;
  --shadow: 0 16px 48px rgb(76 79 105 / 13%);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Avenir Next, Avenir, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

a {
  color: inherit;
}

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

.button,
input[type="submit"].button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.62rem 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--base);
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}

.button--primary,
input[type="submit"].button--primary {
  border-color: #7287fd;
  background: #7287fd;
  color: #fff;
}

.button--dark,
input[type="submit"].button--dark {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.button--ghost {
  background: transparent;
}

.button--small,
input[type="submit"].button--small {
  min-height: 2rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.86rem;
}

.notice {
  max-width: 1120px;
  margin: 1rem auto 0;
  padding: 0.9rem 1rem;
  border: 1px solid #a6d189;
  border-radius: 8px;
  background: #edf7e8;
  color: var(--green);
  font-weight: 450;
}

.flash-stack {
  position: fixed;
  top: 1rem;
  left: 50%;
  z-index: 10;
  display: grid;
  gap: 0.5rem;
  width: min(520px, calc(100% - 2rem));
  transform: translateX(-50%);
}

.flash {
  margin: 0;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--base);
  box-shadow: 0 10px 30px rgb(76 79 105 / 9%);
  color: var(--ink);
}

.flash--alert {
  border-color: #e78284;
  background: #fff0f2;
  color: var(--red);
}

.flash--notice {
  border-color: #a6d189;
  background: #edf7e8;
  color: var(--green);
}

.account-picker {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 3rem 1.5rem;
  background:
    linear-gradient(180deg, rgb(239 241 245 / 72%), rgb(220 224 232 / 88%)),
    var(--paper);
  color: var(--ink);
}

.account-picker__panel {
  width: min(980px, 100%);
  text-align: center;
}

.account-picker h1 {
  margin: 0 0 2.5rem;
  font-size: clamp(2.4rem, 6vw, 5rem);
  font-weight: 500;
}

.account-picker__session {
  display: inline-flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.75rem;
  color: var(--muted);
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1.6rem;
  align-items: start;
}

.profile-card {
  min-width: 0;
  color: var(--muted);
  text-decoration: none;
}

.profile-card__button {
  display: grid;
  gap: 0.8rem;
  color: inherit;
  text-decoration: none;
}

.profile-card__avatar {
  display: grid;
  width: 100%;
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border: 4px solid var(--panel);
  border-radius: 8px;
  background: linear-gradient(145deg, var(--blue), var(--teal));
  color: #fff;
  font-size: clamp(3rem, 9vw, 5.5rem);
  font-weight: 500;
  transition: border-color 160ms ease, transform 160ms ease;
}

.profile-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-card__name {
  display: block;
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 450;
}

.profile-card:hover .profile-card__avatar,
.profile-card__button:focus-visible .profile-card__avatar {
  border-color: #7287fd;
  transform: translateY(-2px);
}

.profile-card:hover,
.profile-card__button:focus-visible {
  color: var(--ink);
}

.profile-card__edit {
  display: inline-flex;
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration: none;
}

.profile-card__edit:hover {
  color: var(--blue);
  text-decoration: underline;
}

.profile-card--new {
  display: grid;
  gap: 0.8rem;
}

.profile-card__avatar--new {
  border-color: var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: clamp(4rem, 11vw, 7rem);
  line-height: 1;
}

.workspace {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1rem 0 4rem;
}

.mini-avatar {
  display: inline-grid;
  width: 140px;
  height: 140px;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: var(--mauve);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
}

.mini-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.project-card {
  margin-top: 1rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--base);
  box-shadow: var(--shadow);
}

.project-card__header {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(2.75rem, 7vw, 5rem) clamp(1.25rem, 5vw, 4rem);
  gap: 8px;
  text-align: center;
}

.project-card__header-actions {
  position: absolute;
  top: 1.25rem;
  left: 1.25rem;
}

.project-card__header h1 {
  margin: 0;
  font-size: clamp(2.7rem, 6vw, 5.2rem);
  line-height: 1;
}

.project-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: 1.35rem clamp(1rem, 4vw, 3rem);
  border-top: 1px solid var(--line);
}

.project-section--pairing {
  background: var(--paper);
}

.project-section h2,
.project-cell h2 {
  margin: 0;
  font-size: 1.35rem;
}

.project-section p {
  max-width: 560px;
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}

.project-cell {
  min-width: 0;
  min-height: 250px;
  padding: clamp(1.25rem, 4vw, 2rem);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.project-cell__header {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.project-cell:nth-child(2n) {
  border-right: 0;
}

.project-cell--full {
  min-height: 0;
  border-right: 0;
}

.plain-list {
  display: grid;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.plain-list li {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  padding: 0.8rem 0;
  border-top: 1px solid var(--line);
}

.plain-list li:first-child {
  border-top: 0;
}

.plain-list small {
  display: block;
  margin-top: 0.1rem;
  color: var(--muted);
}

.collection-tree li {
  display: block;
}

.collection-tree details {
  min-width: 0;
}

.collection-tree summary {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  cursor: pointer;
  list-style: none;
}

.collection-tree summary::-webkit-details-marker {
  display: none;
}

.collection-tree summary::before {
  content: "▸";
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.82rem;
  transition: transform 120ms ease;
}

.collection-tree details[open] > summary::before {
  transform: rotate(90deg);
}

.collection-tree summary > span:first-of-type {
  min-width: 0;
  margin-right: auto;
}

.collection-tree__records {
  display: grid;
  margin: 0.65rem 0 0 1.2rem;
  padding: 0 0 0 0.85rem;
  border-left: 1px solid var(--line);
  list-style: none;
}

.collection-tree__records li {
  padding: 0.65rem 0;
  border-top: 1px solid rgb(204 208 218 / 55%);
}

.collection-tree__records li:first-child {
  border-top: 0;
}

.collection-tree__value {
  max-height: 180px;
  margin: 0.65rem 0 0;
  padding: 0.75rem;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.collection-tree__more {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.quiet-status {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-height: 1.65rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: capitalize;
}

.quiet-status--on,
.quiet-status--succeeded {
  border-color: #a6d189;
  background: #edf7e8;
  color: var(--green);
}

.quiet-status--failed {
  border-color: #e78284;
  background: #fff0f2;
  color: var(--red);
}

.quiet-status--pending,
.quiet-status--sent {
  border-color: #b4befe;
  background: #f1f3ff;
  color: var(--blue);
}

.command-stack {
  display: grid;
  gap: 0.75rem;
  grid-column: 1 / -1;
}

.command-form {
  display: grid;
  grid-template-columns: minmax(170px, 0.55fr) minmax(190px, 0.75fr) minmax(220px, 1fr) auto;
  gap: 0.75rem;
  align-items: end;
  padding: 0.9rem 0;
  border-top: 1px solid var(--line);
}

.command-form:first-child {
  border-top: 0;
}

.command-form label,
.field {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.command-form__device {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

.command-form__device small {
  color: var(--muted);
}

code {
  word-break: break-word;
  color: var(--mauve);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85em;
}

select,
textarea,
input[type="text"],
input[type="url"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--base);
  color: var(--ink);
}

select,
input[type="text"],
input[type="url"] {
  min-height: 2.65rem;
  padding: 0 0.75rem;
}

input[type="file"] {
  width: 100%;
  color: var(--muted);
}

input[type="file"]::file-selector-button {
  min-height: 2.4rem;
  margin-right: 0.75rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--base);
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

textarea {
  min-height: 3.9rem;
  padding: 0.7rem 0.75rem;
  resize: vertical;
}

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

.form-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 2rem 1rem;
}

.form-card {
  width: min(560px, 100%);
  padding: clamp(1.3rem, 4vw, 2rem);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--base);
  box-shadow: 0 10px 30px rgb(76 79 105 / 9%);
}

.form-card h1 {
  margin: 1rem 0 1.25rem;
  font-size: 34px;
}

.back-link {
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
}

.account-form {
  display: grid;
  gap: 1rem;
}

.form-errors {
  padding: 0.9rem 1rem;
  border: 1px solid #e78284;
  border-radius: 8px;
  background: #fff0f2;
  color: var(--red);
}

.form-errors ul {
  margin-bottom: 0;
  padding-left: 1.2rem;
}

.check-field {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.danger-zone {
  display: grid;
  gap: 0.75rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.danger-zone h2 {
  margin: 0;
  font-size: 1.1rem;
}

.danger-zone p {
  margin: 0;
  color: var(--muted);
}

.button--danger,
input[type="submit"].button--danger {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

.button:disabled,
input[type="submit"].button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.passkey-manager .project-card__header {
  padding-bottom: clamp(2rem, 5vw, 3.25rem);
}

.passkey-list {
  margin-top: 0;
}

.form-actions--center {
  justify-content: center;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 3rem 1.5rem;
}

.auth-panel {
  display: grid;
  gap: 1.25rem;
  width: min(560px, 100%);
  text-align: center;
}

.auth-panel h1 {
  margin: 0;
  font-size: clamp(2.7rem, 7vw, 5.2rem);
  font-weight: 500;
  line-height: 1;
}

.auth-panel .account-form {
  justify-items: center;
}

.auth-panel--form {
  width: min(620px, 100%);
}

.auth-panel--form .account-form {
  width: min(460px, 100%);
  justify-self: center;
  justify-items: stretch;
  text-align: left;
}

.auth-kicker {
  margin: 0;
  color: var(--mauve);
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: uppercase;
}

.auth-copy,
.auth-message {
  color: var(--muted);
}

.auth-copy {
  max-width: 46rem;
  margin: 0 auto;
  font-size: 1.05rem;
}

.auth-message {
  min-height: 1.4rem;
  margin: 0;
  text-align: center;
}

.quiet-status--uploading,
.quiet-status--processing {
  border-color: #b4befe;
  background: #f1f3ff;
  color: var(--blue);
}

.project-section--assets {
  display: block;
}

.asset-upload {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(160px, 0.6fr) minmax(180px, 1fr) auto;
  gap: 0.75rem;
  align-items: end;
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.asset-upload__runtime {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.asset-upload__runtime[hidden] {
  display: none;
}

.asset-upload__actions {
  display: flex;
  gap: 0.5rem;
}

.asset-upload__progress,
.asset-upload__message {
  grid-column: 1 / -1;
}

.asset-upload__message {
  min-height: 1.2rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.asset-upload__message:empty {
  display: none;
}

.asset-progress {
  width: 100%;
  height: 0.5rem;
  margin: 0.35rem 0 0.15rem;
  accent-color: #7287fd;
}

.asset-progress[hidden] {
  display: none;
}

.asset-list .asset-row {
  align-items: flex-start;
}

.asset-cover {
  display: grid;
  flex: 0 0 auto;
  width: 56px;
  height: 78px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: linear-gradient(145deg, var(--blue), var(--teal));
  color: #fff;
  font-size: 1.3rem;
  font-weight: 600;
}

.asset-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.asset-row__main {
  display: grid;
  flex: 1 1 auto;
  min-width: 0;
}

.asset-row__file {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-row__error {
  color: var(--red) !important;
}

.asset-row__actions {
  display: flex;
  flex: 0 0 auto;
  gap: 0.5rem;
  align-items: center;
}

.asset-sync {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.asset-sync__kiosk {
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
  font-size: 0.78rem;
}

.asset-sync__kiosk--ready {
  border-color: #a6d189;
  background: #edf7e8;
  color: var(--green);
}

.asset-sync__kiosk--failed {
  border-color: #e78284;
  background: #fff0f2;
  color: var(--red);
}

.asset-sync__kiosk--queued,
.asset-sync__kiosk--downloading,
.asset-sync__kiosk--verifying {
  border-color: #b4befe;
  background: #f1f3ff;
  color: var(--blue);
}

@media (max-width: 900px) {
  .project-section,
  .project-grid,
  .command-form,
  .asset-upload {
    grid-template-columns: 1fr;
  }

  .asset-list .asset-row {
    flex-wrap: wrap;
  }

  .project-cell {
    border-right: 0;
  }
}

@media (max-width: 560px) {
  .workspace {
    width: min(100% - 1rem, 1120px);
    padding-bottom: 2rem;
  }

  .account-picker {
    align-items: start;
    padding-top: 4rem;
  }

  .profile-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .project-card__header,
  .project-section,
  .project-cell {
    padding: 1rem;
  }

  .project-card__header {
    padding-top: 3.5rem;
  }

  .project-card__header-actions {
    top: 1rem;
    left: 1rem;
  }

  .project-card__header h1 {
    font-size: 2.6rem;
  }
}

/* Linked accounts (plan 16) */
.linked-list li {
  align-items: flex-start;
}

.linked-list__main {
  display: grid;
  min-width: 0;
  gap: 0.15rem;
}

.status-dot {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  margin-right: 0.3rem;
  border-radius: 50%;
  background: var(--muted);
}

.status-dot--ok {
  background: #2e9e5b;
}

.status-dot--error {
  background: var(--red);
}

.status-dot--syncing {
  background: var(--blue);
}

.source-badge {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  vertical-align: middle;
}

.linked-unlink {
  position: relative;
}

.linked-unlink summary {
  list-style: none;
  cursor: pointer;
}

.linked-unlink__panel {
  position: absolute;
  right: 0;
  z-index: 5;
  display: grid;
  gap: 0.5rem;
  width: 260px;
  margin-top: 0.4rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
}

.linked-form__auth {
  display: grid;
  gap: 0.75rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.linked-test {
  margin: 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.linked-test--ok {
  border-color: #2e9e5b;
}

.linked-test--error {
  border-color: var(--red);
  color: var(--red);
}

.linked-tabs {
  display: flex;
  gap: 0.4rem;
  margin: 1rem 0;
}

.linked-tabs__tab {
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: inherit;
  text-decoration: none;
}

.linked-tabs__tab--on {
  background: var(--blue);
  color: #fff;
}

.linked-toggle {
  flex: 1 1 auto;
}

.linked-search {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.linked-search input[type="search"] {
  flex: 1 1 auto;
}

.linked-results li {
  gap: 0.75rem;
  align-items: center;
}

.linked-pager {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  margin-top: 1rem;
}

.form-page--wide .form-card {
  width: min(820px, 100%);
}
