:root {
  color: #28231d;
  background: #f5f1eb;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 255, 255, 0.5), transparent 34rem),
    #f5f1eb;
}

button,
input {
  font: inherit;
}

.page {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 64px 0 80px;
}

.intro {
  max-width: 720px;
  margin-bottom: 34px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
  font-size: clamp(42px, 7vw, 76px);
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: 1;
}

.intro > p:last-child {
  margin-bottom: 0;
  color: #70675d;
  font-size: 17px;
}

.upload-panel,
.card {
  border: 1px solid #e2e5e9;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.06);
}

.upload-panel {
  padding: 18px;
}

.drop-zone {
  display: grid;
  min-height: 220px;
  place-items: center;
  align-content: center;
  gap: 8px;
  border: 1px dashed #cbd1d8;
  border-radius: 15px;
  color: #6f665c;
  cursor: pointer;
  text-align: center;
  transition: border-color 160ms ease, background 160ms ease;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: #9a382b;
  background: #f1f3f6;
}

.drop-zone input {
  display: none;
}

.drop-zone strong {
  color: #28231d;
  font-size: 18px;
}

.drop-zone span:last-child {
  max-width: calc(100% - 30px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 50%;
  background: #2d2924;
  color: white;
  font-size: 28px;
  font-weight: 300;
}

#recognize-button {
  width: 100%;
  margin-top: 14px;
  padding: 14px 24px;
  border: 0;
  border-radius: 13px;
  background: #9a382b;
  color: white;
  cursor: pointer;
  font-weight: 700;
}

#recognize-button:disabled {
  background: #c8bdb0;
  cursor: default;
}

.status {
  min-height: 24px;
  margin: 12px 2px 0;
  color: #70675d;
}

.status.error {
  color: #a3261d;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 22px;
  margin-top: 22px;
}

.workspace[hidden] {
  display: none;
}

.card {
  min-width: 0;
  padding: 20px;
}

.card-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.card-heading h2 {
  margin-bottom: 0;
  font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
  font-size: 24px;
  font-weight: 500;
}

.card-heading span {
  color: #81776b;
  font-size: 13px;
}

.preview-stage {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 12px;
  background: #24211e;
}

#preview {
  display: block;
  width: 100%;
  height: auto;
}

#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.recognized-text {
  min-height: 150px;
  margin: 0;
  padding: 22px;
  border-radius: 12px;
  background: #27231f;
  color: #fffaf0;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 28px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-all;
}

.characters {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.character-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid #ddd4c8;
  border-radius: 11px;
}

.character-main {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  background: #f0e2d8;
  color: #812f24;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 27px;
}

.candidate-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  color: #6f665c;
  font-size: 13px;
}

@media (max-width: 820px) {
  .page {
    width: min(100% - 24px, 680px);
    padding-top: 36px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }
}
