:root {
  color-scheme: light;
  --bg: #f5f5f4;
  --surface: #ffffff;
  --surface-2: #fafaf9;
  --text: #18181b;
  --muted: #71717a;
  --line: #e4e4e7;
  --line-strong: #a1a1aa;
  --dark: #18181b;
  --danger: #b91c1c;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, p { margin-top: 0; }

.shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  position: relative;
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.topbar-title {
  position: absolute;
  left: 50%;
  font-size: 14px;
  font-weight: 700;
  transform: translateX(-50%);
}

.brand {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  background: var(--dark);
  font-size: 13px;
  font-weight: 800;
}

.brand-name {
  font-size: 14px;
  font-weight: 700;
}

.brand-name small {
  display: none;
}

.ghost-button,
.icon-button,
.button {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: var(--surface);
}

.ghost-button {
  min-height: 34px;
  padding: 0 11px;
  font-size: 12px;
}

.ghost-button:hover,
.icon-button:hover,
.button.secondary:hover {
  border-color: var(--line-strong);
}

.button {
  display: inline-flex;
  min-height: 38px;
  padding: 0 14px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-color: var(--dark);
  color: #fff;
  background: var(--dark);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}

.button:disabled { cursor: wait; opacity: .55; }

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

.button.danger {
  border-color: var(--danger);
  color: #fff;
  background: var(--danger);
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-visual { display: none; }

.login-form-side {
  width: 100%;
  max-width: 360px;
}

.login-card {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.login-card .lock {
  display: grid;
  width: 34px;
  height: 34px;
  margin-bottom: 22px;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  background: var(--dark);
  font-size: 14px;
}

.login-card h2 {
  margin-bottom: 7px;
  font-size: 21px;
  letter-spacing: -.02em;
}

.login-card > p {
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.field {
  display: grid;
  gap: 6px;
}

.field + .field { margin-top: 12px; }

.field label,
.mini-label {
  color: #52525b;
  font-size: 11px;
  font-weight: 650;
}

.input,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  color: var(--text);
  background: var(--surface);
}

.input {
  min-height: 38px;
  padding: 0 10px;
}

.textarea {
  min-height: 70px;
  padding: 9px 10px;
  resize: vertical;
}

.input:focus,
.textarea:focus {
  border-color: var(--dark);
  box-shadow: 0 0 0 1px var(--dark);
}

.login-card .button {
  width: 100%;
  margin-top: 12px;
}

.form-error {
  min-height: 18px;
  margin: 9px 0 0;
  color: var(--danger);
  font-size: 12px;
}

.secure-note { display: none; }

.hero {
  display: flex;
  padding: 18px 0 6px;
  justify-content: flex-end;
}

.search {
  position: relative;
  width: min(280px, 100%);
}

.search span {
  position: absolute;
  top: 50%;
  left: 11px;
  color: var(--muted);
  transform: translateY(-50%);
}

.search .input { padding-left: 32px; }

.section-block { padding: 17px 0; }

.section-heading {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
  padding-inline: 14px;
}

.section-icon {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
}

.svg-icon {
  display: block;
  width: 15px;
  height: 15px;
  background: currentColor;
  -webkit-mask: var(--icon-url) center / contain no-repeat;
  mask: var(--icon-url) center / contain no-repeat;
}

.section-heading h2 {
  margin-bottom: 1px;
  font-size: 14px;
}

.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 11px;
}

.resource-grid {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.resource-card {
  display: grid;
  min-height: 64px;
  padding: 11px 13px;
  grid-template-columns: 34px minmax(150px, .55fr) minmax(180px, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.resource-card:last-child { border-bottom: 0; }
.resource-card:hover { background: var(--surface-2); }

.resource-top {
  display: contents;
}

.resource-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 5px;
  background: #f4f4f5;
}

.resource-card h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
}

.resource-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.badge {
  grid-column: 4;
  grid-row: 1;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
  white-space: nowrap;
}

.download-button {
  grid-column: 5;
  grid-row: 1;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.download-button:hover { text-decoration: underline; }

.empty {
  padding: 36px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.footer {
  display: flex;
  margin-top: 30px;
  padding: 20px 0 30px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}

.admin-layout {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 190px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  padding: 18px 14px;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.sidebar-label {
  margin: 28px 8px 8px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  min-height: 34px;
  padding: 0 9px;
  align-items: center;
  gap: 7px;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
}

.nav-item.active {
  color: var(--text);
  background: #f4f4f5;
}

.nav-item.button-reset {
  width: 100%;
  border: 0;
}

.sidebar-bottom { margin-top: auto; }

.admin-main {
  min-width: 0;
  padding: 28px clamp(20px, 4vw, 44px) 60px;
}

.admin-header {
  display: flex;
  margin-bottom: 24px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.admin-header h1 {
  margin-bottom: 4px;
  font-size: 23px;
  letter-spacing: -.03em;
}

.admin-header p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 11px;
}

.admin-actions { display: flex; gap: 7px; }

.settings-card,
.editor-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.settings-card {
  display: grid;
  margin-bottom: 22px;
  padding: 17px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.settings-card h2 {
  grid-column: 1 / -1;
  margin-bottom: 0;
  font-size: 14px;
}

.editor-toolbar {
  display: flex;
  margin: 26px 0 10px;
  align-items: center;
  justify-content: space-between;
}

.editor-toolbar h2 {
  margin: 0;
  font-size: 14px;
}

.editor-sections { display: grid; gap: 10px; }
.editor-section {
  position: relative;
  overflow: visible;
}

.editor-section:has(.icon-picker.open) {
  z-index: 10;
}

.editor-section-head {
  display: grid;
  padding: 13px;
  grid-template-columns: 48px minmax(150px, .7fr) minmax(190px, 1fr) auto;
  gap: 9px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.editor-section-actions,
.resource-actions {
  display: flex;
  gap: 5px;
}

.icon-button {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  font-size: 12px;
}

.icon-button.delete:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.resource-editor-list {
  display: grid;
  gap: 1px;
  background: var(--line);
}

.resource-editor {
  display: grid;
  padding: 12px 13px;
  grid-template-columns: 48px minmax(140px, .65fr) minmax(180px, 1fr) minmax(180px, 1.2fr) 95px auto;
  gap: 8px;
  align-items: end;
  background: var(--surface);
}

.add-resource {
  padding: 11px 13px;
  border-top: 1px solid var(--line);
}

.mini-label {
  display: block;
  margin-bottom: 5px;
  font-size: 9px;
  text-transform: uppercase;
}

.icon-field {
  min-width: 0;
}

.icon-picker {
  position: relative;
}

.icon-picker-trigger {
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: var(--surface);
}

.icon-picker-trigger:hover,
.icon-picker.open .icon-picker-trigger {
  border-color: var(--dark);
}

.icon-picker-trigger .svg-icon,
.icon-choice .svg-icon {
  width: 17px;
  height: 17px;
}

.icon-picker-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 15;
  display: none;
  width: 326px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}

.icon-picker.open .icon-picker-menu {
  display: block;
}

.icon-choice-grid {
  display: grid;
  grid-template-columns: repeat(8, 34px);
  gap: 5px;
}

.icon-choice {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
}

.icon-choice:hover {
  background: var(--surface-2);
  border-color: var(--line);
}

.icon-choice.selected {
  border-color: var(--dark);
  background: #f4f4f5;
}

.palette-label {
  margin: 7px 2px 5px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.color-preset-grid {
  display: grid;
  grid-template-columns: repeat(5, 34px);
  gap: 5px;
}

.color-preset {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
}

.color-preset:hover,
.color-preset.selected {
  border-color: var(--dark);
}

.color-preset > span {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 5px;
}

.color-preset .svg-icon {
  width: 13px;
  height: 13px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(340px, calc(100% - 36px));
  padding: 10px 12px;
  border: 1px solid var(--dark);
  border-radius: 6px;
  opacity: 0;
  color: #fff;
  background: var(--dark);
  transform: translateY(8px);
  pointer-events: none;
  transition: 140ms ease;
  font-size: 11px;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); border-color: var(--danger); }

.loading {
  display: grid;
  min-height: 100vh;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 800px) {
  .resource-card {
    grid-template-columns: 34px minmax(120px, .7fr) minmax(140px, 1fr) auto;
  }
  .badge { display: none; }
  .download-button { grid-column: 4; }
  .admin-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    padding: 12px 16px;
    flex-direction: row;
    align-items: center;
  }
  .sidebar-label, .sidebar .nav-item.active, .sidebar-bottom { display: none; }
  .editor-section-head { grid-template-columns: 48px 1fr 1fr; }
  .editor-section-actions { grid-column: 1 / -1; }
  .resource-editor { grid-template-columns: 48px 1fr 1fr; }
  .resource-editor .url-field { grid-column: 1 / 3; }
}

@media (max-width: 580px) {
  .shell { width: min(100% - 22px, 1040px); }
  .hero { padding-top: 14px; }
  .search { width: 100%; }
  .topbar-title {
    font-size: 12px;
  }
  .resource-card {
    grid-template-columns: 32px 1fr auto;
    gap: 9px;
  }
  .resource-card p { display: none; }
  .download-button { grid-column: 3; }
  .footer, .admin-header {
    align-items: flex-start;
    flex-direction: column;
  }
  .settings-card { grid-template-columns: 1fr; }
  .settings-card h2 { grid-column: 1; }
  .admin-actions { width: 100%; }
  .admin-actions .button { flex: 1; }
  .editor-section-head,
  .resource-editor { grid-template-columns: 1fr; }
  .editor-section-actions,
  .resource-editor .url-field { grid-column: 1; }

  .icon-picker-menu {
    width: 248px;
  }

  .icon-choice-grid {
    grid-template-columns: repeat(6, 34px);
  }
}
