/* Creator Hub – DS v4 Bento (personal_repo_designsystem). Type only via --ds-type-*, radius only 20/10/pill. */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ds-bento-canvas);
  color: var(--ds-color-ink);
  font-family: var(--ds-font-web);
  font-size: var(--ds-type-content-size);
  line-height: var(--ds-type-content-line);
  font-weight: 400;
  letter-spacing: var(--ds-type-content-tracking);
}
button, input, textarea, select { font-family: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---- type by function ---- */
.t-page { font-size: var(--ds-type-page-size); line-height: var(--ds-type-page-line); font-weight: 700; letter-spacing: var(--ds-type-page-tracking); margin: 0; }
.t-header { font-size: var(--ds-type-header-size); line-height: var(--ds-type-header-line); font-weight: 600; letter-spacing: var(--ds-type-header-tracking); margin: 0; }
.t-content { font-size: var(--ds-type-content-size); line-height: var(--ds-type-content-line); letter-spacing: var(--ds-type-content-tracking); }
.t-secondary { font-size: var(--ds-type-secondary-size); line-height: var(--ds-type-secondary-line); letter-spacing: var(--ds-type-secondary-tracking); color: var(--ds-color-muted); }
.t-data { font-size: var(--ds-type-data-size); line-height: var(--ds-type-data-line); font-variant-numeric: tabular-nums; }
.t-label { font-size: var(--ds-type-label-size); line-height: var(--ds-type-label-line); font-weight: 600; letter-spacing: var(--ds-type-label-tracking); }
.t-note { font-size: var(--ds-type-note-size); line-height: var(--ds-type-note-line); color: var(--ds-color-muted); }

/* ---- frame ---- */
.frame { max-width: 1280px; margin: 0 auto; padding: 12px var(--ds-bento-gutter) 32px; }
.stack { display: flex; flex-direction: column; gap: var(--ds-bento-tile-gap); }

/* ---- navbar: floating white pill ---- */
.nav {
  position: sticky; top: 12px; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--ds-bento-tile); border-radius: var(--ds-bento-radius-pill);
  box-shadow: var(--ds-shadow-overlay); padding: 6px; margin-bottom: 20px;
}
.brand { display: flex; align-items: center; gap: 8px; padding-left: 6px; font-size: var(--ds-type-button-size); line-height: var(--ds-type-button-line); font-weight: 600; white-space: nowrap; }
.brand img { width: 32px; height: 32px; border-radius: var(--ds-bento-radius-inner); }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: transparent; cursor: pointer; white-space: nowrap;
  font-size: var(--ds-type-button-size); line-height: var(--ds-type-button-line); font-weight: 600; letter-spacing: var(--ds-type-button-tracking);
  padding: 10px 16px; border-radius: var(--ds-bento-radius-pill); color: var(--ds-color-grey);
}
.tab:hover { color: var(--ds-color-ink); }
.tab[aria-selected="true"] { background: var(--ds-accent); color: var(--ds-color-ink); }

/* ---- page header on canvas ---- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: var(--ds-bento-tile-gap); min-height: 40px; }
.page-head .controls { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* ---- tiles ---- */
.tile { background: var(--ds-bento-tile); border-radius: var(--ds-bento-radius-tile); padding: var(--ds-bento-tile-padding); min-width: 0; }
.tile-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 8px; min-height: var(--ds-bento-row-height); padding: 12px 0; border-top: 1px solid var(--ds-bento-hair); }
.row:first-child { border-top: 0; }
.group-label { margin: 0 0 8px; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; cursor: pointer; white-space: nowrap; text-decoration: none;
  font-size: var(--ds-type-button-size); line-height: var(--ds-type-button-line); font-weight: 600; letter-spacing: var(--ds-type-button-tracking);
  padding: 10px 16px; border-radius: var(--ds-bento-radius-pill); min-height: 40px;
  background: var(--ds-bento-canvas); color: var(--ds-color-ink);
}
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--ds-accent); color: var(--ds-color-ink); }
.btn-dark { background: var(--ds-color-ink); color: var(--ds-accent); }
.btn-float { background: var(--ds-bento-tile); box-shadow: var(--ds-shadow-overlay); }
.btn-small { min-height: 32px; padding: 6px 12px; border-radius: var(--ds-bento-radius-inner); font-size: var(--ds-type-label-size); line-height: var(--ds-type-label-line); }
.btn-icon { width: 40px; padding: 0; }
.btn-danger { background: var(--ds-color-red-soft); color: var(--ds-color-red-text); }
.btn svg { width: 16px; height: 16px; flex: none; }

/* segmented toggle (pill) */
.seg { display: inline-flex; background: var(--ds-bento-canvas); border-radius: var(--ds-bento-radius-pill); padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; cursor: pointer; border-radius: var(--ds-bento-radius-pill);
  font-size: var(--ds-type-label-size); line-height: var(--ds-type-label-line); font-weight: 600;
  padding: 7px 12px; color: var(--ds-color-grey); white-space: nowrap;
}
.seg button[aria-pressed="true"] { background: var(--ds-color-ink); color: var(--ds-color-ground); }
.seg.need { box-shadow: inset 0 0 0 2px var(--ds-color-red); }

/* chips / tags */
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--ds-bento-canvas); border-radius: var(--ds-bento-radius-inner); padding: 4px 10px; font-size: var(--ds-type-label-size); line-height: var(--ds-type-label-line); font-weight: 600; }
.chip-dark { background: var(--ds-color-ink); color: var(--ds-accent); }
.chip-accent { background: var(--ds-accent); }

/* ---- inputs ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.input, .textarea, .select {
  width: 100%; border: 0; outline: 0; background: var(--ds-bento-canvas);
  border-radius: var(--ds-bento-radius-inner); padding: 10px 12px;
  font-size: var(--ds-type-input-size); line-height: var(--ds-type-input-line); letter-spacing: var(--ds-type-input-tracking);
}
.input:focus, .textarea:focus, .select:focus { box-shadow: inset 0 0 0 2px var(--ds-color-ink); }
.textarea { resize: vertical; min-height: 96px; }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.select-pill { width: auto; border-radius: var(--ds-bento-radius-pill); padding: 7px 30px 7px 12px; font-size: var(--ds-type-label-size); line-height: var(--ds-type-label-line); font-weight: 600; }
input[type="range"] { width: 100%; accent-color: var(--ds-color-ink); }
input[type="color"] { width: 32px; height: 32px; border: 0; padding: 0; border-radius: var(--ds-bento-radius-inner); background: none; cursor: pointer; }

/* ---- write screen ---- */
.write { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: var(--ds-bento-tile-gap); align-items: start; }
.projects { position: sticky; top: 84px; }
.project-row { width: 100%; text-align: left; border: 0; background: none; cursor: pointer; justify-content: space-between; font-size: var(--ds-type-content-size); line-height: var(--ds-type-content-line); }
.project-row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-row[aria-current="true"] .name::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ds-accent); margin-right: 8px; vertical-align: middle; }
.projects-mobile { display: none; }

.thread { display: flex; flex-direction: column; gap: 0; min-height: 240px; }
.msg { padding: 16px 0; border-top: 1px solid var(--ds-bento-hair); }
.msg:first-child { border-top: 0; padding-top: 0; }
.msg-user { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.msg-user .bubble { background: var(--ds-bento-canvas); border-radius: var(--ds-bento-radius-inner); padding: 10px 12px; max-width: 85%; white-space: pre-wrap; word-break: break-word; max-height: 160px; overflow: auto; }
.msg-ai .post { white-space: pre-wrap; word-break: break-word; }
.msg-ai .post[contenteditable="true"] { outline: 0; box-shadow: inset 0 0 0 2px var(--ds-color-ink); border-radius: var(--ds-bento-radius-inner); padding: 8px; }
.msg-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.msg-foot .spacer { flex: 1; }
.empty { text-align: center; padding: 48px 16px; }

.composer { position: sticky; bottom: 12px; box-shadow: var(--ds-shadow-overlay); }
.composer .opts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.composer .send-row { display: flex; gap: 8px; align-items: flex-end; }
.composer .textarea { min-height: 72px; max-height: 40vh; }
.loading { display: inline-flex; gap: 4px; }
.loading i { width: 6px; height: 6px; border-radius: 50%; background: var(--ds-color-muted); animation: blink 1s infinite; }
.loading i:nth-child(2) { animation-delay: .15s; } .loading i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 50% { opacity: .2; } }

/* ---- image screen ---- */
.img-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: var(--ds-bento-tile-gap); align-items: start; }
.ctrl-group { padding: 14px 0; border-top: 1px solid var(--ds-bento-hair); display: flex; flex-direction: column; gap: 10px; }
.ctrl-group:first-child { border-top: 0; padding-top: 0; }
.ctrl-line { display: flex; align-items: center; gap: 8px; }
.ctrl-line > .t-secondary { min-width: 64px; }
.ctrl-line output { min-width: 36px; text-align: right; }
.swatches { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.swatch { width: 32px; height: 32px; border-radius: var(--ds-bento-radius-inner); border: 1px solid var(--ds-bento-hair); cursor: pointer; padding: 0; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ds-bento-tile), 0 0 0 4px var(--ds-color-ink); }
.drop { display: block; border: 2px dashed var(--ds-bento-hair); border-radius: var(--ds-bento-radius-tile); padding: 32px 16px; text-align: center; cursor: pointer; }
.drop.over { border-color: var(--ds-color-ink); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--ds-bento-tile-gap); margin-top: var(--ds-bento-tile-gap); align-items: start; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 1px solid var(--ds-bento-hair); border-radius: var(--ds-bento-radius-inner); }
input[type="color"]::-moz-color-swatch { border: 1px solid var(--ds-bento-hair); border-radius: var(--ds-bento-radius-inner); }
.shot { display: flex; flex-direction: column; gap: 8px; }
.shot .canvas-wrap { background: repeating-conic-gradient(var(--ds-bento-hair) 0 25%, transparent 0 50%) 0 0 / 16px 16px; border-radius: var(--ds-bento-radius-inner); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.shot canvas { max-width: 100%; height: auto; display: block; }
.shot .foot { display: flex; align-items: center; gap: 8px; }
.shot .foot .spacer { flex: 1; }

/* ---- frameworks ---- */
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--ds-bento-tile-gap); }
.fw details { border-top: 1px solid var(--ds-bento-hair); padding: 10px 0; }
.fw details:last-child { padding-bottom: 0; }
.fw pre, .pre { white-space: pre-wrap; word-break: break-word; font-family: inherit; margin: 0; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: "+"; float: right; font-weight: 600; }
details[open] > summary::after { content: "–"; }

/* ---- popup ---- */
dialog { border: 0; padding: 0; background: transparent; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: var(--ds-color-scrim); }
dialog .tile { box-shadow: var(--ds-shadow-overlay); display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 32px); overflow: auto; }
dialog .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
dialog .actions .left { margin-right: auto; }

/* ---- login ---- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login .tile { width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; }
.login img { width: 48px; height: 48px; border-radius: var(--ds-bento-radius-inner); }

/* ---- toast ---- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; background: var(--ds-color-ink); color: var(--ds-color-ground); border-radius: var(--ds-bento-radius-pill); padding: 10px 18px; box-shadow: var(--ds-shadow-overlay); font-size: var(--ds-type-button-size); line-height: var(--ds-type-button-line); font-weight: 600; }
.err { color: var(--ds-color-red-text); }

/* ---- responsive ---- */
@media (max-width: 1024px) {
  .img-layout { grid-template-columns: 300px minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .write, .img-layout, .grid2 { grid-template-columns: minmax(0, 1fr); }
  .img-layout > section { order: -1; }
  .projects { display: none; }
  .projects-mobile { display: block; }
  .brand span { display: none; }
  .tab { padding: 10px 12px; }
  .composer { bottom: 8px; padding: 12px; }
  .composer .opts { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -12px 10px; padding: 0 12px; }
  .composer .opts::-webkit-scrollbar { display: none; }
  .composer .opts > * { flex: none; }
  .composer .textarea { min-height: 56px; }
}
