* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: #e6e0d4;
  color: #1c1916;
  font-family: Inter, "Noto Sans", "Liberation Sans", sans-serif;
  font-synthesis: none;
  color-scheme: light;
}

main {
  display: grid;
  grid-template-columns: minmax(300px, 560px) minmax(260px, 1fr);
  gap: 36px;
  align-items: start;
  flex: 1 0 auto;
  padding: 32px 40px 20px;
}

h1 {
  margin: 0;
  font-family: "Noto Serif", "Liberation Serif", Georgia, serif;
  font-size: 42px;
  font-weight: 400;
  line-height: 1.1;
}

.lede {
  margin: 12px 0 22px;
  max-width: 38em;
  font-size: 16px;
  line-height: 1.45;
  color: #3f3a34;
}

.panel, .field {
  display: grid;
  gap: 12px;
}

.field { margin-top: 6px; }

.label, .sheet-label {
  margin: 0;
  color: #5e574e;
  font-size: 13px;
}

.sheet-label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: #3f3a34;
}

input {
  width: 100%;
  border: 1px solid #c9c0b2;
  border-radius: 6px;
  background: #fffcf7;
  color: #1c1916;
  font: inherit;
  font-size: 16px;
  padding: 10px 12px;
}

input[type="range"] { padding: 0; accent-color: #1c1916; }

.inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline input { width: 7em; }

.hint, .fine, #status, .notice {
  margin: 0;
  max-width: 46em;
  font-size: 13px;
  line-height: 1.4;
  color: #5e574e;
}

#status { min-height: 1.2em; font-size: 14px; color: #1c1916; }

.notice:empty { display: none; }

.notice { color: #8a2e24; }

button, .file-button {
  justify-self: start;
  border: 1px solid #1c1916;
  border-radius: 6px;
  background: transparent;
  color: #1c1916;
  font: inherit;
  font-size: 15px;
  padding: 10px 16px;
  cursor: pointer;
}

.file-button {
  position: relative;
  display: inline-flex;
  width: fit-content;
  padding: 8px 12px;
  font-size: 14px;
}

.file-button input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  padding: 0;
  border: 0;
  cursor: pointer;
}

button:hover:not(:disabled), .file-button:hover { background: #f3ece1; }

button:disabled { cursor: default; opacity: 0.45; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.segment {
  display: grid;
  gap: 1px;
  background: #1c1916;
  border: 1px solid #1c1916;
  border-radius: 6px;
  overflow: hidden;
}

.segment.cols-2 { grid-template-columns: repeat(2, 1fr); }

.segment button {
  width: 100%;
  justify-self: stretch;
  border: 0;
  border-radius: 0;
  background: #e6e0d4;
  padding: 10px 6px;
  font-size: 14px;
}

.segment button[aria-pressed="true"] {
  background: #1c1916;
  color: #fffcf7;
}

.segment button[aria-pressed="true"]:hover { background: #1c1916; }

:focus-visible { outline: 2px solid #1c1916; outline-offset: 2px; }

.drop {
  min-height: 180px;
  border: 1px dashed #b7ad9e;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 24px;
}

.drop.over { border-style: solid; border-color: #1c1916; }

.drop.compact { min-height: 0; padding: 16px; }

.drop-title { margin: 0; font-size: 16px; }

#frames {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 10px;
}

#frames li {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 8px;
  border: 1px solid #1c1916;
  border-radius: 6px;
  background: #fffcf7;
}

#frames li.drag-over { outline: 2px solid #1c1916; outline-offset: 2px; }

#frames li.dragging { opacity: 0.45; }

.thumb {
  width: 100%;
  height: auto;
  border-radius: 4px;
  background: #e6e0d4;
  cursor: grab;
}

.frame-name {
  margin: 0;
  font-size: 12px;
  color: #5e574e;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.frame-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.frame-actions button {
  padding: 6px 8px;
  font-size: 13px;
}

.stage {
  display: grid;
  justify-items: start;
  gap: 12px;
}

#preview {
  max-width: 100%;
  height: auto;
  background: #fffcf7;
  border: 1px solid #c9c0b2;
  border-radius: 8px;
}

[hidden] { display: none !important; }

noscript { display: block; padding: 16px 20px; background: #fff4e8; }

@media (min-width: 861px) {
  .stage { position: sticky; top: 24px; }
}

@media (max-width: 860px) {
  main { grid-template-columns: 1fr; padding: 24px 18px 16px; }
  h1 { font-size: 34px; }
}
