/* Packlyn Design Software — app frame: navy sidebar and top bar around a light, rounded work area */
body { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); transition: grid-template-columns .22s ease; }
#plyn-root { position: fixed; left: 0; top: 0; width: 0; height: 0; z-index: 700; }
#sidebar, #main { grid-row: 1; }
body.side-collapsed { --side-w: 80px; }

/* ---------- sidebar ---------- */
#sidebar { grid-column: 1; position: relative; display: flex; flex-direction: column; min-height: 0; overflow: hidden; background: var(--chrome); color: var(--chrome-ink); z-index: 20; -webkit-app-region: drag; }
#sidebar > * { -webkit-app-region: no-drag; position: relative; z-index: 1; }
.sb-brand { border: 0; background: none; padding: 12px 18px 6px; display: flex; justify-content: center; align-items: center; min-height: 104px; }
.plat-mac .sb-brand { padding-top: 34px; min-height: 120px; }
.plat-mac.fullscreen .sb-brand { padding-top: 12px; min-height: 104px; }
.sb-brand img { width: 168px; max-width: 100%; height: auto; display: block; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .35)); transition: width .22s ease; }
body.side-collapsed .sb-brand { padding: 14px 8px 8px; min-height: 76px; }
body.side-collapsed.plat-mac .sb-brand { padding-top: 40px; min-height: 96px; }
body.side-collapsed .sb-brand img { width: 62px; }
.sb-rule { height: 1px; margin: 6px 18px 14px; background: linear-gradient(90deg, transparent, rgba(240, 178, 50, .45), transparent); }
.sb-create { margin: 0 16px 14px; min-height: 48px; border-radius: 14px; font-size: 14.5px; gap: 10px; justify-content: flex-start; padding: 0 16px; }
.sb-create .ico { width: 22px; height: 22px; }
body.side-collapsed .sb-create { margin: 0 14px 12px; padding: 0; justify-content: center; }
body.side-collapsed .sb-create span:not(.ico) { display: none; }
.sb-nav { display: grid; gap: 3px; padding: 0 10px; overflow-y: auto; scrollbar-width: none; }
.sb-nav::-webkit-scrollbar { display: none; }
.sb-item { position: relative; display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 13px; min-height: 46px; padding: 0 14px; border: 0; border-radius: 13px; background: transparent; color: var(--chrome-ink); font: 500 14.5px var(--font); text-align: left; transition: background .14s, color .14s; }
.sb-item .ico { width: 24px; height: 24px; color: color-mix(in srgb, var(--chrome-ink) 88%, transparent); }
.sb-item:hover { background: var(--chrome-3); }
.sb-item.on { background: linear-gradient(90deg, var(--chrome-hi), color-mix(in srgb, var(--chrome-hi) 55%, transparent)); color: #fff; }
.sb-item.on .ico { color: var(--gold-hi); }
.sb-item.on::before { content: ''; position: absolute; left: -10px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--gold); }
.sb-item .sb-count { font: 700 10.5px var(--font); color: var(--chrome-muted); background: rgba(255, 255, 255, .07); padding: 1px 7px; border-radius: 999px; }
.sb-item .sb-new { font: 800 9.5px var(--font); letter-spacing: .04em; color: var(--on-gold); background: var(--gold-grad); padding: 1px 6px; border-radius: 999px; }
body.side-collapsed .sb-item { grid-template-columns: 1fr; justify-items: center; padding: 0; min-height: 52px; }
body.side-collapsed .sb-item > span:not(.ico) { display: none; }
.sb-heading { font: 700 10.5px var(--font); color: var(--chrome-muted); padding: 14px 16px 4px; letter-spacing: .02em; }
body.side-collapsed .sb-heading { display: none; }
.sb-fill { flex: 1; min-height: 20px; }
.sb-art { position: absolute !important; left: 0; right: 0; bottom: 0; height: 300px; z-index: 0 !important; pointer-events: none; opacity: .95; }
.sb-art svg { width: 100%; height: 100%; display: block; }
.sb-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(var(--chrome), transparent 38%); }
.sb-foot { display: flex; gap: 4px; padding: 10px 12px 14px; align-items: center; }
body.side-collapsed .sb-foot { flex-direction: column; }
.sb-foot .icon-btn { color: var(--chrome-muted); background: rgba(8, 22, 32, .35); backdrop-filter: blur(3px); }
.sb-foot .icon-btn:hover { color: #fff; background: var(--chrome-3); }
.sb-meta { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; min-width: 0; }
.made-in { display: inline-flex; align-items: center; gap: 6px; font: 600 10.5px/1 var(--font); letter-spacing: .01em; color: var(--chrome-muted); white-space: nowrap; }
.flag-ca { display: inline-flex; width: 18px; height: 9px; border-radius: 1.5px; overflow: hidden; box-shadow: 0 0 0 .5px rgba(255, 255, 255, .35); flex: none; }
.flag-ca svg { width: 100%; height: 100%; display: block; }
.sb-foot .ver { font: 600 10.5px var(--font); color: var(--chrome-muted); background: rgba(8, 22, 32, .35); padding: 3px 8px; border-radius: 999px; }
body.side-collapsed .sb-foot .sb-meta { display: none; }

/* ---------- main column ---------- */
#main { grid-column: 2; display: grid; grid-template-rows: var(--top-h) minmax(0, 1fr); min-width: 0; min-height: 0; }
#topbar { display: flex; align-items: center; gap: 14px; padding: 0 18px 0 6px; background: var(--chrome); color: var(--chrome-ink); -webkit-app-region: drag; min-width: 0; position: relative; z-index: 15; }
.plat-win #topbar, .plat-linux #topbar { padding-right: 150px; }
#topbar > * { -webkit-app-region: no-drag; }
.tn { display: flex; gap: 4px; align-items: center; flex: none; }
.tn-item { display: inline-flex; align-items: center; gap: 9px; height: 42px; padding: 0 16px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--chrome-ink); font: 500 14.5px var(--font); transition: background .14s; }
.tn-item .ico { width: 21px; height: 21px; }
.tn-item:hover { background: var(--chrome-3); }
.tn-item.on { background: var(--gold-grad); color: var(--on-gold); box-shadow: 0 4px 14px rgba(232, 160, 30, .28), inset 0 -2px 0 rgba(120, 70, 0, .18); font-weight: 600; }
.tsearch { position: relative; flex: 1 1 380px; max-width: 560px; min-width: 200px; margin-left: auto; }
.tsearch > .ico { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--chrome-muted); width: 19px; height: 19px; pointer-events: none; }
.tsearch input { width: 100%; height: 42px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .18); background: rgba(255, 255, 255, .04); color: var(--chrome-ink); padding: 0 16px 0 44px; font: 500 13.5px var(--font); }
.tsearch input::placeholder { color: var(--chrome-muted); }
.tsearch input:focus { outline: none; border-color: var(--gold); background: rgba(255, 255, 255, .08); box-shadow: 0 0 0 3px rgba(240, 178, 50, .18); }
/* search results: a panel aligned to the search field, at least wide enough for a title and its details */
.tsearch-results { position: absolute; left: 0; top: calc(100% + 8px); width: max(100%, 460px); max-width: min(620px, calc(100vw - 280px)); background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 48px rgba(6, 22, 32, .22), 0 2px 6px rgba(6, 22, 32, .08); z-index: 50; display: grid; grid-template-rows: minmax(0, 1fr) auto; max-height: min(72vh, 620px); overflow: hidden; transform-origin: 30px 0; animation: tsrIn .14s ease-out; }
@keyframes tsrIn { from { opacity: 0; transform: translateY(-4px) scale(.985); } to { opacity: 1; transform: none; } }
.tsr-list { overflow-y: auto; padding: 6px; overscroll-behavior: contain; }
.tsr-group + .tsr-group { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.tsr-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px 4px; font: 700 11px var(--font); letter-spacing: .02em; color: var(--muted); }
.tsr-more { border: 0; background: transparent; color: var(--teal); font: 600 11.5px var(--font); padding: 2px 4px; border-radius: 6px; }
.tsr-more:hover { background: var(--teal-tint); }
.tsr { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%; min-height: 50px; border: 0; background: transparent; padding: 6px 10px; border-radius: 11px; text-align: left; color: var(--ink); cursor: pointer; transition: background .1s; }
.tsr.on { background: var(--hover); box-shadow: inset 0 0 0 1px var(--line); }
.tsr-ic { --tc: var(--teal); width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--tc) 14%, transparent); color: var(--tc); overflow: hidden; flex: none; }
.tsr-ic .ico { width: 19px; height: 19px; }
.tsr-ic.thumb { background: var(--work); }
.tsr-ic.thumb img { width: 100%; height: 100%; object-fit: cover; }
.tsr-ic.plyn { --tc: var(--gold-dk); }
.tsr-txt { display: grid; gap: 2px; min-width: 0; }
.tsr b { font: 600 13.5px/1.3 var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tsr small { color: var(--muted); font-size: 11.5px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tsr-go { color: var(--muted); opacity: 0; transition: opacity .1s; }
.tsr-go .ico { width: 16px; height: 16px; }
.tsr.on .tsr-go { opacity: 1; }
.tsr kbd, .tsr-foot kbd { font: 600 10.5px var(--font); color: var(--ink-2); background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; }
.tsr-empty { display: flex; gap: 12px; align-items: center; padding: 14px 12px 10px; }
.tsr-empty-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--panel-2); color: var(--muted); flex: none; }
.tsr-empty b { display: block; font: 600 14px var(--font); }
.tsr-empty small { color: var(--muted); font-size: 12px; }
.tsr-foot { display: flex; gap: 16px; padding: 8px 14px; border-top: 1px solid var(--line); background: var(--panel-2); font-size: 11px; color: var(--muted); }
.tsr-foot span { display: inline-flex; align-items: center; gap: 4px; }
.tright { display: flex; align-items: center; gap: 6px; flex: none; }
.tright .icon-btn { width: 42px; height: 42px; border-radius: 50%; color: var(--chrome-ink); }
.tright .icon-btn .ico { width: 21px; height: 21px; }
.tright .icon-btn:hover { background: var(--chrome-3); color: #fff; }
.tavatar { width: 42px; height: 42px; border-radius: 50%; border: 2px solid rgba(240, 178, 50, .75); background: radial-gradient(circle at 30% 25%, #fbd477, #e9a221 70%); display: grid; place-items: center; color: var(--on-gold); padding: 0; }
.tavatar .ico { width: 22px; height: 22px; }
#views { position: relative; min-width: 0; min-height: 0; background: var(--bg); border-top-left-radius: 22px; overflow: hidden; box-shadow: inset 1px 1px 0 rgba(255, 255, 255, .04); }
.pview { position: absolute; inset: 0; overflow: auto; display: none; }
body.view-home #home, body.view-gallery #gallery, body.view-library #library, body.view-ai #aipage, body.view-upscale #upscale, body.view-requests #requests { display: block; }
#editor { position: absolute; inset: 0; display: none; }
body.view-editor #editor { display: grid; }

/* ---------- editor: the left menu becomes a compact rail of tools ---------- */
body.view-editor:not(.side-collapsed) { --side-w: 96px; }
body.view-editor .sb-brand { padding: 12px 8px 4px; min-height: 74px; }
.plat-mac body.view-editor .sb-brand, body.view-editor.plat-mac .sb-brand { padding-top: 38px; min-height: 100px; }
body.view-editor .sb-brand img { width: 74px; }
body.view-editor .sb-rule { margin: 4px 14px 10px; }
body.view-editor .sb-create { margin: 0 14px 10px; padding: 0; justify-content: center; min-height: 44px; border-radius: 13px; }
body.view-editor .sb-create span:not(.ico) { display: none; }
body.view-editor .sb-nav { padding: 0 8px; gap: 2px; }
body.view-editor .sb-item { grid-template-columns: 1fr; justify-items: center; gap: 4px; padding: 8px 2px 7px; min-height: 60px; font-size: 11px; font-weight: 600; text-align: center; border-radius: 12px; line-height: 1.15; }
body.view-editor .sb-item .ico { width: 23px; height: 23px; }
body.view-editor .sb-item .sb-new { position: absolute; top: 4px; right: 4px; font-size: 7.5px; padding: 0 4px; }
body.view-editor .sb-item.on::before { left: -8px; }
body.view-editor .sb-foot { flex-direction: column; }
body.view-editor .sb-foot .sb-meta { display: none; }
body.view-editor .sb-art { opacity: .55; }

/* the sidebar has the same three places with names, so the top bar keeps just their icons when space is short */
@media (max-width: 1500px) { .tn-item { padding: 0 11px; } .tn-item span:not(.ico) { display: none; } }
@media (max-width: 1100px) { .tsearch { min-width: 120px; flex-basis: 220px; } }
@media (max-width: 900px) { .tsearch { min-width: 0; flex-basis: 140px; } .tsearch-results { width: min(460px, calc(100vw - 24px)); } }
@media (max-width: 760px) { body { --side-w: 0px; } #sidebar { display: none; } #topbar { padding-left: 10px; } }
/* very narrow windows (and the online preview on a phone): the editor keeps a slim tool rail */
@media (max-width: 760px) {
  body.view-editor { --side-w: 64px; }
  body.view-editor #sidebar { display: flex; }
  body.view-editor .sb-brand, body.view-editor .sb-rule, body.view-editor .sb-art, body.view-editor .sb-foot { display: none; }
  body.view-editor .sb-create { margin: 10px 8px 8px; min-height: 40px; }
  body.view-editor .sb-nav { padding: 0 4px; }
  body.view-editor .sb-item { font-size: 9.5px; min-height: 52px; padding: 6px 0; }
  body.view-editor .sb-item .ico { width: 21px; height: 21px; }
  body.view-editor #drawer:not(.closed) { width: min(320px, 78vw); }
}
