:root {
  color-scheme: dark;
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  background: #081018;
  color: #f4f7fb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #081018;
}

body.lightboxOpen {
  overflow: hidden;
}

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

button {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: #7ec8ff;
  color: #081018;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: #f4f7fb;
  padding: 10px 12px;
}

select option {
  background: #101923;
}

label {
  display: grid;
  gap: 8px;
  color: rgba(244, 247, 251, 0.78);
  font-size: 14px;
}

.checkRow {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
}

.checkRow input {
  width: auto;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.1;
}

h2 {
  font-size: 20px;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 300px;
  gap: 16px;
  padding: 16px;
}

.panel {
  background: #101923;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.28);
}

.settings,
.history {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
}

.composer {
  padding: 18px;
  display: grid;
  gap: 12px;
}

textarea {
  min-height: 132px;
  resize: vertical;
}

.chips,
.actions,
.downloadActions,
.historyHead,
.previewTop {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chips {
  flex-wrap: wrap;
}

.chips button,
#clearHistory,
.downloadActions button {
  background: rgba(255, 255, 255, 0.07);
  color: #f4f7fb;
  font-weight: 600;
}

.actions {
  justify-content: space-between;
}

.preview {
  min-height: 0;
  padding: 18px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
}

.previewTop,
.historyHead {
  justify-content: space-between;
}

.imageStage {
  min-height: 360px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #070b10;
  overflow: hidden;
  position: relative;
  display: grid;
  place-items: center;
}

.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(244, 247, 251, 0.48);
}

.empty[hidden] {
  display: none;
}

#resultImage {
  width: 100%;
  height: 100%;
  min-height: 360px;
  object-fit: contain;
  display: block;
  cursor: zoom-in;
}

#resultImage[hidden] {
  display: none;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 0;
  color: rgba(244, 247, 251, 0.68);
  font-size: 13px;
}

.meta dt {
  font-weight: 700;
  color: rgba(244, 247, 251, 0.9);
}

.meta dd {
  margin: 0;
}

.eyebrow,
.hint,
#status {
  color: rgba(244, 247, 251, 0.56);
  font-size: 13px;
}

#error {
  color: #ffd2c7;
  background: rgba(255, 99, 71, 0.13);
  border: 1px solid rgba(255, 99, 71, 0.25);
  border-radius: 8px;
  padding: 10px 12px;
}

#loginError {
  color: #ffd2c7;
  background: rgba(255, 99, 71, 0.13);
  border: 1px solid rgba(255, 99, 71, 0.25);
  border-radius: 8px;
  padding: 10px 12px;
}

.loginPage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.loginPanel {
  width: min(420px, 100%);
  padding: 22px;
  display: grid;
  gap: 16px;
}

.historyList {
  overflow: auto;
  display: grid;
  gap: 10px;
}

.record {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.record img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  cursor: zoom-in;
}

.record p {
  color: rgba(244, 247, 251, 0.82);
  font-size: 13px;
  line-height: 1.4;
}

.recordActions {
  display: flex;
  gap: 8px;
}

.recordActions button {
  flex: 1;
  padding: 8px;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(3, 7, 11, 0.9);
  overflow: auto;
  overscroll-behavior: contain;
}

.lightbox[hidden] {
  display: none;
}

.lightboxImage {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.45);
}

.lightboxClose {
  position: absolute;
  top: 18px;
  right: 18px;
  background: rgba(255, 255, 255, 0.1);
  color: #f4f7fb;
}

@media (max-width: 1100px) {
  .shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .history {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .shell {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .actions,
  .previewTop {
    align-items: stretch;
    flex-direction: column;
  }

  .downloadActions,
  .actions button {
    width: 100%;
  }
}
