:root {
  --bg: #f5f5f5;
  --fg: #111111;
  --panel-bg: rgba(255, 255, 255, 0.88);
  --panel-fg: #111;
  --muted: #6c717a;
  --line: rgba(0, 0, 0, 0.14);
  --accent: #20553f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "Helvetica Neue", "SF Pro Text", "Segoe UI", Arial, sans-serif;
}

#app {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#panel {
  width: 320px;
  min-width: 320px;
  max-width: 320px;
  height: 100vh;
  overflow: auto;
  padding: 22px 18px 28px;
  background: var(--panel-bg);
  color: var(--panel-fg);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

#panel.inverted {
  --panel-bg: rgba(14, 14, 14, 0.9);
  --panel-fg: #efefef;
  --line: rgba(255, 255, 255, 0.14);
  --muted: #a8adb7;
}

h1 {
  margin: 4px 0 18px;
  font-family: "Times New Roman", Times, serif;
  font-style: italic;
  font-size: 36px;
  letter-spacing: 0.2px;
  line-height: 1.04;
}

section {
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

h2 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.08em;
}

label {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  margin: 7px 0;
  font-size: 12px;
}

label > span[data-for] {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

input[type="range"] {
  width: 100%;
}

input[type="number"],
select,
textarea,
button,
input[type="color"] {
  font: inherit;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  color: inherit;
  border-radius: 8px;
  padding: 6px 8px;
}

#panel.inverted input[type="number"],
#panel.inverted select,
#panel.inverted textarea,
#panel.inverted button,
#panel.inverted input[type="color"] {
  background: rgba(0, 0, 0, 0.28);
}

button {
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

#paletteError {
  min-height: 16px;
  color: #b30f2e;
  font-size: 11px;
}

#swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.swatch {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid var(--line);
}

#recordStatus {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

#recordPanel {
  display: none;
  margin-top: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 11px;
}

.recTop,
.recBottom {
  display: flex;
  justify-content: space-between;
}

#recLabel {
  color: #d03f3f;
}

.recBar {
  margin: 7px 0;
  height: 4px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}

#recFill {
  width: 0%;
  height: 100%;
  background: #d03f3f;
  transition: width 0.1s linear;
}

#recordDownloadWrap {
  display: none;
  margin-top: 8px;
}

#recordDownload {
  display: block;
  font-size: 11px;
  text-align: center;
  border: 1px solid #3aaa72;
  border-radius: 6px;
  color: #3aaa72;
  background: rgba(20, 90, 54, 0.18);
  text-decoration: none;
  padding: 6px;
}

#previewWrap {
  flex: 1;
  min-width: 0;
  position: relative;
  background: radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.24), rgba(0, 0, 0, 0) 50%);
}

#preview {
  width: 100%;
  height: 100%;
  display: block;
}

@media (max-width: 900px) {
  #app {
    flex-direction: column;
  }

  #panel {
    width: 100%;
    max-width: none;
    min-width: 0;
    height: 45vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  #previewWrap {
    height: 55vh;
  }
}
