:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #65727d;
  --line: #dbe2e6;
  --paper: #f7f9f8;
  --panel: #ffffff;
  --soft: #edf3ef;
  --green: #1f7a5a;
  --green-deep: #0d4f3a;
  --blue: #2358a8;
  --amber: #9a6118;
  --dark: #11191f;
  --shadow: 0 18px 48px rgba(17, 25, 31, .12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(31, 122, 90, .08), transparent 34%),
    radial-gradient(circle at 88% 12%, rgba(35, 88, 168, .11), transparent 28%),
    var(--paper);
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
}

button,
input,
a {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 28px 18px;
  background: rgba(255, 255, 255, .72);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--green-deep), var(--blue));
  font-weight: 800;
}

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

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

.rail {
  display: grid;
  gap: 8px;
}

.rail-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}

.rail-item:hover,
.rail-item.active {
  color: var(--ink);
  background: var(--panel);
  border-color: var(--line);
}

.icon,
.search-icon,
.tool-icon,
.panel-close,
.add-symbol {
  position: relative;
  display: inline-block;
}

.grid-icon::before,
.grid-icon::after {
  content: "";
  position: absolute;
  inset: 4px;
  background:
    linear-gradient(var(--muted), var(--muted)) 0 0 / 7px 7px,
    linear-gradient(var(--muted), var(--muted)) 13px 0 / 7px 7px,
    linear-gradient(var(--muted), var(--muted)) 0 13px / 7px 7px,
    linear-gradient(var(--muted), var(--muted)) 13px 13px / 7px 7px;
  background-repeat: no-repeat;
}

.mail-icon::before,
.mail-tile::before {
  content: "";
  position: absolute;
  inset: 5px 3px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.mail-icon::after,
.mail-tile::after {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  top: 8px;
  height: 9px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
}

.spark-icon::before,
.image-tile::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 3px;
  width: 7px;
  height: 18px;
  background: currentColor;
  clip-path: polygon(50% 0, 65% 38%, 100% 50%, 65% 62%, 50% 100%, 35% 62%, 0 50%, 35% 38%);
}

.bolt-icon::before,
.flow-tile::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 3px;
  width: 11px;
  height: 20px;
  background: currentColor;
  clip-path: polygon(48% 0, 100% 0, 65% 42%, 100% 42%, 30% 100%, 45% 56%, 0 56%);
}

.workspace {
  min-width: 0;
  padding: 32px;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.04;
  letter-spacing: 0;
}

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

.search-wrap input {
  width: 100%;
  height: 44px;
  padding: 0 16px 0 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .84);
  outline: none;
}

.search-wrap input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 122, 90, .16);
}

.search-icon::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 13px;
  width: 12px;
  height: 12px;
  border: 2px solid var(--muted);
  border-radius: 50%;
}

.search-icon::after {
  content: "";
  position: absolute;
  left: 28px;
  top: 27px;
  width: 9px;
  height: 2px;
  background: var(--muted);
  transform: rotate(45deg);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.status-strip article {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 74px;
  padding: 14px;
  background: rgba(255, 255, 255, .74);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-strip small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.online {
  background: #16a36d;
  box-shadow: 0 0 0 5px rgba(22, 163, 109, .14);
}

.planned {
  background: #cf8b2d;
  box-shadow: 0 0 0 5px rgba(207, 139, 45, .15);
}

.neutral {
  background: #60727f;
  box-shadow: 0 0 0 5px rgba(96, 114, 127, .15);
}

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

.tool-card {
  display: flex;
  flex-direction: column;
  min-height: 268px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(17, 25, 31, .04);
}

.tool-card.hidden {
  display: none;
}

.tool-card.live {
  border-color: rgba(31, 122, 90, .28);
  box-shadow: var(--shadow);
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.tool-icon {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  color: var(--green-deep);
  background: var(--soft);
}

.image-tile {
  color: var(--blue);
  background: #eaf0fa;
}

.flow-tile {
  color: var(--amber);
  background: #f6efe5;
}

.badge {
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.live-badge {
  color: #0b6a48;
  background: #e4f5ed;
}

.planned-badge {
  color: #835313;
  background: #f8ecd8;
}

.tool-card h2 {
  margin-bottom: 8px;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 0;
}

.tool-card p {
  color: var(--muted);
  line-height: 1.6;
}

.card-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: auto;
}

.primary-action,
.ghost-action {
  display: inline-grid;
  place-items: center;
  min-width: 88px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.primary-action {
  color: #fff;
  background: var(--dark);
}

.ghost-action {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

.disabled-action {
  color: #6c7983;
  background: #edf1f3;
  cursor: not-allowed;
}

.add-card {
  justify-content: center;
  align-items: flex-start;
  background: repeating-linear-gradient(135deg, #fff, #fff 10px, #f4f7f5 10px, #f4f7f5 20px);
}

.add-symbol {
  width: 46px;
  height: 46px;
  margin-bottom: 22px;
  border: 1px dashed #9ca9b1;
  border-radius: 8px;
  background: rgba(255, 255, 255, .8);
}

.add-symbol::before,
.add-symbol::after {
  content: "";
  position: absolute;
  left: 13px;
  top: 22px;
  width: 20px;
  height: 2px;
  background: var(--muted);
}

.add-symbol::after {
  transform: rotate(90deg);
}

.detail-panel {
  position: fixed;
  top: 24px;
  right: 24px;
  width: min(380px, calc(100vw - 48px));
  padding: 22px;
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  transform: translateX(calc(100% + 32px));
  transition: transform .22s ease;
  z-index: 10;
}

.detail-panel.open {
  transform: translateX(0);
}

.panel-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.panel-close::before,
.panel-close::after {
  content: "";
  position: absolute;
  left: 9px;
  top: 15px;
  width: 13px;
  height: 2px;
  background: var(--ink);
}

.panel-close::before {
  transform: rotate(45deg);
}

.panel-close::after {
  transform: rotate(-45deg);
}

.panel-stack {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.panel-pill {
  padding: 10px 12px;
  color: var(--muted);
  background: #f5f7f6;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  padding: 10px 14px;
  color: #fff;
  background: var(--dark);
  border-radius: 8px;
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

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

@media (max-width: 780px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    gap: 14px;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .rail {
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .rail-item {
    flex: 0 0 auto;
    width: auto;
  }

  .workspace {
    padding: 20px;
  }

  .topbar,
  .status-strip {
    grid-template-columns: 1fr;
    display: grid;
  }

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