:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #080a0e;
  color: #f4f5f7;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: #080a0e;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: #080a0e;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 0 24px;
  border-bottom: 1px solid #242832;
  background: rgba(8, 10, 14, 0.94);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.brand img {
  width: 30px;
  height: 30px;
  border-radius: 7px;
}

.topbar nav {
  display: flex;
  gap: 8px;
}

.topbar nav a,
.compact-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #313642;
  border-radius: 6px;
  background: #11141a;
  color: #c9cdd5;
  font-size: 13px;
  cursor: pointer;
}

.topbar nav a:hover,
.compact-button:hover {
  border-color: #596171;
  color: #ffffff;
}

main {
  width: min(1660px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 110px;
}

.access-state {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  width: min(620px, 100%);
  margin: 12vh auto 0;
  padding: 24px;
  border: 1px solid #292e38;
  border-radius: 8px;
  background: #0d1015;
}

.status-light {
  width: 9px;
  height: 9px;
  margin-top: 7px;
  border-radius: 50%;
  background: #e7b35a;
  box-shadow: 0 0 16px rgba(231, 179, 90, 0.5);
}

.access-state[data-state="error"] .status-light {
  background: #ee716c;
  box-shadow: 0 0 16px rgba(238, 113, 108, 0.46);
}

.access-state p,
.eyebrow {
  margin: 0;
  color: #70d7f2;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.access-state h1 {
  margin: 6px 0 8px;
  font-size: 24px;
  letter-spacing: 0;
}

.access-state span:not(.status-light) {
  color: #9da4af;
  line-height: 1.6;
}

.editor-head {
  display: flex;
  gap: 32px;
  align-items: end;
  justify-content: space-between;
  padding: 0 4px 30px;
  border-bottom: 1px solid #242832;
}

.editor-head h1 {
  margin: 8px 0 10px;
  font-size: 42px;
  font-weight: 660;
  line-height: 1.04;
  letter-spacing: 0;
}

.lead {
  max-width: 660px;
  margin: 0;
  color: #a8aeb8;
  font-size: 16px;
  line-height: 1.65;
}

.system-state {
  display: grid;
  grid-template-columns: repeat(3, minmax(118px, 1fr));
  min-width: min(520px, 48vw);
  border: 1px solid #292e38;
  border-radius: 8px;
  background: #0d1015;
}

.system-state div {
  padding: 14px 16px;
  border-right: 1px solid #292e38;
}

.system-state div:last-child {
  border-right: 0;
}

.system-state span,
.system-state strong {
  display: block;
}

.system-state span {
  margin-bottom: 5px;
  color: #7f8793;
  font-size: 11px;
}

.system-state strong {
  overflow: hidden;
  color: #e6e8ec;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.system-state strong.good {
  color: #83d8a5;
}

.system-state strong.warning {
  color: #edc875;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 310px) minmax(520px, 1fr) minmax(300px, 380px);
  min-height: 720px;
}

.repository-panel,
.cards-panel,
.preview-panel {
  min-width: 0;
  padding: 28px 22px;
}

.repository-panel,
.cards-panel {
  border-right: 1px solid #242832;
}

.panel-head {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.panel-head h2 {
  margin: 5px 0 0;
  font-size: 20px;
  letter-spacing: 0;
}

.panel-note {
  margin: 12px 0 20px;
  color: #8e96a2;
  font-size: 13px;
  line-height: 1.6;
}

.search-field {
  display: block;
  margin-top: 18px;
}

.search-field input,
.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid #303641;
  border-radius: 6px;
  outline: 0;
  background: #0c0f14;
  color: #f2f4f7;
}

.search-field input {
  height: 40px;
  padding: 0 12px;
}

.search-field input:focus,
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: #54bcd8;
  box-shadow: 0 0 0 3px rgba(84, 188, 216, 0.11);
}

.repository-summary {
  display: flex;
  justify-content: space-between;
  margin: 12px 1px 9px;
  color: #737b87;
  font-size: 11px;
}

.repository-list {
  display: grid;
  gap: 7px;
  max-height: calc(100vh - 290px);
  overflow: auto;
  padding-right: 3px;
  scrollbar-color: #343a45 transparent;
}

.repository-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  gap: 10px;
  align-items: center;
  padding: 11px;
  border: 1px solid #272c35;
  border-radius: 7px;
  background: #0c0f14;
}

.repository-item.is-selected {
  border-color: #315d68;
  background: #0d1418;
}

.repository-copy {
  min-width: 0;
}

.repository-copy strong,
.repository-copy span,
.repository-copy small {
  display: block;
}

.repository-copy strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.repository-copy span {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 4px;
  color: #8e96a2;
  font-size: 11px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.repository-copy small {
  margin-top: 7px;
  color: #626b77;
  font-size: 10px;
}

.repository-add,
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid #343a45;
  border-radius: 6px;
  background: #141820;
  color: #d8dce2;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}

.repository-add:hover,
.icon-button:hover {
  border-color: #62c9e3;
  color: #82ddf2;
}

.repository-add:disabled,
.icon-button:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.card-editor-list {
  display: grid;
  gap: 12px;
}

.card-editor {
  border: 1px solid #2a303a;
  border-radius: 8px;
  background: #0d1015;
}

.card-editor-head {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 52px;
  padding: 8px 10px;
  border-bottom: 1px solid #292e38;
}

.card-index {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: #171b23;
  color: #70d7f2;
  font-size: 12px;
  font-weight: 700;
}

.card-identity {
  min-width: 0;
}

.card-identity strong,
.card-identity small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-identity strong {
  font-size: 13px;
}

.card-identity small {
  margin-top: 3px;
  color: #747c88;
  font-size: 10px;
}

.card-toolbar {
  display: flex;
  gap: 5px;
}

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

.field {
  min-width: 0;
}

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

.field > span {
  display: flex;
  justify-content: space-between;
  margin: 0 0 6px 1px;
  color: #969da8;
  font-size: 11px;
}

.field input,
.field select {
  height: 38px;
  padding: 0 10px;
}

.field textarea {
  min-height: 74px;
  resize: vertical;
  padding: 9px 10px;
  line-height: 1.5;
}

.field-note {
  margin: 5px 1px 0;
  color: #68717d;
  font-size: 10px;
  line-height: 1.45;
}

.ai-tools {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 7px;
  align-items: end;
  padding-top: 2px;
}

.ai-tools .field textarea {
  min-height: 58px;
}

.tool-button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid #34404a;
  border-radius: 6px;
  background: #131920;
  color: #cfe8ee;
  font-size: 12px;
  cursor: pointer;
}

.tool-button:hover {
  border-color: #58bdd6;
  color: #ffffff;
}

.tool-button.danger {
  border-color: #493137;
  color: #dca2a2;
}

.preview-sticky {
  position: sticky;
  top: 86px;
}

.preview-grid {
  display: grid;
  gap: 9px;
  margin-top: 18px;
}

.preview-card {
  position: relative;
  min-height: 250px;
  overflow: hidden;
  border: 1px solid #2b313b;
  border-radius: 8px;
  background: #0d1117;
}

.preview-card.copy-disc {
  background: #0c0d10;
}

.preview-card.copy-game {
  background: #11100e;
}

.preview-card.copy-terminal {
  background: #09100c;
}

.preview-card-copy {
  position: relative;
  z-index: 2;
  padding: 20px 20px 120px;
}

.preview-card-copy .preview-label {
  margin: 0;
  color: #70d7f2;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.preview-card-copy h3 {
  margin: 8px 0 0;
  font-size: 23px;
  line-height: 1.12;
  letter-spacing: 0;
}

.preview-card-copy > p:not(.preview-label) {
  margin: 9px 0 0;
  color: #a0a7b1;
  font-size: 11px;
  line-height: 1.5;
}

.preview-links {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  color: #70cce4;
  font-size: 10px;
}

.preview-card img {
  position: absolute;
  z-index: 1;
  right: 10px;
  bottom: 0;
  left: 10px;
  width: calc(100% - 20px);
  height: 112px;
  border-radius: 6px 6px 0 0;
  object-fit: cover;
  object-position: top center;
}

.preview-placeholder {
  position: absolute;
  right: 18px;
  bottom: 18px;
  left: 18px;
  height: 84px;
  border: 1px solid #314139;
  border-radius: 6px;
  background: #0a1510;
}

.preview-placeholder::before,
.preview-placeholder::after {
  position: absolute;
  right: 14px;
  left: 14px;
  height: 1px;
  background: #40775b;
  content: "";
}

.preview-placeholder::before {
  top: 29px;
}

.preview-placeholder::after {
  top: 46px;
  width: 62%;
}

.empty-state {
  margin: 0;
  padding: 22px 12px;
  border: 1px dashed #303640;
  border-radius: 7px;
  color: #7d8591;
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.publish-bar {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: 12px max(24px, calc((100vw - 1628px) / 2));
  border-top: 1px solid #2c323c;
  background: rgba(10, 12, 16, 0.97);
  backdrop-filter: blur(18px);
}

.publish-bar strong,
.publish-bar span {
  display: block;
}

.publish-bar strong {
  font-size: 13px;
}

.publish-bar strong.error {
  color: #ee8d88;
}

.publish-bar strong.success {
  color: #86dca8;
}

.publish-bar span {
  margin-top: 4px;
  color: #7e8793;
  font-size: 11px;
}

.publish-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.secondary-action,
.primary-action {
  min-width: 110px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.secondary-action {
  border: 1px solid #3a414d;
  background: #151920;
  color: #e0e3e8;
}

.primary-action {
  border: 1px solid #7dcfe3;
  background: #a9e5f1;
  color: #071014;
}

.secondary-action:hover {
  border-color: #687180;
}

.primary-action:hover {
  background: #c4f1f8;
}

@media (max-width: 1280px) {
  .editor-head {
    align-items: stretch;
    flex-direction: column;
  }

  .system-state {
    min-width: 0;
  }

  .workspace {
    grid-template-columns: 280px minmax(480px, 1fr);
  }

  .cards-panel {
    border-right: 0;
  }

  .preview-panel {
    grid-column: 1 / -1;
    border-top: 1px solid #242832;
  }

  .preview-sticky {
    position: static;
  }

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

@media (max-width: 820px) {
  .topbar {
    padding: 0 12px;
  }

  .brand span {
    display: none;
  }

  .topbar nav a {
    padding: 0 9px;
  }

  main {
    width: min(100% - 20px, 680px);
    padding-top: 24px;
  }

  .system-state {
    grid-template-columns: 1fr;
  }

  .system-state div {
    border-right: 0;
    border-bottom: 1px solid #292e38;
  }

  .system-state div:last-child {
    border-bottom: 0;
  }

  .workspace {
    display: block;
  }

  .repository-panel,
  .cards-panel,
  .preview-panel {
    padding: 24px 2px;
    border-right: 0;
    border-bottom: 1px solid #242832;
  }

  .repository-list {
    max-height: 380px;
  }

  .card-fields,
  .preview-grid {
    grid-template-columns: 1fr;
  }

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

  .ai-tools .field {
    grid-column: 1 / -1;
  }

  .tool-button {
    min-width: 0;
  }

  .publish-bar {
    position: static;
    align-items: stretch;
    flex-direction: column;
    margin-top: 24px;
    padding: 16px;
    border: 1px solid #2c323c;
    border-radius: 8px;
  }

  .publish-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .editor-head h1 {
    font-size: 34px;
  }

  .card-editor-head {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .card-toolbar {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

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

  .publish-actions {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: no-preference) {
  button,
  a,
  input,
  textarea,
  select {
    transition: border-color 160ms ease, color 160ms ease, background-color 160ms ease, opacity 160ms ease;
  }
}
