:root {
  color-scheme: light;
  --ink: #10243e;
  --muted: #60738a;
  --line: rgba(21, 68, 104, 0.12);
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --primary: #087fbd;
  --primary-dark: #08639a;
  --cyan: #12c9c1;
  --shadow: 0 22px 58px rgba(17, 71, 116, 0.13);
  --shadow-soft: 0 10px 30px rgba(17, 71, 116, 0.09);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: #e8f7fb;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 5%, rgba(31, 219, 204, 0.48), transparent 29rem),
    radial-gradient(circle at 92% 0%, rgba(44, 105, 218, 0.5), transparent 34rem),
    linear-gradient(135deg, #d7fbf4 0%, #e5f5fb 42%, #e7f0ff 100%);
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

.background-pattern {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.38;
  background-image:
    linear-gradient(30deg, rgba(7, 135, 176, 0.13) 12%, transparent 12.5%, transparent 87%, rgba(7, 135, 176, 0.13) 87.5%, rgba(7, 135, 176, 0.13)),
    linear-gradient(150deg, rgba(7, 135, 176, 0.13) 12%, transparent 12.5%, transparent 87%, rgba(7, 135, 176, 0.13) 87.5%, rgba(7, 135, 176, 0.13)),
    linear-gradient(30deg, rgba(255, 255, 255, 0.2) 12%, transparent 12.5%, transparent 87%, rgba(255, 255, 255, 0.2) 87.5%, rgba(255, 255, 255, 0.2)),
    linear-gradient(150deg, rgba(255, 255, 255, 0.2) 12%, transparent 12.5%, transparent 87%, rgba(255, 255, 255, 0.2) 87.5%, rgba(255, 255, 255, 0.2));
  background-size: 132px 230px;
  background-position: 0 0, 0 0, 66px 115px, 66px 115px;
  mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.72) 43%, transparent 100%);
}

.page-shell {
  width: min(1160px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 30px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 58px;
  margin-bottom: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 10px);
  gap: 4px;
  width: 38px;
  height: 38px;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 13px;
  background: linear-gradient(140deg, #13cfc4, #2671d9);
  box-shadow: 0 10px 26px rgba(13, 123, 183, 0.24);
}

.brand-mark span {
  border-radius: 3px;
  background: #fff;
}

.brand-mark span:nth-child(2),
.brand-mark span:nth-child(3) {
  opacity: 0.7;
}

.brand-copy {
  display: grid;
  line-height: 1.05;
}

.brand-copy strong {
  font-size: 1rem;
  letter-spacing: 0.015em;
}

.brand-copy small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 650;
  font-size: 0.9rem;
  line-height: 1;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0);
}

.button:focus-visible,
.icon-button:focus-visible,
.tool-card:focus-visible,
.icon-choice:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(14, 165, 233, 0.26);
  outline-offset: 2px;
}

.button-primary {
  color: #fff;
  background: linear-gradient(135deg, #079bc3, #1667cb);
  box-shadow: 0 10px 22px rgba(13, 113, 187, 0.22);
}

.button-primary:hover {
  box-shadow: 0 13px 28px rgba(13, 113, 187, 0.28);
}

.button-secondary {
  color: #075f8f;
  border-color: rgba(8, 127, 189, 0.16);
  background: rgba(222, 247, 252, 0.8);
}

.button-quiet {
  border-color: rgba(23, 67, 102, 0.11);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 24px rgba(24, 85, 126, 0.07);
  backdrop-filter: blur(12px);
}

.button-danger {
  color: #fff;
  background: #dc3f59;
  box-shadow: 0 10px 22px rgba(201, 43, 70, 0.22);
}

.button-icon,
.category-icon,
.tool-icon svg,
.modal-icon svg,
.icon-choice svg,
.action-icon svg,
.empty-icon svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.button-icon {
  display: inline-flex;
}

.eyebrow {
  margin: 0 0 8px;
  color: #087aa8;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h2,
p {
  margin-top: 0;
}

.admin-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(7, 154, 176, 0.18);
  border-radius: 16px;
  background: rgba(223, 251, 250, 0.88);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
}

.admin-status {
  display: flex;
  align-items: center;
  gap: 11px;
}

.admin-status > div {
  display: grid;
  gap: 2px;
}

.admin-status strong {
  font-size: 0.9rem;
}

.admin-status span:not(.status-dot) {
  color: var(--muted);
  font-size: 0.78rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #16ad83;
  box-shadow: 0 0 0 5px rgba(22, 173, 131, 0.12);
}

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

.catalog {
  display: grid;
  gap: 20px;
}

.category-card {
  position: relative;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 40px;
  margin-bottom: 17px;
}

.category-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.category-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  color: var(--category-accent, var(--primary));
  border-radius: 10px;
  background: color-mix(in srgb, var(--category-accent, var(--primary)) 10%, white);
}

.category-icon svg {
  display: block;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
}

.category-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.25;
}

.category-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.75rem;
}

.category-actions,
.tool-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(24, 67, 101, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, color 150ms ease;
}

.icon-button:hover {
  color: var(--primary);
  background: #fff;
  transform: translateY(-1px);
}

.icon-button.danger:hover {
  color: #d52f4c;
  background: #fff1f3;
}

.action-icon {
  display: inline-flex;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.tool-item {
  position: relative;
  min-width: 0;
}

.tool-card {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 96px;
  padding: 14px;
  color: inherit;
  border: 1px solid rgba(22, 65, 98, 0.09);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.68);
  text-decoration: none;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease, background 180ms ease;
}

.tool-card:hover {
  z-index: 1;
  border-color: color-mix(in srgb, var(--accent) 24%, white);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 13px 28px color-mix(in srgb, var(--accent) 11%, transparent);
  transform: translateY(-3px);
}

.tool-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 13%, white);
  border-radius: 15px;
  background: color-mix(in srgb, var(--accent) 9%, white);
}

.tool-icon svg {
  width: 25px;
  height: 25px;
}

.tool-copy {
  display: grid;
  min-width: 0;
}

.tool-copy strong {
  overflow: hidden;
  font-size: 0.94rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-copy small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
  overflow-wrap: break-word;
  white-space: normal;
}

.tool-path {
  overflow: hidden;
  margin-top: 7px;
  color: color-mix(in srgb, var(--accent) 72%, #38516a);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.68rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-actions {
  position: absolute;
  z-index: 3;
  top: 7px;
  right: 7px;
  padding: 4px;
  border: 1px solid rgba(22, 65, 98, 0.09);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 7px 20px rgba(30, 70, 103, 0.13);
}

.tool-actions .icon-button {
  width: 29px;
  height: 29px;
  border: 0;
  background: transparent;
}

.tool-actions .action-icon svg {
  width: 16px;
  height: 16px;
}

.admin-mode .tool-card {
  padding-top: 43px;
}

.add-site-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 96px;
  padding: 14px;
  color: #18769c;
  border: 1px dashed rgba(8, 127, 189, 0.35);
  border-radius: var(--radius-lg);
  background: rgba(222, 247, 252, 0.48);
  cursor: pointer;
  font-weight: 700;
  transition: background 160ms ease, transform 160ms ease;
}

.add-site-card:hover {
  background: rgba(222, 247, 252, 0.88);
  transform: translateY(-2px);
}

.empty-category {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 84px;
  padding: 15px;
  color: var(--muted);
  border: 1px dashed rgba(33, 80, 115, 0.18);
  border-radius: var(--radius-lg);
}

.empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  color: #56a2b8;
  border-radius: 13px;
  background: rgba(207, 241, 247, 0.7);
}

.catalog-empty,
.catalog-error {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 32px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.catalog-empty h2,
.catalog-error h2 {
  margin: 14px 0 6px;
  font-size: 1.1rem;
}

.catalog-empty p,
.catalog-error p {
  margin-bottom: 17px;
  color: var(--muted);
}

.loading-card {
  display: grid;
  gap: 14px;
  padding: 25px;
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.72);
}

.loading-card span {
  height: 18px;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(124, 183, 200, 0.13), rgba(255, 255, 255, 0.8), rgba(124, 183, 200, 0.13));
  background-size: 220% 100%;
  animation: shimmer 1.4s infinite linear;
}

.loading-card span:nth-child(1) { width: 22%; }
.loading-card span:nth-child(2) { height: 76px; }
.loading-card span:nth-child(3) { width: 68%; }

@keyframes shimmer {
  to { background-position: -220% 0; }
}

footer {
  display: flex;
  justify-content: center;
  gap: 7px;
  padding: 27px 0 0;
  color: rgba(43, 75, 102, 0.62);
  font-size: 0.76rem;
}

.modal {
  width: min(640px, calc(100% - 28px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 0;
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 22px;
  background: rgba(252, 254, 255, 0.98);
  box-shadow: 0 32px 90px rgba(9, 47, 80, 0.32);
  overflow: auto;
}

.modal::backdrop {
  background: rgba(13, 39, 68, 0.42);
  backdrop-filter: blur(7px);
}

.modal-small {
  width: min(470px, calc(100% - 28px));
}

.modal form {
  padding: 24px;
}

.modal-heading {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.modal-heading .eyebrow {
  margin-bottom: 5px;
}

.modal-heading h2 {
  margin-bottom: 0;
  font-size: 1.28rem;
  line-height: 1.2;
}

.modal-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--primary);
  border-radius: 14px;
  background: #e5f5fb;
}

.modal-close {
  align-self: start;
  font-size: 1.35rem;
  line-height: 1;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: #29435d;
  font-size: 0.86rem;
  font-weight: 700;
}

.field > span small {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.field input:not([type="color"]),
.field select {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  color: var(--ink);
  border: 1px solid rgba(31, 78, 112, 0.16);
  border-radius: 12px;
  background: #f8fbfd;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.field input:not([type="color"]):hover,
.field select:hover {
  border-color: rgba(8, 127, 189, 0.32);
}

.field input:not([type="color"]):focus,
.field select:focus {
  border-color: #1493c3;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(20, 147, 195, 0.09);
  outline: none;
}

.field-help {
  margin-top: -2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.45;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  gap: 14px;
}

.form-grid-bottom {
  align-items: end;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 1fr);
}

.color-field {
  grid-template-columns: minmax(0, 1fr) 50px auto;
  align-items: center;
}

.color-field > span {
  grid-column: 1 / -1;
}

.color-field input[type="color"] {
  width: 50px;
  height: 42px;
  padding: 3px;
  border: 1px solid rgba(31, 78, 112, 0.16);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.color-field output {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 600;
}

.icon-picker {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 7px;
  max-height: 145px;
  padding: 3px 3px 5px;
  overflow-y: auto;
}

.icon-picker.compact {
  grid-template-columns: repeat(10, 1fr);
  max-height: 105px;
}

.icon-choice {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  min-width: 38px;
  padding: 0;
  color: #526b81;
  border: 1px solid rgba(31, 78, 112, 0.12);
  border-radius: 11px;
  background: #f7fafc;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.icon-choice:hover {
  color: #087fbd;
  border-color: rgba(8, 127, 189, 0.25);
  background: #edf9fc;
  transform: translateY(-1px);
}

.icon-choice.selected {
  color: #fff;
  border-color: #087fbd;
  background: linear-gradient(135deg, #11b8bd, #1670cf);
  box-shadow: 0 7px 16px rgba(10, 120, 183, 0.2);
}

.switch-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  margin-bottom: 16px;
  color: #29435d;
  font-size: 0.85rem;
  font-weight: 650;
  cursor: pointer;
}

.switch-field input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #c7d4df;
  transition: background 160ms ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 7px rgba(22, 52, 77, 0.24);
  transition: transform 160ms ease;
}

.switch-field input:checked + .switch {
  background: #0d9db7;
}

.switch-field input:checked + .switch::after {
  transform: translateX(18px);
}

.switch-field input:focus-visible + .switch {
  outline: 3px solid rgba(14, 165, 233, 0.26);
  outline-offset: 2px;
}

.form-error {
  min-height: 19px;
  margin: 0 0 6px;
  color: #cf3450;
  font-size: 0.8rem;
  line-height: 1.45;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 6px;
}

.danger-heading .modal-icon {
  color: #cf3450;
  background: #fff0f3;
}

.danger-heading .eyebrow {
  color: #cf3450;
}

.confirm-copy {
  color: var(--muted);
  line-height: 1.7;
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100% - 40px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 15px;
  color: #fff;
  border-radius: 13px;
  background: rgba(17, 46, 73, 0.94);
  box-shadow: 0 14px 38px rgba(12, 41, 70, 0.28);
  font-size: 0.84rem;
  line-height: 1.45;
  opacity: 0;
  transform: translateY(10px);
  animation: toast-in 220ms ease forwards;
}

.toast.success::before,
.toast.error::before {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-weight: 800;
}

.toast.success::before {
  content: "✓";
  background: #16ad83;
}

.toast.error::before {
  content: "!";
  background: #df405b;
}

@keyframes toast-in {
  to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 761px) and (max-width: 980px) {
  .tools-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 24px, 620px);
    padding-top: 16px;
  }

  .topbar {
    margin-bottom: 24px;
  }

  .admin-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .category-card {
    padding: 17px;
    border-radius: 20px;
  }

  .tools-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .tool-card {
    grid-template-columns: 44px minmax(0, 1fr);
    min-height: 106px;
    padding: 12px;
  }

  .tool-icon {
    width: 44px;
    height: 44px;
    border-radius: 13px;
  }

  .tool-icon svg {
    width: 23px;
    height: 23px;
  }

  .tool-copy small {
    display: block;
  }

  .tool-path {
    font-size: 0.64rem;
  }

  .form-grid,
  .form-grid-bottom {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .icon-picker,
  .icon-picker.compact {
    grid-template-columns: repeat(6, 1fr);
  }
}

@media (max-width: 480px) {
  .brand-copy small {
    display: none;
  }

  .topbar .button {
    padding: 0 13px;
  }

  .category-header {
    align-items: flex-start;
  }

  .category-actions {
    display: grid;
    grid-template-columns: repeat(2, 34px);
  }

  .tools-grid {
    grid-template-columns: 1fr 1fr;
  }

  .tool-card {
    display: flex;
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
    min-height: 150px;
  }

  .tool-copy {
    width: 100%;
  }

  .admin-mode .tool-card {
    padding-top: 46px;
  }

  .tool-actions {
    left: 7px;
    right: 7px;
    justify-content: flex-end;
  }

  .modal form {
    padding: 19px;
  }

  .modal-heading {
    grid-template-columns: 40px minmax(0, 1fr) 34px;
  }

  .modal-icon {
    width: 40px;
    height: 40px;
  }

  .icon-picker,
  .icon-picker.compact {
    grid-template-columns: repeat(5, 1fr);
  }

  .modal-actions .button {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
