.auto-layout-page { display: grid; gap: 1.1rem; }
.auto-layout-card {
  min-width: 0;
  border: 1px solid var(--theme-line);
  border-radius: 1.15rem;
  background: var(--theme-card);
  padding: clamp(1rem, 2.5vw, 1.4rem);
  color: var(--theme-card-text);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--theme-text) 5%, transparent);
}
.auto-layout-card h2 { font-size: 1rem; font-weight: 800; }
.auto-layout-card > p { margin-top: .3rem; color: var(--theme-card-muted); font-size: .8rem; }
.auto-layout-upload {
  position: relative;
  display: flex;
  min-height: 8.5rem;
  align-items: center;
  justify-content: center;
  border: 1.5px dashed color-mix(in srgb, var(--theme-primary) 40%, var(--theme-line));
  border-radius: .9rem;
  background: color-mix(in srgb, var(--theme-primary) 4%, var(--theme-card));
  padding: 1rem;
  text-align: center;
  cursor: pointer;
}
.auto-layout-upload:hover { border-color: var(--theme-primary); }
.auto-layout-upload input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.auto-layout-upload:focus-within { outline: 3px solid color-mix(in srgb, var(--theme-primary) 24%, transparent); outline-offset: 2px; }
.auto-layout-upload strong { display: block; color: var(--theme-primary); font-size: .9rem; }
.auto-layout-upload span { display: block; margin-top: .25rem; color: var(--theme-card-muted); font-size: .75rem; overflow-wrap: anywhere; }
.auto-layout-error { margin-top: .65rem; color: #be123c; font-size: .8rem; }
.auto-layout-options { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .85rem; }
.auto-layout-chip {
  min-height: 2.65rem;
  border: 1px solid var(--theme-line);
  border-radius: .8rem;
  background: var(--theme-background);
  padding: .55rem .85rem;
  color: var(--theme-text);
  font-size: .82rem;
  font-weight: 700;
}
.auto-layout-chip[aria-pressed="true"] {
  border-color: var(--theme-primary);
  background: var(--theme-primary);
  color: var(--theme-primary-text);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--theme-primary) 22%, transparent);
}
.auto-layout-custom-dimensions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.auto-layout-custom-dimensions[hidden] { display: none; }
.auto-layout-piece-dimensions { margin-top: .75rem; }
.auto-layout-custom-dimensions label,
.auto-layout-custom-size { display: grid; gap: .35rem; color: var(--theme-card-text); font-size: .78rem; font-weight: 700; }
.auto-layout-custom-dimensions input,
.auto-layout-custom-size input { min-width: 0; min-height: 2.65rem; border: 1px solid var(--theme-line); border-radius: .75rem; background: var(--theme-background); padding: .5rem .7rem; color: var(--theme-text); }
.auto-layout-custom-dimensions input:focus,
.auto-layout-custom-size input:focus { border-color: var(--theme-primary); outline: 2px solid color-mix(in srgb, var(--theme-primary) 20%, transparent); }
.auto-layout-gap-field { display: grid; max-width: 16rem; gap: .35rem; color: var(--theme-card-text); font-size: .78rem; font-weight: 700; }
.auto-layout-gap-field input { min-width: 0; min-height: 2.65rem; border: 1px solid var(--theme-line); border-radius: .75rem; background: var(--theme-background); padding: .5rem .7rem; color: var(--theme-text); }
.auto-layout-gap-field input:focus { border-color: var(--theme-primary); outline: 2px solid color-mix(in srgb, var(--theme-primary) 20%, transparent); }
.auto-layout-workspace { display: grid; gap: 1.1rem; align-items: start; }
.auto-layout-result {
  display: flex;
  min-height: 8.5rem;
  flex-direction: column;
  justify-content: center;
  border: 1px solid color-mix(in srgb, var(--theme-primary) 18%, var(--theme-line));
  border-radius: 1rem;
  background: linear-gradient(135deg, color-mix(in srgb, var(--theme-primary) 9%, var(--theme-card)), var(--theme-card));
  padding: 1.2rem;
}
.auto-layout-result strong { color: var(--theme-primary); font-size: clamp(2rem, 7vw, 3.25rem); line-height: 1; letter-spacing: -.045em; }
.auto-layout-result span { margin-top: .5rem; color: var(--theme-card-muted); font-size: .9rem; font-weight: 650; }
.auto-layout-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; margin-top: .85rem; }
.auto-layout-detail { border-radius: .75rem; background: var(--theme-background); padding: .7rem .8rem; }
.auto-layout-detail span { display: block; color: var(--theme-card-muted); font-size: .7rem; }
.auto-layout-detail strong { display: block; margin-top: .15rem; font-size: .88rem; }
.auto-layout-canvas-wrap { display: grid; min-height: 15rem; place-items: center; overflow: auto; border: 1px solid var(--theme-line); border-radius: .9rem; background-color: var(--theme-background); background-image: radial-gradient(var(--theme-line) .7px, transparent .7px); background-size: 14px 14px; padding: 1rem; }
.auto-layout-canvas { display: block; width: min(100%, 34rem); max-height: 66vh; border: 1px solid #cbd5e1; background: #fff; box-shadow: 0 8px 24px rgb(15 23 42 / 12%); }
.auto-layout-reference { width: 100%; margin-top: .8rem; text-align: left; font-size: .8rem; }
.auto-layout-reference summary { width: fit-content; color: var(--theme-primary); font-weight: 750; cursor: pointer; }
.auto-layout-reference table { width: 100%; margin-top: .75rem; border-collapse: collapse; }
.auto-layout-reference th, .auto-layout-reference td { border-bottom: 1px solid var(--theme-line); padding: .5rem .4rem; }
.auto-layout-reference th { color: var(--theme-card-muted); font-size: .68rem; text-align: left; }
.auto-layout-reference td:last-child, .auto-layout-reference th:last-child { text-align: right; }
@media (min-width: 900px) {
  .auto-layout-workspace { grid-template-columns: minmax(15rem, .8fr) minmax(20rem, 1.2fr); }
  .auto-layout-result { min-height: 10rem; }
}
@media (max-width: 520px) {
  .auto-layout-chip { flex: 1 1 calc(33.333% - .5rem); padding-inline: .45rem; }
  .auto-layout-canvas-wrap { min-height: 12rem; padding: .65rem; }
}
