* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #f2f0eb;
  color: #2b2b2b;
  min-height: 100vh;
}

header {
  background: #fff;
  border-bottom: 1px solid #ddd;
  padding: 14px 24px 0;
  position: sticky;
  top: 0;
  z-index: 50;
}
header h1 { font-size: 1.3rem; margin-bottom: 10px; }

nav { display: flex; gap: 4px; }
.tab-btn {
  border: none;
  background: transparent;
  padding: 10px 18px;
  font-size: 0.95rem;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  color: #666;
}
.tab-btn.active {
  background: #f2f0eb;
  color: #1a3a8f;
  font-weight: 600;
}

main { padding: 20px; max-width: 1100px; margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; }

.panel {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.hint { color: #777; font-size: 0.88rem; margin-bottom: 12px; line-height: 1.5; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar label { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: #555; }

button, .file-btn {
  background: #1a3a8f;
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  cursor: pointer;
}
button:hover, .file-btn:hover { background: #142c6e; }
button:disabled { background: #b7b7b7; cursor: not-allowed; }
button.danger { background: #b03030; }
button.danger:hover { background: #8d2626; }
.file-btn { display: inline-block; }

#progress-label { font-size: 0.88rem; color: #444; font-weight: 600; }

/* Chart grid */
#chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.glyph-cell { text-align: center; }
.glyph-cell .label {
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 3px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}
.glyph-cell .label b { font-size: 1rem; color: #1a3a8f; }
.glyph-cell .redo {
  background: none; border: none; color: #999; padding: 0 4px; font-size: 0.9rem;
}
.glyph-cell .redo:hover { color: #b03030; background: none; }
.glyph-cell canvas {
  width: 100%;
  aspect-ratio: 1;
  border: 1.5px dashed #c9c4b8;
  border-radius: 8px;
  background: #fdfcf9;
  touch-action: none;
  cursor: crosshair;
}
.glyph-cell.done canvas { border: 1.5px solid #7cae7c; background: #f6fbf4; }

textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 12px;
  resize: vertical;
}

#preview-canvas {
  width: 100%;
  background: repeating-linear-gradient(#fdfcf9, #fdfcf9 39px, #e8e4da 40px);
  border: 1px solid #ddd;
  border-radius: 8px;
}

details { margin-bottom: 14px; }
details summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }
details label { display: flex; gap: 8px; align-items: center; font-size: 0.88rem; }
details input { flex: 1; padding: 6px 10px; border: 1px solid #ccc; border-radius: 6px; }

#doc-stage-wrap { overflow: auto; }
#doc-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
}
#doc-stage img { display: block; max-width: 100%; }

.answer-box {
  position: absolute;
  cursor: grab;
  border: 1px dashed transparent;
  border-radius: 4px;
}
.answer-box:hover { border-color: #1a3a8f88; background: #1a3a8f0d; }
.answer-box.dragging { cursor: grabbing; border-color: #1a3a8f; }
.answer-box canvas { display: block; pointer-events: none; }
.answer-box .del {
  position: absolute;
  top: -10px; right: -10px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #b03030;
  color: #fff;
  font-size: 11px;
  line-height: 20px;
  text-align: center;
  padding: 0;
  display: none;
}
.answer-box:hover .del { display: block; }

#doc-status { min-height: 1.2em; font-weight: 500; }
#doc-status.error { color: #b03030; }
#doc-status.ok { color: #3a7a3a; }
