:root {
  --font-color: #F3EFE6;
  --tekhelet: #202326;
  --indianred: #D46A5F;
  --aquamarine: #4FB9AE;
  --goldenrod: #D8993E;
  --coral: #E6AD61;
  --editor-bg-color: #202326;
  --header-bg-color: #17191B;
  --sidebar-bg-color: #25292C;
  --tab-bg-color: var(--goldenrod);
  --textarea-bg-color: #292D30;
  --surface-raised: #25292C;
  --surface-hover: #303538;
  --muted-font-color: #A9ADA8;
  --subtle-font-color: #7F8683;
  --border-color: #41484A;
  --border-strong: #596164;
  --focus-color: var(--aquamarine);
  --shadow-color: rgba(7, 9, 10, 0.28);
  --border-radius: 0.45rem;
  --header-mobile-height: 8rem;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.material-symbols-outlined {
  font-variation-settings:
    'FILL' 0,
    'wght' 300,
    'GRAD' 0,
    'opsz' 24;
  margin-right: 0.4rem;
}

* {
  box-sizing: border-box;
  scrollbar-color: rgba(255, 255, 255, 0.25) rgba(0, 0, 0, 0);
  scrollbar-width: thin;
  padding: 0;
  margin: 0;
}

body,
html {
  background: var(--editor-bg-color);
  color: var(--font-color);
  font-family: 'Barlow', sans-serif;
  font-size: 1rem;
  font-style: normal;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h2 {
  font-family: 'Barlow', sans-serif;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--font-color);
  line-height: 1.25;
  letter-spacing: -0.015em;
  margin-bottom: 0.35rem;
}

h3 {
  font-family: 'Barlow', sans-serif;
  font-size: 1rem;
  font-weight: 400;
  color: var(--muted-font-color);
  line-height: 1.5;
}

.section-heading {
  font-family: 'Barlow', sans-serif;
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-font-color);
}

.clickable,
button {
  user-select: none;
  cursor: pointer;
  color: var(--font-color);
  font-family: 'Barlow', sans-serif;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease,
    box-shadow 150ms ease, transform 150ms ease;
}

.clickable:hover,
button:hover {
  transform-origin: center;
  transform: translateY(-1px);
}

.btn-ai {
  background: var(--goldenrod);
  color: #211A10;
  border: 1px solid transparent;
  padding: 1rem;
  border-radius: var(--border-radius);
  font-family: 'Barlow', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  float: right;
  margin-left: 1rem;
  box-shadow: 0 10px 24px var(--shadow-color);
}

.btn-ai:hover {
  background: var(--coral);
  box-shadow: 0 12px 28px var(--shadow-color);
}

textarea {
  font-family: 'Barlow', sans-serif;
  font-size: 1.1rem;
  font-style: normal;
  font-weight: 400;
  color: var(--font-color);
  background: var(--textarea-bg-color);
  border: 1px solid var(--border-color);
  margin-top: 1rem;
  margin-bottom: 1rem;
  padding: 1rem;
  border-radius: var(--border-radius);
  width: 100%;
  field-sizing: content;
  min-height: 10rem;
  max-height: 30rem;
  resize: none;
  outline: none;
  line-height: 1.6;
  box-shadow: 0 12px 30px rgba(7, 9, 10, 0.16);
}

textarea::placeholder,
input::placeholder {
  color: var(--subtle-font-color);
  opacity: 1;
}

#canvas-container {
  position: fixed;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  top: 0;
  left: 100vw;
  transition: all 200ms ease-in-out;
  z-index: 3;
}

#canvas-container #edit-btn {
  position: absolute;
  bottom: 2rem;
  left: calc(100vw - 8rem);
  display: flex;
  align-items: center;
  justify-content: left;
  width: 6rem;
  padding: 1rem;
  background: #F0F0F0;
  color: black;
  border-radius: var(--border-radius);
  z-index: 9;
}

#controls-btn {
  position: absolute;
  right: 9rem;
  bottom: 2rem;
  z-index: 9;
  display: flex;
  align-items: center;
  padding: 1rem;
  border: none;
  border-radius: var(--border-radius);
  background: var(--goldenrod);
  color: #211A10;
  font-size: 1rem;
  font-weight: 600;
  box-shadow: 0 10px 24px var(--shadow-color);
}

#controls-btn[hidden] {
  display: none;
}

#effect-controls-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(24rem, 100vw);
  height: 100vh;
  z-index: 8;
  overflow-y: auto;
  padding: 2rem;
  background: var(--sidebar-bg-color);
  border-left: 1px solid var(--border-color);
  box-shadow: -18px 0 44px var(--shadow-color);
  transform: translateX(100%);
  transition: transform 200ms ease-in-out;
}

#effect-controls-panel.active {
  transform: translateX(0);
}

#effect-controls {
  /*
   * Reserve scrollable space below the final control for the floating
   * Controls and Edit buttons.
   */
  padding-bottom: 4.5rem;
}

.effect-controls-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.effect-controls-header h2 {
  margin: 0;
}

#close-controls-btn {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--surface-raised);
  color: var(--font-color);
}

#close-controls-btn .material-symbols-outlined {
  margin: 0;
}

.effect-control {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.65rem 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-color);
}

.effect-control label {
  font-weight: 500;
}

.effect-control output {
  color: var(--aquamarine);
  font-variant-numeric: tabular-nums;
}

.effect-control input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--goldenrod);
}

.effect-control input[type="color"] {
  width: 3rem;
  height: 2.25rem;
  padding: 0.15rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--textarea-bg-color);
}

.effect-control input[type="checkbox"] {
  grid-column: 1;
  grid-row: 1;
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--goldenrod);
}

.effect-control-checkbox {
  grid-template-columns: auto 1fr;
}

.effect-control-checkbox label {
  grid-column: 2;
  justify-self: start;
}

.effect-control select {
  min-width: 8rem;
  padding: 0.55rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--textarea-bg-color);
  color: var(--font-color);
}

#editor-container {
  position: fixed;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  top: 0;
  left: -100vw;
  transition: all 200ms ease-in-out;
}

#editor-container.active,
#canvas-container.active {
  left: 0;
}

/* 
HEADER
*/

#header {
  position: absolute;
  width: 100%;
  height: 6rem;
  background: var(--header-bg-color);
  overflow: hidden;
}

#header #options-container {
  position: absolute;
  right: 2rem;
  bottom: 1rem;
}

#header #tabs-container {
  position: absolute;
  left: 1rem;
  bottom: 0;
  display: flex;
  align-items: flex-end;
}

.settings-item {
  float: left;
  margin-left: 1rem;
  display: flex;
  align-items: center;
  justify-content: left;
}

.settings-item .material-symbols-outlined {
  font-size: 1.0rem;
  margin-right: 0.3rem;
}

.tab-item {
  float: left;
  padding: 0.5rem 1rem;
  margin-right: 1rem;
  background: color-mix(in srgb, black 40%, var(--tab-bg-color) 60%);
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  color: color-mix(in srgb, white 70%, var(--tekhelet) 30%);
  transition: all 200ms ease-in-out;
}

.tab-item.active {
  background: var(--tab-bg-color);
  color: white;
  font-weight: 600;
}

.tab-item:hover {
  color: color-mix(in srgb, white 90%, var(--indianred) 10%);
  padding-bottom: 1.05rem;
  transition: all 200ms ease-in-out;
}

/* 
EDITOR
*/

#editor-body {
  position: absolute;
  width: 100%;
  height: calc(100vh - 6rem);
  top: 6rem;
  background: var(--editor-bg-color);
  overflow: hidden;
  overflow-y: scroll;
}

.editor-item {
  position: absolute;
  width: 100%;
  max-height: 0px;
  min-height: 0px;
  transition: all 200ms ease-in-out;
  overflow: hidden;
  background: var(--editor-bg-color);
}

.editor-item.active {
  min-height: 100%;
  padding-bottom: 10rem;
}

#idea-container,
#instructions-container {
  display: flex;
  align-items: start;
  justify-content: center;
}

#idea-container .ui-block,
#instructions-container .ui-block {
  width: 50%;
  padding: 2rem;
}

.code-editor {
  display: block;
  position: relative;
  float: left;
  width: 50%;
  padding: 0;
}

.code-editor .CodeMirror-code::after {
  content: "";
  display: block;
  height: 20rem;
  pointer-events: none;
}

.color-palette {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(2rem, 1fr));
  gap: 0.5rem;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.1);
  border-radius: var(--border-radius);
  margin: 0.5rem 0;
}

.color-palette #color-palette {
  padding-right: 2rem;
}

.color-swatch {
  width: 2rem;
  height: 2rem;
  border-radius: 2rem;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s ease;
}

.color-swatch:hover {
  transform: scale(1.05);
  border-color: rgba(255, 255, 255, 0.5);
}

.color-swatch.selected {
  border-color: var(--aquamarine);
  border-width: 3px;
  transform: scale(1.05);
}

#effect-container {
  display: block;
}

#effect-container .ui-block {
  display: block;
  position: relative;
  float: left;
  width: 50%;
  padding: 2rem;
}

.effect-buttons {
  position: absolute;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  gap: 1rem;
  flex-direction: row-reverse;
  z-index: 10;
}

#spellbook-container .effect-buttons {
  position: absolute;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  gap: 1rem;
  flex-direction: row-reverse;
  z-index: 10;
}

#spellbook-container.active .effect-buttons {
  position: fixed;
}

#effect-container #play-btn,
button#export-spellbook {
  position: static;
  display: flex;
  align-items: center;
  justify-content: left;
  width: auto;
  padding: 1rem;
  background: var(--aquamarine);
  color: var(--tekhelet);
  border-radius: var(--border-radius);
  font-weight: 500;
  font-size: 1.1rem;
  border: none
}

#effect-container #save-btn,
button#import-spellbook {
  position: static;
  display: flex;
  align-items: center;
  justify-content: left;
  width: auto;
  padding: 1rem;
  background: color-mix(in srgb, var(--tekhelet) 10%, white 90%);
  color: var(--tekhelet);
  border-radius: var(--border-radius);
  font-weight: 500;
  font-size: 1.1rem;
  border: none
}

#effect-container #play-btn:hover,
.effect-buttons #export-spellbook:hover {
  background: color-mix(in srgb, white 60%, var(--aquamarine) 40%);
}

#effect-container #save-btn:hover,
.effect-buttons #import-spellbook:hover {
  background: color-mix(in srgb, var(--tekhelet) 20%, white 80%);
}

/* 
SIDE BAR
*/

.side-bar {
  position: fixed;
  left: -100vw;
  top: 0;
  box-sizing: border-box;
  transition: all 200ms ease-in-out;
  height: 100vh;
  overflow: hidden;
  overflow-y: scroll;
  background: var(--sidebar-bg-color);
  padding: 2rem;
  padding-top: 5rem;
  z-index: 999;
}

.side-bar.active {
  left: 0;
}

.close-btn {
  position: absolute;
  top: 2rem;
  right: 2rem;
}

.side-bar h3 {
  font-weight: 500
}

.side-bar p {
  color: color-mix(in srgb, white 90%, var(--tekhelet) 10%);
  margin-bottom: 1rem
}

.side-bar a {
  color: var(--aquamarine)
}

.side-bar smalltext {
  font-size: 0.8rem;
  color: color-mix(in srgb, white 80%, var(--tekhelet) 20%);
  font-style: normal;
  font-weight: 400;
}

.side-bar input[type="password"],
.side-bar select {
  color: var(--indianred);
  font-size: 1.1rem;
  background: white;
  border: none;
  padding: 0.5rem;
  border-radius: var(--border-radius);
  width: 100%;
  field-sizing: content;
  resize: none;
  outline: none;
}

.side-bar select {
  font-family: "Barlow", sans-serif;
  cursor: pointer;
}

.side-bar #credits {
  position: absolute;
  bottom: 2rem;
  left: 2rem;
}

#history-list {
  display: block;
  /* Remove list styling */
  padding: 0;
  margin-top: 1rem;
  border-radius: var(--border-radius);
}

.history-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.5rem;
  align-items: center;
  padding-bottom: 0.6rem;
  padding-top: 0.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.4);
  list-style: none;
}

.history-item .history-meta,
.history-item .prompt,
.history-item .refinement-prompt {
  grid-column: 1;
}

.history-item .history-meta {
  grid-row: 1;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.history-item .date-time,
.history-item .history-type {
  font-size: 0.8rem;
  opacity: 0.8;
}

.history-item .history-type {
  color: var(--aquamarine);
  font-weight: 500;
}

.history-item .prompt {
  grid-row: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  font-size: 0.9rem;
}

.history-item .refinement-prompt {
  grid-row: 3;
  color: var(--muted-font-color);
  font-size: 0.85rem;
  line-height: 1.4;
  white-space: pre-wrap;
}

.history-btn {
  grid-row: 1 / -1;
  align-self: center;
  padding: 0.5rem;
  cursor: pointer;
}

.history-btn svg {
  width: 20px;
  height: 20px;
  fill: white;
  transition: all 200ms ease-in-out;
}

.history-btn.with-icon {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 0.5rem;
  background-color: rgba(255, 255, 255, 0.1);
  font-size: 0.9rem;
}

.history-btn.with-icon:hover {
  background: rgba(255, 255, 255, 0.4);
}

.history-btn.with-icon.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.side-bar-buttons {
  position: absolute;
  top: 5rem;
  right: 2rem;
  display: flex;
  gap: 1rem;
  flex-direction: row-reverse;
}

.side-bar #import-history,
.side-bar #export-history {
  position: static;
  display: flex;
  align-items: center;
  justify-content: left;
  width: auto;
  padding: 0.4rem;
  padding-left: 0.8rem;
  padding-right: 0.8rem;
  background: var(--aquamarine);
  color: var(--tekhelet);
  border-radius: var(--border-radius);
  font-weight: 500;
  font-size: 1rem;
  border: none
}

.side-bar #export-history:hover {
  background: color-mix(in srgb, white 60%, var(--aquamarine) 40%)
}

.side-bar #import-history {
  background: color-mix(in srgb, var(--tekhelet) 10%, white 90%);
}

.side-bar #import-history:hover {
  background: white;
}

#settings-container {
  width: 400px;
}

#history-container,
#spellbook-container {
  width: 100vw;
}

#spellbook-container {
  background: var(--header-bg-color);
  height: 100vh;
  overflow-y: scroll;
  padding-left: 0;
  padding-right: 0;
}

#spellbook-container .ui-block {
  padding-left: 2rem;
  padding-right: 2rem;
}

#spellbook-container #spellbook-welcome {
  position: relative;
  float: left;
  margin-bottom: 5.0rem;
}

#spellbook-container #spellbook-welcome h1 {
  position: relative;
  float: left;
  clear: both;
  font-family: "Domine", "Barlow", sans-serif;
  font-size: 2.5rem;
  line-height: 1.1em;
  font-weight: 600;
}

#spellbook-container #spellbook-welcome span.app-name {
  background: linear-gradient(110deg, var(--indianred) 30%, var(--coral) 80%, var(--goldenrod));
  color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  /* color: var(--indianred); */
}

#spellbook-container #spellbook-welcome h2 {
  position: relative;
  float: left;
  clear: both;
  font-family: "Domine", "Barlow", sans-serif;
  font-size: 2.5rem;
  line-height: 1.1em;
  font-weight: 600;
}

#spellbook-container.active .close-btn {
  position: fixed;
}

/*
SPELL LIST
*/

.modal-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: -1;
}

.modal-wrapper.active {
  z-index: 999;
}

#save-spell-modal {
  width: 400px;
  height: auto;
  background: var(--editor-bg-color);
  border-radius: var(--border-radius);
  padding: 2rem;
}

#save-cancel-btns {
  display: flex;
  gap: 1rem;
  flex-direction: row-reverse;
}

.modal input[type="text"] {
  color: var(--indianred);
  font-family: "Barlow", sans-serif;
  font-weight: 400;
  font-size: 1.1rem;
  background: white;
  border: none;
  padding: 1rem;
  margin-top: 1rem;
  margin-bottom: 1rem;
  border-radius: var(--border-radius);
  width: 100%;
  field-sizing: content;
  resize: none;
  outline: none;
}

#save-spell-btn {
  position: static;
  display: flex;
  align-items: center;
  justify-content: left;
  width: auto;
  padding: 1rem;
  background: var(--aquamarine);
  color: var(--tekhelet);
  border-radius: var(--border-radius);
  font-weight: 500;
  border: none;
  font-size: 1.1rem;
}

#cancel-save-spell-btn {
  position: static;
  display: flex;
  align-items: center;
  justify-content: left;
  width: auto;
  padding: 1rem;
  background: color-mix(in srgb, var(--tekhelet) 10%, white 90%);
  color: var(--tekhelet);
  border-radius: var(--border-radius);
  font-weight: 500;
  border: none;
  font-size: 1.1rem;
}

#save-spell-btn:hover {
  background: color-mix(in srgb, white 60%, var(--aquamarine) 40%);
}

#cancel-save-spell-btn:hover {
  background: color-mix(in srgb, var(--tekhelet) 20%, white 80%);
}

#spell-list {
  /* position: absolute; */
  position: relative;
  width: 100vw;
  /* height: 100vh; */
  display: grid;
  align-items: start;
  grid-template-columns: repeat(auto-fill, minmax(20rem, 2.0fr));
  /* grid-template-rows: repeat(auto-fill, 18rem); */
  gap: 2rem;
  padding: 0;
  /* overflow-y: scroll; */
  padding-bottom: 20rem;
  /* padding-top: 20rem; */
  z-index: -1;
}

#spellbook-container.active #spell-list::after {
  content: "";
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100vw;
  height: 10vh;
  background: linear-gradient(0deg, var(--header-bg-color) 0%, rgba(0, 0, 0, 0));
}

#add-spell-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 3px dashed rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  gap: 0.25rem;
}

#add-spell-btn .material-symbols-outlined {
  font-size: 3rem;
  margin: 0;
}

#add-spell-btn span:not(.material-symbols-outlined) {
  font-size: 1.1rem;
  color: white;
  font-weight: 500;
}

#add-spell-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  border: 3px dashed white;
  transform: translateY(-2px);
  transition: all 0.2s ease-
}

/* Spell Item Base */
.spell-item {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 18rem;
  border-radius: var(--border-radius);
  border: 3px solid rgba(255, 255, 255, 0.3);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: all 200ms ease-in-out;
}

/* Example spell tag */
.spell-item.example::after {
  content: "EXAMPLE";
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 0.3rem 0.5rem;
  background: white;
  color: var(--tekhelet);
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--border-radius);
  z-index: 5;
}

/* Delete Spell Button */
.del-spell-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  cursor: pointer;
}

.spell-item:hover {
  opacity: 1;
  border: 3px solid white;
  transform: translateY(-1px);
  transition: all 200ms ease-in-out;
  box-shadow: 0px 2px 10px black 20%;
}

.del-spell-btn:hover {
  background: var(--indianred);
  transform: translateY(-1px);
  transition: all 200ms ease-in-out;
  box-shadow: 0px 2px 10px black 20%;
}

.del-spell-btn .material-symbols-outlined {
  font-size: 1.25rem;
  color: white;
  margin: 0;
}

/* Spell Image/Thumbnail */
.spell-item .spell-img {
  position: relative;
  width: 100%;
  height: 60%;
  background-size: cover;
  background-position: center;
  background-color: rgba(0, 0, 0, 0.3);
}

/* Spell Metadata (text area) */
.spell-item .spell-meta {
  padding: 0.75rem;
  height: 40%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.25rem;
}

.spell-item .spell-meta h3 {
  font-size: 1rem;
  font-weight: 500;
  margin: 0;
  color: white;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spell-item .spell-meta .date-time {
  font-size: 0.75rem;
  opacity: 0.7;
  color: rgba(255, 255, 255, 0.8);
}

/* Responsive breakpoints */
@media (max-width: 640px) {
  #spell-list {
    grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
    gap: 1rem;
  }

  .spell-item {
    height: 10rem;
  }
}

@media (min-width: 641px) and (max-width: 1024px) {
  #spell-list {
    grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
    gap: 1.5rem;
  }

  .spell-item {
    height: 12rem;
  }
}

@media (min-width: 1025px) and (max-width: 1600px) {
  #spell-list {
    grid-template-columns: repeat(auto-fill, minmax(14rem, 1.2fr));
    gap: 2rem;
  }

  .spell-item {
    height: 14rem;
  }
}

#spellbook-btn {
  position: absolute;
  bottom: 2rem;
  left: 2rem;
  display: flex;
  align-items: center;
  justify-content: left;
  width: auto;
  padding: 1rem;
  background: none;
  color: white;
  outline: 1px solid white;
  border-radius: var(--border-radius);
  z-index: 2;
}

#spellbook-btn:hover {
  background: color-mix(in srgb, white 20%, var(--tekhelet) 80%);
}

#spell-saving-modal,
#load-spell-modal {
  width: 400px;
  height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner {
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid var(--aquamarine);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 0.8s linear infinite;
}

/*
BUSY
*/

#busy {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: -1;
  user-select: none;
}

#busy.active {
  z-index: 999;
}

@media (width <=800px) {

  body,
  html {
    font-size: 17px;
  }

  #header {
    height: var(--header-mobile-height);
  }

  #header .header-item {
    width: 100%;
  }

  #header #options-container {
    top: 1rem;
    left: 1rem;
  }

  #header .settings-item {
    margin-left: 0;
    margin-right: 1rem;
  }

  #header #tabs-container {
    left: 0rem;
    display: flex;
    justify-content: center;
  }

  #header .tab-item {
    margin: 0 0.25rem;
  }

  #editor-body {
    height: calc(100vh - var(--header-mobile-height));
    top: var(--header-mobile-height);
  }

  #idea-container,
  #instructions-container,
  #effect-container {
    display: block;
    left: -100vw;
    top: 0;
    max-height: 10000px;
    padding-top: 2rem;
  }

  #idea-container.active,
  #instructions-container.active,
  #effect-container.active {
    left: 0;
    top: 0;
    max-height: 10000px;
  }

  .ui-block {
    width: 100% !important;
    padding: 1.5rem !important;
  }

  .code-editor {
    width: 100% !important;
  }

  #spellbook-btn {
    position: fixed;
    top: 0.5rem;
    right: 0.5rem;
    bottom: unset;
    left: unset;
  }

  #effect-controls-panel {
    width: 100vw;
    padding: 1.25rem;
  }

  #effect-container.active #play-btn {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 2;
  }

  #effect-container.active::before {
    content: "";
    position: fixed;
    top: unset;
    right: unset;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 20vh;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0));
    z-index: 1;
  }

  #effect-container.active #save-btn {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    z-index: 2;
  }

  .side-bar {
    width: 100% !important;
    padding: 3rem 0.5rem;
  }

  .copy-history {
    display: none !important;
  }

  .side-bar #credits {
    position: absolute;
    bottom: 2rem;
    left: 0;
  }

  #spellbook-container #spellbook-welcome {
    margin-bottom: 0;
  }

  #spellbook-container #spellbook-welcome h1,
  #spellbook-container #spellbook-welcome h2 {
    font-size: 1.5rem;
  }

}

/*
GRAPHITE & AMBER VISUAL SYSTEM
Layout and positioning intentionally remain governed by the original rules above.
*/

* {
  scrollbar-color: var(--border-strong) transparent;
}

::selection {
  color: #101514;
  background: color-mix(in srgb, var(--aquamarine) 72%, white);
}

button,
input,
textarea {
  font-family: 'Barlow', sans-serif;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
.clickable:focus-visible {
  outline: 2px solid var(--focus-color);
  outline-offset: 3px;
}

textarea:focus,
.side-bar input[type="password"]:focus,
.side-bar select:focus,
.modal input[type="text"]:focus {
  border-color: var(--focus-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus-color) 22%, transparent);
}

#header {
  border-bottom: 1px solid var(--border-color);
}

.settings-item {
  color: var(--muted-font-color);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.settings-item:hover,
.close-btn:hover {
  color: var(--font-color);
}

.tab-item {
  background: #1D2022;
  border: 1px solid var(--border-color);
  border-bottom: none;
  color: var(--muted-font-color);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.tab-item.active {
  background: var(--tab-bg-color);
  border-color: transparent;
  color: #211A10;
  font-weight: 600;
}

.tab-item:hover {
  color: var(--font-color);
  padding-bottom: 0.5rem;
  border-color: var(--border-strong);
}

.tab-item.active:hover {
  color: #211A10;
  border-color: transparent;
}

.color-palette {
  background: var(--surface-raised);
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 24px rgba(7, 9, 10, 0.14);
}

.color-swatch {
  border-color: var(--border-color);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.24);
}

.color-swatch:hover {
  border-color: var(--border-strong);
}

.color-swatch.selected {
  border-color: var(--focus-color);
}

#effect-container #play-btn,
button#export-spellbook,
.side-bar #export-history,
#save-spell-btn {
  background: var(--goldenrod);
  color: #211A10;
  border: 1px solid transparent;
  font-weight: 600;
  box-shadow: 0 10px 24px var(--shadow-color);
}

#effect-container #save-btn,
button#import-spellbook,
.side-bar #import-history,
#cancel-save-spell-btn {
  background: var(--surface-raised);
  color: var(--font-color);
  border: 1px solid var(--border-color);
  font-weight: 500;
}

#effect-container #play-btn:hover,
.effect-buttons #export-spellbook:hover,
.side-bar #export-history:hover,
#save-spell-btn:hover {
  background: var(--coral);
  color: #211A10;
}

#effect-container #save-btn:hover,
.effect-buttons #import-spellbook:hover,
.side-bar #import-history:hover,
#cancel-save-spell-btn:hover {
  background: var(--surface-hover);
  color: var(--font-color);
  border-color: var(--border-strong);
}

.side-bar {
  border-right: 1px solid var(--border-color);
  box-shadow: 18px 0 44px var(--shadow-color);
}

.side-bar h3 {
  color: var(--font-color);
  font-weight: 600;
}

.side-bar p {
  color: var(--muted-font-color);
  line-height: 1.6;
}

.side-bar a {
  color: var(--aquamarine);
  text-decoration-color: color-mix(in srgb, var(--aquamarine) 45%, transparent);
  text-underline-offset: 0.2em;
}

.side-bar smalltext {
  color: var(--subtle-font-color);
}

.side-bar input[type="password"],
.side-bar select,
.modal input[type="text"] {
  color: var(--font-color);
  background: var(--textarea-bg-color);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
}

.history-item {
  border-bottom-color: var(--border-color);
}

.history-item .date-time {
  color: var(--subtle-font-color);
}

.history-item .prompt {
  color: var(--font-color);
}

.history-btn svg {
  fill: var(--muted-font-color);
}

.history-btn.with-icon {
  background: var(--surface-raised);
  border: 1px solid var(--border-color);
}

.history-btn.with-icon:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

#spellbook-container {
  background: var(--header-bg-color);
}

#spellbook-container #spellbook-welcome h1,
#spellbook-container #spellbook-welcome h2 {
  color: var(--font-color);
  letter-spacing: -0.025em;
}

#spellbook-container #spellbook-welcome span.app-name {
  background: linear-gradient(110deg, var(--goldenrod) 20%, var(--coral) 72%);
  color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
}

.modal-wrapper,
#busy {
  background: rgba(8, 10, 11, 0.72);
  backdrop-filter: blur(4px);
}

#save-spell-modal,
#spell-saving-modal,
#load-spell-modal {
  background: var(--surface-raised);
  border: 1px solid var(--border-color);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
}

#add-spell-btn,
.spell-item {
  background: var(--surface-raised);
  border: 1px solid var(--border-color);
  box-shadow: 0 12px 28px rgba(7, 9, 10, 0.18);
}

#add-spell-btn {
  border-style: dashed;
}

#add-spell-btn span:not(.material-symbols-outlined),
.spell-item .spell-meta h3 {
  color: var(--font-color);
}

#add-spell-btn:hover,
.spell-item:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  box-shadow: 0 16px 34px var(--shadow-color);
}

.spell-item.example::after {
  background: var(--goldenrod);
  color: #211A10;
  border-radius: 0.3rem;
}

.spell-item .spell-img {
  background-color: #17191B;
  border-bottom: 1px solid var(--border-color);
}

.spell-item .spell-meta .date-time {
  color: var(--subtle-font-color);
}

.del-spell-btn {
  background: rgba(12, 14, 15, 0.78);
  border: 1px solid var(--border-color);
}

.del-spell-btn:hover {
  background: var(--indianred);
}

#spellbook-btn {
  color: var(--font-color);
  background: var(--surface-raised);
  outline: none;
  border: 1px solid var(--border-color);
  font-weight: 500;
}

#spellbook-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.spinner {
  border-color: var(--border-color);
  border-top-color: var(--goldenrod);
  width: 44px;
  height: 44px;
}