:root {
  color-scheme: light;
}

body {
  margin: 0px;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

.app {
  display: flex;
  align-items: flex-start;
}

.sidebar {
  width: 380px;
  min-width: 380px;
  max-width: 380px;
  box-sizing: border-box;
  background: linear-gradient(180deg, #f5edfe 0%, #eff5ff 100%);
  box-shadow: 4px 0 15px rgba(0, 0, 0, 0.05);
  padding: 16px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  z-index: 10;
}

.sidebar-title {
  font-size: 1.4em;
  font-weight: 700;
  margin: 0;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
  color: #222;
}

.reset-top {
  margin-top: 12px;
}

.sidebar-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  scrollbar-gutter: stable;
}

.sidebar-spacer {
  flex-grow: 1;
}

.book-promo-card {
  position: relative;
  margin: 10px 20px 0;
  border: 1px solid #ded3ee;
  border-radius: 11px;
  background: #f1eafa;
  box-sizing: border-box;
  flex-shrink: 0;
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.book-promo-card:hover {
  background: #eee4f9;
  border-color: #cdb9e4;
  box-shadow: 0 3px 8px rgba(83, 50, 112, 0.08);
}

.book-promo-link {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 10px;
  border-radius: inherit;
  color: #333;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
}

.book-promo-link:focus-visible {
  outline: 3px solid rgba(111, 54, 151, 0.3);
  outline-offset: 2px;
}

.book-promo-dismiss {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #665f6b;
  font: inherit;
  font-size: 18px;
  line-height: 20px;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.book-promo-dismiss:hover {
  background: rgba(111, 54, 151, 0.1);
  color: #3f2354;
}

.book-promo-dismiss:focus-visible {
  outline: 2px solid #6f3697;
  outline-offset: 1px;
}

.book-promo-icon {
  width: 80px;
  height: 80px;
  display: grid;
  place-items: center;
  flex: 0 0 80px;
  border-radius: 9px;
  background: #e2d5f0;
  overflow: hidden;
  color: #6f3697;
}

.book-promo-icon img {
  width: 64px;
  height: 64px;
  display: block;
  object-fit: contain;
}

.book-promo-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
  line-height: 1.25;
}

.book-promo-heading,
.book-promo-description,
.book-promo-cta {
  overflow-wrap: anywhere;
}

.book-promo-heading {
  font-size: 15px;
  font-weight: 700;
  color: #222;
}

.book-promo-description {
  font-size: 14px;
  font-weight: 400;
  color: #555;
}

.book-promo-cta {
  margin-top: 2px;
  font-size: 15px;
  font-weight: 700;
  color: #6f3697;
}

.sidebar-footer {
  padding: 20px;
  padding-bottom: 0;
  border-top: 1px solid #eee;
  display: grid;
  gap: 10px;
  flex-shrink: 0;
}

.footer-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 1.1em;
  font-weight: 600;
  color: #333;
  cursor: pointer;
  user-select: none;
}

.sidebar-footer .arrow {
  display: inline-block;
  transition: transform 0.15s ease;
}

.sidebar-footer.collapsed .arrow {
  transform: rotate(-90deg);
}

.footer-body {
  display: grid;
  gap: 10px;
}

.sidebar-footer.collapsed .footer-body {
  display: none;
}
.workspace {
  flex: 1;
  background: linear-gradient(0deg, #d7d6df 0%, #d5dbe5 100%);
  display: flex;
  height: 100vh;
}

#canvasContainer {
  flex: 1;
  display: flex;
  justify-content: center;
  overflow: hidden;
  position: relative;
  align-items: center;
}

.canvas-frame {
  position: relative;
  padding: 28px 56px 40px 28px;
}

.external-ruler {
  position: absolute;
  display: block;
  pointer-events: none;
  z-index: 2;
  border: 1px solid #c7ccd3;
  background: #f5f6f8;
  box-sizing: border-box;
}

.ruler-top {
  border-bottom: none;
}

.ruler-left {
  border-right: none;
}

.dimension {
  position: absolute;
  color: #b8b8b8;
  font-size: 12px;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dimension .line {
  background: #6f6f6f;
}

.dimension.vertical {
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  writing-mode: vertical-rl;
}

.dimension.vertical .line {
  width: 1px;
  height: 80px;
}

.dimension.horizontal {
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
}

.dimension.horizontal .line {
  width: 120px;
  height: 1px;
}

.settings-group {
  background: #fdfdfd;
  border: 1px solid #eee;
  padding: 20px;
  border-radius: 8px;
  display: grid;
  gap: 10px;
  flex-shrink: 0;
  min-width: 0;
  box-sizing: border-box;
}

.settings-group .group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 1.1em;
  font-weight: 600;
  color: #333;
  cursor: pointer;
  user-select: none;
}

.settings-separator {
  border-top: 1px solid #eee;
  margin: 15px 0;
}

.settings-group .arrow {
  display: inline-block;
  transition: transform 0.15s ease;
}

.settings-group.collapsed .arrow {
  transform: rotate(-90deg);
}

.settings-group.collapsed .group-body {
  display: none;
}

.control {
  display: grid;
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
}

label {
  display: block;
  width: 100%;
  font-size: 14px;
  font-weight: 600;
  color: #555;
}

.control-label {
  margin-top: 8px;
} 

.control-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.control-row input[type="range"] {
  flex: 1;
}

.control-row input[type="number"] {
  width: 65px;
  text-align: center;
  flex-shrink: 0;
  padding: 5px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.control-row select {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  flex: 1 1 0%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.unit-label {
  width: 35px;
  flex-shrink: 0;
  font-size: 0.9em;
  color: #888;
  text-align: left;
}

.radio-group {
  display: grid;
  gap: 6px;
}

.radio-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.radio-row label {
  font-weight: 400;
}

.radio-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.radio-with-icon img {
  width: 14px;
  object-fit: contain;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  padding-top: 10px;
}

.checkbox-row input[type="checkbox"] {
  margin: 0;
}

.reset-button {
  margin-top: 8px;
  padding: 6px 12px;
  border: 1px solid #ddd;
  background: #f8f9fa;
  color: #666;
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.primary-button {
  margin-top: 8px;
  padding: 6px 12px;
  border: none;
  background: #007bff;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.layers-list {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  will-change: transform;
}

.layer-item.active {
  border-color: #2b6fe3;
  background: #eaf1ff;
}

.layer-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.layer-action,
.layer-rename,
.layer-duplicate,
.layer-visibility,
.layer-delete {
  border: 1px solid #ccc;
  background: #f7f7f7;
  color: #444;
  cursor: pointer;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.layer-visibility.is-hidden {
  opacity: 0.6;
}

.layer-actions button:hover {
  background: #efefef;
}

.layer-action img,
.layer-rename img,
.layer-duplicate img,
.layer-visibility img,
.layer-delete img {
  width: 14px;
  height: 14px;
  display: block;
}

.layer-action:disabled,
.layer-rename:disabled {
  opacity: 0.4;
  cursor: default;
}

.layer-name-container {
  flex: 1;
  max-width: 180px;
  height: 30px;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.layer-name,
.layer-name-input {
  width: 100%;
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
  color: #333;
}

.layer-name-input {
  border: none;
  padding: 0;
  margin: 0;
  background: transparent;
}

.layer-name-input:focus {
  outline: 1px solid #bbb;
  outline-offset: 2px;
}

.layer-item button {
  cursor: default;
}

.sidebar-content::-webkit-scrollbar {
  width: 8px;
}

.sidebar-content::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
  background: #d0d0d0;
  border-radius: 8px;
}

.layer-delete {
  margin-left: 5px;
}

#mainCanvas {
  border: 1px solid #919191;
  display: block;
  max-width: 100%;
  max-height: 90vh;
  width: auto;
  height: auto;
  object-fit: contain;
  background: #fff;
  box-shadow: 4px 0 15px rgba(0, 0, 0, 0.15);
  transform-origin: center center;
  transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

#exportCanvas {
  display: none;
}

#mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

#mobile-overlay .overlay-content {
  text-align: center;
  color: #fff;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 40px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  max-width: 320px;
}

#mobile-overlay .overlay-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

#mobile-overlay h2 {
  font-size: 1.4em;
  margin: 0 0 10px;
}

#mobile-overlay p {
  margin: 0 0 10px;
  font-size: 0.95em;
  line-height: 1.4;
}

@media (max-width: 768px) {
  #mobile-overlay {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }

  body {
    overflow: hidden;
  }
}
