:root {
  color-scheme: light;
  --bg: #f5f9ff;
  --panel: #ffffff;
  --panel-soft: #eef6ff;
  --line: #d7e7f7;
  --line-strong: #a9cbed;
  --text: #15243a;
  --muted: #62748d;
  --blue: #1769e0;
  --blue-strong: #0d55c7;
  --cyan: #0ea5c6;
  --green: #119c67;
  --shadow: 0 18px 50px rgba(17, 76, 142, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, #e8f4ff 0, #f8fbff 280px, var(--bg) 100%);
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 56px;
}

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

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

.brand-logo {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: #ffffff;
  background: var(--blue);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(23, 105, 224, 0.22);
}

.brand-logo svg {
  width: 24px;
  height: 24px;
}

.brand strong,
.brand span span {
  display: block;
}

.brand strong {
  font-size: 18px;
  line-height: 1.2;
}

.brand span span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions,
.search-panel,
.inline-actions,
.form-actions,
.upload-zone {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button,
.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.icon-button {
  width: 40px;
  color: var(--blue);
  background: rgba(255, 255, 255, 0.78);
  border-color: var(--line);
}

.primary-button,
.secondary-button {
  gap: 8px;
  padding: 0 14px;
  font-weight: 700;
}

.primary-button {
  color: #ffffff;
  background: var(--blue);
  box-shadow: 0 12px 24px rgba(23, 105, 224, 0.22);
}

.secondary-button {
  color: var(--blue);
  background: #ffffff;
  border-color: var(--line);
  text-decoration: none;
}

.icon-button:hover,
.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
}

.primary-button:hover {
  background: var(--blue-strong);
}

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

.main {
  padding-top: 26px;
}

.workspace-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.title-block h1,
.modal-header h2 {
  margin: 0;
  font-size: 32px;
  line-height: 1.15;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(420px, 100%);
  height: 44px;
  padding: 0 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search-box input {
  width: 100%;
  min-width: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
}

.counter {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  background: rgba(17, 156, 103, 0.1);
  border: 1px solid rgba(17, 156, 103, 0.2);
  border-radius: 8px;
  white-space: nowrap;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.category-stack {
  display: grid;
  gap: 26px;
}

.category-section {
  display: grid;
  gap: 14px;
}

.category-header,
.panel-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.category-header h2,
.panel-header h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.category-eyebrow {
  margin-bottom: 6px;
}

.category-count {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 9px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 850;
  background: rgba(23, 105, 224, 0.08);
  border: 1px solid rgba(23, 105, 224, 0.16);
  border-radius: 8px;
  white-space: nowrap;
}

.tool-card {
  min-height: 156px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.tool-link {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  min-height: 156px;
  padding: 18px;
  color: inherit;
  text-decoration: none;
}

.tool-logo {
  position: relative;
  display: grid;
  grid-row: 1 / span 2;
  width: 56px;
  height: 56px;
  place-items: center;
  overflow: hidden;
  color: var(--blue);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tool-logo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tool-logo img[src=""],
.tool-logo img.is-hidden {
  display: none;
}

.tool-initials {
  font-size: 18px;
  font-weight: 900;
}

.tool-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 6px;
}

.tool-title {
  overflow-wrap: anywhere;
  font-size: 18px;
  font-weight: 850;
  line-height: 1.25;
}

.tool-subtitle {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 24px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  max-width: 100%;
  padding: 0 7px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-overflow: ellipsis;
  background: #f7fbff;
  border: 1px solid var(--line);
  border-radius: 8px;
  white-space: nowrap;
}

.tool-path {
  grid-column: 1 / span 2;
  align-self: end;
  width: fit-content;
  max-width: 100%;
  padding: 6px 9px;
  overflow: hidden;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  background: rgba(23, 105, 224, 0.08);
  border: 1px solid rgba(23, 105, 224, 0.16);
  border-radius: 8px;
  white-space: nowrap;
}

.tool-arrow {
  display: grid;
  grid-column: 3;
  grid-row: 1;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--blue);
  background: #f3f8ff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tool-card:hover {
  border-color: var(--line-strong);
}

.tool-card:hover .tool-arrow {
  color: #ffffff;
  background: var(--blue);
}

.empty-state {
  display: grid;
  min-height: 220px;
  place-items: center;
  padding: 32px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.74);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
}

.empty-state h2 {
  margin: 10px 0 0;
  font-size: 18px;
}

.empty-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--blue);
  font-size: 24px;
  font-weight: 800;
  background: var(--panel-soft);
  border-radius: 8px;
}

.is-hidden,
.is-disabled {
  display: none !important;
}

.modal {
  width: min(720px, calc(100% - 28px));
  padding: 0;
  background: transparent;
  border: 0;
}

.modal::backdrop {
  background: rgba(14, 33, 58, 0.38);
  backdrop-filter: blur(8px);
}

.modal-panel {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 28px 70px rgba(10, 40, 82, 0.28);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  font-size: 24px;
}

.modal-body {
  padding: 18px 20px 20px;
}

.manage-grid {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(0, 1.6fr);
  gap: 16px;
  align-items: start;
}

.panel {
  display: grid;
  gap: 16px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.add-panel {
  margin-top: 16px;
}

.manage-tool-list {
  display: grid;
  gap: 10px;
}

.manage-tool {
  display: grid;
  gap: 5px;
  width: 100%;
  min-height: 64px;
  padding: 12px;
  color: var(--text);
  text-align: left;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.manage-tool:hover,
.manage-tool.is-active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 105, 224, 0.12);
}

.manage-tool-title {
  overflow-wrap: anywhere;
  font-weight: 850;
}

.manage-tool-meta,
.empty-inline {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.empty-inline {
  min-height: 120px;
  padding: 18px;
  background: var(--panel-soft);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
}

.upload-zone {
  align-items: stretch;
  margin-bottom: 16px;
}

.upload-drop {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex: 1;
  min-width: 0;
  min-height: 66px;
  gap: 14px;
  padding: 0 16px;
  color: var(--text);
  text-align: left;
  background: var(--panel-soft);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
}

.upload-drop svg {
  flex: 0 0 auto;
  color: var(--blue);
}

.upload-drop span {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.upload-drop strong,
.upload-drop small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-drop small {
  color: var(--muted);
}

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

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.field-wide {
  grid-column: 1 / -1;
}

.field input,
.field select,
.path-input {
  width: 100%;
  min-height: 42px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
}

.field input,
.field select {
  padding: 0 12px;
}

.field input:focus,
.field select:focus,
.path-input:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 105, 224, 0.14);
}

.path-input {
  display: flex;
  align-items: center;
  overflow: hidden;
}

.path-input span {
  display: grid;
  align-self: stretch;
  width: 36px;
  place-items: center;
  color: var(--blue);
  background: var(--panel-soft);
  border-right: 1px solid var(--line);
}

.path-input input {
  min-height: 40px;
  border: 0;
  border-radius: 0;
}

.inline-actions input {
  min-width: 0;
}

.status-line {
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-line.is-error {
  color: #b42318;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 12px;
  }

  .topbar,
  .workspace-header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .search-panel {
    justify-content: space-between;
  }

  .workspace-header > .counter {
    align-self: flex-start;
  }

  .search-box {
    flex: 1;
  }

  .title-block h1 {
    font-size: 28px;
  }

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

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

  .category-header,
  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .upload-zone,
  .inline-actions,
  .form-actions {
    flex-direction: column;
  }

  .upload-zone > *,
  .inline-actions > *,
  .form-actions > * {
    width: 100%;
  }

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