:root {
  --bg: #f4f7fb;
  --panel: #fff;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e2ef;
  --primary: #165dff;
  --primary-dark: #0b3fb3;
  --danger: #b42318;
  --green: #12805c;
  --shadow: 0 18px 60px rgba(23, 32, 51, .12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.public-shell,
.app-shell {
  min-height: 100vh;
}

.public-shell {
  display: flex;
  flex-direction: column;
}

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

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 6vw;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.topbar nav {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  font-size: 1.1rem;
}

.brand span {
  padding: 4px 8px;
  border-radius: 999px;
  background: #e7f8f1;
  color: var(--green);
  font-size: .68rem;
  letter-spacing: .04em;
}

.btn,
button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.btn.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.btn.primary:hover {
  background: var(--primary-dark);
}

.btn.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: .9rem;
}

.btn.icon-btn {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
}

.btn.icon-btn svg,
.copy-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn.danger,
.danger {
  color: var(--danger);
}

.public-main {
  width: min(1180px, 88vw);
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, .98fr) minmax(340px, .82fr);
  gap: 42px;
  align-items: center;
  min-height: calc(100vh - 72px);
  padding: 54px 0;
}

.hero > div:first-child {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--primary);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .8rem;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.8rem, 6.4vw, 5.7rem);
  line-height: .9;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 720px;
  margin: 24px 0;
  color: #475467;
  font-size: 1.25rem;
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.device-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.epaper-preview {
  display: grid;
  align-content: center;
  min-height: 360px;
  aspect-ratio: 600 / 448;
  padding: 36px;
  border: 16px solid #20283a;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, .08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(0, 0, 0, .08) 1px, transparent 1px),
    linear-gradient(135deg, #fff 0 28%, #fff238 28% 54%, #ff7e00 54% 72%, #6440ff 72% 100%);
  background-size: 28px 28px, 28px 28px, auto;
  color: #111827;
}

.epaper-preview span,
.epaper-preview em {
  font-style: normal;
  font-weight: 900;
}

.epaper-preview strong {
  display: block;
  max-width: 380px;
  margin: 12px 0;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1;
}

.hardware-preview-section {
  margin-bottom: 46px;
}

.hardware-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.hardware-preview-card {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.hardware-preview-card img,
.epaper-type-preview img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.hardware-preview-card strong,
.epaper-type-preview strong {
  color: var(--ink);
  font-weight: 900;
}

.hardware-preview-card span,
.epaper-type-preview span {
  color: var(--muted);
  font-size: .84rem;
  font-weight: 800;
}

.feature-band {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin: 18px 0 56px;
}

.feature-band article,
.panel,
.auth-card,
.design-card,
.asset-card,
.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 32px rgba(23, 32, 51, .08);
}

.feature-band article,
.panel {
  padding: 24px;
}

.feature-band h2,
.panel h2 {
  margin: 0 0 10px;
}

.feature-band p,
.panel p,
.page-head p {
  color: var(--muted);
  line-height: 1.5;
}

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 32px;
}

.auth-card {
  display: grid;
  gap: 14px;
  width: min(440px, 100%);
  padding: 28px;
}

.auth-card h1 {
  margin: 0;
}

.auth-card p {
  margin: 0;
  color: var(--muted);
}

label {
  display: grid;
  gap: 7px;
  font-weight: 800;
  color: #344054;
}

input,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
}

.notice {
  padding: 12px;
  border: 1px solid #a6f4c5;
  border-radius: 8px;
  background: #ecfdf3;
  color: #067647;
  font-weight: 800;
}

.notice.danger {
  border-color: #fecdca;
  background: #fff5f4;
  color: var(--danger);
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100vh;
  padding: 24px 18px;
  background: #111827;
  color: #fff;
}

.sidebar nav {
  display: grid;
  gap: 8px;
}

.sidebar nav a,
.logout {
  padding: 11px 12px;
  border-radius: 8px;
  color: #d7deea;
  font-weight: 800;
}

.sidebar nav a:hover,
.logout:hover {
  background: rgba(255, 255, 255, .1);
  color: #fff;
}

.sidebar-separator {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 4px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, .16);
  color: #94a3b8;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.sidebar-separator::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, .1);
}

.logout {
  margin-top: auto;
}

.sidebar-bottom {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.sidebar-bottom a {
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  color: #fff;
  font-weight: 900;
}

.sidebar-bottom a:hover {
  background: rgba(255, 255, 255, .1);
}

.sidebar-bottom + .logout {
  margin-top: 0;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  padding: 34px;
}

.designer-main {
  padding: 24px;
}

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

.page-head.compact {
  margin-bottom: 14px;
}

.page-head h1 {
  margin: 0;
  font-size: 2.2rem;
}

.page-head p {
  margin: 6px 0 0;
}

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

.stat {
  padding: 20px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-weight: 900;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 2.5rem;
}

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

.design-card {
  min-width: 0;
  overflow: hidden;
  padding: 14px;
}

.design-card h2 {
  margin: 12px 0 4px;
  font-size: 1.08rem;
}

.design-card p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: .9rem;
}

.thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 600 / 448;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: repeating-conic-gradient(#eef2f7 0 25%, #fff 0 50%) 50% / 28px 28px;
  overflow: hidden;
  color: var(--muted);
  font-weight: 900;
}

.thumb img,
.asset-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.project-thumb {
  position: relative;
  display: grid;
  text-decoration: none;
}

.project-thumb img {
  grid-area: 1 / 1;
}

.project-thumb .processed {
  position: absolute;
  inset: 0;
  opacity: 0;
  z-index: 1;
  transition: opacity .16s ease;
}

.project-thumb:hover .processed,
.project-thumb:focus-visible .processed {
  opacity: 1;
}

.project-thumb:hover .clean,
.project-thumb:focus-visible .clean {
  opacity: 0;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  max-width: 100%;
}

.card-actions form {
  display: contents;
  margin: 0;
}

.card-actions .btn {
  flex: 0 0 auto;
  min-width: 0;
  white-space: nowrap;
}

.btn.icon-btn.bin-depth {
  gap: 3px;
  width: auto;
  min-width: 52px;
  padding: 0 8px;
  font-size: .72rem;
}

.btn.icon-btn.bin-depth span {
  font-weight: 900;
}

.btn.icon-btn.bin-depth svg {
  width: 15px;
  height: 15px;
}

.asset-actions {
  margin-top: 10px;
}

.form-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 180px auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

.filter-bar.compact {
  margin: 0;
}

.quick-create {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.quick-create label {
  display: grid;
  gap: 6px;
  min-width: min(420px, 100%);
  color: #334155;
  font-weight: 800;
}

.form-stack {
  display: grid;
  gap: 14px;
  max-width: 620px;
}

.form-stack.wide-form {
  max-width: none;
}

.form-stack.compact {
  gap: 8px;
  max-width: none;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 8px;
}

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

textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}

.check-row {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 800;
}

.check-row input {
  width: auto;
}

.api-token-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 560px);
  gap: 16px;
  align-items: center;
  min-width: 0;
}

.api-token-card h2,
.api-token-card p {
  margin: 0;
}

.api-token-card p {
  margin-top: 6px;
  color: var(--muted);
}

.api-token-box {
  min-width: 0;
}

.api-token-box span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.api-token-box code {
  white-space: nowrap;
}

.api-swagger-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin-top: 16px;
  min-width: 0;
}

.api-swagger-card h2,
.api-swagger-card p {
  margin: 0;
}

.api-swagger-card p {
  margin-top: 6px;
  color: var(--muted);
}

.api-swagger-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.api-doc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
  max-width: 980px;
}

.epaper-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.api-example {
  display: grid;
  gap: 10px;
  align-content: start;
  min-width: 0;
  overflow: hidden;
}

.api-example h2,
.api-example p {
  margin: 0;
}

.api-example p {
  color: var(--muted);
  line-height: 1.45;
}

.api-code {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.api-example pre,
.api-code pre {
  margin: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

.api-example code,
.api-code code {
  display: block;
  width: max-content;
  min-width: 100%;
  white-space: pre;
}

.api-swagger-document .api-code {
  max-height: 72vh;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.feature-card {
  display: grid;
  gap: 12px;
  align-content: start;
}

.feature-card h2,
.feature-card p,
.section-title {
  margin: 0;
}

.feature-card p {
  color: var(--muted);
  line-height: 1.5;
}

.section-title {
  margin-top: 24px;
  margin-bottom: 10px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.status-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: #eaf1ff;
  color: #0b5bd3;
  font-size: .78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.endpoint-list div {
  display: grid;
  gap: 10px;
  max-width: 980px;
}

.endpoint-list code {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 10px;
  white-space: normal;
  overflow: hidden;
}

.endpoint-list code span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border-radius: 6px;
  background: #1f6feb;
  color: #fff;
  font-size: .72rem;
  font-weight: 900;
}

.endpoint-list code strong {
  min-width: 0;
  overflow-x: auto;
  color: inherit;
  font-family: inherit;
  font-weight: 800;
  white-space: nowrap;
}

.algorithm-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: 10px;
}

.algorithm-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.algorithm-row input {
  width: auto;
  margin-top: 4px;
}

.algorithm-row span {
  display: grid;
  gap: 4px;
}

.algorithm-row strong {
  color: var(--ink);
}

.algorithm-row em {
  color: var(--muted);
  font-style: normal;
  line-height: 1.35;
}

.epaper-type-card {
  min-width: 0;
}

.epaper-type-preview {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.epaper-type-preview img {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.epaper-type-preview div {
  display: grid;
  gap: 5px;
  min-width: 0;
  text-align: center;
}

.brand-kit-form {
  max-width: 820px;
}

.card-profile {
  margin-top: -4px;
  color: var(--muted);
  font-size: .82rem;
}

.asset-manager {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.asset-upload {
  max-width: none;
  position: sticky;
  top: 24px;
}

.asset-upload h2 {
  margin: 0;
}

.asset-library {
  min-width: 0;
}

.asset-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 520px);
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
}

.asset-toolbar strong,
.asset-toolbar span {
  display: block;
}

.asset-toolbar span {
  color: var(--muted);
  font-size: .9rem;
}

.asset-card {
  display: grid;
  grid-template-rows: 170px minmax(0, auto);
  gap: 0;
  overflow: hidden;
  padding: 0;
}

.asset-preview {
  display: grid;
  place-items: center;
  border-bottom: 1px solid var(--line);
  background: repeating-conic-gradient(#eef2f7 0 25%, #fff 0 50%) 50% / 24px 24px;
  overflow: hidden;
}

.asset-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.asset-meta {
  min-width: 0;
  padding: 12px;
}

.asset-card strong,
.asset-card span,
.asset-card input {
  display: block;
  overflow-wrap: anywhere;
}

.asset-card input,
.copy-line input {
  font-size: .78rem;
}

.asset-card span {
  color: var(--muted);
  font-size: .86rem;
}

.copy-line {
  display: grid;
  gap: 6px;
  min-width: 0;
  margin: 10px 0;
  color: var(--muted);
  font-size: .78rem;
}

.copy-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 6px;
  min-width: 0;
  width: 100%;
}

.asset-card .copy-control,
.design-card .copy-control {
  display: grid;
}

.copy-control input {
  width: auto;
  min-width: 0;
  margin: 0;
}

.copy-line .copy-control input {
  width: 100%;
  max-width: 100%;
}

.copy-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--primary);
  cursor: pointer;
}

.copy-btn:hover {
  border-color: var(--primary);
  background: #eff6ff;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.preset-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.preset-thumb {
  width: 100%;
}

.preset-card h3,
.preset-card p {
  margin: 0;
}

.preset-card p {
  color: var(--muted);
  line-height: 1.4;
}

.link {
  border: 0;
  background: none;
  padding: 0;
  font-weight: 900;
  cursor: pointer;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

td span {
  color: var(--muted);
}

code {
  display: block;
  max-width: 100%;
  overflow: auto;
  padding: 12px;
  border-radius: 8px;
  background: #101828;
  color: #e6edf7;
}

.empty {
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.muted.compact {
  margin: 0;
  font-size: .9rem;
  line-height: 1.4;
}

.iot-footer {
  margin-top: auto;
  padding: 28px 12px 4px;
  text-align: center;
  color: var(--muted);
  font-weight: 900;
}

.iot-footer a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  color: inherit;
}

.iot-footer a:hover {
  color: var(--primary);
  background: #eaf1ff;
}

@media (max-width: 900px) {
  .hero,
  .feature-band,
  .app-shell,
  .stats,
  .asset-manager,
  .asset-toolbar,
  .api-token-card,
  .api-swagger-card,
  .api-doc-grid,
  .epaper-type-grid,
  .epaper-type-preview,
  .filter-bar {
    grid-template-columns: 1fr;
  }

  .asset-upload {
    position: static;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .main,
  .designer-main {
    padding: 18px;
  }

  .page-head,
  .form-row {
    align-items: stretch;
    flex-direction: column;
  }
}
