:root {
  color-scheme: light;
  --ink: #18212b;
  --muted: #5c6673;
  --line: #d6dbe2;
  --paper: #f6f1e7;
  --panel: #ffffff;
  --accent: #0f7c80;
  --accent-strong: #0b5f62;
  --cut: #c43d3d;
  --score: #2f6ecb;
  --shadow: 0 14px 40px rgba(22, 31, 43, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #edf0f3;
}

button,
input,
select {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(300px, 360px) 1fr;
}

.panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow: auto;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.1;
}

p {
  margin: 0;
}

.brand p,
.status,
#sheetInfo {
  color: var(--muted);
  font-size: 0.92rem;
}

.control-group {
  display: grid;
  gap: 14px;
}

.compact-grid {
  grid-template-columns: 1fr 1fr;
}

label {
  display: grid;
  gap: 7px;
  color: #2b3440;
  font-size: 0.88rem;
  font-weight: 650;
}

label span {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-weight: 500;
}

.detected-size span {
  display: block;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfcfd;
  color: var(--muted);
}

input[type="number"] {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fbfcfd;
  color: var(--ink);
}

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fbfcfd;
  color: var(--ink);
  font-weight: 650;
}

input[type="range"] {
  accent-color: var(--accent);
}

.file-drop {
  min-height: 118px;
  border: 1.5px dashed #b8c1cc;
  border-radius: 8px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 18px;
  cursor: pointer;
  background: #fbfcfd;
}

.file-drop input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-title {
  color: var(--accent-strong);
  font-size: 1rem;
}

.file-name {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.range,
.check {
  font-weight: 600;
}

.check {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.check input {
  accent-color: var(--accent);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

button {
  border: 0;
  border-radius: 7px;
  padding: 11px 12px;
  background: #dfe6ed;
  color: var(--ink);
  font-weight: 750;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.98);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#downloadBtn {
  background: var(--accent);
  color: white;
}

.workspace {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.toolbar {
  min-height: 74px;
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
}

.toolbar > div:first-child {
  display: grid;
  gap: 3px;
}

.legend {
  display: flex;
  gap: 14px;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.legend span {
  display: inline-flex;
  gap: 7px;
  align-items: center;
}

.legend i {
  width: 24px;
  height: 0;
  border-top: 2px solid;
}

.legend .cut {
  border-color: var(--cut);
}

.legend .score {
  border-color: var(--score);
  border-top-style: dashed;
}

.preview {
  padding: 28px;
  overflow: auto;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 26px;
}

.sheet-card {
  display: grid;
  gap: 10px;
}

.sheet-card h2 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.sheet-card svg {
  background: var(--paper);
  border: 1px solid #cac4b8;
  box-shadow: var(--shadow);
  max-width: min(78vw, 720px);
  height: auto;
}

.empty {
  color: var(--muted);
  align-self: center;
  margin: auto;
  text-align: center;
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
  }

  .panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .preview {
    padding: 18px;
  }
}
