:root {
  color-scheme: light;
  --bg: #edf2f7;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #132238;
  --muted: #64748b;
  --line: #d8e1eb;
  --line-strong: #bac8d8;
  --teal: #0f766e;
  --teal-soft: #e1f4f1;
  --amber: #d97706;
  --amber-soft: #fff4dc;
  --danger: #b91c1c;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.12);
  font-family: "Cairo", "Tajawal", "Noto Sans Arabic", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 34%),
    linear-gradient(225deg, rgba(217, 119, 6, 0.09), transparent 30%),
    var(--bg);
  color: var(--ink);
}

body {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  min-height: 100vh;
}

.draft-app {
  display: grid;
  grid-template-rows: 56px minmax(0, 1fr) 34px;
  height: 100vh;
}

.topbar,
.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
}

.topbar {
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--teal), #164e63);
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.22);
}

.brand h1 {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.1;
  font-weight: 900;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 210px;
}

.zoom-cluster {
  display: inline-flex;
  align-items: center;
  gap: 0;
  min-height: 34px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.zoom-cluster .icon-button {
  border: 0;
  border-radius: 0;
}

.zoom-meter {
  min-width: 62px;
  padding-inline: 10px;
  border-inline: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 900;
  text-align: center;
}

.button,
.tool-button,
.icon-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 800;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.button:hover,
.tool-button:hover,
.icon-button:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.button:focus-visible,
.tool-button:focus-visible,
.icon-button:focus-visible,
.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.2);
  outline-offset: 2px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
}

.button.primary {
  border-color: transparent;
  background: var(--teal);
  color: #fff;
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.2);
}

.button.warn {
  border-color: #fed7aa;
  background: var(--amber-soft);
  color: #92400e;
}

.button.danger {
  border-color: #fecaca;
  background: #fff1f2;
  color: var(--danger);
}

.button.slim {
  min-height: 30px;
  padding-inline: 10px;
  font-size: 0.78rem;
}

.icon-button {
  width: 34px;
  display: grid;
  place-items: center;
  padding: 0;
}

.tool-button {
  min-width: 68px;
  display: grid;
  place-items: center;
  gap: 1px;
  padding: 5px 8px;
}

.tool-button svg,
.icon-button svg,
.button svg,
.brand-mark svg,
.panel h2 svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool-button span {
  font-size: 0.72rem;
  line-height: 1;
}

.tool-button.active {
  border-color: rgba(15, 118, 110, 0.34);
  background: var(--teal-soft);
  color: #0f514b;
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.08);
}

.workspace {
  display: grid;
  grid-template-columns: 76px minmax(360px, 1fr) 306px;
  min-height: 0;
}

.rail,
.inspector {
  min-height: 0;
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.9);
}

.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  border-left: 1px solid var(--line);
  overflow-y: auto;
}

.rail-title {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.canvas-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 14px;
  background:
    linear-gradient(90deg, rgba(15, 23, 42, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(15, 23, 42, 0.04) 1px, transparent 1px);
  background-size: 24px 24px;
}

.canvas-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 360px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.floating-scale {
  position: absolute;
  inset-block-start: 12px;
  inset-inline-start: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid rgba(203, 213, 225, 0.84);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.ruler-mark {
  width: 54px;
  height: 8px;
  border-inline: 2px solid var(--teal);
  border-bottom: 2px solid var(--teal);
}

.inspector {
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.panel {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.panel h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 0.92rem;
  font-weight: 900;
}

.panel h2 small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.field-grid.one {
  grid-template-columns: 1fr;
}

.field {
  display: grid;
  gap: 5px;
}

.field label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 7px 9px;
  font-size: 0.84rem;
  font-weight: 750;
}

.field textarea {
  min-height: 68px;
  resize: vertical;
}

.toggle-row,
.layer-row,
.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toggle-row {
  min-height: 34px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 850;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.swatch {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border: 2px solid #fff;
  border-radius: 7px;
  box-shadow: 0 0 0 1px var(--line);
}

.swatch.active {
  box-shadow: 0 0 0 2px var(--teal), 0 8px 16px rgba(15, 23, 42, 0.14);
}

.metrics {
  display: grid;
  gap: 6px;
}

.metric-row {
  min-height: 30px;
  padding: 6px 8px;
  border-radius: 7px;
  background: var(--panel-soft);
  font-size: 0.78rem;
  font-weight: 850;
}

.metric-row span:first-child {
  color: var(--muted);
}

.layer-list {
  display: grid;
  gap: 7px;
}

.layer-row {
  min-height: 38px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-size: 0.78rem;
  font-weight: 850;
}

.layer-row.active {
  border-color: rgba(15, 118, 110, 0.34);
  background: var(--teal-soft);
}

.layer-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.statusbar {
  padding: 0 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.status-group {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.measure-note {
  color: #0f766e;
}

.kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  min-height: 20px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font-size: 0.72rem;
}

.mobile-tools {
  display: none;
}

@media (max-width: 1060px) {
  body {
    overflow: auto;
  }

  .draft-app {
    height: auto;
    min-height: 100vh;
    grid-template-rows: auto minmax(620px, 72vh) auto;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .brand,
  .top-actions {
    min-width: 0;
  }

  .toolbar {
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .workspace {
    grid-template-columns: 68px minmax(0, 1fr);
  }

  .inspector {
    grid-column: 1 / -1;
    border-right: 0;
    border-top: 1px solid var(--line);
  }

  .inspector {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel {
    border-left: 1px solid var(--line);
  }
}

@media (max-width: 720px) {
  .draft-app {
    grid-template-rows: auto minmax(560px, 68vh) auto;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .rail {
    display: none;
  }

  .mobile-tools {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    padding-block: 2px;
  }

  .canvas-wrap {
    padding: 9px;
  }

  .inspector {
    grid-template-columns: 1fr;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .statusbar {
    align-items: flex-start;
    flex-direction: column;
    min-height: 56px;
    padding: 8px 12px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .rail,
  .inspector,
  .statusbar,
  .floating-scale {
    display: none !important;
  }

  .draft-app,
  .workspace,
  .canvas-wrap,
  .canvas-stage {
    display: block;
    width: 100%;
    height: 100vh;
    min-height: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }
}
