/* Shared classroom shell, extracted from the live interactive tool template.
   Keep the template and adopting tools on this same visual contract. */
:root {
  --blue: #149bd7;
  --ink: #102131;
  --line: #d8e2ea;
  --muted: #5c6b78;
  --touch: 48px;
  --radius: 8px;
}

* { box-sizing: border-box; }

html,
body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: #edf5f9;
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select { font: inherit; }

button { min-height: var(--touch); }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  background: #071018;
  color: #ffffff;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  display: inline-flex;
  border-radius: 6px;
}

.brand-logo:focus-visible {
  outline: 4px solid rgba(20, 155, 215, 0.35);
  outline-offset: 3px;
}

.brand img {
  width: 142px;
  height: auto;
  display: block;
  object-fit: contain;
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 2.05rem);
  line-height: 1.05;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.icon-button {
  width: var(--touch);
  min-width: var(--touch);
  min-height: var(--touch);
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 2px solid #263d51;
  border-radius: var(--radius);
  background: #122436;
  color: #ffffff;
  cursor: pointer;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: #8fd8f3;
  background: var(--blue);
  color: #06111a;
}

.icon {
  width: 24px;
  height: 24px;
  display: block;
  pointer-events: none;
}

.home-button {
  min-height: var(--touch);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 2px solid #263d51;
  border-radius: var(--radius);
  background: #122436;
  color: #ffffff;
  text-decoration: none;
  font-weight: 800;
  white-space: nowrap;
}

.home-button:hover,
.home-button:focus-visible {
  border-color: #8fd8f3;
  background: var(--blue);
  color: #06111a;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 8px 14px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  overflow: visible;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-group.questions { margin-left: auto; }

.toolbar button,
.toolbar summary {
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid #b9c9d5;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.toolbar button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
}

.toolbar details { position: relative; }

.toolbar summary {
  display: flex;
  align-items: center;
  list-style: none;
}

.toolbar summary::-webkit-details-marker { display: none; }

.menu-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  left: 0;
  width: min(300px, calc(100vw - 28px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 32px rgba(7, 16, 24, 0.18);
}

.workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
}

.model-panel {
  min-width: 0;
  min-height: 420px;
  display: grid;
  place-items: stretch;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.model-host {
  width: 100%;
  height: 100%;
  min-height: inherit;
}

.template-note,
.load-error {
  align-self: center;
  justify-self: center;
  max-width: 620px;
  margin: 20px;
  padding: 18px;
  border: 2px dashed #9fb8c8;
  border-radius: 8px;
  background: #f7fbfd;
  text-align: center;
  font-weight: 800;
}

.load-error {
  border-style: solid;
  border-color: #d84f4f;
  background: #fff5f5;
}

.feedback {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  font-weight: 800;
}

.instructions-dialog {
  width: min(680px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  box-shadow: 0 24px 64px rgba(7, 16, 24, 0.35);
}

.instructions-dialog::backdrop { background: rgba(7, 16, 24, 0.58); }

.instructions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  color: #ffffff;
  background: #071018;
}

.instructions-header h2 { margin: 0; }

.instructions-body {
  padding: 18px;
  line-height: 1.55;
  overflow: auto;
}

@media (max-width: 860px) {
  .topbar { grid-template-columns: 1fr; }
  .top-actions { justify-content: flex-start; flex-wrap: wrap; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-group.questions { margin-left: 0; }
  .toolbar-group > button,
  .toolbar-group > details { flex: 1 1 150px; }
  .toolbar summary { justify-content: center; }
  .model-panel { min-height: 360px; }
}

@media (max-width: 600px) {
  .app[data-screen-fit] .topbar { padding: 8px; gap: 8px; }
  .app[data-screen-fit] .brand { gap: 10px; }
  .app[data-screen-fit] .brand img { width: 90px; }
  .app[data-screen-fit] .brand h1 { font-size: 18px; }
  .app[data-screen-fit] .top-actions { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
  .app[data-screen-fit] .icon-button { width: 100%; min-width: 0; }
  .app[data-screen-fit] .home-button { padding: 0; font-size: 14px; }
}

@media print {
  @page { size: A4 landscape; margin: 8mm; }

  .topbar,
  .toolbar,
  .feedback,
  .instructions-dialog { display: none !important; }

  html,
  body,
  .app,
  .workspace {
    width: 100%;
    min-height: 0;
    height: auto;
    padding: 0;
    background: #ffffff;
  }

  .model-panel {
    min-height: 0;
    height: 176mm;
    border: 0;
  }
}
