:root {
  --bg-main: #f7f1f2;
  --bg-accent: #f2dfe2;
  --ink: #2a1016;
  --ink-soft: #6f2b38;
  --panel: rgba(255, 255, 255, 0.92);
  --line: #bc5a6d;
  --brand: #c41230;
  --brand-dark: #930e24;
  --alert: #b80f2c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 15%, #ffe7eb 0%, transparent 35%),
    radial-gradient(circle at 85% 85%, #f6d6dc 0%, transparent 40%),
    var(--bg-main);
  min-height: 100vh;
}

.home-body {
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.home-main {
  width: min(900px, 95vw);
}

.home-header h1 {
  margin: 0;
  font-size: clamp(2rem, 3.4vw, 3rem);
}

.home-header p {
  margin: 0.5rem 0 0;
  color: var(--ink-soft);
}

.tool-grid {
  margin-top: 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.tool-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.25rem;
  backdrop-filter: blur(4px);
}

.tool-card h2 {
  margin-top: 0;
}

.tool-link {
  display: inline-block;
  margin-top: 0.5rem;
  text-decoration: none;
  background: var(--brand-dark);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 8px;
}

.placeholder-card {
  opacity: 0.7;
}

.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.top-nav a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

.top-nav button,
.button-row button,
.pre-exam-actions button,
.control-panel input,
.control-panel select,
.control-panel textarea {
  font: inherit;
}

.exam-app {
  padding: 1rem;
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 1rem;
  min-height: calc(100vh - 60px);
}

.control-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  display: grid;
  gap: 0.6rem;
  align-content: start;
}

.control-panel h1 {
  margin: 0 0 0.5rem;
  font-size: 1.4rem;
}

.control-panel input,
.control-panel select,
.control-panel textarea {
  width: 100%;
  border: 1px solid #c57b89;
  border-radius: 8px;
  padding: 0.55rem;
}

.time-row {
  display: grid;
  gap: 0.45rem;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

.button-row button,
#preExamActions button,
#fullscreenBtn {
  border: none;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  padding: 0.6rem;
  cursor: pointer;
}

#preExamActions button:first-child {
  background: var(--brand-dark);
}

.pre-exam-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 260px));
  justify-content: center;
  gap: 0.6rem;
}

.pre-exam-view {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0.7rem;
  min-height: 70vh;
}

.course-title {
  margin: 0;
  text-align: center;
  font-size: clamp(1.8rem, 3vw, 3rem);
}

.chart-wrap {
  margin: 0;
  display: grid;
  place-items: center;
}

.chart-wrap img {
  max-width: 100%;
  max-height: 48vh;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}

.notice-box {
  background: #ffffffcc;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem;
}

.notice-box h3 {
  margin: 0 0 0.6rem;
  font-size: clamp(1.3rem, 2.1vw, 2rem);
}

.notice-box p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.4;
  min-height: 3rem;
  font-size: clamp(1.3rem, 2.1vw, 2rem);
}

.exam-app.preview-only {
  grid-template-columns: 1fr;
}

.exam-view {
  position: relative;
  min-height: 80vh;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.75);
  display: grid;
  place-items: center;
}

.current-time {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  font-size: clamp(1.5rem, 2.8vw, 3.2rem);
  font-weight: 700;
}

.end-time {
  position: absolute;
  top: clamp(3.5rem, 5.2vw, 5.4rem);
  right: 1.2rem;
  font-size: clamp(1.3rem, 2.2vw, 2.4rem);
  font-weight: 800;
  color: var(--alert);
}

.timer {
  font-size: clamp(4.6rem, 15vw, 12.5rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.015em;
  color: var(--alert);
  text-align: center;
  display: inline-block;
  position: relative;
  padding-right: 0.52em;
}

.timer-main {
  font-size: 1em;
}

.timer-seconds {
  position: absolute;
  right: 0;
  bottom: -0.04em;
  font-size: 0.3em;
  line-height: 1;
  font-weight: 700;
  opacity: 0.9;
}

.exam-notice-box {
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  background: #ffffffde;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
}

.exam-notice-box h3 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.1rem, 1.8vw, 1.6rem);
}

.exam-notice-box p {
  margin: 0;
  white-space: pre-wrap;
  font-size: clamp(1.1rem, 1.8vw, 1.6rem);
}

.exam-edit-wrap {
  position: absolute;
  left: 1rem;
  top: 1rem;
  width: min(420px, calc(100% - 2rem));
}

#editInstructionsBtn,
#saveExamInstructionsBtn {
  border: none;
  border-radius: 8px;
  background: var(--brand-dark);
  color: white;
  padding: 0.5rem 0.7rem;
  cursor: pointer;
}

.exam-instruction-editor {
  margin-top: 0.45rem;
  display: grid;
  gap: 0.45rem;
  background: #ffffffea;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem;
}

.exam-instruction-editor textarea {
  width: 100%;
  resize: vertical;
  min-height: 90px;
  border: 1px solid #c57b89;
  border-radius: 8px;
  padding: 0.5rem;
  font: inherit;
}

.hidden {
  display: none;
}

@media (max-width: 900px) {
  .exam-app {
    grid-template-columns: 1fr;
  }

  .pre-exam-view {
    min-height: 55vh;
  }

  .button-row {
    grid-template-columns: 1fr;
  }

  .pre-exam-actions {
    grid-template-columns: 1fr;
  }
}
