/* ============================================================
   PATTERN CONVERTER — Navy & Relief (PRO Version 6.0)
   ============================================================ */

:root {
  --navy-deep: #081D33; --navy-950: #050F1F; --navy-700: #152F4D; --navy: #0F3A5F; --navy-mid: #1C4E82;
  --blue: #2F6FB0; --blue-light: #8FB7E3;
  --paper: #F4F7FB; --white: #FFFFFF;
  --ink: #0B2540; --ink-soft: #3A5470;
  --amber-bg: #FDECC8; --amber-ink: #8A5E10; --amber-border: #E8A33D;
  --green-mid: #3FA26D; --green-deep: #1F6E45;
  --highlight-bg: #E7F1FC; --highlight-border: #9CC2EA;
  --radius-sm: 8px; --radius: 12px; --radius-lg: 16px;
  --shadow-card: 0 3px 0 #C4D5E8, 0 10px 20px rgba(15,40,70,0.10), inset 0 1px 0 #fff;
  --shadow-card-lg: 0 6px 0 #C4D5E8, 0 12px 22px rgba(15,40,70,0.14), inset 0 1px 0 #fff;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: var(--font-body);
  background: #E2E9F1;
  background-image: radial-gradient(ellipse at top, rgba(143,183,227,0.18), transparent 60%);
  background-attachment: fixed;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.5;
  min-height: 100vh;
}
button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }

/* ============================================================ HEADER */
.app-header {
  background: repeating-linear-gradient(45deg, transparent 0, transparent 6px, rgba(255,255,255,0.03) 6px, rgba(255,255,255,0.03) 7px), linear-gradient(180deg, var(--navy-mid) 0%, var(--navy-deep) 100%);
  padding: 18px max(24px, calc((100vw - 1800px) / 2 + 28px));
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  box-shadow: 0 5px 0 rgba(8,29,51,0.35), 0 12px 22px rgba(8,29,51,0.28), inset 0 1px 0 rgba(255,255,255,0.15);
  position: relative; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--blue) 0%, var(--navy) 100%);
  display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr;
  gap: 2px; padding: 7px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), inset 0 -1px 0 rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.35);
}
.brand-mark span { border-radius: 1px; display: block; }
.brand-mark span:nth-child(1) { background: #FFD700; }
.brand-mark span:nth-child(2) { background: #FF69B4; }
.brand-mark span:nth-child(3) { background: var(--blue-light); }
.brand-mark span:nth-child(4) { background: #90EE90; }
.brand-text { min-width: 0; }
.brand-text h1 {
  font-family: var(--font-display); font-size: 1.15rem; font-weight: 700;
  color: #FFFFFF; letter-spacing: -0.015em; text-shadow: 0 1px 0 rgba(0,0,0,0.2);
  line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-text p {
  font-family: var(--font-body); font-size: 0.72rem; color: var(--blue-light);
  font-weight: 500; margin-top: 1px; letter-spacing: 0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ============================================================ BUTTONS */
.btn-gold {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid #B8860B;
  background: linear-gradient(180deg, #FDE08B 0%, #D4AF37 100%);
  color: #1A1A1A; font-family: var(--font-body); font-size: 0.8rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; text-shadow: 0 1px 0 rgba(255,255,255,0.4);
  box-shadow: 0 2px 0 #B8860B, 0 4px 8px rgba(212,175,55,0.3), inset 0 1px 0 rgba(255,255,255,0.6);
  transition: all 0.2s; cursor: pointer;
}
.btn-gold:hover {
  background: linear-gradient(180deg, #FFEAA7 0%, #E5C158 100%);
  transform: translateY(-1px); box-shadow: 0 3px 0 #B8860B, 0 6px 12px rgba(212,175,55,0.4), inset 0 1px 0 rgba(255,255,255,0.6);
}
.btn-gold:active { transform: translateY(1px); box-shadow: 0 1px 0 #B8860B, 0 2px 4px rgba(212,175,55,0.2), inset 0 1px 2px rgba(0,0,0,0.1); }
.btn-gold svg { stroke: #1A1A1A; }

.btn-success {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 11px 16px; 
  font-family: var(--font-body); font-size: 0.82rem; font-weight: 700; border-radius: var(--radius-sm); 
  border: 1px solid #1F6E45; background: linear-gradient(180deg, #3FA26D 0%, #2B7A4F 100%); 
  color: #FFFFFF; box-shadow: 0 2px 0 #1F6E45, 0 4px 8px rgba(31,110,69,0.2), inset 0 1px 0 rgba(255,255,255,0.2); 
  transition: all 0.2s; text-shadow: 0 1px 0 rgba(0,0,0,0.2);
}
.btn-success:hover { 
  background: linear-gradient(180deg, #2B7A4F 0%, #1F6E45 100%); 
  transform: translateY(-2px); box-shadow: 0 3px 0 #1F6E45, 0 6px 12px rgba(31,110,69,0.3), inset 0 1px 0 rgba(255,255,255,0.2); 
}
.btn-success:active { transform: translateY(1px); box-shadow: 0 1px 0 #1F6E45, 0 2px 4px rgba(31,110,69,0.1), inset 0 1px 0 rgba(255,255,255,0.2); }

.btn-tertiary { 
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 11px 16px; 
  font-family: var(--font-body); font-size: 0.82rem; font-weight: 700; border-radius: var(--radius-sm); 
  border: 1px solid #CBD5E1; background: linear-gradient(180deg, #F8FAFC 0%, #E2E8F0 100%); 
  color: var(--navy); box-shadow: 0 2px 0 #CBD5E1, 0 4px 8px rgba(15,40,70,0.05), inset 0 1px 0 #fff; 
  transition: all 0.2s; 
}
.btn-tertiary:hover { 
  background: linear-gradient(180deg, #E2E8F0 0%, #CBD5E1 100%); 
  transform: translateY(-2px); color: var(--navy-deep); 
  box-shadow: 0 3px 0 #CBD5E1, 0 6px 12px rgba(15,40,70,0.08), inset 0 1px 0 #fff; 
}
.btn-tertiary:active { transform: translateY(1px); box-shadow: 0 1px 0 #CBD5E1, 0 2px 4px rgba(15,40,70,0.04), inset 0 1px 0 #fff; }

.lang-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.03) 100%);
  border: 1px solid rgba(255,255,255,0.18); border-radius: var(--radius-sm);
  color: var(--blue-light); font-family: var(--font-body); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em;
  transition: all 0.2s; box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 1px 3px rgba(0,0,0,0.2);
  flex-shrink: 0;
}
.lang-btn:hover { background: linear-gradient(180deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0.05) 100%); color: #FFFFFF; transform: translateY(-1px); box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 3px 6px rgba(0,0,0,0.25); }
.lang-btn:active { transform: translateY(1px); box-shadow: inset 0 1px 2px rgba(0,0,0,0.3); }

/* ============================================================ LAYOUT */
.main-layout {
  padding: 32px max(24px, calc((100vw - 1800px) / 2 + 28px));
  display: grid; grid-template-columns: 1fr; gap: 20px; align-items: start;
}
@media (min-width: 1024px) { .main-layout { grid-template-columns: 320px minmax(0, 1fr) 320px; } }
.controls-column, .editor-column, .materials-column { min-width: 0; }
.controls-column > .card + .card { margin-top: 20px; }

/* ============================================================ CARDS */
.card { background: linear-gradient(180deg, #FFFFFF 0%, #F0F4F9 100%); border: 1px solid var(--highlight-border); border-radius: var(--radius); box-shadow: var(--shadow-card); overflow: hidden; }
.card-header { padding: 14px 18px; background: linear-gradient(180deg, #FBFCFE 0%, #F2F6FB 100%); border-bottom: 1px solid var(--highlight-border); display: flex; justify-content: space-between; align-items: center; gap: 10px; box-shadow: inset 0 1px 0 #fff; }
.card-header h2, .card-header h3 { font-family: var(--font-display); font-size: 1rem; font-weight: 700; color: var(--navy); letter-spacing: -0.01em; line-height: 1.2; }
.card-body { padding: 18px; }

/* ============================================================ UPLOAD */
.upload-area { border: 2px dashed var(--highlight-border); border-radius: var(--radius); padding: 24px 16px; text-align: center; background: linear-gradient(180deg, #FFFFFF 0%, #F7FAFD 100%); transition: all 0.2s; box-shadow: inset 0 2px 4px rgba(15,40,70,0.05); position: relative; cursor: pointer; }
.upload-area:hover { border-color: var(--navy-mid); background: linear-gradient(180deg, var(--highlight-bg) 0%, #F0F7FE 100%); box-shadow: inset 0 2px 4px rgba(15,40,70,0.05), 0 4px 8px rgba(28,78,130,0.1); }
#image-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 2; }
.upload-icon { width: 42px; height: 42px; margin: 0 auto 12px; background: linear-gradient(180deg, var(--navy-mid) 0%, var(--navy-deep) 100%); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #FFFFFF; box-shadow: inset 0 1px 0 rgba(255,255,255,0.25), 0 3px 8px rgba(8,29,51,0.3); }
.upload-icon svg { width: 18px; height: 18px; }
.upload-hint { font-family: var(--font-display); font-size: 0.92rem; font-weight: 600; color: var(--ink); pointer-events: none; line-height: 1.4; }
#image-preview { border: 2px solid var(--highlight-border); box-shadow: 0 2px 6px rgba(15,40,70,0.1); pointer-events: none; }
.small-text { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 0.72rem; color: var(--ink-soft); margin-top: 12px; font-weight: 500; }

/* ============================================================ FORM */
.option-group { margin-bottom: 18px; }
.field-label { display: block; font-family: var(--font-body); font-size: 0.72rem; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px; }
.size-inputs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.size-box { position: relative; }
.size-arrow { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-family: Arial, sans-serif; font-size: 1.1rem; font-weight: 900; color: var(--navy-mid); pointer-events: none; line-height: 1; }
.num-input { width: 100%; padding: 9px 12px 9px 32px; font-family: var(--font-display); font-size: 0.92rem; font-weight: 600; color: var(--ink); background: linear-gradient(180deg, #FFFFFF 0%, #FAFCFE 100%); border: 1.5px solid var(--highlight-border); border-radius: var(--radius-sm); text-align: left; outline: none; box-shadow: inset 0 1px 3px rgba(15,40,70,0.06); transition: all 0.2s; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.num-input::-webkit-outer-spin-button, .num-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num-input:focus { border-color: var(--navy-mid); box-shadow: inset 0 1px 3px rgba(15,40,70,0.06), 0 0 0 3px rgba(28,78,130,0.15); }
.size-x { font-family: var(--font-display); font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); }

/* ============================================================ COLOR PICKER */
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(26px, 1fr)); gap: 5px; margin-bottom: 10px; }
.color-item { aspect-ratio: 1; border-radius: 50%; cursor: pointer; position: relative; transition: transform 0.15s; box-shadow: inset 0 1px 1px rgba(255,255,255,0.5), inset 0 -1px 1px rgba(0,0,0,0.18), 0 0 0 1px rgba(8,29,51,0.15), 0 1px 2px rgba(8,29,51,0.12); }
.color-item:hover { transform: scale(1.12); }
.color-item.selected { box-shadow: inset 0 1px 1px rgba(255,255,255,0.5), inset 0 -1px 1px rgba(0,0,0,0.18), 0 0 0 2px #FFFFFF, 0 0 0 3.5px var(--navy-mid), 0 1px 2px rgba(8,29,51,0.15); }
.color-item.selected::after { content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 10px; height: 10px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E"); background-size: contain; background-repeat: no-repeat; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.8)); pointer-events: none; }

.delete-custom-color {
  position: absolute; top: -4px; right: -4px; width: 14px; height: 14px;
  background: #ef4444; color: white; border-radius: 50%;
  font-size: 10px; font-weight: bold; display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: 1px solid white; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  z-index: 5;
}
.delete-custom-color:hover { background: #b91c1c; transform: scale(1.1); }

.selected-summary { font-size: 0.7rem; font-weight: 600; color: var(--ink-soft); font-style: italic; text-align: center; min-height: 16px; margin-bottom: 10px; padding: 0 4px; }
.stash-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 10px; border-top: 1px solid rgba(15,40,70,0.08); }
.text-btn { background: none; border: none; color: var(--navy-mid); cursor: pointer; font-family: var(--font-body); font-weight: 700; text-decoration: none; font-size: 0.72rem; padding: 4px 0; transition: color 0.15s; }
.text-btn:hover { color: var(--navy-deep); }
label.text-btn { margin: 0; cursor: pointer; }
.hidden-color-picker { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; }

/* ============================================================ BUTTONS (GENERAL) */
.btn-primary, .btn-secondary { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 11px 16px; font-family: var(--font-body); font-size: 0.82rem; font-weight: 700; border-radius: var(--radius-sm); border: none; transition: all 0.2s; letter-spacing: 0.005em; text-align: center; line-height: 1.2; }
.btn-primary { background: linear-gradient(180deg, var(--navy-mid) 0%, var(--navy-deep) 100%); color: #FFFFFF; border: 1px solid #050F1F; box-shadow: 0 3px 0 #050F1F, 0 6px 12px rgba(8,29,51,0.3), inset 0 1px 0 rgba(255,255,255,0.18); text-shadow: 0 1px 0 rgba(0,0,0,0.25); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 5px 0 #050F1F, 0 10px 18px rgba(8,29,51,0.35), inset 0 1px 0 rgba(255,255,255,0.22); }
.btn-primary:active { transform: translateY(1px); box-shadow: 0 2px 0 #050F1F, 0 2px 4px rgba(8,29,51,0.2), inset 0 1px 2px rgba(0,0,0,0.2); }
.btn-secondary { background: linear-gradient(180deg, #FFFFFF 0%, #EDF2F8 100%); color: var(--navy); border: 1px solid var(--highlight-border); box-shadow: 0 2px 0 #C4D5E8, 0 4px 8px rgba(15,40,70,0.08), inset 0 1px 0 #fff; }
.btn-secondary:hover { transform: translateY(-2px); color: var(--navy-mid); box-shadow: 0 3px 0 #C4D5E8, 0 6px 12px rgba(15,40,70,0.12), inset 0 1px 0 #fff; }
.btn-secondary:active { transform: translateY(1px); box-shadow: 0 1px 0 #C4D5E8, 0 2px 4px rgba(15,40,70,0.06), inset 0 1px 0 #fff; }
.btn-primary:disabled, .btn-secondary:disabled { background: #E2E8F0; color: #94A3B8; box-shadow: none; transform: none; cursor: not-allowed; border-color: transparent; text-shadow: none; }
.btn-primary:focus-visible, .btn-secondary:focus-visible { outline: 2px solid var(--navy-mid); outline-offset: 3px; }
.button-stack { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }

/* ============================================================ CANVAS & ZOOM */
.canvas-card { box-shadow: var(--shadow-card-lg); display: flex; flex-direction: column; }
.canvas-wrapper {
  background: linear-gradient(180deg, #FBFCFE 0%, #F0F4F9 100%);
  padding: 24px;
  display: flex; justify-content: center; align-items: center;
  height: 65vh;
  min-height: 400px;
  position: relative; overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(15,40,70,0.04);
}
.canvas-wrapper::before { content: ''; position: absolute; inset: 0; background-image: linear-gradient(rgba(28,78,130,0.03) 1px, transparent 1px), linear-gradient(90deg, rgba(28,78,130,0.03) 1px, transparent 1px); background-size: 24px 24px; pointer-events: none; z-index: 0; }
#pattern-canvas-normal { display: block; outline: none; position: relative; z-index: 1; width: 100%; height: 100%; object-fit: contain; }

.canvas-actions { padding: 16px 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; background: linear-gradient(180deg, #F9FBFE 0%, #FFFFFF 100%); border-top: 1px solid var(--highlight-border); }
@media (max-width: 1023px) { .canvas-actions { grid-template-columns: 1fr; } }

/* ============================================================ EDITOR UI */
#editor-workspace {
  background: var(--paper) !important;
  border-top: 1px solid var(--highlight-border);
}

#editor-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: linear-gradient(180deg, #FFFFFF 0%, #F9FBFE 100%);
  border-bottom: 2px solid var(--highlight-border);
  box-shadow: 0 4px 12px rgba(15,40,70,0.08);
  flex-wrap: wrap;
  z-index: 20;
}
.toolbar-group { display: flex; gap: 4px; background: #E2EAF4; padding: 3px; border-radius: var(--radius-sm); border: 1px solid var(--highlight-border); }
.toolbar-divider { width: 2px; height: 28px; background: var(--highlight-border); margin: 0 6px; border-radius: 2px; }

.toolbar-label {
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--navy);
  background: #FDE08B;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #D4AF37;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.tool-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; color: var(--ink-soft);
  border: none; border-radius: 6px;
  transition: all 0.15s;
}
.tool-btn:hover { background: rgba(255,255,255,0.6); color: var(--navy); }
.tool-btn.active {
  background: var(--navy-mid) !important;
  color: white !important;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1), 0 2px 5px rgba(0,0,0,0.2);
  transform: scale(1.05);
}

.toolbar-palette {
  display: flex; gap: 6px; align-items: center;
  padding: 6px 10px; background: var(--paper);
  border-radius: var(--radius-sm); border: 1px solid var(--highlight-border);
  max-height: 46px; overflow-x: auto;
}
.toolbar-palette::-webkit-scrollbar { height: 4px; }
.toolbar-palette::-webkit-scrollbar-thumb { background: var(--highlight-border); border-radius: 2px; }

.add-color-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px dashed var(--highlight-border);
  background: transparent; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink-soft); margin-left: 4px; font-weight: bold; font-size: 1.2rem;
}
.add-color-btn:hover { color: var(--navy-mid); border-color: var(--navy-mid); }

.color-popover {
  display: none; position: absolute; top: 100%; right: 0;
  margin-top: 8px; background: var(--white);
  padding: 12px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card-lg); border: 1px solid var(--highlight-border);
  z-index: 1000; width: 180px;
}
.color-popover.show { display: block; }

#editor-panels {
  display: flex; flex: 1; overflow: hidden; gap: 16px; padding: 16px;
}

#context-container {
  width: 25%; min-width: 200px;
  height: 100% !important; min-height: 0 !important;
  border-radius: var(--radius); background: var(--white);
  border: 1px solid var(--highlight-border);
  cursor: crosshair; display: flex; justify-content: center; align-items: center;
  box-shadow: var(--shadow-card);
}
#context-canvas { max-width: 100%; max-height: 100%; object-fit: contain; }

#edit-panel {
  width: 75%; flex: 1; background: var(--white);
  border: 1px solid var(--highlight-border); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-card);
}
.edit-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: var(--paper);
  border-bottom: 1px solid var(--highlight-border);
}
.edit-panel-header .ref-title {
  color: var(--navy); font-family: var(--font-display);
  font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700;
}

#lupa-container {
  flex: 1; height: 100% !important; min-height: 0 !important;
  cursor: crosshair; overflow: auto; background: var(--paper);
  display: block; 
  padding: 20px;
  position: relative;
}
#lupa-canvas { 
  display: block; 
  margin: 0 auto; 
  cursor: none; 
}

/* ============================================================ MATERIALS */
.summary-banner { padding: 12px 16px; border-bottom: 1px solid var(--amber-border); background: linear-gradient(180deg, var(--amber-bg) 0%, #FBE5B8 100%); color: var(--amber-ink); font-size: 0.76rem; font-weight: 600; box-shadow: inset 0 1px 0 rgba(255,255,255,0.7); text-align: center; }
.summary-banner.summary-good { background: linear-gradient(180deg, #E6F3EC 0%, #D2EADB 100%); border-color: var(--green-mid); color: var(--green-deep); }
.summary-banner.summary-bad { background: linear-gradient(180deg, var(--amber-bg) 0%, #FBE5B8 100%); border-color: var(--amber-border); color: var(--amber-ink); }

.materials-head { 
  display: grid; grid-template-columns: 1fr 36px 105px; gap: 8px;
  padding: 10px 16px; background: linear-gradient(180deg, var(--navy-mid) 0%, var(--navy-deep) 100%);
  color: #FFFFFF; font-family: var(--font-display); font-size: 0.64rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.09em; text-shadow: 0 1px 0 rgba(0,0,0,0.2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12); 
}
.mh-qty { text-align: right; }
.mh-status { text-align: center; }

.materials-grid-vertical { display: flex; flex-direction: column; max-height: 600px; overflow-y: auto; background: #FFFFFF; }

.material-card { 
  display: grid; grid-template-columns: 1fr 36px 105px; gap: 8px;
  padding: 9px 16px; align-items: center;
  border-bottom: 0.5px solid rgba(15,40,70,0.08); font-size: 0.76rem; transition: background 0.1s; 
}
.material-card:nth-child(odd) { background: var(--paper); }
.material-card:nth-child(even) { background: #FFFFFF; }
.material-card:last-child { border-bottom: none; }
.material-card:hover { background: var(--highlight-bg); }
.material-info { display: flex; align-items: center; gap: 8px; min-width: 0; }
.material-right { display: contents; }
.color-swatch { width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; display: inline-block; box-shadow: inset 0 1px 1px rgba(255,255,255,0.5), inset 0 -1px 1px rgba(0,0,0,0.15), 0 0 0 1px rgba(8,29,51,0.12); }
.material-code { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; font-size: 0.76rem; color: var(--ink); }
.material-qty { text-align: right; font-family: var(--font-display); font-size: 0.78rem; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }

.badge { 
  display: inline-flex; align-items: center; justify-content: center; gap: 3px;
  padding: 2px 6px; border-radius: 20px;
  font-family: var(--font-body); font-size: 0.54rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.02em;
  white-space: nowrap; line-height: 1.4;
  min-width: 58px; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  text-align: center; justify-self: center; 
}
.badge-have { background: #D6F0E0; color: var(--green-deep); border: 1px solid var(--green-mid); }
.badge-buy  { background: var(--amber-bg); color: var(--amber-ink); border: 1px solid var(--amber-border); }
.badge-swap { background: var(--highlight-bg); color: var(--navy); border: 1px solid var(--highlight-border); }

/* ============================================================ MODAL (PAYWALL) */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(8,29,51,0.6); display: flex; justify-content: center; align-items: center;
  z-index: 2000; backdrop-filter: blur(8px);
}
.modal-content {
  background: linear-gradient(180deg, #FFFFFF 0%, #F0F4F9 100%);
  padding: 30px; border-radius: var(--radius-lg); width: 90%; max-width: 420px;
  box-shadow: 0 10px 30px rgba(8,29,51,0.3), inset 0 1px 0 #fff;
  text-align: center; position: relative; border: 1px solid var(--highlight-border);
}
.modal-close {
  position: absolute; top: 12px; right: 16px; background: none; border: none;
  font-size: 1.5rem; cursor: pointer; color: var(--ink-soft); transition: color 0.2s;
}
.modal-close:hover { color: #ef4444; }
.modal-title { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; color: var(--navy); margin-bottom: 8px; }
.modal-desc { color: var(--ink-soft); font-size: 0.9rem; margin-bottom: 20px; line-height: 1.5; }
.pro-feature-list {
  background: var(--paper); padding: 16px; border-radius: var(--radius-sm);
  margin-bottom: 24px; text-align: left; font-size: 0.85rem; font-weight: 500;
  color: var(--ink); border: 1px solid var(--highlight-border);
}
.pro-feature-list p { margin-bottom: 6px; }
.modal-buy-btn {
  padding: 14px; font-size: 0.95rem; margin-bottom: 24px;
}
.modal-license-text { font-size: 0.8rem; color: var(--ink-soft); margin-bottom: 10px; font-weight: 500; }
.license-input-group { display: flex; gap: 10px; }
.license-input-group .num-input { padding: 10px; text-align: center; text-transform: uppercase; }

/* ============================================================ RESPONSIVE */
@media (max-width: 1023px) {
  .canvas-wrapper { height: 55vh; }
  .brand-text p { display: none; }
  .canvas-actions { grid-template-columns: 1fr; }
  #editor-panels { flex-direction: column; padding: 10px; gap: 10px; }
  #context-container { width: 100%; height: 30% !important; min-height: 150px; }
  #edit-panel { width: 100%; height: 70%; }
}
@media (max-width: 480px) {
  .app-header { padding: 14px 16px; flex-wrap: wrap; }
  .header-actions { width: 100%; justify-content: space-between; margin-top: 10px; }
  .main-layout { padding: 16px; gap: 14px; }
  .card-body { padding: 14px; }
  .brand-mark { width: 34px; height: 34px; padding: 6px; }
  .brand-text h1 { font-size: 1rem; }
  .canvas-wrapper { height: 45vh; padding: 16px; }
}

/* ============================================================ FULLSCREEN EDITOR */
body.editor-fullscreen {
  overflow: hidden;
}
body.editor-fullscreen .app-header,
body.editor-fullscreen .controls-column,
body.editor-fullscreen .materials-column {
  display: none !important;
}
body.editor-fullscreen .main-layout {
  padding: 0;
  margin: 0;
  height: 100vh;
  width: 100vw;
  display: block;
}
body.editor-fullscreen .editor-column {
  height: 100%;
  width: 100%;
  max-width: none;
  margin: 0;
}
body.editor-fullscreen #result-section {
  height: 100%;
  border: none;
  border-radius: 0;
  box-shadow: none;
}
body.editor-fullscreen #result-section .card-header {
  display: none;
}
body.editor-fullscreen #editor-workspace {
  height: 100%;
  border-top: none;
}
body.editor-fullscreen #editor-panels {
  height: calc(100vh - 65px);
}

/* ============================================================
   LANDING PAGE STYLES (A PRUEBA DE BALAS)
   ============================================================ */

.landing-body {
  background-color: #F4F7FB;
  background-image: 
    radial-gradient(circle at 15% 50%, rgba(47, 111, 176, 0.08), transparent 25%),
    radial-gradient(circle at 85% 30%, rgba(47, 111, 176, 0.08), transparent 25%);
  background-attachment: fixed;
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden; /* Previene scroll horizontal por desbordes */
}

.landing-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 40px;
  background: #081D33;
  color: white;
  box-shadow: 0 4px 12px rgba(8,29,51,0.2);
}

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

.landing-brand h1 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.landing-btn {
  text-decoration: none;
  width: auto;
  padding: 10px 20px;
}

.landing-btn-large {
  text-decoration: none;
  display: inline-flex;
  width: auto;
  padding: 14px 28px;
  font-size: 1rem;
  border-radius: var(--radius);
}

.landing-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 60px 24px;
}

/* HERO SECTION */
.landing-hero {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 60px;
  align-items: center;
  margin-bottom: 80px;
}

.hero-content h2 {
  font-family: var(--font-display);
  font-size: 3.4rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--navy-deep);
  margin-bottom: 20px;
}

.hero-content h2 .highlight {
  color: #2F6FB0;
}

.hero-content p {
  font-size: 1.15rem;
  color: var(--ink-soft);
  margin-bottom: 32px;
  line-height: 1.5;
}

.hero-visuals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)); /* Evita que las columnas crezcan infinitamente */
  gap: 20px;
  width: 100%;
}

.visual-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--highlight-border);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0; /* Crucial para que el grid no colapse */
  overflow: hidden;
}

.card-label {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--navy);
}

.comparison {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.comparison img {
  width: 100px; /* Tamaño fijo seguro para evitar desbordes */
  height: 100px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: #F8FAFC;
}

.arrow-icon {
  color: var(--navy-mid);
  flex-shrink: 0;
}

.pdf-preview-mock {
  width: 100%;
  display: flex;
  gap: 12px;
  background: #F8FAFC;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid #E2E8F0;
  align-items: center;
}

.pdf-preview-mock img {
  width: 60px;
  height: 60px;
  object-fit: contain;
  flex-shrink: 0;
}

.mock-list {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.mock-line {
  height: 6px;
  background: #CBD5E1;
  border-radius: 3px;
  width: 100%;
}

.mock-line.short {
  width: 60%;
}

/* PRO SECTION */
.landing-pro {
  background: linear-gradient(135deg, #FFFDF5 0%, #FFF8E5 100%);
  border: 2px solid #FDE08B;
  border-radius: var(--radius-lg);
  padding: 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); /* El minmax(0, x) es clave aquí */
  gap: 40px;
  align-items: center;
  box-shadow: 0 10px 30px rgba(212,175,55,0.1);
}

.pro-badge {
  display: inline-block;
  background: #F59E0B;
  color: white;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 16px;
  letter-spacing: 0.05em;
}

.pro-content h3 {
  font-family: var(--font-display);
  font-size: 2.2rem;
  color: #78350F;
  margin-bottom: 12px;
  line-height: 1.1;
}

.pro-content p {
  color: #92400E;
  font-size: 1.05rem;
  margin-bottom: 24px;
  line-height: 1.5;
}

.pro-price {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: #78350F;
  margin-bottom: 24px;
}

.pro-price span {
  font-size: 1rem;
  font-weight: 500;
  color: #B45309;
}

.pro-visual {
  position: relative;
  width: 100%;
}

/* CONTENEDOR DEL GIF */
.editor-mockup {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  border: 1px solid #E2E8F0;
  width: 100%;
  background: #081D33;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 400px; /* Limitamos la altura máxima del contenedor */
}

.editor-mockup img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 400px;
  object-fit: contain; /* El GIF se adapta sin cortarse */
}

.demo-overlay-btn {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: rgba(15, 58, 95, 0.9);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 10px 20px;
  border-radius: 30px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: all 0.2s;
  z-index: 10;
}

.demo-overlay-btn:hover {
  background: var(--navy-mid);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* MODALS */
.landing-modal {
  max-width: 800px;
  width: 95%;
  padding: 32px;
  text-align: center;
}

.modal-large {
  max-width: 900px;
}

.modal-image-comparison {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-top: 24px;
}

.modal-image-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.modal-image-box span {
  font-weight: 600;
  color: var(--navy);
  font-size: 0.9rem;
}

.modal-image-box img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--highlight-border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* MODAL DE VIDEO */
.modal-video-container {
  margin-top: 24px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #081D33;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  display: flex;
  justify-content: center;
  position: relative;
  width: 100%;
  min-height: 300px;
  max-height: 60vh;
}

.modal-video-container img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* RESPONSIVE */
@media (max-width: 1100px) {
  .landing-hero {
    gap: 30px;
  }
  .comparison img {
    width: 80px;
    height: 80px;
  }
}

@media (max-width: 1023px) {
  .landing-hero {
    grid-template-columns: 1fr;
    gap: 40px;
    text-align: center;
  }
  
  .hero-content h2 {
    font-size: 2.5rem;
  }

  .landing-pro {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 30px 20px;
  }

  .pro-content {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
}

@media (max-width: 600px) {
  .landing-header {
    padding: 12px 20px;
  }
  
  .landing-main {
    padding: 40px 16px;
  }

  .hero-content h2 {
    font-size: 2rem;
  }

  .hero-visuals {
    grid-template-columns: 1fr;
  }

  .comparison img {
    width: 120px;
    height: 120px;
  }

  .modal-image-comparison {
    flex-direction: column;
    align-items: center;
  }

  .landing-modal {
    padding: 24px 16px;
  }
}
