:root {
  font-family: system-ui, "Microsoft YaHei", sans-serif;
  color: #222;
  background: #fff;
  --blue: #3558ff;
}
.close-icon {
  width: 18px;
  height: 18px;
  vertical-align: middle;
}
* {
  box-sizing: border-box;
}
body {
  height: 100dvh;
  min-height: 420px;
  margin: 0;
  overflow: hidden;
}
button,
input,
a {
  font: inherit;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
  background: #fff;
  color: #222;
  border: 1px solid #ddd;
  border-radius: 6px;
  min-height: 44px;
  padding: 8px 14px;
}
button:disabled {
  opacity: 0.35;
  cursor: default;
}
button:hover:not(:disabled) {
  background: #f1f4ff;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
canvas:focus-visible {
  outline: 3px solid #8ea3ff;
  outline-offset: 2px;
}
svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
::selection {
  background: #dce5ff;
}
input {
  caret-color: #3558ff;
}
* {
  scrollbar-width: thin;
  scrollbar-color: #bdc8e5 white;
}
.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px max(12px, calc((100vw - 1100px)/2));
  border-bottom: 1px solid #e9e9e9;
  background: #fff;
  position: relative;
  z-index: 2;
}
.top-action {
  height: 64px;
  min-width: 77px;
  border: 0;
  text-decoration: none;
  color: #222;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 2px 10px;
  font-size: 13px;
}
.top-action svg {
  width: 30px;
  height: 30px;
}
.topbar .add {
  display: flex;
  gap: 9px;
  align-items: center;
  justify-content: center;
  border: 0;
  color: white;
  background: #3558ff;
  border-radius: 30px;
  min-height: 52px;
  min-width: 180px;
  font-size: 20px;
  font-weight: 600;
  margin-left: auto;
}
.topbar .add svg {
  width: 31px;
  height: 31px;
}
.topbar .add:hover {
  background: #2547ef;
}
.finish {
  border: 0;
  background: #d91e40;
  color: #fff;
  min-height: 52px;
  border-radius: 30px;
  font-size: 19px;
  min-width: 160px;
}
.finish:hover {
  background: #bf1735 !important;
}
#editLabel {
  font-size: 20px;
  min-width: 80px;
}
#workspace {
  height: calc(100dvh - 76px);
  position: relative;
  overflow: hidden;
}
canvas {
  height: 100%;
  width: 100%;
  display: block;
  touch-action: none;
  outline: none;
}
#hint {
  position: absolute;
  top: 14px;
  left: 16px;
  right: 88px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #ecf1ff;
  color: #334463;
  border-radius: 7px;
  font-size: 13px;
  pointer-events: none;
}
#hint button {
  pointer-events: auto;
  border: 0;
  min-height: 24px;
  font-size: 23px;
  line-height: 1;
  padding: 0 2px;
  margin-left: auto;
  background: transparent;
  color: #7183a0;
}
#tools {
  position: absolute;
  right: 12px;
  bottom: 70px;
  border: 1px solid #d6d6d6;
  border-radius: 11px;
  padding: 3px;
  background: #fff;
  box-shadow: 0 3px 9px #0002;
  width: 62px;
  max-height: calc(100% - 100px);
  overflow: auto;
}
#tools button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 0;
  width: 54px;
  min-height: 54px;
  padding: 5px 2px;
  border-radius: 4px;
  font-size: 24px;
  gap: 1px;
}
#tools button span {
  font-size: 11px;
}
#tools button[aria-pressed="true"] {
  background: #eaf0ff;
  color: #244bc5;
}
#settingsDialog label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
}
#settingsDialog input {
  width: 20px;
  height: 20px;
}
#tools #collapse {
  border-bottom: 1px solid #eee;
  margin-bottom: 2px;
}
#tools button svg {
  width: 24px;
  height: 24px;
}
#tools.collapsed #toolItems {
  display: none;
}
#tools.collapsed #collapse {
  margin: 0;
  border: 0;
}
#selection {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-top: 1px solid #ddd;
  padding: 7px 16px;
  z-index: 2;
}
#selection strong {
  font-size: 13px;
  margin-right: auto;
  max-width: 28%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#selection button {
  min-height: 40px;
  font-size: 12px;
  padding: 7px 12px;
  border: 0;
  color: #3558ff;
}
#selection #remove {
  color: #c93838;
}
#liveStatus {
  position: absolute;
  left: 16px;
  bottom: 16px;
  max-width: calc(100% - 110px);
  font-size: 12px;
  line-height: 1.7;
  background: #ffffffed;
  border-radius: 5px;
  padding: 5px 10px;
  color: #556579;
  pointer-events: none;
}
#workspace.has-selection #liveStatus {
  bottom: 72px;
}
#toast {
  position: absolute;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  padding: 11px 18px;
  background: #202c41e8;
  color: #fff;
  font-size: 13px;
  border-radius: 8px;
  max-width: 90%;
  opacity: 0;
  pointer-events: none;
  z-index: 4;
}
#toast.show {
  opacity: 1;
}
dialog {
  width: 530px;
  max-width: calc(100vw - 28px);
  max-height: 85dvh;
  border: 1px solid #ddd;
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 14px 60px #182c5330;
  overflow: auto;
  color: #263650;
}
dialog::backdrop {
  background: #11182777;
}
.dialog-head {
  display: flex;
  align-items: center;
  gap: 15px;
  justify-content: space-between;
}
h2 {
  font-size: 20px;
  margin: 0;
}
.dialog-head > button {
  border: 0;
  font-size: 25px;
  padding: 0;
  min-width: 35px;
}
dialog p {
  font-size: 13px;
  line-height: 1.8;
  color: #61728b;
  margin: 12px 0 18px;
}
#componentList {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
#componentList button {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 7px;
  gap: 8px;
  min-height: 165px;
  background: #fafcff;
}
#componentList img {
  height: 100px;
  max-width: 125px;
  object-fit: contain;
}
.teaching-symbol {
  height: 100px;
  width: 110px;
  display: grid;
  place-items: center;
  border: 2px solid #455262;
  background: #e7ebee;
  color: #263650;
  font-size: 30px;
  font-weight: 700;
}
#componentList strong {
  font-size: 13px;
}
#componentList small {
  font-size: 11px;
  color: #65738c;
}
#exampleList {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin: 18px 0;
}
#exampleList button {
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 14px;
  gap: 5px;
}
#exampleList small {
  font-size: 12px;
  color: #66768b;
}
label {
  display: block;
  font-size: 13px;
  margin: 15px 0 10px;
}
input:not([type="file"]), #reconnectForm select {
  width: 100%;
  min-height: 43px;
  padding: 10px;
  border: 1px solid #becbe0;
  border-radius: 6px;
  margin-top: 7px;
  color: #263650;
}
#reconnectForm select {
  display: block;
  min-height: 44px;
  font: inherit;
  font-size: 16px;
  background: #fff;
}
#reconnectError { color: #a31b35; }
.file-actions {
  display: grid;
  gap: 10px;
}
.project-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
#libraryList { padding: 0; margin: 12px 0 0; list-style: none; }
#libraryList li { display: flex; align-items: stretch; gap: 8px; padding: 8px 0; border-top: 1px solid #ddd; }
#libraryList .open-project { flex: 1; min-width: 0; text-align: left; overflow-wrap: anywhere; }
#libraryList .open-project small { display: block; color: #536a80; margin-top: 4px; }
#libraryList .delete-project, #saveAsError { color: #a31b35; }
.file-label {
  border: 1px dashed #b9c7e0;
  border-radius: 7px;
  padding: 12px;
  margin: 0;
}
input[type="file"] {
  display: block;
  width: 100%;
  margin-top: 10px;
  font-size: 12px;
}
.fine {
  font-size: 12px !important;
}
#infoBody {
  font-size: 14px;
  line-height: 1.9;
  padding-top: 15px;
}
#infoBody ul {
  padding-left: 22px;
}
#infoBody button {
  margin-top: 12px;
}
#infoBody input {
  margin-bottom: 8px;
}
[hidden] {
  display: none !important;
}
@media (max-width: 600px) {
  .topbar {
    height: 66px;
    padding: 5px 9px;
    gap: 3px;
  }
  .top-action {
    height: 56px;
    min-width: 56px;
    padding: 2px 8px;
    font-size: 12px;
  }
  .top-action svg {
    width: 27px;
    height: 27px;
  }
  .topbar .add {
    min-width: 139px;
    min-height: 45px;
    font-size: 17px;
    padding: 7px 12px;
    gap: 6px;
  }
  .topbar .add svg {
    width: 26px;
    height: 26px;
  }
  #workspace {
    height: calc(100dvh - 66px);
  }
  #editLabel {
    font-size: 18px;
    min-width: 70px;
  }
  .finish {
    min-width: 130px;
    min-height: 45px;
    font-size: 16px;
    padding: 8px 13px;
  }
  #hint {
    top: 8px;
    left: 10px;
    right: 10px;
    font-size: 12px;
    padding: 8px 10px;
    gap: 5px;
  }
  #tools {
    right: 8px;
    width: 52px;
    bottom: 60px;
    max-height: calc(100% - 85px);
  }
  #tools button {
    width: 44px;
    min-height: 47px;
  }
  #selection {
    padding: 7px 9px;
    gap: 2px;
  }
  #selection strong {
    max-width: 25%;
    font-size: 12px;
  }
  #selection button {
    font-size: 12px;
    padding: 6px 8px;
  }
  #liveStatus {
    left: 10px;
    bottom: 10px;
    font-size: 11px;
    padding: 4px 7px;
  }
  dialog {
    padding: 18px;
  }
  #componentList button {
    min-height: 148px;
  }
  #componentList img {
    height: 85px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
