/* ═══════════════════════════════════════════
   بيت الأحلام — Claymorphism design tokens
   palette from ui_ux_search: warm grey + gold
   ═══════════════════════════════════════════ */
:root {
  --bg:            #FAF5F2;
  --bg-alt:        #F3EAE3;
  --surface:       #FFFFFF;
  --surface-2:     #FDFAF7;
  --primary:       #78716C;
  --primary-dark:  #57534E;
  --secondary:     #A8A29E;
  --accent:        #D97706;
  --accent-soft:   #F59E0B;
  --fg:            #1C1917;
  --fg-muted:      #78716C;
  --border:        #EEEDED;
  --border-soft:   #E7DFD8;
  --destructive:   #DC2626;
  --success:       #16A34A;
  --sky:           #7DD3FC;
  --radius-sm:     12px;
  --radius:        18px;
  --radius-lg:     26px;
  --clay-in:       inset 0 -3px 0 rgba(120,113,108,.14), inset 0 3px 8px rgba(255,255,255,.9);
  --clay-out:      0 10px 22px -10px rgba(87,83,78,.45), 0 4px 10px -6px rgba(87,83,78,.3);
  --clay-press:    inset 0 4px 10px rgba(87,83,78,.22);
  --font-display:  'Baloo Bhaijaan 2', 'Fredoka', system-ui, sans-serif;
  --font-body:     'Cairo', 'Nunito', system-ui, sans-serif;
  --focus:         0 0 0 4px rgba(217,119,6,.25);
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 600px at 15% -10%, #FFF4E6 0%, transparent 60%),
    radial-gradient(900px 500px at 95% 0%, #EAF4FF 0%, transparent 55%),
    var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; letter-spacing: -.01em; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: none; box-shadow: var(--focus); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #E3D9D0; border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ── Layout ── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  padding: .7rem 1.1rem;
  background: rgba(250,245,242,.82);
  backdrop-filter: blur(14px);
  border-bottom: 2px solid var(--border-soft);
}
.brand { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.brand-badge {
  width: 46px; height: 46px; border-radius: 16px; flex: none;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(160deg, var(--accent-soft), var(--accent));
  box-shadow: var(--clay-out), inset 0 2px 0 rgba(255,255,255,.5);
}
.brand-badge svg { width: 24px; height: 24px; stroke-width: 2.2; }
.brand-text h1 { font-size: 1.25rem; line-height: 1.1; }
.brand-text p { margin: 0; font-size: .74rem; color: var(--fg-muted); }
.stats { display: flex; gap: .55rem; margin-inline-start: auto; flex-wrap: wrap; }
.chip {
  display: flex; align-items: center; gap: .5rem;
  padding: .4rem .75rem; border-radius: var(--radius-sm);
  background: var(--surface); border: 2px solid var(--border);
  box-shadow: var(--clay-in); min-width: 104px;
}
.chip svg { width: 18px; height: 18px; color: var(--primary); flex: none; }
.chip div { display: flex; flex-direction: column; line-height: 1.15; }
.chip span { font-family: var(--font-display); font-weight: 600; font-size: .95rem; }
.chip small { font-size: .62rem; color: var(--fg-muted); }
.chip.wallet { background: linear-gradient(160deg,#FFF7ED,#FFEFD6); border-color: #F3D9AE; }
.chip.wallet svg { color: var(--accent); }
.chip.wallet.low { background: linear-gradient(160deg,#FEF2F2,#FDE4E4); border-color: #F6C6C6; }
.chip.wallet.low svg, .chip.wallet.low span { color: var(--destructive); }
.chip.pop { animation: pop .45s ease; }
@keyframes pop { 0% { transform: scale(1) } 40% { transform: scale(1.12) } 100% { transform: scale(1) } }
.actions { display: flex; align-items: center; gap: .4rem; }

/* ── Clay buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .55rem 1rem; border-radius: 999px; font-size: .84rem; font-weight: 700;
  border: 2px solid transparent; background: var(--surface); color: var(--fg);
  box-shadow: var(--clay-out), var(--clay-in);
  transition: transform .16s cubic-bezier(.34,1.56,.64,1), box-shadow .16s ease, filter .16s ease;
}
.btn svg { width: 17px; height: 17px; }
.btn:hover { transform: translateY(-2px); filter: saturate(1.05); }
.btn:active { transform: translateY(1px) scale(.985); box-shadow: var(--clay-press); }
.btn.primary { background: linear-gradient(165deg, var(--accent-soft), var(--accent)); color: #fff; border-color: #fff6e6; }
.btn.ghost { background: var(--surface-2); border-color: var(--border-soft); color: var(--primary-dark); }
.btn.danger { color: var(--destructive); border-color: #F6D5D5; }
.btn.wide { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center;
  border: 2px solid var(--border-soft); background: var(--surface); color: var(--primary-dark);
  box-shadow: var(--clay-out), var(--clay-in);
  transition: transform .16s cubic-bezier(.34,1.56,.64,1), box-shadow .16s ease, color .16s ease;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { transform: translateY(-2px); color: var(--accent); }
.icon-btn:active { transform: translateY(1px); box-shadow: var(--clay-press); }
.icon-btn.active { background: linear-gradient(165deg,#FFF3E0,#FFE7C2); border-color: #F3D09A; color: var(--accent); }
.icon-btn.sm { width: 34px; height: 34px; border-radius: 12px; }
.icon-btn.sm svg { width: 16px; height: 16px; }
.icon-btn[disabled] { opacity: .4; cursor: not-allowed; }

/* ── Stage & side panel ── */
.stage { display: flex; gap: 1rem; padding: 1rem; height: calc(100dvh - 74px); }
.panel {
  width: 330px; flex: none; display: flex; flex-direction: column; gap: .75rem;
  background: var(--surface); border: 2px solid var(--border-soft);
  border-radius: var(--radius-lg); padding: .85rem;
  box-shadow: var(--clay-out), var(--clay-in);
}
.tabs { display: flex; gap: .3rem; background: var(--bg-alt); padding: .3rem; border-radius: 999px; }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: .1rem;
  padding: .45rem .3rem; border: none; background: transparent; border-radius: 999px;
  font-size: .7rem; font-weight: 700; color: var(--fg-muted);
  transition: all .18s ease;
}
.tab svg { width: 18px; height: 18px; }
.tab:hover { color: var(--primary-dark); }
.tab.active { background: var(--surface); color: var(--accent); box-shadow: var(--clay-out), var(--clay-in); }
.panel-body { flex: 1; overflow-y: auto; padding-inline-end: .25rem; display: flex; flex-direction: column; gap: .85rem; }
.palette { display: grid; grid-template-columns: repeat(3, 1fr); gap: .55rem; }
.pal-item {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: .25rem;
  padding: .5rem .3rem .4rem; border-radius: var(--radius-sm);
  border: 2px solid var(--border); background: var(--surface-2);
  box-shadow: var(--clay-in);
  transition: transform .16s cubic-bezier(.34,1.56,.64,1), border-color .16s ease, box-shadow .16s ease;
}
.pal-item:hover { transform: translateY(-3px); border-color: #EBD9C0; box-shadow: var(--clay-out), var(--clay-in); }
.pal-item.active { border-color: var(--accent); background: linear-gradient(165deg,#FFF8EF,#FFEFD9); box-shadow: var(--clay-out), var(--clay-in); }
.pal-item canvas { width: 44px; height: 44px; border-radius: 10px; background: var(--bg-alt); }
.pal-item .lbl { font-size: .68rem; font-weight: 700; color: var(--primary-dark); text-align: center; line-height: 1.2; }
.pal-item .cost { font-size: .6rem; color: var(--fg-muted); font-weight: 600; }
.pal-item .size { position: absolute; inset-inline-start: .3rem; top: .3rem; font-size: .55rem; color: var(--secondary); font-weight: 700; }
.pal-item.poor { opacity: .55; }
.pal-item.poor .cost { color: var(--destructive); }

/* ── Props (colours / materials / hints) ── */
.props { display: flex; flex-direction: column; gap: .7rem; }
.prop-block {
  border: 2px solid var(--border); border-radius: var(--radius); padding: .6rem .7rem;
  background: var(--surface-2); box-shadow: var(--clay-in);
}
.prop-block h4 {
  font-size: .74rem; color: var(--fg-muted); text-transform: uppercase;
  letter-spacing: .06em; margin-bottom: .5rem; display: flex; align-items: center; gap: .35rem;
}
.prop-block h4 svg { width: 14px; height: 14px; }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: .4rem; }
.swatch {
  aspect-ratio: 1; border-radius: 10px; border: 2px solid rgba(0,0,0,.08);
  box-shadow: inset 0 -3px 6px rgba(0,0,0,.12), inset 0 2px 4px rgba(255,255,255,.6);
  transition: transform .15s cubic-bezier(.34,1.56,.64,1), box-shadow .15s ease;
}
.swatch:hover { transform: scale(1.1); }
.swatch.active { box-shadow: 0 0 0 3px var(--accent), inset 0 -2px 6px rgba(0,0,0,.15); transform: scale(1.04); }
.mat-list { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.mat {
  display: flex; align-items: center; gap: .45rem; padding: .35rem .5rem;
  border-radius: 10px; border: 2px solid var(--border); background: var(--surface);
  font-size: .72rem; font-weight: 700; color: var(--primary-dark); text-align: start;
}
.mat .dot { width: 20px; height: 20px; border-radius: 7px; flex: none; box-shadow: inset 0 -2px 4px rgba(0,0,0,.15); }
.mat:hover { border-color: #EBD9C0; }
.mat.active { border-color: var(--accent); background: #FFF8EF; }
.mat .mc { margin-inline-start: auto; font-size: .62rem; color: var(--fg-muted); font-weight: 600; }
.mini-note { font-size: .7rem; color: var(--fg-muted); line-height: 1.6; margin: 0; }
.panel-foot { display: flex; flex-direction: column; gap: .45rem; padding-top: .3rem; border-top: 2px dashed var(--border-soft); }

/* ── Board & canvas ── */
.board { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .6rem; }
.canvas-wrap {
  position: relative; flex: 1; min-height: 0; overflow: auto;
  border-radius: var(--radius-lg); padding: .6rem;
  background: linear-gradient(170deg,#FDFBF9,#F4EDE6);
  border: 2px solid var(--border-soft);
  box-shadow: var(--clay-out), var(--clay-in);
}
.canvas-wrap canvas {
  display: block; border-radius: var(--radius);
  box-shadow: 0 16px 40px -20px rgba(87,83,78,.6);
  touch-action: none; cursor: crosshair;
}
.badge-float {
  position: absolute; top: .6rem; inset-inline-start: .6rem; z-index: 3;
  background: linear-gradient(165deg,#ECFDF5,#D6F5E3); color: #065F46;
  border: 2px solid #B8E6CE; border-radius: 999px; padding: .35rem .8rem;
  font-size: .76rem; font-weight: 700; box-shadow: var(--clay-out);
  animation: pop .5s ease;
}
.hintbar {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  background: var(--surface); border: 2px solid var(--border-soft);
  border-radius: var(--radius); padding: .45rem .7rem;
  box-shadow: var(--clay-out), var(--clay-in);
}
.hint { display: flex; align-items: center; gap: .45rem; font-size: .78rem; color: var(--primary-dark); font-weight: 600; }
.hint svg { width: 16px; height: 16px; color: var(--accent); flex: none; }
.zoombar { display: flex; align-items: center; gap: .45rem; margin-inline-start: auto; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 130px; height: 8px;
  background: var(--bg-alt); border-radius: 99px; padding: 0; box-shadow: var(--clay-in);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: linear-gradient(165deg,var(--accent-soft),var(--accent));
  border: 2px solid #fff; box-shadow: var(--clay-out); cursor: grab;
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid #fff;
  background: var(--accent); box-shadow: var(--clay-out);
}

/* ── Toasts, modal, modal internals ── */
.toasts {
  position: fixed; bottom: 1.1rem; inset-inline-start: 1.1rem; z-index: 200;
  display: flex; flex-direction: column; gap: .5rem; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: .5rem;
  padding: .6rem 1rem; border-radius: 999px; font-size: .82rem; font-weight: 700;
  background: var(--surface); border: 2px solid var(--border-soft);
  box-shadow: var(--clay-out); animation: slideIn .3s cubic-bezier(.34,1.56,.64,1);
}
.toast svg { width: 17px; height: 17px; }
.toast.success { color: #065F46; background: #ECFDF5; border-color: #BBE9CE; }
.toast.error { color: #991B1B; background: #FEF2F2; border-color: #F7C9C9; }
.toast.info { color: #1E3A8A; background: #EFF6FF; border-color: #BFDBFE; }
@keyframes slideIn { from { opacity: 0; transform: translateY(14px) scale(.96) } to { opacity: 1; transform: none } }
.overlay {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 1rem;
  background: rgba(41,37,36,.45); backdrop-filter: blur(6px); animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.modal {
  width: min(620px, 100%); max-height: 86dvh; overflow-y: auto;
  background: var(--surface); border: 3px solid #fff;
  border-radius: var(--radius-lg); padding: 1.4rem;
  box-shadow: 0 30px 70px -30px rgba(41,37,36,.7);
  animation: fadeUp .28s cubic-bezier(.34,1.56,.64,1);
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(18px) scale(.97) } to { opacity: 1; transform: none } }
.modal-head { display: flex; align-items: flex-start; gap: .7rem; margin-bottom: 1rem; }
.modal-head h2 { font-size: 1.3rem; }
.modal-head p { margin: .2rem 0 0; font-size: .8rem; color: var(--fg-muted); }
.modal-head .icon-btn { margin-inline-start: auto; flex: none; }
.modal-badge {
  width: 46px; height: 46px; border-radius: 16px; flex: none; display: grid; place-items: center;
  background: linear-gradient(160deg,#FFF3E0,#FFE5C0); color: var(--accent);
  box-shadow: var(--clay-in); border: 2px solid #F5DFBE;
}
.modal-badge svg { width: 22px; height: 22px; }

/* ── Modal content pieces ── */
.steps { display: flex; flex-direction: column; gap: .55rem; margin: 0 0 1rem; padding: 0; list-style: none; }
.steps li {
  display: flex; gap: .65rem; align-items: flex-start;
  background: var(--surface-2); border: 2px solid var(--border);
  border-radius: var(--radius); padding: .6rem .75rem; box-shadow: var(--clay-in);
}
.steps .num {
  width: 26px; height: 26px; flex: none; border-radius: 9px; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: .8rem;
  background: linear-gradient(160deg,var(--accent-soft),var(--accent)); color: #fff;
}
.steps strong { font-size: .84rem; }
.steps span { display: block; font-size: .76rem; color: var(--fg-muted); line-height: 1.55; }
.kbd {
  display: inline-block; padding: 0 .35rem; border-radius: 6px; font-size: .72rem;
  background: var(--bg-alt); border: 1px solid var(--border-soft); font-weight: 700; color: var(--primary-dark);
}
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-bottom: 1rem; }
.slot {
  text-align: start; border-radius: var(--radius); padding: .6rem; border: 2px solid var(--border);
  background: var(--surface-2); box-shadow: var(--clay-in);
  transition: transform .16s cubic-bezier(.34,1.56,.64,1), border-color .16s;
}
.slot:hover { transform: translateY(-3px); border-color: #EBD9C0; }
.slot.filled { border-color: #D8E9D5; background: #F5FAF4; }
.slot strong { display: block; font-size: .8rem; font-family: var(--font-display); }
.slot em { display: block; font-size: .66rem; color: var(--fg-muted); font-style: normal; margin-top: .15rem; }
.slot .mini { display: flex; gap: .35rem; margin-top: .5rem; }
.slot .mini button {
  flex: 1; font-size: .68rem; font-weight: 700; padding: .3rem; border-radius: 8px;
  border: 2px solid var(--border); background: var(--surface); color: var(--primary-dark);
}
.slot .mini button.del { color: var(--destructive); border-color: #F6D5D5; }

/* ── Room report & generic rows ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .55rem; margin-bottom: .9rem; }
.stat-card {
  border: 2px solid var(--border); border-radius: var(--radius); padding: .55rem .7rem;
  background: var(--surface-2); box-shadow: var(--clay-in);
}
.stat-card b { font-family: var(--font-display); font-size: 1.15rem; display: block; color: var(--accent); }
.stat-card small { font-size: .66rem; color: var(--fg-muted); font-weight: 600; }
.room-row {
  display: flex; align-items: center; gap: .55rem; padding: .45rem .6rem;
  border-bottom: 1px dashed var(--border-soft); font-size: .8rem;
}
.room-row:last-child { border-bottom: none; }
.room-row .pill {
  width: 22px; height: 22px; border-radius: 8px; display: grid; place-items: center;
  background: var(--bg-alt); font-size: .68rem; font-weight: 700; color: var(--primary-dark);
}
.room-row .nm { font-weight: 700; }
.room-row .ar { margin-inline-start: auto; color: var(--fg-muted); font-size: .74rem; font-weight: 600; }
.empty {
  text-align: center; padding: 1.6rem 1rem; color: var(--fg-muted); font-size: .82rem;
  border: 2px dashed var(--border-soft); border-radius: var(--radius);
}
.modal-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .9rem; }
.modal-actions .btn { flex: 1 1 auto; justify-content: center; }
.field-row { display: flex; gap: .5rem; align-items: center; }
.field-row input[type="text"] {
  flex: 1; padding: .55rem .8rem; border-radius: var(--radius-sm); font-family: inherit;
  border: 2px solid var(--border); background: var(--surface-2); font-size: .85rem; color: var(--fg);
  box-shadow: var(--clay-in);
}
.field-row input[type="text"]:focus { border-color: var(--accent); box-shadow: var(--focus); }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .stage { flex-direction: column; height: auto; min-height: calc(100dvh - 74px); }
  .panel { width: 100%; order: 2; }
  .board { order: 1; }
  .canvas-wrap { max-height: 62dvh; }
  .panel-body { max-height: none; }
  .stats { order: 3; width: 100%; }
  .topbar { flex-wrap: wrap; }
}
@media (max-width: 640px) {
  .brand-text p { display: none; }
  .stats { gap: .4rem; }
  .chip { min-width: 0; padding: .3rem .55rem; }
  .chip small { display: none; }
  .actions .btn span { display: none; }
  .palette { grid-template-columns: repeat(4, 1fr); }
  .slots { grid-template-columns: 1fr; }
  .hint { font-size: .72rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ── عناصر اللوحة: عناوين الأقسام وأزرار الأدوات ── */
.palette.onecol { grid-template-columns: 1fr; }
.sec-title {
  grid-column: 1 / -1; font-size: .68rem; font-weight: 800; color: var(--fg-muted);
  letter-spacing: .04em; padding-top: .45rem; margin-top: .15rem;
  border-top: 2px dashed var(--border-soft);
}
.sec-title:first-child { border-top: none; padding-top: 0; }
.pal-item svg { width: 30px; height: 30px; color: var(--accent); stroke-width: 1.8; }
.pal-item.tool { min-height: 78px; justify-content: center; }
.pal-item.tool .lbl { font-size: .7rem; }
.pal-item.tool.active svg { color: #B45309; }
