:root {
  --what-bg: #ffe2d1;
  --what-ink: #c0431f;
  --who-bg: #ffc266;
  --who-deep: #f0a022;
  --who-ink: #7a4200;
  --why-bg: #d3e9ff;
  --why-ink: #1b5fa8;
  --center-bg: #fff6b0;
  --center-border: #f0cf3d;
  --how-bg: #d7f0cd;
  --how-ink: #227a3c;
  --ink: #2a2a2a;
  --paper: #fffdf6;
  --page-bg: #eef1f6;
  --accent: #3f6dae;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  padding: 32px 16px;
  background: var(--page-bg);
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sheet {
  width: 100%;
  max-width: 1120px;
  background: var(--paper);
  border-radius: 20px;
  padding: 26px 30px 34px;
  box-shadow: 0 18px 40px rgba(40, 30, 10, 0.12), 0 2px 8px rgba(40, 30, 10, 0.06);
}

/* Header banner */
.banner {
  display: flex;
  align-items: center;
  gap: 18px;
  background: #fff;
  border-radius: 14px;
  padding: 18px 30px;
  box-shadow: 0 3px 0 rgba(0,0,0,0.05), 0 8px 18px rgba(210, 150, 60, 0.15);
  position: relative;
  clip-path: polygon(0 0, 95% 0, 100% 20px, 100% 100%, 0 100%);
}

.banner::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 20px 20px 0 0;
  border-color: #e8dcc4 transparent transparent transparent;
}

.banner-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  background: conic-gradient(#f5a623 0deg 255deg, #fff1d6 255deg 360deg);
  border: 2.5px solid #d98c1f;
  box-shadow: inset 0 0 0 3px #fff, 0 2px 4px rgba(0,0,0,0.12);
}

.banner-title {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

/* Top row: badge + student info */
.top-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 18px 4px 22px;
}

.student-info {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  color: #6b6b6b;
}

.student-info label {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  padding: 6px 12px 6px 14px;
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.field {
  display: inline-block;
  min-width: 64px;
  min-height: 18px;
  border: none;
  border-bottom: 1.5px solid #cfcabb;
  padding: 1px 3px;
  font-weight: 400;
  color: var(--ink);
  outline: none;
  transition: border-color .15s ease;
}

.field:focus { border-color: var(--accent); }

.field:empty:before {
  content: attr(data-placeholder);
  color: #b7b2a3;
}

input.date-field {
  font-family: inherit;
  font-size: 13px;
  background: transparent;
  cursor: pointer;
}

input.date-field::-webkit-calendar-picker-indicator {
  cursor: pointer;
  filter: opacity(0.6);
}

.field[hidden] { display: none; }

/* Main layout */
.main-layout {
  display: flex;
  gap: 26px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.compass {
  flex: 2 1 640px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: auto auto auto;
  grid-template-areas:
    "what what who"
    "why center who"
    ". how how";
  gap: 16px;
}

.box {
  border-radius: 14px;
  padding: 16px 20px;
  min-height: 120px;
  box-shadow: 0 4px 12px rgba(60, 40, 10, 0.07);
  transition: transform .15s ease, box-shadow .15s ease;
}

.box:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(60, 40, 10, 0.1);
}

.box .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255,255,255,0.65);
  margin-right: 6px;
  font-size: 14px;
}

.box h2 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 800;
  display: flex;
  align-items: center;
}

.box .sub {
  margin: 0 0 10px;
  font-weight: 700;
  font-size: 13.5px;
  opacity: 0.85;
}

.box .answer {
  min-height: 60px;
  background: rgba(255,255,255,0.6);
  border: 1.5px dashed rgba(0,0,0,0.08);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
  line-height: 1.55;
  outline: none;
  transition: border-color .15s ease, background .15s ease;
}

.box .answer:focus {
  background: #fff;
  border-color: var(--accent);
  border-style: solid;
}

.box .answer:empty:before {
  content: attr(data-placeholder);
  color: #8b8b8b;
}

.what   { grid-area: what;   background: var(--what-bg); }
.what h2 { color: var(--what-ink); }

.who    { grid-area: who;    background: linear-gradient(160deg, var(--who-bg), var(--who-deep)); display: flex; flex-direction: column; }
.who h2 { color: var(--who-ink); }
.who .answer { flex: 1; }

.why    { grid-area: why;    background: var(--why-bg); }
.why h2 { color: var(--why-ink); }

.how    { grid-area: how;    background: var(--how-bg); }
.how h2 { color: var(--how-ink); }

.center-topic {
  grid-area: center;
  background: var(--center-bg);
  border: 2px dashed var(--center-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 14px;
  gap: 6px;
}

.center-topic .tag {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #a3860a;
  background: rgba(255,255,255,0.6);
  padding: 3px 10px;
  border-radius: 999px;
}

.topic {
  font-size: 19px;
  font-weight: 800;
  min-width: 80%;
  outline: none;
  border-radius: 6px;
  padding: 2px 6px;
  transition: background .15s ease;
}

.topic:focus { background: rgba(255,255,255,0.55); }

.topic.is-placeholder { color: #7a6a1a; }

/* Questions panel */
.questions-panel {
  flex: 1 1 300px;
  min-width: 280px;
}

.questions-panel h3 {
  font-size: 18px;
  font-weight: 800;
  margin: 4px 0 14px;
  text-align: center;
  color: #444;
}

.question-set {
  position: relative;
  background: #fff;
  border-left: 5px solid var(--accent);
  border-radius: 10px;
  padding: 14px 34px 14px 16px;
  margin-bottom: 14px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.06);
  transition: box-shadow .15s ease;
}

.question-set:hover { box-shadow: 0 6px 16px rgba(0,0,0,0.09); }

.question {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.55;
  min-height: 22px;
  margin-bottom: 8px;
  outline: none;
  color: #222;
}

.question.is-placeholder { color: #9a9a9a; font-style: italic; font-weight: 400; }

.answer-box {
  min-height: 40px;
  background: #f7f6ef;
  border-radius: 6px;
  padding: 9px 11px;
  font-size: 14px;
  line-height: 1.5;
  border-top: 1px dashed #d8d2c0;
  outline: none;
  transition: background .15s ease;
}

.answer-box:focus { background: #fdf9ea; }

.answer-box:empty:before {
  content: attr(data-placeholder);
  color: #a19b8c;
}

.delete-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: #f1efe6;
  color: #999;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.delete-btn:hover { background: #f6c9c9; color: #a33; }

#add-question-btn {
  display: block;
  width: 100%;
  padding: 11px;
  border: 2px dashed #9cbf9c;
  border-radius: 10px;
  background: #eef7ee;
  color: #319140;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
  transition: background .15s ease, transform .1s ease;
}

#add-question-btn:hover { background: #dff0df; transform: translateY(-1px); }

/* Save row */
.save-row {
  width: 100%;
  max-width: 1120px;
  text-align: center;
  margin-top: 26px;
}

#save-image-btn {
  padding: 13px 32px;
  font-size: 16px;
  font-weight: 800;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, #5580c9, var(--accent));
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(63, 109, 174, 0.35);
  transition: transform .12s ease, box-shadow .12s ease;
}

#save-image-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(63, 109, 174, 0.4);
}

#save-image-btn:active { transform: translateY(0); }

.hint {
  font-size: 12px;
  color: #8a8a8a;
  margin-top: 10px;
}

/* Hide interactive chrome while capturing the sheet as an image */
body.capturing .delete-btn,
body.capturing #add-question-btn {
  visibility: hidden;
}

body.capturing .box:hover,
body.capturing .question-set:hover {
  transform: none;
  box-shadow: 0 4px 12px rgba(60, 40, 10, 0.07);
}

@media (max-width: 800px) {
  .main-layout { flex-direction: column; }
  .compass { width: 100%; }
}
