:root {
  --background: #f4f6f1;
  --foreground: #17201c;
  --muted: #63716a;
  --line: #dfe6dc;
  --paper: #ffffff;
  --paper-strong: #f9fbf7;
  --green: #2f6f5e;
  --coral: #d66a4b;
  --blue: #3e6aa8;
  --gold: #c99a2d;
  --purple: #8b5a9f;
  --shadow: 0 18px 50px rgba(40, 50, 43, 0.12);
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(47, 111, 94, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(214, 106, 75, 0.1), transparent 30%),
    var(--background);
  color: var(--foreground);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: progress; opacity: 0.62; }
a { color: inherit; text-decoration: none; }

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(18px);
}

.brand-block { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  background: #18251f;
  color: #fff8e7;
  font-size: .85rem;
  font-weight: 900;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 1.35rem; line-height: 1.2; }

.deploy-panel, .ops-head, .admin-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-strong);
}

.admin-banner { justify-content: space-between; margin-bottom: 14px; background: rgba(47,111,94,.08); }
.deploy-panel p, .ops-head p { margin: 0 0 3px; color: var(--muted); font-size: .78rem; }
.deploy-panel strong, .ops-head strong, .admin-banner strong { color: var(--foreground); font-size: .95rem; }

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(47, 111, 94, 0.13);
}

.category-list { display: grid; gap: 8px; }
.category {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #34443d;
  text-align: left;
}
.category:hover, .category.active {
  border-color: rgba(47,111,94,.2);
  background: rgba(47,111,94,.08);
  color: var(--foreground);
}
.category strong {
  display: grid;
  min-width: 30px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  background: #fff;
  color: var(--green);
  font-size: .75rem;
}

.source-card {
  margin-top: auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}
.source-card img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.source-card a { display: block; padding: 12px; color: #34443d; font-size: .84rem; font-weight: 800; }

.workspace { min-width: 0; padding: 24px; }
.topbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.search-wrap { position: relative; }
.search-wrap label {
  position: absolute;
  left: 16px;
  top: 10px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
}
.search-wrap input {
  width: 100%;
  min-height: 62px;
  padding: 25px 16px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: rgba(255,255,255,.86);
  color: var(--foreground);
  box-shadow: 0 10px 30px rgba(35,45,40,.06);
}
.search-wrap input:focus {
  border-color: rgba(47,111,94,.48);
  box-shadow: 0 0 0 4px rgba(47,111,94,.12);
}

.actions, .admin-links { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.icon-button, .icon-only, .card-actions a, .card-actions button, .admin-links a, .editor-actions button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--foreground);
  font-weight: 900;
}
.icon-button, .admin-links a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}
.icon-button span:first-child, .icon-only span {
  display: grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 6px;
  background: rgba(47,111,94,.1);
  color: var(--green);
  font-size: .7rem;
  text-transform: uppercase;
}
.icon-button.primary { border-color: #17201c; background: #17201c; color: #fff; }
.icon-button.primary span:first-child { background: rgba(255,255,255,.18); color: #fff; }
.icon-only { display: grid; width: 42px; place-items: center; }

.hero-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(120deg, rgba(255,255,255,.92), rgba(255,255,255,.78)),
    linear-gradient(90deg, rgba(47,111,94,.14), rgba(201,154,45,.12));
  box-shadow: var(--shadow);
}
.hero-band h2 { margin: 0 0 8px; font-size: 1.85rem; line-height: 1.15; }
.hero-copy { max-width: 760px; margin-bottom: 0; color: var(--muted); line-height: 1.7; }
.metric-row { display: grid; grid-template-columns: repeat(3, 92px); gap: 8px; }
.metric-row div {
  min-height: 82px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.76);
  border-radius: 8px;
  background: rgba(255,255,255,.72);
  text-align: center;
}
.metric-row span { display: block; color: var(--coral); font-size: 1.45rem; font-weight: 900; }
.metric-row p { margin: 4px 0 0; color: var(--muted); font-size: .78rem; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; align-items: start; }
.link-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(248px, 1fr)); gap: 14px; }
.link-card {
  position: relative;
  overflow: hidden;
  min-height: 230px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 12px 34px rgba(39,48,42,.08);
}
.card-topline { position: absolute; inset: 0 0 auto; height: 4px; background: var(--accent); }
.card-header {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 38px;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}
.card-header.readonly { grid-template-columns: 46px minmax(0, 1fr); }
.favicon-wrap {
  position: relative;
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,.06);
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 12%, #ffffff);
}
.favicon-wrap img { position: relative; z-index: 1; width: 28px; height: 28px; }
.favicon-wrap span { position: absolute; color: #1c1f1d; font-size: .8rem; font-weight: 900; }
.card-header h3 { overflow: hidden; margin: 0 0 3px; font-size: 1.02rem; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.card-header p { overflow: hidden; margin: 0; color: var(--muted); font-size: .8rem; text-overflow: ellipsis; white-space: nowrap; }
.star {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(201,154,45,.38);
  border-radius: 8px;
  background: rgba(201,154,45,.13);
  color: #9b6a00;
  font-weight: 900;
}
.card-description { min-height: 48px; margin-bottom: 16px; color: #34443d; line-height: 1.55; }
.tag-row { display: flex; min-height: 30px; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.tag-row span {
  padding: 5px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 10%, #ffffff);
  color: #34443d;
  font-size: .74rem;
  font-weight: 900;
}
.card-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.card-actions.public-actions { grid-template-columns: 1fr; }
.card-actions a, .card-actions button { display: grid; min-height: 38px; place-items: center; color: #34443d; font-size: .85rem; }
.card-actions a { border-color: transparent; background: var(--accent); color: #fff; }

.ops-panel {
  position: sticky;
  top: 24px;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.82);
  box-shadow: 0 12px 34px rgba(39,48,42,.08);
}
.stack-list { display: grid; gap: 8px; }
.stack-list div {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.stack-list span { color: var(--muted); font-size: .82rem; }
.stack-list strong { font-size: .86rem; }
.mini-copy { padding: 12px; border-radius: 8px; background: rgba(62,106,168,.1); color: #304564; line-height: 1.6; }
.mini-copy p { margin-bottom: 0; }

.empty-state {
  display: grid;
  min-height: 220px;
  place-items: center;
  grid-column: 1 / -1;
  border: 1px dashed rgba(47,111,94,.35);
  border-radius: 8px;
  background: rgba(255,255,255,.64);
  color: var(--muted);
  text-align: center;
}
.empty-state strong { color: var(--foreground); }

.modal-layer, .login-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20,27,23,.5);
  backdrop-filter: blur(8px);
}
.editor, .login-card {
  display: grid;
  width: min(540px, 100%);
  gap: 13px;
  padding: 20px;
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.editor-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.editor h2, .login-card h2 { margin: 0; font-size: 1.35rem; }
.editor label, .login-card label { display: grid; gap: 7px; color: #34443d; font-weight: 900; }
.editor input, .editor select, .editor textarea, .login-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: #fbfcfa;
  color: var(--foreground);
}
.editor input, .editor select, .login-card input { min-height: 44px; padding: 0 12px; }
.editor textarea { min-height: 94px; padding: 12px; resize: vertical; }
.swatch-row { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 34px; height: 34px; border: 3px solid #fff; border-radius: 999px; box-shadow: 0 0 0 1px rgba(23,32,28,.16); }
.swatch.selected { box-shadow: 0 0 0 3px rgba(23,32,28,.28); }
.editor-actions { display: flex; justify-content: flex-end; gap: 10px; }
.editor-actions button, .login-card button { min-width: 96px; padding: 0 16px; }
.editor-actions .submit, .login-card button { border-color: #17201c; background: #17201c; color: #fff; min-height: 42px; border-radius: 8px; font-weight: 900; }
.notice { margin: 0; color: var(--muted); line-height: 1.55; }

@media (max-width: 1120px) {
  .nav-shell { grid-template-columns: 240px minmax(0, 1fr); }
  .content-grid { grid-template-columns: minmax(0, 1fr); }
  .ops-panel { position: static; grid-template-columns: 1fr 1fr; }
  .mini-copy { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  .nav-shell { display: block; }
  .sidebar { position: static; height: auto; padding: 18px; border-right: 0; border-bottom: 1px solid var(--line); }
  .category-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .source-card { display: none; }
  .workspace { padding: 18px; }
  .topbar, .admin-banner, .hero-band { grid-template-columns: 1fr; }
  .admin-banner { align-items: stretch; flex-direction: column; }
  .actions, .admin-links { justify-content: stretch; }
  .icon-button, .admin-links a { flex: 1 1 120px; justify-content: center; }
  .metric-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ops-panel { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .workspace, .sidebar { padding: 14px; }
  .category-list, .link-grid { grid-template-columns: 1fr; }
  .hero-band { padding: 16px; }
  .hero-band h2 { font-size: 1.48rem; }
  .metric-row { gap: 6px; }
  .metric-row div { min-height: 72px; padding: 10px 6px; }
  .card-actions { grid-template-columns: 1fr; }
}
