* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: #e7f2ea;
  color: #1d2b24;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.desk-view {
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: #fff;
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 10px 30px rgba(28, 68, 46, 0.08);
}

.login-view .card { width: min(420px, 100%); }

h1, h2, p { margin: 0; }

.hint, .error { min-height: 1.4em; }

.hint { color: #5d6f65; margin-top: 6px; }

.error { color: #b42318; }

.card h2 + .hint { margin-bottom: 16px; }

label {
  display: grid;
  gap: 6px;
  margin: 0;
  font-size: 14px;
}

input, select, button, .file, .avatar {
  height: 42px;
  border-radius: 10px;
}

input, select {
  width: 100%;
  border: 1px solid #d5e3da;
  padding: 0 12px;
  background: #fff;
}

button {
  border: 1px solid transparent;
  padding: 0 16px;
  background: #2f8f68;
  color: #fff;
  cursor: pointer;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.top h1 { margin: 0; }

.top button, .file, #reset-covers, #add-app {
  background: #e7f2ea;
  color: #1d2b24;
  border-color: #d5e3da;
}

.work {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 22px;
  align-items: start;
}

.stage {
  position: relative;
  width: 280px;
  height: 498px;
  overflow: hidden;
  border-radius: 18px;
  background: #16342c;
  touch-action: none;
}

#preview {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

#preview .slide {
  position: absolute;
  inset: 0;
  background-color: #d7ebe0;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 0.8s ease;
}

#preview .slide.on {
  opacity: 1;
}

.grid {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  pointer-events: none;
}

.cell {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.38);
}

.chip {
  position: absolute;
  z-index: 2;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: auto;
  margin: 0;
  padding: 4px 2px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  text-align: center;
  cursor: grab;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  touch-action: none;
  overflow: hidden;
}

.chip .dot {
  width: 32px;
  height: 32px;
  margin: 0 auto 6px;
  border-radius: 12px;
  background-color: #2f8f68;
  background-image: linear-gradient(160deg, #8fd4aa, #2f8f68);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

.chip .name {
  display: block;
  width: 100%;
  max-height: 2.4em;
  overflow: hidden;
  font-size: 11px;
  line-height: 1.2;
  text-wrap: balance;
}

@media (max-width: 800px) {
  .work { grid-template-columns: 1fr; }
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.file {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  cursor: pointer;
}

.file input { display: none; }

.cover-tools {
  flex-wrap: wrap;
  align-items: end;
  margin-top: 14px;
}

.slide-seconds {
  width: 160px;
  margin-left: auto;
}

#cover-status { margin-top: 12px; }

.cover-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.cover-card {
  width: 92px;
  cursor: grab;
}

.cover-card.over {
  outline: 2px solid #2f8f68;
  border-radius: 12px;
}

.cover-thumb {
  position: relative;
  width: 92px;
  height: 164px;
  border-radius: 10px;
  overflow: hidden;
  background: #d7ebe0;
}

.cover-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cover-index {
  position: absolute;
  left: 6px;
  top: 6px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(22, 52, 44, 0.72);
  color: #fff;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
}

.cover-card button {
  width: 100%;
  height: 32px;
  margin-top: 6px;
  background: #fff;
  border-color: #d5e3da;
  color: #b42318;
}

#cover-error { margin: 10px 0 0; }

.editor {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.fields {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 12px;
  align-items: end;
}

.app-table { display: grid; gap: 8px; }

.app-head, .app-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 0.85fr) minmax(0, 1.25fr) 140px;
  column-gap: 10px;
  align-items: center;
}

.app-head {
  color: #5d6f65;
  font-size: 13px;
  line-height: 1.2;
}

.app-head span:first-child { text-align: center; }

#apps { display: grid; gap: 8px; }

.avatar {
  display: grid;
  place-items: center;
  width: 42px;
  margin: 0;
  padding: 0;
  border: 1px solid #d5e3da;
  background-color: #e7f2ea;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  overflow: hidden;
  cursor: pointer;
  color: #3d6b54;
  font-size: 12px;
}

.avatar input { display: none; }

.avatar.has-icon .placeholder { display: none; }

.app-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.app-actions button {
  width: 66px;
  flex: 0 0 66px;
  padding: 0;
  background: #fff;
  border-color: #d5e3da;
  color: #5d6f65;
}

.clear-icon:disabled {
  visibility: hidden;
}

.app-actions .remove { color: #b42318; }

.editor-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.editor-actions button { min-width: 112px; }

#save-error { margin: 0; }

.login-view label + label { margin-top: 14px; }

.login-view .hint { margin-bottom: 8px; }

.login-view .error { margin: 8px 0; }

.login-view button[type="submit"] {
  width: 100%;
  margin-top: 8px;
}

@media (max-width: 800px) {
  .fields { grid-template-columns: 1fr; }
  .app-head { display: none; }
  .app-row {
    grid-template-columns: 42px minmax(0, 1fr);
    row-gap: 8px;
  }
  .app-row .package,
  .app-actions { grid-column: 2; }
}
