/* ============================================================
   Photo Editor - Dark Theme Styles
   ============================================================ */

/* ── Body / Layout Override ── */
.pe-body main {
  overflow: hidden;
  padding: 0;
  margin: 0;
}

/* ── Root Layout ── */
.pe-layout {
  display: grid;
  grid-template-rows: 50px 1fr;
  grid-template-columns: 1fr;
  height: calc(100vh - 56px);
  background: #1a1b26;
  color: #c0caf5;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  overflow: hidden;
}

/* ── Topbar ── */
.pe-topbar {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #13131c;
  border-bottom: 1px solid #1e1f2e;
  padding: 0 12px;
  gap: 8px;
  flex-shrink: 0;
  z-index: 10;
}

.pe-topbar-left,
.pe-topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.pe-topbar-right {
  justify-content: flex-end;
}

.pe-topbar-center {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

/* ── Title Input ── */
.pe-title-input {
  background: transparent;
  border: 1px solid transparent;
  color: #c0caf5;
  font-size: 14px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 6px;
  text-align: center;
  min-width: 180px;
  max-width: 320px;
  transition: border-color 0.15s, background 0.15s;
  outline: none;
}

.pe-title-input:hover {
  border-color: #2a2b3d;
  background: #1a1b26;
}

.pe-title-input:focus {
  border-color: #e53935;
  background: #1a1b26;
}

/* ── Buttons ── */
.pe-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 6px;
  border: 1px solid #2a2b3d;
  background: #1f2030;
  color: #c0caf5;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
  line-height: 1;
  height: 30px;
}

.pe-btn:hover {
  background: #292e42;
  border-color: #3d4166;
}

.pe-btn:active {
  background: #1a1b26;
}

.pe-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.pe-btn-icon {
  padding: 5px 7px;
  min-width: 30px;
  justify-content: center;
}

.pe-btn-primary {
  background: #e53935;
  border-color: #e53935;
  color: #fff;
}

.pe-btn-primary:hover {
  background: #c62828;
  border-color: #c62828;
}

.pe-btn-ghost {
  background: transparent;
  border-color: transparent;
  color: #7982b3;
}

.pe-btn-ghost:hover {
  background: #292e42;
  border-color: #2a2b3d;
  color: #c0caf5;
}

/* ── Desktop export format buttons ── */
.pe-export-2x-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #565f89;
  cursor: pointer;
  white-space: nowrap;
}
/* ── Export dropdown ── */
.pe-export-wrap { position: relative; }
.pe-export-trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid rgba(122,162,247,0.3);
  background: rgba(122,162,247,0.1);
  color: #7aa2f7;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.pe-export-trigger:hover { background: rgba(122,162,247,0.18); border-color: rgba(122,162,247,0.5); }
.pe-export-caret { transition: transform 0.15s; }
.pe-export-wrap.open .pe-export-caret { transform: rotate(180deg); }
.pe-export-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 210px;
  background: #1a1b2e;
  border: 1px solid #2a2b42;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  padding: 8px;
  z-index: 200;
}
.pe-export-wrap.open .pe-export-dropdown { display: block; }
.pe-export-dd-2x {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: #a9b1d6;
}
.pe-export-dd-2x:hover { background: rgba(255,255,255,0.04); }
.pe-export-dd-hint { margin-left: auto; font-size: 10px; color: #565f89; font-weight: 400; }
.pe-export-dd-divider { height: 1px; background: #2a2b42; margin: 6px 0; }
.pe-export-dd-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 8px;
  border-radius: 7px;
  border: none;
  background: none;
  cursor: pointer;
  transition: background 0.12s;
  text-align: left;
}
.pe-export-dd-btn:hover { background: rgba(255,255,255,0.05); }
.pe-export-dd-btn:active { background: rgba(255,255,255,0.08); }
.pe-export-dd-fmt {
  width: 34px;
  height: 20px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}
.pe-export-dd-fmt--png { background: rgba(122,162,247,0.15); color: #7aa2f7; }
.pe-export-dd-fmt--jpg { background: rgba(229,87,87,0.15); color: #e57373; }
.pe-export-dd-info { display: flex; flex-direction: column; gap: 2px; }
.pe-export-dd-name { font-size: 12px; font-weight: 700; color: #c0caf5; }
.pe-export-dd-sub { font-size: 10px; color: #565f89; }

/* ── Divider ── */
.pe-divider {
  width: 1px;
  height: 20px;
  background: #2a2b3d;
  margin: 0 4px;
  flex-shrink: 0;
}

/* ── Zoom Display ── */
.pe-zoom-display {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #1a1b26;
  border: 1px solid #2a2b3d;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 600;
  color: #c0caf5;
  min-width: 52px;
  height: 30px;
  cursor: default;
  user-select: none;
}

/* ── Main Area ── */
.pe-main {
  display: flex;
  flex-direction: row;
  height: 100%;
  overflow: hidden;
}

/* ── Icon Bar (Photoshop-style vertical tool strip) ── */
.pe-iconbar {
  width: 48px;
  flex-shrink: 0;
  background: #1f2030;
  border-right: 1px solid #2a2b3d;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0 6px;
  gap: 1px;
  overflow-y: auto;
  overflow-x: hidden;
}

.pe-iconbar-sep {
  width: 28px;
  height: 1px;
  background: #2a2b3d;
  margin: 6px 0;
  flex-shrink: 0;
}

.pe-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: #7982b0;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  position: relative;
  padding: 0;
}
.pe-icon-btn:hover {
  background: #292e42;
  color: #c0caf5;
}
.pe-icon-btn.active {
  background: rgba(229, 57, 53, 0.18);
  color: #e53935;
  border-color: rgba(229, 57, 53, 0.4);
}
.pe-icon-btn.active::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 20%;
  bottom: 20%;
  width: 2px;
  background: #e53935;
  border-radius: 0 2px 2px 0;
}
.pe-icon-btn svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

/* ── Left Panel ── */
.pe-left-panel {
  width: 260px;
  flex-shrink: 0;
  background: #16161e;
  border-right: 1px solid #2a2b3d;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pe-tab-bar {
  display: flex;
  border-bottom: 1px solid #2a2b3d;
  background: #1a1b28;
  flex-shrink: 0;
}

.pe-tab {
  flex: 1;
  padding: 8px 4px;
  border: none;
  background: transparent;
  color: #565f89;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}

.pe-tab:hover {
  color: #c0caf5;
  background: #1f2030;
}

.pe-tab.active {
  color: #e53935;
  border-bottom-color: #e53935;
  background: #16161e;
}

.pe-panel-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
}

.pe-tab-pane {
  display: none;
}

.pe-tab-pane.active {
  display: block;
}

/* ── Sections ── */
.pe-section {
  padding: 10px 12px;
  border-bottom: 1px solid #2a2b3d;
}

.pe-section:last-child {
  border-bottom: none;
}

.pe-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #565f89;
  margin-bottom: 8px;
}

/* ── Canvas Area ── */
.pe-canvas-area {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #2d2f3f;
  position: relative;
  background-image:
    linear-gradient(rgba(0,0,0,0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.08) 1px, transparent 1px);
  background-size: 20px 20px;
}

.pe-canvas-wrapper {
  position: relative;
  box-shadow: 0 8px 48px rgba(0,0,0,0.7), 0 0 0 1px rgba(0,0,0,0.4);
  line-height: 0;
}

.pe-canvas-wrapper canvas {
  display: block;
}

/* Grid overlay */
.pe-canvas-wrapper.show-grid::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(192,202,245,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(192,202,245,0.06) 1px, transparent 1px);
  background-size: 20px 20px;
  z-index: 1000;
}

/* ── Right Panel ── */
.pe-right-panel {
  width: 290px;
  flex-shrink: 0;
  background: #16161e;
  border-left: 1px solid #2a2b3d;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pe-no-selection {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: #565f89;
  text-align: center;
  gap: 10px;
  font-size: 13px;
}

.pe-no-selection svg {
  opacity: 0.3;
  width: 40px;
  height: 40px;
}

/* ── Property Groups ── */
.pe-prop-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pe-prop-label {
  font-size: 11px;
  color: #565f89;
  font-weight: 500;
}

.pe-prop-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Number Input ── */
.pe-num-input {
  background: #1a1b26;
  border: 1px solid #2a2b3d;
  color: #c0caf5;
  border-radius: 5px;
  padding: 4px 6px;
  font-size: 12px;
  width: 64px;
  outline: none;
  transition: border-color 0.15s;
  -moz-appearance: textfield;
}

.pe-num-input::-webkit-outer-spin-button,
.pe-num-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

.pe-num-input:focus {
  border-color: #e53935;
}

.pe-num-input.wide {
  width: 100%;
}

/* ── Color Swatch ── */
.pe-color-swatch {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid #2a2b3d;
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
}

.pe-color-swatch:hover {
  border-color: #3d4166;
}

.pe-color-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  padding: 0;
  cursor: pointer;
  opacity: 0;
}

.pe-color-preview {
  position: absolute;
  inset: 3px;
  border-radius: 3px;
  pointer-events: none;
}

/* ── Slider ── */
.pe-slider {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #2a2b3d;
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  transition: background 0.15s;
}

.pe-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e53935;
  cursor: pointer;
  border: 2px solid #1a1b26;
  transition: transform 0.1s;
}

.pe-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.pe-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e53935;
  cursor: pointer;
  border: 2px solid #1a1b26;
}

/* ── Select ── */
.pe-select {
  background: #1a1b26;
  border: 1px solid #2a2b3d;
  color: #c0caf5;
  border-radius: 5px;
  padding: 5px 24px 5px 8px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23565f89' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  background-size: 10px;
}

.pe-select:focus {
  border-color: #e53935;
}

.pe-font-select {
  width: 100%;
}

/* ── Text Button Group ── */
.pe-text-btn-group {
  display: flex;
  gap: 2px;
}

.pe-text-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 5px;
  border: 1px solid #2a2b3d;
  background: #1f2030;
  color: #7982b3;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.pe-text-btn:hover {
  background: #292e42;
  color: #c0caf5;
}

.pe-text-btn.active {
  background: rgba(229,57,53,0.15);
  border-color: rgba(229,57,53,0.4);
  color: #e53935;
}

/* ── Shape Grid ── */
.pe-shape-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.pe-shape-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 10px 6px;
  border-radius: 7px;
  border: 1px solid #2a2b3d;
  background: #1f2030;
  color: #7982b3;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.pe-shape-btn:hover {
  background: #292e42;
  border-color: #3d4166;
  color: #c0caf5;
}

.pe-shape-btn.active {
  background: rgba(229,57,53,0.12);
  border-color: rgba(229,57,53,0.45);
  color: #e53935;
}

.pe-shape-btn svg {
  width: 22px;
  height: 22px;
}

/* ── Layer List ── */
.pe-layer-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 4px 0;
}

.pe-layer-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid rgba(42,43,61,0.5);
  position: relative;
}

.pe-layer-item:hover {
  background: #292e42;
}

.pe-layer-item.selected {
  background: rgba(229,57,53,0.1);
  border-left: 2px solid #e53935;
  padding-left: 10px;
}

.pe-layer-item.dragging {
  opacity: 0.5;
}

.pe-layer-thumb {
  width: 30px;
  height: 30px;
  border-radius: 4px;
  background: #24283b;
  border: 1px solid #2a2b3d;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pe-layer-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.pe-layer-name {
  flex: 1;
  font-size: 12px;
  color: #c0caf5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pe-layer-name.muted {
  color: #565f89;
  font-style: italic;
}

.pe-layer-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.pe-layer-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: #565f89;
  cursor: pointer;
  transition: all 0.12s;
  padding: 0;
}

.pe-layer-action-btn:hover {
  background: #3d4166;
  color: #c0caf5;
}

.pe-layer-action-btn.active {
  color: #e53935;
}

.pe-layer-action-btn svg {
  width: 13px;
  height: 13px;
}

/* ── Filter Slider Row ── */
.pe-filter-slider-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.pe-filter-slider-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pe-filter-slider-label span:first-child {
  font-size: 11px;
  color: #7982b3;
}

.pe-filter-slider-label span:last-child {
  font-size: 11px;
  color: #565f89;
  font-weight: 600;
  min-width: 32px;
  text-align: right;
}

/* ── Toggle Checkbox Row ── */
.pe-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}

.pe-toggle-label {
  font-size: 12px;
  color: #7982b3;
}

.pe-toggle {
  position: relative;
  width: 32px;
  height: 18px;
}

.pe-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.pe-toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #2a2b3d;
  border-radius: 18px;
  transition: background 0.2s;
}

.pe-toggle-slider::before {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #565f89;
  left: 3px;
  top: 3px;
  transition: transform 0.2s, background 0.2s;
}

.pe-toggle input:checked + .pe-toggle-slider {
  background: rgba(229,57,53,0.3);
}

.pe-toggle input:checked + .pe-toggle-slider::before {
  transform: translateX(14px);
  background: #e53935;
}

/* ── Canvas Preset Grid ── */
.pe-preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.pe-preset-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 7px 8px;
  border-radius: 6px;
  border: 1px solid #2a2b3d;
  background: #1f2030;
  color: #7982b3;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.4;
}

.pe-preset-btn strong {
  font-size: 11px;
  color: #c0caf5;
  font-weight: 600;
}

.pe-preset-btn:hover {
  background: #292e42;
  border-color: #3d4166;
}

/* ── Background Colors ── */
.pe-bg-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pe-bg-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  flex-shrink: 0;
}

.pe-bg-swatch:hover {
  transform: scale(1.15);
  border-color: #c0caf5;
}

.pe-bg-swatch.active {
  border-color: #e53935;
}

.pe-bg-swatch.transparent-swatch {
  background: repeating-conic-gradient(#3d4166 0% 25%, #1f2030 0% 50%) 0 0 / 14px 14px;
}

/* ── Upload Zone ── */
.pe-upload-zone {
  border: 2px dashed #2a2b3d;
  border-radius: 8px;
  padding: 20px 12px;
  text-align: center;
  color: #565f89;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.pe-upload-zone:hover {
  border-color: #e53935;
  color: #c0caf5;
}

.pe-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 7px;
  border: 1px solid #2a2b3d;
  background: #1f2030;
  color: #c0caf5;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  justify-content: center;
}

.pe-upload-btn:hover {
  background: #292e42;
  border-color: #3d4166;
}

.pe-upload-btn svg {
  width: 14px;
  height: 14px;
}

/* ── URL Input Row ── */
.pe-url-row {
  display: flex;
  gap: 5px;
  margin-top: 6px;
}

.pe-url-input {
  flex: 1;
  background: #1a1b26;
  border: 1px solid #2a2b3d;
  color: #c0caf5;
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s;
}

.pe-url-input:focus {
  border-color: #e53935;
}

.pe-url-input::placeholder {
  color: #565f89;
}

/* ── Custom Canvas Size Inputs ── */
.pe-canvas-size-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.pe-canvas-size-row label {
  font-size: 11px;
  color: #565f89;
  min-width: 12px;
}

/* ── Inline Label ── */
.pe-inline-label {
  font-size: 11px;
  color: #565f89;
  min-width: 18px;
}

/* ── Lock Aspect Ratio Btn ── */
.pe-lock-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 5px;
  border: 1px solid #2a2b3d;
  background: #1f2030;
  color: #565f89;
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
  flex-shrink: 0;
}

.pe-lock-btn:hover {
  background: #292e42;
  color: #c0caf5;
}

.pe-lock-btn.locked {
  border-color: #e53935;
  color: #e53935;
  background: rgba(229,57,53,0.1);
}

.pe-lock-btn svg {
  width: 12px;
  height: 12px;
}

/* ── Context Menu ── */
.pe-context-menu {
  position: fixed;
  z-index: 9999;
  background: #1f2030;
  border: 1px solid #2a2b3d;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  padding: 4px;
  min-width: 160px;
}

.pe-context-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 12px;
  border: none;
  background: transparent;
  color: #c0caf5;
  font-size: 13px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.12s;
}

.pe-context-menu button:hover {
  background: #292e42;
}

.pe-context-menu button.danger {
  color: #e53935;
}

.pe-context-menu button.danger:hover {
  background: rgba(229,57,53,0.15);
}

.pe-context-menu hr {
  border: none;
  border-top: 1px solid #2a2b3d;
  margin: 4px 0;
}

/* ── Draw Controls ── */
.pe-draw-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pe-draw-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Align Button Group ── */
.pe-align-group {
  display: flex;
  gap: 2px;
}

.pe-align-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  border-radius: 5px;
  border: 1px solid #2a2b3d;
  background: #1f2030;
  color: #7982b3;
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
}

.pe-align-btn:hover {
  background: #292e42;
  color: #c0caf5;
}

.pe-align-btn.active {
  background: rgba(229,57,53,0.15);
  border-color: rgba(229,57,53,0.4);
  color: #e53935;
}

.pe-align-btn svg {
  width: 14px;
  height: 14px;
}

/* ── Panel Section Divider ── */
.pe-panel-divider {
  height: 1px;
  background: #2a2b3d;
  margin: 4px 0;
}

/* ── Right Panel Header ── */
.pe-right-panel-header {
  padding: 10px 12px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #565f89;
  background: #1f2030;
  border-bottom: 1px solid #2a2b3d;
  flex-shrink: 0;
}

/* ── Right Panel Tabs (Properties / History) ── */
.pe-rpanel-tabs {
  display: flex;
  border-bottom: 1px solid #2a2b3d;
  flex-shrink: 0;
  background: #1f2030;
}
.pe-rpanel-tab {
  flex: 1;
  padding: 8px 0;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  color: #565f89;
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.pe-rpanel-tab:hover { color: #c0caf5; }
.pe-rpanel-tab.active {
  color: #c0caf5;
  border-bottom-color: #e53935;
}

/* ── History Panel ── */
.pe-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #565f89;
  border-bottom: 1px solid #2a2b3d;
  flex-shrink: 0;
}
.pe-history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
  border-bottom: 1px solid #1f2030;
  transition: background 0.1s;
}
.pe-history-item:hover { background: #1f2030; }
.pe-history-item.pe-history-current {
  background: #1e2130;
  border-left: 2px solid #e53935;
}
.pe-history-item.pe-history-future {
  opacity: 0.35;
  cursor: default;
}
.pe-history-num {
  font-size: 10px;
  color: #565f89;
  min-width: 18px;
  text-align: right;
}
.pe-history-label {
  font-size: 12px;
  color: #c0caf5;
}

/* ── Canvas Preset Select ── */
.pe-canvas-preset-select {
  background: #1a1b26;
  border: 1px solid #2a2b3d;
  color: #c0caf5;
  border-radius: 5px;
  padding: 4px 24px 4px 8px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23565f89' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  background-size: 10px;
  height: 30px;
  max-width: 150px;
}

.pe-canvas-preset-select:focus {
  border-color: #e53935;
}

/* ── Grid Toggle ── */
.pe-grid-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #7982b3;
  cursor: pointer;
  user-select: none;
}

/* ── Scrollbars ── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #2a2b3d;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #3d4166;
}

.pe-canvas-area::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

.pe-canvas-area::-webkit-scrollbar-thumb {
  background: #2a2b3d;
  border-radius: 4px;
}

/* ── Quick actions row ── */
.pe-quick-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* ── Prop Full Row ── */
.pe-prop-full {
  width: 100%;
}

/* ── Spacer ── */
.pe-spacer {
  flex: 1;
}

/* ══════════════════════════════════════════
   Mobile Bottom Bar (desktop: hidden)
   ══════════════════════════════════════════ */
.pe-mobile-bar    { display: none; }
.pe-mobile-backdrop { display: none; }

/* ══════════════════════════════════════════
   Mobile Layout  ≤ 768px
   ══════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── Grid: bottom row accounts for safe-area (notch phones) ── */
  .pe-layout {
    grid-template-rows: 50px 1fr calc(58px + env(safe-area-inset-bottom, 0px));
  }

  /* ── Topbar: strip down to essentials, move exports to bottom bar ── */
  .pe-topbar { padding: 0 8px; gap: 4px; }
  .pe-topbar-left .pe-divider,
  .pe-topbar-left select,
  .pe-topbar-left label.pe-grid-toggle { display: none; }
  .pe-topbar-right .pe-divider,
  .pe-topbar-right #pe-zoom-out,
  .pe-topbar-right #pe-zoom-in,
  .pe-topbar-right #pe-zoom-fit,
  .pe-topbar-right .pe-zoom-display,
  .pe-topbar-right label,
  .pe-topbar-right #pe-export-png,
  .pe-topbar-right #pe-export-jpg { display: none; }
  #pe-undo-btn, #pe-redo-btn { display: none; }
  .pe-title-input { font-size: 13px; min-width: 80px; }

  /* ── Desktop side panels hidden normally ── */
  .pe-iconbar     { display: none; }
  .pe-left-panel  { display: flex !important; }
  .pe-right-panel { display: flex !important; }

  /* ── Panels become slide-up bottom sheets ── */
  .pe-left-panel,
  .pe-right-panel {
    position: fixed;
    left: 0; right: 0;
    bottom: calc(58px + env(safe-area-inset-bottom, 0px));
    width: 100% !important;
    max-height: 62vh;
    z-index: 300;
    border-radius: 18px 18px 0 0;
    border-top: 1px solid #2a2b3d;
    border-right: none;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.5);
    transform: translateY(110%);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
  }
  .pe-left-panel::before,
  .pe-right-panel::before {
    content: '';
    display: block;
    width: 36px; height: 4px;
    background: #3a3b50;
    border-radius: 2px;
    margin: 10px auto 4px;
    flex-shrink: 0;
  }
  .pe-left-panel.mobile-open,
  .pe-right-panel.mobile-open {
    transform: translateY(0);
  }

  /* ── Sticky tabs inside sheets so they don't scroll away ── */
  .pe-tab-bar {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #13131c;
  }
  .pe-rpanel-tabs {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #13131c;
  }

  /* ── Backdrop ── */
  .pe-mobile-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 299;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
  }
  .pe-mobile-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }

  /* ── Mobile Bottom Bar ── */
  .pe-mobile-bar {
    display: flex;
    align-items: stretch;
    background: #13131c;
    border-top: 1px solid #1e1f2e;
    padding: 0 2px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    z-index: 200;
  }
  .pe-mobile-bar::-webkit-scrollbar { display: none; }

  /* Tighter buttons so all 9 fit ~375px without scrolling */
  .pe-mobile-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 5px 6px;
    min-width: 40px;
    background: none;
    border: none;
    color: #565f89;
    cursor: pointer;
    border-top: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
  }
  .pe-mobile-btn svg { width: 19px; height: 19px; }
  .pe-mobile-btn span {
    font-size: 8px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
  }
  .pe-mobile-btn:hover,
  .pe-mobile-btn:active { color: #c0caf5; background: #1f2030; }
  .pe-mobile-btn.active { color: #e53935; border-top-color: #e53935; }
  .pe-mobile-btn.export-active { color: #e53935; }

  .pe-mobile-sep {
    width: 1px;
    background: #1e1f2e;
    margin: 8px 2px;
    flex-shrink: 0;
  }

  /* ── Canvas area: full width on mobile ── */
  .pe-main { position: relative; }
  .pe-canvas-area { touch-action: none; }

  /* ── Panel scroll with momentum ── */
  .pe-panel-content {
    max-height: calc(62vh - 80px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  #pe-rpanel-props, #pe-rpanel-layers, #pe-rpanel-history {
    max-height: calc(62vh - 50px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ── Mobile Export Sheet (PNG vs JPG choice) ── */
  .pe-mobile-export-sheet {
    position: fixed;
    left: 0; right: 0;
    bottom: calc(58px + env(safe-area-inset-bottom, 0px));
    background: #1a1b26;
    border-top: 1px solid #2a2b3d;
    border-radius: 18px 18px 0 0;
    padding: 14px 16px 16px;
    z-index: 350;
    transform: translateY(110%);
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -8px 32px rgba(0,0,0,0.5);
  }
  .pe-mobile-export-sheet.open { transform: translateY(0); }
  .pe-mobile-export-sheet-handle {
    width: 36px; height: 4px;
    background: #3a3b50;
    border-radius: 2px;
    margin: 0 auto 12px;
  }
  .pe-mobile-export-sheet-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #565f89;
    text-align: center;
    margin-bottom: 12px;
  }
  /* 2× row */
  .pe-m-2x-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 500;
    color: #7982b3;
    padding: 0 2px;
    margin-bottom: 14px;
    cursor: pointer;
  }

  .pe-mobile-export-btns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .pe-mobile-export-btns button {
    padding: 20px 12px 18px;
    border-radius: 14px;
    border: 1px solid rgba(122,162,247,0.25);
    background: rgba(122,162,247,0.07);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s, border-color 0.15s;
  }
  .pe-mobile-export-btns button:active { background: rgba(122,162,247,0.14); }
  .pe-m-dl-icon { color: #7aa2f7; opacity: 0.8; }
  .pe-m-fmt-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 10px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.06em;
  }
  .pe-m-fmt-badge--png { background: rgba(122,162,247,0.15); color: #7aa2f7; }
  .pe-m-fmt-badge--jpg { background: rgba(229,87,87,0.15); color: #e57373; }
  .pe-m-fmt-sub {
    font-size: 10px;
    font-weight: 400;
    color: #565f89;
    text-align: center;
    line-height: 1.4;
  }
  .pe-mobile-export-btns .m-export-jpg {
    background: rgba(229,57,53,0.07);
    border-color: rgba(229,57,53,0.25);
  }
  .pe-mobile-export-btns .m-export-jpg .pe-m-fmt-name { color: #e57373; }
  .pe-mobile-export-btns .m-export-jpg:active { background: rgba(229,57,53,0.12); }
}

/* ============================================================
   Recent Projects Panel (landing page)
   ============================================================ */
.pe-projects-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.pe-projects-header-left {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text, #111);
}
.pe-projects-ttl {
  font-size: 11px;
  color: var(--text-dim, #888);
  background: var(--bg-card, #f4f4f5);
  border: 1px solid var(--border, #e4e4e7);
  border-radius: 20px;
  padding: 2px 9px;
}
.pe-projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.pe-projects-cta {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent-dim, #fff0f0);
  border: 1px solid var(--accent, #e63946)33;
  font-size: 13px;
  color: var(--text-dim, #555);
  display: flex;
  align-items: center;
  gap: 8px;
}
.pe-projects-cta svg { flex-shrink: 0; opacity: 0.7; }
.pe-projects-cta > span { flex: 1; min-width: 0; line-height: 1.5; }
.pe-projects-cta a { color: var(--accent, #e63946); font-weight: 600; text-decoration: none; }
.pe-projects-cta a:hover { text-decoration: underline; }
.pe-proj-card {
  background: var(--bg-card, #fff);
  border: 1px solid var(--border, #e4e4e7);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.12s;
}
.pe-proj-card:hover {
  border-color: var(--accent, #e63946);
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}
.pe-proj-thumb {
  width: 100%;
  aspect-ratio: 4/3;
  background: var(--bg, #f8f8fb);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-bottom: 1px solid var(--border, #e4e4e7);
}
.pe-proj-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.pe-proj-info {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: relative;
}
.pe-proj-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #111);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 24px;
}
.pe-proj-meta {
  font-size: 11px;
  color: var(--text-dim, #888);
}
.pe-proj-del {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-dim, #aaa);
  cursor: pointer;
  padding: 3px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.pe-proj-del:hover {
  color: var(--accent, #e63946);
  background: rgba(230, 57, 70, 0.08);
}

/* ============================================================
   Photo Editor - Landing Page
   ============================================================ */

#pe-landing {
  min-height: 100vh;
}

.pe-lnd-box {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 0 40px;
}

/* ── Drop Zone ── */
.pe-lnd-drop {
  border: 2px dashed var(--border, #d0d5dd);
  border-radius: 16px;
  background: #f7f8fb;
  padding: 56px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s;
  text-align: center;
}

.pe-lnd-drop:hover,
.pe-lnd-drop.drag-over {
  border-color: var(--accent, #e63946);
  background: color-mix(in srgb, var(--accent, #e63946) 4%, var(--bg-card, #fff));
}

.pe-lnd-icon {
  width: 56px;
  height: 56px;
  color: var(--text-dim, #888);
  flex-shrink: 0;
}

.pe-lnd-drop-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text, #111);
  margin: 0;
}

.pe-lnd-drop-sub {
  font-size: 13px;
  color: var(--text-dim, #888);
  margin: 0;
}

.pe-lnd-browse-btn {
  font-size: inherit;
  font-weight: 700;
  color: var(--accent, #e63946);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.pe-lnd-drop:hover .pe-lnd-browse-btn {
  opacity: 0.75;
}

/* ── Divider ── */
.pe-lnd-or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 28px 0 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim, #888);
}

.pe-lnd-or::before,
.pe-lnd-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border, #d0d5dd);
}

/* ── Preset Grid ── */
.pe-lnd-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.pe-lnd-preset {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 10px 14px;
  border: 1px solid var(--border, #d0d5dd);
  border-radius: 12px;
  background: var(--bg-card, #fff);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text, #111);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  text-align: center;
}

.pe-lnd-preset:hover {
  border-color: var(--accent, #e63946);
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
  background: color-mix(in srgb, var(--accent, #e63946) 4%, var(--bg-card, #fff));
}

.pe-lnd-preset svg {
  width: 28px;
  height: 28px;
  color: var(--accent, #e63946);
  flex-shrink: 0;
}

.pe-lnd-preset strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
}

.pe-lnd-preset span {
  font-size: 11px;
  color: var(--text-dim, #888);
}

/* ── Feature Section ── */
.pe-lnd-features {
  margin-top: 56px;
}

.pe-lnd-features h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 20px;
  color: var(--text, #111);
}

.pe-lnd-how-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 40px;
}

.pe-lnd-step {
  background: var(--bg-card, #fff);
  border: 1px solid var(--border, #d0d5dd);
  border-radius: 12px;
  padding: 20px 16px;
}

.pe-lnd-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent, #e63946);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}

.pe-lnd-step h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--text, #111);
}

.pe-lnd-step p {
  font-size: 13px;
  color: var(--text-dim, #888);
  margin: 0;
  line-height: 1.5;
}

.pe-lnd-feat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.pe-lnd-feat-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--bg-card, #fff);
  border: 1px solid var(--border, #d0d5dd);
  border-radius: 10px;
  padding: 14px 14px;
}

.pe-lnd-feat-item svg {
  width: 20px;
  height: 20px;
  color: var(--accent, #e63946);
  flex-shrink: 0;
  margin-top: 1px;
}

.pe-lnd-feat-item strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 2px;
  color: var(--text, #111);
}

.pe-lnd-feat-item p {
  font-size: 12px;
  color: var(--text-dim, #888);
  margin: 0;
  line-height: 1.4;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .pe-lnd-presets {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .pe-lnd-how-steps {
    grid-template-columns: 1fr;
  }
  .pe-lnd-feat-grid {
    grid-template-columns: 1fr;
  }
  .pe-lnd-drop {
    padding: 36px 20px;
  }
}

@media (max-width: 420px) {
  .pe-lnd-presets {
    grid-template-columns: repeat(2, 1fr);
  }
  .pe-lnd-preset {
    padding: 10px 8px;
    gap: 4px;
  }
  .pe-lnd-preset strong { font-size: 11px; }
  .pe-lnd-preset span   { font-size: 10px; }
  .pe-lnd-drop {
    padding: 28px 16px;
    border-radius: 12px;
  }
  .pe-lnd-drop-title { font-size: 14px; }
}
