:root {
  color-scheme: light;
  --ink: #172337;
  --muted: #59677a;
  --subtle: #e1e6ed;
  --paper: #fff;
  --canvas: #f4f6f9;
  --navy: #111e34;
  --red: #a72c2f;
  --gold: #925900;
  --focus: #2463cb;
  --radius: 14px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-height: 100svh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--canvas);
  color: var(--ink);
  line-height: 1.5;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .58; cursor: wait; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
h1, h2, p { margin: 0; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

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

.skip-link {
  position: fixed;
  z-index: 3;
  left: 12px;
  top: 12px;
  padding: .5rem 1rem;
  border-radius: 8px;
  background: var(--paper);
  transform: translateY(calc(-100% - 20px));
}

.skip-link:focus { transform: none; }

.container {
  width: min(100% - 64px, 1160px);
  margin-inline: auto;
}

.site-header {
  border-bottom: 1px solid var(--subtle);
  background: var(--paper);
}

.header-inner,
.brand {
  display: flex;
  align-items: center;
}

.header-inner {
  min-height: 69px;
  justify-content: space-between;
  gap: 1rem;
}

.brand { gap: 1rem; }
.brand-logo { width: 76px; height: 32px; object-fit: contain; }
.brand-divider { width: 1px; height: 23px; background: var(--subtle); }
.brand-name { color: var(--muted); font-size: .875rem; font-weight: 620; }

.button {
  min-height: 42px;
  padding: .5rem .9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: .875rem;
  font-weight: 640;
}

.button-subtle { border-color: var(--subtle); background: var(--paper); color: var(--ink); }
.button-subtle:hover { border-color: #b5c1d0; background: #f7f9fc; }
.button-primary { background: var(--red); color: #fff; }
.button-primary:hover { background: #8d2227; }
.header-action { flex: none; }

.icon-lock {
  width: 12px;
  height: 10px;
  margin-top: 5px;
  position: relative;
  border: 1.5px solid currentColor;
  border-radius: 2px;
}

.icon-lock::before {
  content: "";
  position: absolute;
  left: 2px;
  bottom: 100%;
  width: 6px;
  height: 6px;
  border: 1.5px solid currentColor;
  border-bottom: 0;
  border-radius: 5px 5px 0 0;
}

.page {
  flex: 1;
  padding-block: 2rem 3rem;
}

.launchpad-panel {
  --launchpad-gutter: clamp(1rem, 3.25vw, 3rem);
  display: flex;
  flex-direction: column;
  min-height: 100svh;
}

.launchpad-panel .header-inner,
.launchpad-panel .page,
.launchpad-panel .site-footer { padding-inline: var(--launchpad-gutter); }

.launchpad-panel .header-inner { min-height: 56px; }
.launchpad-panel .brand-logo { width: 65px; height: 27px; }
.launchpad-panel .page { padding-block: 1.1rem 1.5rem; }

.launchpad-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(12rem, 32vw, 25rem);
  align-items: center;
  gap: .65rem 1rem;
}

.launchpad-intro h1 {
  font-size: 1.55rem;
  font-weight: 740;
  letter-spacing: -.04em;
  line-height: 1.15;
}

.search {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 .55rem 0 .75rem;
  border: 1px solid #c5cfdd;
  border-radius: 9px;
  background: #f7f9fc;
  color: var(--ink);
}

.search:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }

.icon-search {
  position: relative;
  flex: 0 0 14px;
  height: 14px;
  margin-right: 2px;
  border: 1.7px solid #51647d;
  border-radius: 50%;
}

.icon-search::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 1.7px;
  top: 10px;
  left: 10px;
  transform: rotate(45deg);
  transform-origin: left center;
  border-radius: 2px;
  background: #51647d;
}

.search input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
}

.search input::-webkit-search-cancel-button { appearance: none; }
.search input::placeholder { color: #5e6e83; opacity: 1; }

.search kbd {
  flex: none;
  padding: .12rem .45rem;
  border: 1px solid var(--subtle);
  border-radius: 5px;
  background: #f5f7fa;
  color: var(--muted);
  font-family: inherit;
  font-size: .75rem;
  font-weight: 600;
}

#clear-search {
  flex: 0 0 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
}

#clear-search:hover { background: var(--canvas); color: var(--ink); }

.catalog-section { margin-top: .95rem; }
.section-heading {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin-bottom: .75rem;
}

.catalog-section .section-heading { margin-bottom: .45rem; }
.catalog-section .section-heading h2 { font-size: 1.0625rem; }

.section-heading h2,
.panel h2 {
  font-size: 1.25rem;
  line-height: 1.25;
  letter-spacing: -.02em;
  font-weight: 720;
}

.section-icon {
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  border-radius: 9px;
}

.favorites-icon { background: #fff0d8; color: var(--gold); font-size: 1rem; }
.gallery-icon { background: #e5ebf5; color: #324b70; }
.personal-icon { background: #e4edf9; color: #2e547a; }

.icon-person {
  position: relative;
  width: 13px;
  height: 14px;
}

.icon-person::before,
.icon-person::after {
  content: "";
  position: absolute;
  background: currentColor;
}

.icon-person::before {
  top: 0;
  left: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.icon-person::after {
  inset: 8px 0 0;
  border-radius: 7px 7px 2px 2px;
}

.icon-grid {
  width: 6px;
  height: 6px;
  align-self: start;
  justify-self: start;
  margin: 7px;
  border-radius: 1px;
  background: currentColor;
  box-shadow: 9px 0 currentColor, 0 9px currentColor, 9px 9px currentColor;
}

.count {
  margin-left: auto;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 550;
}

.empty-favorites {
  padding: .55rem .75rem;
  border: 1px dashed #c8d3e1;
  border-radius: 10px;
  background: #f7f9fc;
  color: var(--muted);
  font-size: .9375rem;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17.5rem), 1fr));
  gap: .625rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tile {
  min-width: 0;
  position: relative;
  border: 1px solid var(--subtle);
  border-radius: 10px;
  background: #fcfdff;
}

.tile:has(a.tile-entry:hover) { border-color: #a8b7cc; box-shadow: 0 3px 9px #14274012; }

.tile-entry {
  display: flex;
  align-items: center;
  gap: .65rem;
  min-width: 0;
  min-height: 66px;
  height: 100%;
  padding: .55rem 3.1rem .55rem .65rem;
  border-radius: 9px;
}

.tile-logo {
  display: grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  place-items: center;
  padding: 4px;
  border: 1px solid #edf0f4;
  border-radius: 10px;
  background: var(--paper);
}

.tile-logo img { width: 100%; height: 100%; object-fit: contain; }

.tile-initials {
  overflow: hidden;
  background: #e8eef8;
  color: #29456c;
  font-size: .8125rem;
  font-weight: 740;
}

.tile-details {
  display: grid;
  align-content: center;
  gap: .16rem;
  min-width: 0;
}

.tile-name {
  font-weight: 690;
  font-size: .9375rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.tile-description {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  color: var(--muted);
  font-size: .8125rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.star-button {
  position: absolute;
  top: calc(50% - 22px);
  right: .18rem;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #64748a;
  line-height: 1;
  font-size: 1.375rem;
}

.star-button:hover { background: #f0f3f8; color: var(--ink); }
.star-button[aria-pressed="true"] { background: #fff6e6; color: var(--gold); }
.star-button[aria-pressed="true"]:hover { background: #ffedcb; }

.personal-add {
  min-height: 36px;
  margin-left: .35rem;
  padding: .35rem .65rem;
  gap: .35rem;
  font-size: .8125rem;
}

.personal-add span { font-size: 1rem; line-height: 1; }
.personal-tile .tile-entry { min-height: 88px; }
.personal-tile .star-button { top: 0; }

.personal-edit {
  position: absolute;
  right: .18rem;
  bottom: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 650;
}

.personal-edit:hover { background: #f0f3f8; color: var(--ink); }
.personal-edit:focus-visible,
.personal-tile .star-button:focus-visible { z-index: 1; }

.status-panel {
  padding: .85rem 1rem;
  border: 1px solid var(--subtle);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--muted);
}

.status-panel + button { margin-top: .65rem; }
.personal-storage-status { margin-bottom: .5rem; color: var(--red); font-size: .875rem; }

.site-footer {
  min-height: 59px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .45rem 1rem;
  padding-block: .85rem;
  border-top: 1px solid var(--subtle);
  color: var(--muted);
  font-size: .8125rem;
}

.launchpad-panel .site-footer {
  min-height: 40px;
  padding-block: .45rem;
  background: var(--paper);
}

.admin-page { padding-top: 2.75rem; }

.admin-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.7rem;
}

.admin-heading h1 {
  font-size: clamp(2rem, 4.2vw, 2.9rem);
  font-weight: 740;
  letter-spacing: -.05em;
  line-height: 1.09;
}

.admin-heading p { margin-top: .6rem; color: var(--muted); }
.admin-heading button { flex: none; }

.admin-grid {
  display: grid;
  grid-template-columns: minmax(275px, .85fr) minmax(0, 1.6fr);
  align-items: start;
  gap: 1rem;
}

.panel {
  min-width: 0;
  padding: 1.35rem;
  border: 1px solid var(--subtle);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 2px 5px #14274007;
}

.sign-in-panel,
.status-panel#session-status { max-width: 29rem; }
.panel > h2 { margin-bottom: 1rem; }
.stack { display: grid; gap: 1rem; }
.stack > .button { justify-self: start; }
.field { display: grid; gap: .38rem; }
.field label { font-size: .9375rem; font-weight: 650; }

.field input,
.field textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: .52rem .7rem;
  border: 1px solid #c5cfdd;
  border-radius: 8px;
  background: #fcfdff;
  color: var(--ink);
}

.field textarea { resize: vertical; }

.field input[type="file"] { padding: .35rem; font-size: .875rem; }
.field input::file-selector-button {
  margin-right: .55rem;
  padding: .32rem .55rem;
  border: 1px solid var(--subtle);
  border-radius: 5px;
  background: var(--canvas);
  color: var(--ink);
  cursor: pointer;
}

.field-hint,
.admin-list-status { color: var(--muted); font-size: .875rem; }

.logo-preview {
  display: flex;
  align-items: center;
  gap: .65rem;
  color: var(--muted);
  font-size: .875rem;
}

.logo-preview img {
  padding: 5px;
  border: 1px solid var(--subtle);
  border-radius: 7px;
  object-fit: contain;
}

.form-status { color: #1e623a; font-size: .875rem; }
.form-status:empty { position: absolute; }
.error { color: #a32228; }
.admin-gallery-heading { margin-bottom: .65rem; }
.admin-list-status + button { margin-top: .65rem; }
.admin-list { margin: 0; padding: 0; list-style: none; }

.admin-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: .75rem;
  min-height: 59px;
  padding-block: .5rem;
}

.admin-list li + li { border-top: 1px solid #edf0f5; }
.admin-list img { object-fit: contain; }
.admin-list strong,
.admin-list span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-list strong { font-size: .9375rem; }
.admin-list span { color: var(--muted); font-size: .8125rem; }
.row-actions { display: flex; gap: .35rem; }
.row-action { min-height: 38px; padding: .38rem .7rem; }

.pinned-tile .tile-entry { padding-inline-end: .65rem; }
.icon-folder {
  position: relative;
  width: 15px;
  height: 10px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
}

.icon-folder::before {
  content: '';
  position: absolute;
  top: -4px;
  left: -1px;
  width: 7px;
  height: 4px;
  border: inherit;
  border-bottom: 0;
  border-radius: 2px 2px 0 0;
}

.groups-list { display: grid; gap: .75rem; }
.groups-list h3 { margin: 0 0 .35rem; font-size: .9375rem; overflow-wrap: anywhere; }
.app-group {
  padding: .65rem;
  border: 1px solid var(--subtle);
  border-radius: 10px;
}

.group-empty { margin: 0; font-size: .875rem; color: var(--muted); }
#group-drag-help, #group-drop-status:not(:empty) { margin-bottom: .6rem; }
.groups-dragging .app-group { border-style: dashed; border-color: #a6b5c9; }
.groups-dragging .group-drop-target { border-color: var(--focus); background: #e8effd; }
.tile-dragging { opacity: .55; }

@media (pointer: fine) {
  .tile-entry[draggable="true"]::before {
    content: '';
    width: 6px;
    height: 15px;
    flex: none;
    background: radial-gradient(circle, #8190a5 1px, transparent 1.15px) 0 0 / 3px 5px;
    cursor: grab;
  }
}

@media (pointer: coarse) {
  #group-drag-help { display: none; }
}

@media (min-width: 900px) {
  .gallery-expanded {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    column-gap: 1.15rem;
  }

  .gallery-expanded > .gallery-section {
    position: sticky;
    top: 1rem;
    align-self: start;
    min-width: 0;
    padding-left: 1.15rem;
    border-left: 1px solid var(--subtle);
  }

  .gallery-expanded #gallery-content { max-height: 68svh; overflow-y: auto; padding: .2rem; }
  .gallery-expanded #gallery-list { grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); }
}

.edit-dialog { width: min(100% - 32px, 29rem); color: var(--ink); }
.edit-dialog::backdrop { background: #0a1429a6; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; }

#groups-dialog { width: min(100% - 32px, 36rem); }
.groups-dialog-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.group-form { padding-block: 1rem; border-bottom: 1px solid var(--subtle); }
.group-form h3 { margin: 0; font-size: 1rem; }
.group-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.group-fields select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: .52rem .7rem;
  border: 1px solid #c5cfdd;
  border-radius: 8px;
  background: #fcfdff;
  color: var(--ink);
  font: inherit;
}

#group-status:not(:empty) { margin-top: .75rem; }

.personal-dialog .stack { gap: .75rem; }
.personal-dialog label span { color: var(--muted); font-weight: 500; }
.personal-dialog .personal-checkbox { display: flex; align-items: center; gap: .45rem; min-height: 28px; }
.personal-checkbox input { width: 1rem; min-height: 0; height: 1rem; margin: 0; accent-color: var(--red); }
.personal-delete { margin-right: auto; color: var(--red); }

@media (max-width: 820px) {
  .container { width: calc(100% - 40px); }
  .admin-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 540px) {
  .container { width: calc(100% - 32px); }
  .page { padding-block: 1.25rem 2.25rem; }
  .brand { gap: .65rem; }
  .site-footer { flex-wrap: wrap; }
  .launchpad-intro { grid-template-columns: minmax(0, 1fr); }
  .group-fields { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 490px) {
  .search kbd { display: none; }
}

@media (max-width: 470px) {
  .brand-divider, .brand-name { display: none; }
  .admin-heading { align-items: center; }
  .admin-list li { grid-template-columns: auto minmax(0, 1fr); }
  .row-actions { grid-column: 2; }
}
