:root {
  --ivory: #efe7d6;
  --marble: #f5f0e6;
  --marble-edge: #d8cdb6;
  --stone: #cdbfa4;
  --stone-dark: #9c8d72;
  --ink: #2c2620;
  --ink-soft: #5b5142;
  --pompeii: #9d3a2c;
  --pompeii-dark: #7d2c20;
  --lapis: #2d4a76;
  --gold: #b0884a;
  --shadow: rgba(44, 38, 32, 0.22);
}

* { box-sizing: border-box; }

/* id selectors with display:grid/flex would otherwise beat the UA [hidden] rule */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  font-family: "EB Garamond", Georgia, serif;
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 50% -10%, #fbf7ee 0%, var(--ivory) 55%, #e3d9c4 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2.2rem 1.2rem 3rem;
}

/* plaster grain overlay */
.grain {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.05;
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: 0;
}

main, header, footer { position: relative; z-index: 1; width: 100%; }

/* ---- masthead ---- */
#masthead {
  text-align: center;
  margin-bottom: 1.8rem;
}
#masthead h1 {
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: clamp(2.6rem, 7vw, 4.4rem);
  letter-spacing: 0.22em;
  margin: 0;
  color: var(--ink);
  text-shadow: 0 1px 0 #fff, 0 2px 3px var(--shadow);
}
.tagline {
  font-style: italic;
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  color: var(--ink-soft);
  margin: 0.3rem 0 0;
  letter-spacing: 0.04em;
}
/* Greek-key meander rule */
.meander {
  height: 16px;
  margin: 1rem auto 0;
  max-width: 320px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='16' viewBox='0 0 32 16'%3E%3Cpath d='M1 15V4h11V9H6v2h8V2H1' fill='none' stroke='%239d3a2c' stroke-width='1.4'/%3E%3C/svg%3E");
  background-repeat: repeat-x;
  background-position: center;
  opacity: 0.8;
}

/* ---- marble tablets ---- */
.tablet {
  max-width: 920px;
  margin: 0 auto;
  padding: 1.6rem;
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.6), rgba(255,255,255,0) 40%),
    linear-gradient(312deg, var(--marble-edge), rgba(216,205,182,0) 30%),
    repeating-linear-gradient(122deg, rgba(180,168,144,0.10) 0 2px, rgba(180,168,144,0) 2px 22px),
    var(--marble);
  border: 1px solid var(--marble-edge);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.7),
    inset 0 0 0 6px rgba(255,255,255,0.25),
    0 14px 34px -16px var(--shadow);
}

/* ---- intake / dropzone ---- */
#drop {
  display: block;
  cursor: pointer;
  border: 2px dashed var(--stone-dark);
  border-radius: 4px;
  background: rgba(255,255,255,0.25);
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
}
#drop:hover, #drop:focus, #drop.over {
  background: rgba(255,255,255,0.5);
  border-color: var(--pompeii);
  outline: none;
}
#drop.over { transform: scale(1.005); }
.drop-frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 3.4rem 1rem;
  text-align: center;
}
.drop-mark { font-size: 2.6rem; color: var(--stone-dark); line-height: 1; }
.drop-title { font-family: "Cinzel", serif; font-size: 1.4rem; letter-spacing: 0.08em; }
.drop-sub { color: var(--ink-soft); font-style: italic; }

.note {
  margin: 1rem 0 0;
  padding: 0.7rem 0.9rem;
  border-left: 3px solid var(--pompeii);
  background: rgba(157, 58, 44, 0.08);
  color: var(--pompeii-dark);
  font-size: 0.98rem;
  line-height: 1.4;
}
/* "please wait" variant — calm lapis, not alarm-red */
.note.note-working {
  border-left-color: var(--lapis);
  background: rgba(45, 74, 118, 0.08);
  color: var(--lapis);
}

/* ---- workshop ---- */
#workshop {
  display: grid;
  grid-template-columns: 1fr 250px;
  gap: 1.4rem;
  align-items: start;
}
.canvas-frame {
  position: relative;
  background: #efe7d6;
  padding: 12px;
  border-radius: 3px;
  border: 1px solid var(--marble-edge);
  box-shadow:
    inset 0 0 0 2px rgba(255,255,255,0.6),
    inset 0 0 26px rgba(44,38,32,0.10);
}
#out {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 2px;
  box-shadow: 0 6px 18px -8px var(--shadow);
}
#busy {
  position: absolute;
  inset: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(245,240,230,0.78);
  font-family: "Cinzel", serif;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

/* ---- controls ---- */
.controls { display: flex; flex-direction: column; gap: 1.1rem; }
.control { display: flex; flex-direction: column; gap: 0.4rem; }
.control label {
  font-family: "Cinzel", serif;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.val { color: var(--pompeii); font-family: "EB Garamond", serif; }

select, input[type="range"] { width: 100%; }
select {
  font-family: "EB Garamond", serif;
  font-size: 1rem;
  padding: 0.45rem 0.5rem;
  color: var(--ink);
  background: rgba(255,255,255,0.6);
  border: 1px solid var(--stone-dark);
  border-radius: 3px;
}
input[type="range"] { accent-color: var(--pompeii); }

/* ---- photomosaic library intake ---- */
#libdrop {
  display: block;
  cursor: pointer;
  border: 2px dashed var(--stone-dark);
  border-radius: 4px;
  background: rgba(255,255,255,0.25);
  padding: 0.9rem 0.6rem;
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.35;
  transition: background 0.2s, border-color 0.2s;
}
#libdrop em { color: var(--ink-soft); font-size: 0.85rem; }
#libdrop:hover, #libdrop:focus, #libdrop.over {
  background: rgba(255,255,255,0.5);
  border-color: var(--pompeii);
  outline: none;
}
#libbar {
  height: 6px;
  border-radius: 3px;
  background: rgba(156, 141, 114, 0.35);
  overflow: hidden;
}
#libbar i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--pompeii);
  transition: width 0.2s;
}
.lib-status {
  margin: 0;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--ink-soft);
  line-height: 1.35;
}

.buttons { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.4rem; }
.btn {
  font-family: "Cinzel", serif;
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  padding: 0.6rem 0.8rem;
  border-radius: 3px;
  border: 1px solid var(--stone-dark);
  background: linear-gradient(#fbf7ee, #e7ddc8);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.15s, background 0.15s;
  box-shadow: 0 2px 0 var(--marble-edge);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn-primary {
  background: linear-gradient(var(--pompeii), var(--pompeii-dark));
  border-color: var(--pompeii-dark);
  color: #fdf2ec;
  box-shadow: 0 2px 0 #5e201757;
}
.btn-quiet { background: transparent; border-color: transparent; color: var(--ink-soft); box-shadow: none; }
.btn-quiet:hover { color: var(--pompeii); }

footer {
  margin-top: 2rem;
  text-align: center;
  color: var(--ink-soft);
  font-style: italic;
  font-size: 0.92rem;
  max-width: 560px;
}

@media (max-width: 680px) {
  #workshop { grid-template-columns: 1fr; }
}
