:root {
  color-scheme: light;
  --ink: #171a16;
  --ink-soft: #5e655c;
  --paper: #f3f3ed;
  --surface: #ffffff;
  --surface-muted: #e9ebe3;
  --line: #d7dacd;
  --accent: #c9f431;
  --accent-deep: #a7d30b;
  --danger: #c43c32;
  --danger-soft: #fff0ee;
  --blue: #d9e8ff;
  --orange: #ffe4bd;
  --violet: #e8ddff;
  --shadow: 0 18px 50px rgba(31, 37, 26, 0.1);
  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 88% 0%, rgba(201, 244, 49, 0.16), transparent 24rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

svg {
  width: 1.2em;
  height: 1.2em;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

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

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 72px 6px 38px;
}

.brand-line,
.section-kicker {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.17em;
}

.brand-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--accent);
  background: var(--ink);
  border-radius: 10px;
  transform: rotate(-4deg);
}

.brand-mark svg {
  width: 19px;
  height: 19px;
  stroke-width: 1.9;
}

.hero h1 {
  margin: 18px 0 8px;
  font-size: clamp(3.25rem, 8vw, 6.8rem);
  font-weight: 850;
  letter-spacing: -0.075em;
  line-height: 0.92;
}

.hero-copy > p:last-child {
  max-width: 34rem;
  margin: 20px 0 0;
  color: var(--ink-soft);
  font-size: clamp(1rem, 1.5vw, 1.18rem);
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  font-weight: 750;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

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

.button:focus-visible,
.icon-button:focus-visible,
.tool-card:focus-visible,
.chip:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(167, 211, 11, 0.4);
  outline-offset: 2px;
}

.button-primary {
  color: #171a16;
  background: var(--accent);
  box-shadow: 0 10px 24px rgba(167, 211, 11, 0.22);
}

.button-primary:hover {
  background: #d5fb4d;
  box-shadow: 0 13px 28px rgba(167, 211, 11, 0.3);
}

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

.button-quiet {
  color: var(--ink-soft);
  border-color: var(--line);
}

.button-danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.button-small {
  min-height: 38px;
  padding: 7px 13px;
  font-size: 0.84rem;
}

.hero-add {
  min-width: 142px;
  margin-bottom: 4px;
}

.hero-add svg {
  stroke-width: 2.2;
}

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

.stat-card {
  min-height: 164px;
  padding: 22px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(215, 218, 205, 0.9);
  border-radius: var(--radius-md);
  backdrop-filter: blur(10px);
}

.stat-card strong {
  display: block;
  margin: 16px 0 3px;
  font-size: 2.85rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.06em;
  line-height: 1;
}

.stat-label {
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 750;
}

.stat-caption {
  color: #858b80;
  font-size: 0.78rem;
}

.stat-accent {
  color: white;
  background: var(--ink);
  border-color: var(--ink);
  overflow: hidden;
  position: relative;
}

.stat-accent::after {
  position: absolute;
  right: -33px;
  bottom: -53px;
  width: 130px;
  height: 130px;
  background: var(--accent);
  border-radius: 50%;
  content: "";
  opacity: 0.95;
}

.stat-accent .stat-label,
.stat-accent .stat-caption {
  color: #bac0b5;
}

.catalog-panel {
  padding: 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.catalog-topline,
.filter-row,
.form-section-heading,
.form-actions,
.detail-topline,
.detail-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.catalog-topline h2,
.editor-heading h2 {
  margin: 6px 0 0;
  font-size: clamp(1.7rem, 3vw, 2.35rem);
  letter-spacing: -0.04em;
}

.controls {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 12px;
  margin: 28px 0 18px;
}

.search-control,
.status-control {
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.search-control {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 15px;
  background: #fafbf7;
}

.search-control svg {
  flex: 0 0 auto;
  color: #7b8275;
}

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

.search-control input::placeholder {
  color: #969c91;
}

.status-control {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 5px 0 14px;
  color: var(--ink-soft);
  background: #fafbf7;
  font-size: 0.82rem;
  font-weight: 700;
}

.status-control select {
  min-width: 110px;
  height: 40px;
  padding: 0 28px 0 8px;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-weight: 700;
}

.filter-row {
  align-items: flex-start;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 34px;
  padding: 6px 13px;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 750;
}

.chip:hover,
.chip.is-active {
  color: var(--ink);
  background: var(--accent);
  border-color: var(--accent-deep);
}

.result-count {
  flex: 0 0 auto;
  margin: 7px 0 0;
  color: #858b80;
  font-size: 0.8rem;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding-top: 22px;
}

.tool-card {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 294px;
  padding: 22px;
  flex-direction: column;
  color: inherit;
  text-align: left;
  background: #fafbf7;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.tool-card::after {
  position: absolute;
  top: 0;
  right: 0;
  width: 78px;
  height: 6px;
  background: var(--card-accent, var(--accent));
  border-bottom-left-radius: 6px;
  content: "";
}

.tool-card:hover {
  border-color: #bfc4b5;
  box-shadow: 0 16px 28px rgba(31, 37, 26, 0.1);
  transform: translateY(-3px);
}

.card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.category-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 800;
}

.category-badge {
  padding: 6px 9px;
  background: var(--surface-muted);
  border-radius: 7px;
}

.status-badge {
  color: var(--ink-soft);
}

.status-dot {
  width: 7px;
  height: 7px;
  background: #6e7670;
  border-radius: 50%;
}

.status-owned .status-dot {
  background: #57a53f;
  box-shadow: 0 0 0 3px rgba(87, 165, 63, 0.14);
}

.status-ordered .status-dot {
  background: #d58b1a;
}

.status-lent .status-dot {
  background: #517ebd;
}

.status-maintenance .status-dot {
  background: #c43c32;
}

.status-wishlist .status-dot {
  background: #965ab7;
}

.tool-card h3 {
  display: -webkit-box;
  margin: 21px 0 8px;
  font-size: 1.12rem;
  letter-spacing: -0.02em;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.tool-meta {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 650;
}

.tool-meta span + span::before {
  margin: 0 7px;
  color: #b5baae;
  content: "·";
}

.spec-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: auto 0 18px;
  padding-top: 22px;
}

.spec-pill {
  max-width: 100%;
  padding: 6px 8px;
  color: #60675c;
  background: #eff0e9;
  border-radius: 7px;
  font-size: 0.71rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 15px;
  color: #8b9186;
  border-top: 1px solid var(--line);
  font-size: 0.74rem;
}

.card-arrow {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.card-arrow svg {
  width: 14px;
  height: 14px;
}

.empty-state {
  padding: 72px 24px 54px;
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 62px;
  height: 62px;
  margin: 0 auto 16px;
  place-items: center;
  color: var(--ink-soft);
  background: var(--surface-muted);
  border-radius: 20px;
  transform: rotate(-4deg);
}

.empty-icon svg {
  width: 29px;
  height: 29px;
}

.empty-state h3 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

.empty-state p {
  margin: 0 0 20px;
  color: var(--ink-soft);
}

footer {
  padding: 26px 0 44px;
  color: #777e72;
  text-align: center;
  font-size: 0.75rem;
}

.modal {
  width: min(760px, calc(100% - 32px));
  max-height: min(880px, calc(100vh - 32px));
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 90px rgba(16, 19, 14, 0.28);
  overflow: hidden;
}

.modal::backdrop {
  background: rgba(20, 24, 18, 0.62);
  backdrop-filter: blur(5px);
}

.modal-frame {
  position: relative;
  max-height: min(880px, calc(100vh - 32px));
  padding: 34px;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  z-index: 2;
  top: 20px;
  right: 20px;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  color: var(--ink-soft);
  background: var(--surface-muted);
  border: 0;
  border-radius: 50%;
}

.icon-button:hover {
  color: var(--ink);
  background: #dde0d5;
}

.detail-hero {
  margin: -34px -34px 0;
  padding: 34px 72px 30px 34px;
  background: #f3f4ed;
  border-bottom: 1px solid var(--line);
}

.detail-topline {
  justify-content: flex-start;
}

.detail-hero h2 {
  max-width: 590px;
  margin: 22px 0 12px;
  font-size: clamp(1.7rem, 4.5vw, 2.55rem);
  letter-spacing: -0.05em;
  line-height: 1.1;
}

.detail-subtitle {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.detail-section {
  padding: 28px 0;
  border-bottom: 1px solid var(--line);
}

.detail-section:last-of-type {
  border-bottom: 0;
}

.detail-section h3,
.form-section h3 {
  margin: 0 0 15px;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
}

.detail-list,
.spec-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.detail-item,
.spec-item {
  min-width: 0;
  padding: 14px;
  background: #f7f8f3;
  border-radius: 12px;
}

.detail-item dt,
.spec-item dt {
  margin-bottom: 6px;
  color: #81877d;
  font-size: 0.7rem;
  font-weight: 750;
}

.detail-item dd,
.spec-item dd {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.detail-note {
  margin: 0;
  padding: 16px;
  color: #4f564c;
  background: #f7f8f3;
  border-left: 3px solid var(--accent-deep);
  border-radius: 0 12px 12px 0;
  line-height: 1.65;
  white-space: pre-wrap;
}

.detail-actions {
  justify-content: flex-end;
  padding-top: 26px;
}

.detail-actions .button-danger {
  margin-right: auto;
}

.editor-modal {
  width: min(820px, calc(100% - 32px));
}

.editor-heading {
  padding-right: 48px;
}

.editor-heading > p:last-child {
  margin: 9px 0 0;
  color: var(--ink-soft);
}

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

.form-section {
  margin-top: 30px;
  padding-top: 25px;
  border-top: 1px solid var(--line);
}

.form-section-heading {
  align-items: flex-start;
  margin-bottom: 14px;
}

.form-section-heading h3 {
  margin-bottom: 4px;
}

.form-section-heading p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.76rem;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
}

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

.field > span {
  color: #596057;
  font-size: 0.76rem;
  font-weight: 750;
}

.field em {
  color: var(--danger);
  font-style: normal;
}

.field input,
.field select,
.field textarea,
.spec-key,
.spec-value {
  width: 100%;
  color: var(--ink);
  background: #fafbf7;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: 0;
}

.field input,
.field select,
.spec-key,
.spec-value {
  height: 44px;
  padding: 0 12px;
}

.field textarea {
  min-height: 88px;
  padding: 11px 12px;
  resize: vertical;
}

.spec-editor {
  display: grid;
  gap: 8px;
}

.spec-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.7fr) minmax(180px, 1.3fr) 38px;
  gap: 8px;
}

.remove-spec-button {
  align-self: center;
}

.spec-empty {
  padding: 15px;
  color: #858b80;
  text-align: center;
  background: #f7f8f3;
  border: 1px dashed var(--line);
  border-radius: 12px;
  font-size: 0.78rem;
}

.form-actions {
  position: sticky;
  bottom: -34px;
  margin: 30px -34px -34px;
  padding: 18px 34px;
  justify-content: flex-end;
  background: rgba(255, 255, 255, 0.95);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.toast {
  position: fixed;
  z-index: 10;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100% - 48px));
  padding: 12px 16px;
  color: white;
  background: var(--ink);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  font-weight: 650;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tool-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .page-shell {
    width: min(100% - 24px, 1280px);
  }

  .hero {
    align-items: flex-start;
    padding: 42px 2px 28px;
    flex-direction: column;
  }

  .hero-add {
    width: 100%;
  }

  .catalog-panel {
    padding: 20px;
    border-radius: 20px;
  }

  .catalog-topline {
    align-items: flex-start;
    flex-direction: column;
  }

  .catalog-actions,
  .catalog-actions .button {
    width: 100%;
  }

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

  .status-control {
    justify-content: space-between;
  }

  .filter-row {
    flex-direction: column;
  }

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

  .tool-card {
    min-height: 272px;
  }

  .modal,
  .editor-modal {
    width: 100%;
    max-width: none;
    max-height: calc(100vh - 12px);
    margin: auto 0 0;
    border-radius: 22px 22px 0 0;
  }

  .modal-frame {
    max-height: calc(100vh - 12px);
    padding: 26px 20px;
  }

  .detail-hero {
    margin: -26px -20px 0;
    padding: 29px 62px 25px 20px;
  }

  .modal-close {
    top: 16px;
    right: 16px;
  }

  .form-grid,
  .detail-list,
  .spec-list {
    grid-template-columns: 1fr;
  }

  .spec-row {
    grid-template-columns: 1fr 1fr 38px;
  }

  .form-actions {
    bottom: -26px;
    margin: 28px -20px -26px;
    padding: 15px 20px;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    gap: 8px;
  }

  .stat-card {
    min-height: 134px;
    padding: 16px;
  }

  .stat-card strong {
    margin-top: 13px;
    font-size: 2.25rem;
  }

  .stat-caption {
    display: none;
  }

  .spec-row {
    grid-template-columns: 1fr 38px;
  }

  .spec-key {
    grid-column: 1 / -1;
  }
}

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